public static T EnsureCreateProxWithAttribute <T>(this ProxyHelper proxHelper, IConfiguration configuration) where T : class { var nameTransfer = IdentityMapNameTransfer.FromTypeAttributes(typeof(T)); return(EnsureCreateProx <T>(proxHelper, configuration, nameTransfer)); }
public static ProxyCreator CreateComplexProxy <T>(this ProxyHelper proxyHelper, bool autoAnalysis) { var type = new[] { typeof(T) }; var objType = typeof(object); var map = new Dictionary <Type, INameTransfer>(); map.Add(type[0], IdentityMapNameTransfer.FromTypeAttributes(type[0])); if (autoAnalysis) { while (type.Length != 0) { var includeTypes = type.SelectMany(x => x.GetProperties() .Where(y => y.CanWrite && y.CanRead && y.PropertyType.IsClass && x.GetCustomAttribute <ConfigStepInAttribute>() != null || y.GetCustomAttribute <ConfigStepInAttribute>() != null && !map.ContainsKey(y.PropertyType))) .ToList(); var notInclues = new List <PropertyInfo>(); foreach (var item in includeTypes) { if (map.ContainsKey(item.PropertyType)) { notInclues.Add(item); continue; } var nameMap = IdentityMapNameTransfer.FromTypeAttributes(item.PropertyType); map.Add(item.PropertyType, nameMap); } type = includeTypes.Except(notInclues).Select(x => x.DeclaringType).Distinct().ToArray(); } } return(CreateComplexProxy <T>(proxyHelper, map)); }
public static ObjectNamedCreator Create(Type type) { var transfer = IdentityMapNameTransfer.FromTypeAttributes(type); return(new ObjectNamedCreator(type, transfer, IdentityNamedCreator.Instance, CompilePropertyVisitor.Instance)); }
public static ProxyCreator CreateComplexProxy(this ProxyHelper proxyHelper, Type type) { if (proxyHelper is null) { throw new ArgumentNullException(nameof(proxyHelper)); } if (type is null) { throw new ArgumentNullException(nameof(type)); } var nameTransfer = IdentityMapNameTransfer.FromTypeAttributes(type); return(CreateComplexProxy(proxyHelper, type, nameTransfer)); }
public IReadOnlyDictionary <PropertyInfo, INameTransfer> Create(Type type, bool force) { if (type is null) { throw new ArgumentNullException(nameof(type)); } var properties = type.GetProperties(); var map = new Dictionary <PropertyInfo, INameTransfer>(); foreach (var item in properties) { var configPath = item.GetCustomAttribute <ConfigPathAttribute>(); if (IsStepable(item) && (force || CanStepIn(item))) { var transfer = IdentityMapNameTransfer.FromTypeAttributes(configPath?.Name ?? item.Name, item.PropertyType, true); map.Add(item, transfer); } } return(map); }
public static object EnsureCreateProxWithAttribute(this ProxyHelper proxHelper, Type type, IConfiguration configuration) { 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)); } var nameTransfer = IdentityMapNameTransfer.FromTypeAttributes(type); return(EnsureCreateProx(proxHelper, type, configuration, nameTransfer)); }