Hi,
I have an method that takes in an observable collection (returned from a webservice) of objects and analyzes them according to their attributes.
Here is the code snippet from the method
private double analyze(ObservableCollection mobjColl)
{
FieldInfo fi = null;
foreach (MyApp.MyObj oi in mobjColl)
...
I have a situation in a WebForm where I need to recurse throguh the control tree to find all controls that implement a given interface.
How would I do this?
I have tried writing an extension method like this
public static class ControlExtensions
{
public static List<T> FindControlsByInterface<T>(this Control control)
{
...
The lack of reflection in Medium Trust hosting environments seems to cause a lot of problems for many popular web applications.
Why is ReflectionPermission disabled by default with Medium Trust?
What risk does reflection pose in a shared hosting environment?
For random reference, see MSDN: How to use Medium Trust in ASP.NET 2.0
...
I'm working on extending the errorprovider to the propertygrid and treeview controls. I found a very helpful post at: Example
detailing how to add the errorprovider to a propertygrid, and it works very well. My question is how did the author know that IPropertyValueUIService is the interface that the propertygrid uses to display the i...
After an interop call, I get back a COM object.
I know this object will be one of three possible COM classes (Class1, Class2, Class3), but do not know which one in runtime.
The reflection upon that object (interopObject.GetType()) returns the base RCW wrapper of System.__ComObject.
What I need is to set some properties on the object - ...
I am interested to know the technical reasons: why does reflection not perform well in .NET?
...
I have a class:
public abstract class SendAgencyFileComponent : ISendAgencyFileComponent
{
public AgencyOutput agencyOutput;
public TDXDataTypes.DB.Entity client;
public TDXDataTypes.DB.Entity agency;
public SendAgencyFileComponent(AgencyOutput agencyOutput, TDXDataTypes.DB.Entity client, TDXDataTypes.DB.Entity agency)
...
Hi,
I've created a simple Attribute:
[AttributeUsage(AttributeTargets.Method)]
public class InitAttribute : System.Attribute
{
public InitAttribute()
{
Console.WriteLine("Works!");
}
}
and I apply it to a simple method:
static class Logger
{
public static string _severity;
public static void Init(string s...
Following the advice got on another question of mine, I converted the code there quoted to be used with PostSharp:
Attribute:
[Serializable]
public sealed class InitAttribute : OnMethodBoundaryAspect
{
public override void OnEntry(MethodExecutionEventArgs eventArgs)
{
Console.Write("Works!");
}
}
static class Logg...
Hi,
Is there any library (like open source projects etc) that makes it easier to use complex reflection like creating objects or classes on the fly, inspecting instances etc?
Thanks
...
I would like to do something like this:
public class Foobar {
@Tag final private int foo;
@Tag final private int bar;
@Tag final private int baz;
@Tag final private int quux;
static private final TagValidator validator =
TagValidator.autoGenerate(Foobar.class);
public Foobar(Something something)
{
va...
Hi,
I've got a class that's got a bunch of public methods, and I'd like to reflect over it to find the set of member methods that could be used as a particular delegate.
For example:
delegate void InterestingFunc(int i);
class Entity
{
public void F();
public void G();
public void H(int i);
public void X(int i);
}
C...
I'm writing a console tool to generate some C# code for objects in a class library. The best/easiest way I can actual generate the code is to use reflection after the library has been built. It works great, but this seems like a haphazard approch at best. Since the generated code will be compiled with the library, after making a change I...
I'm writing a really simple IoC/DI container, and I've got the following code:
ConstructorInfo[] ctors = concreteType.GetConstructors();
if (ctors.Length == 0)
return Activator.CreateInstance(concreteType);
// more code goes here...
I can't come up with a test case that results in a type having zero constructors, even with this:...
Duplicate: http://stackoverflow.com/questions/1034350/dynamic-class-creation-in-objective-c/1034368#1034368
Is it possible to create an instance of a class by name? Something like:
NSString* className = @"Car";
id* p = [Magic createClassByName:className];
[p turnOnEngine];
I don't know if this is possible in objective-c but seems lik...
Suppose I have an interface:
public interface FooInterface {
public void someMethod();
}
and I have a class that implements this interface:
public class FooClass implements FooInterface {
public void someMethod() {
//do cool things
}
public void someOtherMethod() {
//do other cool things
}
...
I was reading and found this code as an aswer to a question
public List<T> LoadPlugin<T>(string directory)
{
Type interfaceType = typeof(T);
List<T> implementations = new List<T>();
//TODO: perform checks to ensure type is valid
foreach (var file in System.IO.Directory.GetFiles(directory))
{
//TODO: add pro...
I have an NSString containing the name of a selector I would like to call with performSelector. How can I get a reference to the selector from the string?
...
Let's say I have a Type called type.
I want to determine if I can do this with my type (without actually doing this to each type):
If type is System.Windows.Point then I could do this:
Point point1 = new Point();
However if type is System.Environment then this will not fly:
Environment environment1 = new Environment(); //wrong
So...
I'm trying to get this Generic DuplicateValidationRule working, which basically checks a Collection for duplicates (based on a generic business object type passed in). Lets take the IBankAccount Business Object for example:
public interface IBankAccount : IMyBusinessObjectBase
{
IBank Bank
{
get;
set;
}
IBankAccountType BankAcc...