public NamedAnalysis() { type = typeof(StudentClass); nameTransfer = IdentityMapNameTransfer.FromTypeAttributes(type); objectNamedCreator = new ObjectNamedCreator(type, nameTransfer, IdentityNamedCreator.Instance, ReflectionPropertyVisitor.Instance); }
protected virtual ObjectNamedCreator CreateCreator(PropertyInfo info, INameTransfer transfer) { return(new ObjectNamedCreator(info.PropertyType, transfer, NamedCreator, PropertyVisitor)); }
protected override ObjectNamedCreator CreateCreator(PropertyInfo info, INameTransfer transfer) { return(new ProxyCreator(ProxyHelper, info.PropertyType, transfer, NamedCreator, PropertyVisitor)); }
public object CreateProxy(Type type, IConfiguration configuration, INameTransfer nameTransfer) { if (proxMap.TryGetValue(type, out var proxType)) { return(CreateInstance(proxType, configuration, nameTransfer)); } return(null); }
public ProxyCreator(ProxyHelper proxyHelper, Type type, INameTransfer nameTransfer, INamedCreator namedCreator, IPropertyVisitor propertyVisitor) : base(type, nameTransfer, namedCreator, propertyVisitor) { ProxyHelper = proxyHelper ?? throw new ArgumentNullException(nameof(proxyHelper)); BuildType(type); }
public ObjectNamedCreator(Type type, INameTransfer nameTransfer, INamedCreator namedCreator, IPropertyVisitor propertyVisitor) { PropertyVisitor = propertyVisitor ?? throw new ArgumentNullException(nameof(propertyVisitor)); NameTransfer = nameTransfer ?? throw new ArgumentNullException(nameof(nameTransfer)); NamedCreator = namedCreator ?? throw new ArgumentNullException(nameof(namedCreator)); Type = type ?? throw new ArgumentNullException(nameof(type)); propertyInfos = new Dictionary <PropertyInfo, IPropertyProxyInfo>(); IsForceStepIn = type.GetCustomAttribute <ConfigStepInAttribute>() != null; ConfigPath = Type.GetCustomAttribute <ConfigPathAttribute>(); }
public static T AutoCreateProxy <T>(this IConfiguration configuration, INameTransfer nameTransfer = null) where T : class { var type = typeof(T); var forceStepIn = type.GetCustomAttribute <ConfigStepInAttribute>() != null; if (forceStepIn || type.GetProperties().Any(x => x.CanWrite && x.PropertyType.IsClass && x.GetCustomAttributes <ConfigStepInAttribute>() != null)) { return(CreateComplexProxy <T>(configuration)); } return(CreateProxy <T>(configuration, nameTransfer)); }
public static T CreateProxy <T>(this IConfiguration configuration, INameTransfer nameTransfer = null) where T : class { if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } if (nameTransfer is null) { return(ProxyHelper.Default.EnsureCreateProxWithAttribute <T>(configuration)); } return(ProxyHelper.Default.EnsureCreateProx <T>(configuration, nameTransfer)); }
public object CreateProxy(Type type, IConfiguration configuration, INameTransfer nameTransfer) { if (type is null) { throw new ArgumentNullException(nameof(type)); } if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } if (nameTransfer is null) { throw new ArgumentNullException(nameof(nameTransfer)); } if (proxMap.TryGetValue(type, out var proxType)) { return(CreateInstance(proxType, configuration, nameTransfer)); } return(null); }
public static ProxyCreator CreateComplexProxy <T>(this ProxyHelper proxyHelper, INameTransfer nameTransfer, INamedCreator namedCreator, Visitors.IPropertyVisitor propertyVisitor) where T : class { return(CreateComplexProxy(proxyHelper, typeof(T), nameTransfer, namedCreator, propertyVisitor)); }
public PostalCodeFileReader(INameTransfer municipalityNameTransfer, INameTransfer townAreaNameTransfer) => (this.municipalityNameTransfer, this.townAreaNameTransfer) = (municipalityNameTransfer, townAreaNameTransfer);
protected virtual object CreateInstance(Type type, IConfiguration configuration, INameTransfer nameTransfer) { var c = constructCompileManager.GetCompiled(constructorMap[type]); return(c.Creator(nameTransfer, configuration)); }
public AddressFileReader(INameTransfer municipalityNameTransfer) => (this.municipalityNameTransfer) = (municipalityNameTransfer);
public static T AutoCreateProxy <T>(this IConfiguration configuration, string section, INameTransfer nameTransfer = null) where T : class { return(AutoCreateProxy <T>(configuration.GetSection(section), nameTransfer)); }
public static object CreateProxy(this IConfiguration configuration, Type type, INameTransfer nameTransfer) { if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } if (type is null) { throw new ArgumentNullException(nameof(type)); } if (nameTransfer is null) { return(ProxyHelper.Default.EnsureCreateProxWithAttribute(type, configuration)); } return(ProxyHelper.Default.EnsureCreateProx(type, configuration, nameTransfer)); }
public static object AutoCreateProxy(this IConfiguration configuration, Type type, INameTransfer nameTransfer) { if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } if (type is null) { throw new ArgumentNullException(nameof(type)); } var forceStepIn = type.GetCustomAttribute <ConfigStepInAttribute>() != null; if (forceStepIn || type.GetProperties().Any(x => x.CanWrite && x.PropertyType.IsClass && x.GetCustomAttributes <ConfigStepInAttribute>() != null)) { return(CreateComplexProxy(configuration, type)); } return(CreateProxy(configuration, type, nameTransfer)); }
public static T EnsureCreateProx <T>(this ProxyHelper proxHelper, IConfiguration configuration, INameTransfer nameTransfer) where T : class { return((T)EnsureCreateProx(proxHelper, typeof(T), configuration, nameTransfer)); }
public static ProxyCreator CreateComplexProxy(this ProxyHelper proxyHelper, Type type, INameTransfer nameTransfer, INamedCreator namedCreator) { if (proxyHelper is null) { throw new ArgumentNullException(nameof(proxyHelper)); } if (type is null) { throw new ArgumentNullException(nameof(type)); } if (nameTransfer is null) { throw new ArgumentNullException(nameof(nameTransfer)); } if (namedCreator is null) { throw new ArgumentNullException(nameof(namedCreator)); } return(CreateComplexProxy(proxyHelper, type, nameTransfer, namedCreator, CompilePropertyVisitor.Instance)); }
public static ProxyCreator CreateComplexProxy(this ProxyHelper proxyHelper, Type type, INameTransfer nameTransfer) { return(CreateComplexProxy(proxyHelper, type, nameTransfer, IdentityNamedCreator.Instance)); }
public static ProxyCreator CreateComplexProxy <T>(this ProxyHelper proxyHelper, INameTransfer nameTransfer) where T : class { return(CreateComplexProxy(proxyHelper, typeof(T), nameTransfer)); }
public static object EnsureCreateProx(this ProxyHelper proxHelper, Type type, IConfiguration configuration, INameTransfer nameTransfer) { if (proxHelper is null) { throw new ArgumentNullException(nameof(proxHelper)); } if (type is null) { throw new ArgumentNullException(nameof(type)); } if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } if (nameTransfer is null) { throw new ArgumentNullException(nameof(nameTransfer)); } if (!proxHelper.HasTypeProxy(type)) { proxHelper.BuildProx(type); } return(proxHelper.CreateProxy(type, configuration, nameTransfer)); }
public static T AutoCreateProxy <T>(this IConfiguration configuration, string section, INameTransfer nameTransfer) where T : class { return((T)AutoCreateProxy(configuration, typeof(T), section, nameTransfer)); }
public static ProxyCreator CreateComplexProxy(this ProxyHelper proxyHelper, Type type, INameTransfer nameTransfer, INamedCreator namedCreator, Visitors.IPropertyVisitor propertyVisitor) { if (proxyHelper is null) { throw new ArgumentNullException(nameof(proxyHelper)); } if (type is null) { throw new ArgumentNullException(nameof(type)); } if (nameTransfer is null) { throw new ArgumentNullException(nameof(nameTransfer)); } if (namedCreator is null) { throw new ArgumentNullException(nameof(namedCreator)); } if (propertyVisitor is null) { throw new ArgumentNullException(nameof(propertyVisitor)); } var creator = new ProxyCreator(proxyHelper, type, nameTransfer, namedCreator, propertyVisitor); creator.Analysis(); return(creator); }
public static object AutoCreateProxy(this IConfiguration configuration, Type type, string section, INameTransfer nameTransfer) { if (type is null) { throw new ArgumentNullException(nameof(type)); } if (string.IsNullOrEmpty(section)) { throw new ArgumentException($"“{nameof(section)}”不能为 Null 或空。", nameof(section)); } return(AutoCreateProxy(configuration.GetSection(section), type, nameTransfer)); }
protected virtual object CreateInstance(Type type, IConfiguration configuration, INameTransfer nameTransfer) { return(Activator.CreateInstance(type, nameTransfer, configuration)); }
public static T AutoCreateProxy <T>(this IConfiguration configuration, INameTransfer nameTransfer) { return((T)AutoCreateProxy(configuration, typeof(T), nameTransfer)); }
public static T EnsureCreateProx <T>(this ProxyHelper proxHelper, IConfiguration configuration, INameTransfer nameTransfer) where T : class { var type = typeof(T); if (!proxHelper.HasTypeProxy(type)) { proxHelper.BuildProx(type); } return((T)proxHelper.CreateProxy(typeof(T), configuration, nameTransfer)); }