Questions tagged [dynamic-method]

DynamicMethod is a .Net class that can be used to define a method at runtime using CIL.

System.Reflection.Emit.DynamicMethod is a .Net class that can be used to define a method at runtime using .

46 questions
0
votes
1 answer

Does DynamicMethod 'skipVisibility' have a performance penalty?

When creating a DynamicMethod in C# for which bypassing visibility is not necessary or irrelevant, what is the best value to specify for the skipVisibility parameter of the DynamicMethod constructor? Is there a performance penalty, i.e., associated…
Glenn Slayden
  • 17,543
  • 3
  • 114
  • 108
0
votes
1 answer

How to return value with dynamic method calls through getattr()

I have a class that is called that runs a while loop command prompt, i am using dir() and getattr() to dynamically create a list of methods for a command shell. I want to return values, but return from a dynamically called method just exits to main…
0
votes
3 answers

Dynamically call method in c#

I've got a lot of entity classes, and now in all properties of the entity classes need to add new functionality (call some method) in the getters and setters. What i want to say looks like this: public class PersistentClass : BaseClass { private…
nikolavas
  • 63
  • 1
  • 2
  • 7
0
votes
1 answer

Get a return value from dynamically calling java class

I need to get a retrun value from dynamically calling java class by passing a variable values to that calling method. I try to use the java.lang.reflect.Method; PredictionManager pm = new PredictionManager(); Class invokeclass =…
Milinda Bandara
  • 542
  • 8
  • 23
0
votes
2 answers

Add a method dynamically in ax 2012 component

I want to add a method dynamically to a component in ax 2012, how can I do this through code? Is it possible?
0
votes
1 answer

How to call a dynamic method to return square of number?

I want to create a simple dynamic method that returns square of a integer number(i.e - If number is 5, it should return 25). I have written the code below:- class Square { public int CalculateSquare(int value) { return value * value;…
K P
  • 31
  • 6
0
votes
2 answers

Dynamic php method

Is it possible to create a method dynamically? For example: I have a method called "createMethod()". I would like to pass variables to this method describing how the dynamic method would look like (function description, params as an array or…
Kęstutis
  • 55
  • 5
0
votes
1 answer

Dynamic methods using define_method and eval

I've put together two sample classes implemented in a couple of different ways which pretty well mirrors what I want to do in my Rails model. My concern is that I don't know what, if any are the concerns of using either method. And I've only found…
MCB
  • 2,021
  • 1
  • 18
  • 32
0
votes
1 answer

How to refactor instance methods using dynamic methods in Ruby?

I want to refactor this: class Collection def artists @songs.map { |song| song.artist }.uniq end def albums @songs.map { |song| song.album }.uniq end def names @songs.map { |song| song.name }.uniq end end into something like…
Alexander Popov
  • 23,073
  • 19
  • 91
  • 130
0
votes
1 answer

How to write really dynamic methods in Objective-C?

I have just started to develop this library It's main goal is to allow programmer to write methods name like sentences to work with Core Data. Examples: [moc RD_createUserWithName:@"John" age:@29 married:@YES]; [moc…
AndrewShmig
  • 4,843
  • 6
  • 39
  • 68
0
votes
1 answer

How to invoke Nullable.HasValue in DynamicMethod?

I'm writing some code using DynamicMethod. Inside my DynamicMethod, I want to invoke the Nullable.HasValue (and also the Nullable.Value) properties. I've written some code to do some, but I keep getting the Operation could destabilize the runtime…
Vivian River
  • 31,198
  • 62
  • 198
  • 313
0
votes
1 answer

How to factor type parameters out of my code that uses DynamicMethod and Entity Framework?

I am creating a framework that is meant to allow web developers to create CRUD pages without having to go thru repetitive steps. To that end, I want to provide "default" methods that do things like sorting, filtering, and the like. A developer…
Vivian River
  • 31,198
  • 62
  • 198
  • 313
0
votes
1 answer

Accessing environment variables

I am setting the below environment variable. ENV["RAILS_RELATIVE_URL_ROOT"] = "/prefix" Is there any way of accessing this env variable other than ENV["RAILS_RELATIVE_URL_ROOT"]? I know rails env can be accesses like Rails.env. Can all the env…
usha
  • 28,973
  • 5
  • 72
  • 93
0
votes
1 answer

How to have a dynamically added function access dynamically added properties

I have a generic class that I add dynamic properties to, and I want to add methods dynamically to instances, as certain instances will have different methods, but they need to access these dynamic properties. How do I do this? class…
James Black
  • 41,583
  • 10
  • 86
  • 166
0
votes
1 answer

Implementing dynamic methods in rails for key/value pair

Let's say I have a database table called 'options' with corresponding model called Option. Structure of this table is simple and as follows ... id -> primary key, auto increment name -> key value -> value for the key Sample data rows could be…