internal Type GetConcreteType(ReferenceContext context, ICell cell) { var cType = context.SegmentType; if (cType != null && !cType.Type.IsAbstract) { return(cType.Type); } //use custom type resolver if there is a one which can resolve this type if (cType != null && Resolvers != null && Resolvers.Any()) { var resolver = Resolvers.FirstOrDefault(r => r.CanResolve(cType)); if (resolver != null) { return(resolver.Resolve(cType.Type, cell, context.CMapping, context.Mapping)); } } if (context.PropertyInfo != null) { var pType = context.PropertyInfo.PropertyType; pType = GetNonNullableType(pType); if (pType.IsValueType || pType == typeof(string)) { return(pType); } if (typeof(IEnumerable).IsAssignableFrom(pType)) { pType = pType.GetGenericArguments()[0]; if (pType.IsValueType || pType == typeof(string)) { return(pType); } } if (Resolvers != null && Resolvers.Any()) { var resolver = Resolvers.FirstOrDefault(r => r.CanResolve(pType)); if (resolver != null) { return(resolver.Resolve(pType, cell, context.CMapping, context.Mapping)); } } } Log.WriteLine("It wasn't possible to find a non-abstract type for table {0}, class {1}", context.CMapping.TableName, context.CMapping.Class); return(null); }
private ExpressType GetConcreteType(ReferenceContext context) { var cType = context.SegmentType; if (cType != null && !cType.Type.IsAbstract) { return(cType); } //use fallback to retrieve a non-abstract type (defined in a configuration file?) var fbTypeName = context.CMapping.FallBackConcreteType; if (context.IsRoot && !string.IsNullOrWhiteSpace(fbTypeName)) { var eType = MetaData.ExpressType(fbTypeName.ToUpper()); if (eType != null && !eType.Type.IsAbstract) { return(eType); } } //use custom type resolver if there is a one which can resolve this type if (cType != null && Resolvers != null && Resolvers.Any()) { var resolver = Resolvers.FirstOrDefault(r => r.CanResolve(cType)); if (resolver != null) { return(resolver.Resolve(cType, context, MetaData)); } } Log.WriteLine("It wasn't possible to find a non-abstract type for table {0}, class {1}", context.CMapping.TableName, context.CMapping.Class); return(null); }
public ExtInfo GetInfo(string section, string key) { ValidateSection(section); return(Resolvers.FirstOrDefault(r => r.Key == key)); }
/// <summary> /// Finds the resolver. /// </summary> /// <returns>The resolver.</returns> /// <param name="type">Type.</param> internal ContentResolver FindResolver(Type type) { return(Resolvers.FirstOrDefault(r => r.Key.Equals(type)).Value); }