private ComplexTypeModel extractIndividualConstructors( ComplexTypeModel compTypeAtHand, ConstructorModel constructorAtHand, ConstructorInfo[] constructors) { for (int i = 0; i < constructors.Length; i++) { ConstructorInfo constructorInfo = constructors[i]; } return compTypeAtHand; }
public ComplexTypeModel extract(ComplexTypeModel compTypeAtHand, Type classAtHand) { iExtractor[] extractors = new iExtractor[] { new FieldExtractor() , new ConstructorExtractor(), new StructExtractor()}; for (int i = 0; i < extractors.Length; i++) { compTypeAtHand = extractors[i].extract(compTypeAtHand, classAtHand); } return compTypeAtHand; }
public ComplexTypeModel extract(ComplexTypeModel compTypeAtHand, Type classAtHand) { ConstructorModel constructorAtHand = new ConstructorModel(classAtHand.Name); constructorAtHand.setNoArgConstructor(true); ConstructorInfo constructorInfo = classAtHand.GetConstructor(new Type[] { }); //Class doesnt have no-arg constructor, extract other constructors constructorAtHand.setNoArgConstructor(false); ConstructorInfo[] constructors = classAtHand.GetConstructors(); compTypeAtHand.setConstructorModel(constructorAtHand); return compTypeAtHand; }
public object build(ComplexTypeModel compType) { object objToBuild = null; ConstructorModel constructorModelAtHand = compType.getConstructorModel(); if (constructorModelAtHand.hasNoArgConstructor()) { objToBuild = Activator.CreateInstance(compType.getRepresentationalTypeFromAssembly()); } else { //Logic to handle where no no-arg constructors exist objToBuild = FormatterServices.GetUninitializedObject( compType.getRepresentationalTypeFromAssembly()); } return objToBuild; }
public ComplexTypeModel extract(ComplexTypeModel compTypeAtHand, Type classAtHand) { Dictionary<string, FieldModel> allFieldsInComplexType = compTypeAtHand.getAllFieldsInThisComplexType(); FieldInfo[] fieldInfo = classAtHand.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); //Console.WriteLine("Length of Fields is " + fieldInfo.Length); for (int i = 0; i < fieldInfo.Length; i++) { string tmpFieldName = ""; Type tmpFieldType; tmpFieldName = fieldInfo[i].Name; tmpFieldType = fieldInfo[i].FieldType; FieldModel fieldAtHand = new FieldModel(tmpFieldName, tmpFieldType); allFieldsInComplexType.Add(fieldAtHand.getFieldName(), fieldAtHand); } //Console.WriteLine("Added complex type " + compTypeAtHand.getActualTypeName()); return compTypeAtHand; }
public ComplexTypeModel extract(ComplexTypeModel compTypeAtHand, Type classAtHand) { Dictionary<string, PropertyModel> allPropertiesInComplexType = compTypeAtHand.getAllPropertiesInThisComplexType(); PropertyInfo[] propertyInfo = classAtHand.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); //Console.WriteLine("Length of Properties is " + propertyInfo.Length); for (int i = 0; i < propertyInfo.Length; i++) { string tmpFieldName = ""; Type tmpFieldType; tmpFieldName = propertyInfo[i].Name; tmpFieldType = propertyInfo[i].PropertyType; PropertyModel propertyAtHand = new PropertyModel(tmpFieldName, tmpFieldType); allPropertiesInComplexType.Add(propertyAtHand.getPropertyName(), propertyAtHand); } return compTypeAtHand; }
public object build(ComplexTypeModel compType) { object objToBuild = null; ConstructorModel constructorModelAtHand = compType.getConstructorModel(); if (constructorModelAtHand.hasNoArgConstructor()) { Console.WriteLine("Constructor Info " + constructorModelAtHand.hasNoArgConstructor() + " " + constructorModelAtHand.getClassOfContructor() + compType.getActualTypeName()); objToBuild = Activator.CreateInstance(compType.getRepresentationalTypeFromAssembly()); } else { //Logic to handle where no no-arg constructors exist objToBuild = FormatterServices.GetUninitializedObject( compType.getRepresentationalTypeFromAssembly()); //var constructor = compType.getRepresentationalTypeFromAssembly().GetConstructor(Type.EmptyTypes); //constructor.Invoke(uninitializedObject, null); } Console.WriteLine(objToBuild); return objToBuild; }
public ComplexTypeModel extract(ComplexTypeModel compTypeAtHand, Type classAtHand) { return compTypeAtHand; }
private static ComplexTypeModel createComplexModel(string typeName, Assembly dLLAssembly) { Type classType = dLLAssembly.GetType(typeName); ComplexTypeModel complexTypeAtHand = new ComplexTypeModel(typeName); iExtractor extractor = new ObjectExtractor(); complexTypeAtHand = extractor.extract(complexTypeAtHand, classType); complexTypeAtHand.setRepresentationalTypeFromAssembly(classType); return complexTypeAtHand; }