I'm looking for a list of reasonable use cases of putting attributes in a parameter.
I can think of some good cases for attributes in a method, but can't seem to see a good usage of a parameter attribute. Please, enlighten me.
And what about attributes on the return type of a method?
...
Hi,
How can I change the HttpContext.Current.Request.UserAgent property using reflection?
Thanks
...
Hello
I have a C# 3.0 WinForms application which is occasionally required to control Excel with automation. This is working nicely with normal early binding but I've had some problems when people don't have Excel installed but still want to use my app except for the Excel part. Late binding seems to be a solution to this. Late binding i...
How can I subscribe to a ObservableCollection<??> without knowing the element type of the collection? Is there a way to do this without too many 'magic strings'?
This is a question for the .NET version 3.5. I think 4.0 would make my life much easier, right?
Type type = collection.GetType();
if(type.IsGenericType
&& type.GetGenericT...
Currently i am using reflection with sql. I find if i want to make a specialize query it is easiest to get the results by creating a new class inheriting from another and adding the 2 members/columns for my specialized query. Then due to reflections in the lib in my c# code i can write foreach(var v in list) { v.AnyMember and v.MyExtraMe...
When I start up an R3 Alpha 99 session, and enter this as the first command, I get an error:
>> is-email-addr: get bind to-word "email?" bind? 'system
** Script error: email? is not in the specified context
** Where: bind
** Near: bind to-word "email?" bind? 'system
But if I quit, restart and instead execute a test to prove that the e...
Hi all,
I allready asked at:
Is it possible to call unmanaged code using C# reflection from managed code ?
if it is possible to call C/C++ library unmanaged function with Invoke and reflection from .NET and the answer is yes.
What I am not clear about is can I call using P/Invoke ANY assembly written/compiled/build with other compile...
How can I print out the (public and internal) variables and their values of a Groovy object?
I.e
class X
{
def X = 10
def Y = 5
private void doPrivate()
{
def Z = 3
}
}
Should give
X, 10
Y, 5
Z, 3
This has to be a dynamic solution, i.e at runtime.
...
I have a method that has the following signature:
private object GetNestedObject<y>(y objToAccess, string nestedObjectName)
I'm using Reflection to get the nestedObject from the objToAccess and return it.
This works well except it's really slow (I have to do this a few hundred thousand times).
I came across HyperDescriptor, but sinc...
Hi,
I have a few classes in the class library (separate assembly). I referenced it to my project and I want to initialize one specific class from that library. I know only its name. All of the classes implements one interface.
And here comes the problem.
My code so far:
using MyLibrary;
...
IMyInterface dll = Activator.CreateInstance("...
Like this:
public class remoteStatusCounts : RemoteStatus
{
public int statusCount;
public remoteStatusCounts(RemoteStatus r)
{
Type t = r.GetType();
foreach (PropertyInfo p in t.GetProperties())
{
this.property(p) = p.GetValue(); //example pseudocode
}
}
}
The example ...
Let's say I have a function that takes a string. That string contains the fully name of an enum type (e.g. "MyCompany.Area.AotherNamespace.MyEnum").
How could I create an array of strings (or List<string>) whose elements are the values of MyCompany.Area.AotherNamespace.MyEnum?
Is that even possible?
I'm basically trying to serialize a...
I would like to build a generic class that I can use to implement Parameterized Properties in C#. The basic code I want is this:
public class ParameterizedProperty<typeReturn, typeIndexer> {
private typeReturn oReturn = default(typeReturn);
public typeReturn this[typeIndexer oIndexer] {
get { return oReturn[oIndexer]; }...
Hi
I have a database with a "configs" table
each new row in the configs table is 4 a different client which can config his environment to his liking (theme,companyname,language, culture...)
one record,lets say id=-1, is the default config. all new configs should copy everything from there
i want that each time i (the main admin) add a ne...
.Net 3.5, using C#
I have an instance of a class (A) that has been called via a virtual method from a derived class (B). Within the method (a method of class A) I have discovered the Type of class B that has made the call, and using reflection I have examined class B and discovered a property whose value I want to access.
Is there any ...
I'm not quite sure what to do here, here's the situation:
Given these models...
class Post < ActiveRecord::Base
has_many :post_assets
has_many :assets, :through => :post_assets
acts_as_scopeable :assets, :scopes => [:featured]
end
class PostAssets < ActiveRecord::Base
belongs_to :post
belongs_to :asset
# context is so we...
I am looking into using the new Backup API that available since Android 2.2, but need to maintain backwards compatibility (to 1.5 to be exact).
The docs state:
The backup service and the APIs you must use are available only on devices running API Level 8 (Android 2.2) or greater, so you should also set your android:minSdkVersion att...
Consider the following snippet:
public class ReflectionTest {
public static void main(String[] args) {
ReflectionTest test = new ReflectionTest();
String object = new String("Hello!");
// 1. String is accepted as an Object
test.print(object);
// 2. The appropriate method is not found with ...
Is there a lib that can build a simple GUI by looking at a class or method signature?
For Example:
class MyMath{
public static double sqrt(double d){
//impl
}
}
To
So that when the button is clicked the method is invoked and the result is shown.
Do you know any examples of something like that in Java or ...
On a button push, my webapp copies several classes in to the project and then checks if the new files contain a class named my.namespace.myclass with Type.GetType("my.namespace.myclass", false, true);
This returns null even though i can see the class with correct namespace, and if I write my.namespace.myclass inside my code(after refresh...