void InitObjectsOfType <T>(List <string> Names, ref List <T> ConstructedObjects, Assembly CompiledAssembly, string Sufix = "") { Type ObjectType; foreach (string name in Names) { ObjectType = CompiledAssembly.GetType(name + Sufix); if (ObjectType != null) { T RulesObject; RulesObject = (T)FormatterServices.GetUninitializedObject(ObjectType); ConstructorInfo Constructor; if (typeof(T) == typeof(ModuleDef)) { Constructor = ObjectType.GetConstructor(new Type[] { typeof(TargetRules) }); if (Constructor != null) { Constructor.Invoke(RulesObject, new object[] { TargetRulesObject }); } } else { Constructor = ObjectType.GetConstructor(new Type[] { }); if (Constructor != null) { Constructor.Invoke(RulesObject, new object[] { }); } } ConstructedObjects.Add(RulesObject); } } }
public void CallConstructor(Type[] paramTypes, Object[] paramValues) { var ctor = ObjectType.GetConstructor(paramTypes); if (ctor == null) { throw new DynamicProxyException(DynamicErrorMessages.ProxyCtorNotFound); } ObjectInstance = ctor.Invoke(paramValues); }