public static IList <IConstructor> GetConstructors(ITypeResolver typeResolver, IType typeId) { Type runtimeType = typeId.RuntimeType; List <IConstructor> list = (List <IConstructor>)null; if (runtimeType != (Type)null) { ConstructorInfo[] constructors = PlatformTypeHelper.GetConstructors(runtimeType); if (constructors != null && constructors.Length > 0) { foreach (ConstructorInfo constructorInfo in constructors) { if (PlatformTypeHelper.IsAccessibleConstructor(constructorInfo)) { if (list == null) { list = new List <IConstructor>(constructors.Length); } list.Add((IConstructor) new Constructor(typeResolver, typeId, constructorInfo, PlatformTypeHelper.GetNameWithParameters((MethodBase)constructorInfo))); } } } } if (list != null) { return((IList <IConstructor>) new ReadOnlyCollection <IConstructor>((IList <IConstructor>)list)); } return((IList <IConstructor>)ReadOnlyCollections <IConstructor> .Empty); }
public IList <IConstructor> GetConstructors() { if (this.constructors == null) { this.constructors = PlatformTypeHelper.GetConstructors(this.platformTypes.DefaultTypeResolver, this); } return(this.constructors); }
private static ConstructorInfo GetConstructor(Type type, IList <IParameter> arguments) { ConstructorInfo[] constructors = PlatformTypeHelper.GetConstructors(type); if (constructors != null && (int)constructors.Length > 0) { ConstructorInfo[] constructorInfoArray = constructors; for (int i = 0; i < (int)constructorInfoArray.Length; i++) { ConstructorInfo constructorInfo = constructorInfoArray[i]; if ((int)constructorInfo.GetParameters().Length == arguments.Count) { return(constructorInfo); } } } return(null); }
public bool Refresh() { ITypeId typeId = this.baseType; IPropertyId propertyId = this.nameProperty; IPropertyId propertyId1 = this.defaultContentProperty; ITypeId typeId1 = this.itemType; ITypeId typeId2 = this.nullableType; System.ComponentModel.TypeConverter typeConverter = this.typeConverter; IAssembly assembly = this.GetAssembly(this.typeResolver, this.assemblyName); if (!assembly.IsLoaded) { return(true); } this.assembly = assembly; this.type = this.GetRuntimeType(); this.typeConverter = null; this.initializationException = null; if (this.type != null) { this.lastResolvedType = this.type; this.isBuilt = true; } this.Cache(); bool flag = true; if (this.constructors != null) { foreach (Constructor constructor in this.constructors) { ICachedMemberInfo cachedMemberInfo = constructor; if (cachedMemberInfo == null || cachedMemberInfo.Refresh()) { continue; } flag = false; } if (flag && this.type != null) { int num = 0; ConstructorInfo[] constructors = PlatformTypeHelper.GetConstructors(this.type); if (constructors != null) { ConstructorInfo[] constructorInfoArray = constructors; for (int i = 0; i < (int)constructorInfoArray.Length; i++) { if (PlatformTypeHelper.IsAccessibleConstructor(constructorInfoArray[i])) { num++; } } } if (num != this.constructors.Count) { flag = false; } } } if (!this.members.Refresh()) { flag = false; } if (flag && (typeId != this.baseType || typeId1 != this.itemType || typeId2 != this.nullableType)) { flag = false; } if (flag && (propertyId != this.nameProperty || propertyId1 != this.defaultContentProperty)) { flag = false; } if (flag && ProjectContextType.GetTypeConverterId(typeConverter) != ProjectContextType.GetTypeConverterId(this.typeConverter)) { flag = false; } if (flag && this.constructorArgumentProperties != null) { IConstructorArgumentProperties constructorArgumentProperties = PlatformTypeHelper.GetConstructorArgumentProperties(this); if (constructorArgumentProperties.Count == this.constructorArgumentProperties.Count) { foreach (string constructorArgumentProperty in constructorArgumentProperties) { if (constructorArgumentProperties[constructorArgumentProperty] == this.constructorArgumentProperties[constructorArgumentProperty]) { continue; } flag = false; break; } } else { flag = false; } } return(flag); }