IMapping IMappingFactory.Create(IComponentContainer components, IDictionary <string, object> parameters) { var context = new BuilderContext( components, parameters, Type.GetCustomAttributes().OfType <ITypeDefaultAttribute>().ToDictionary(x => x.Key, x => x.Value)); var filler = context.GetParameter <byte>(Parameter.Filler); var list = new List <MapperPosition>(); list.AddRange(CreateTypeEntries(context)); list.AddRange(CreateMemberEntries(context)); MapperPositionHelper.Layout( list, mapAttribute.Size, Type.FullName, validation, mapAttribute.UseDelimiter ? context.GetParameter <byte[]>(Parameter.Delimiter) : null, mapAttribute.AutoFiller ? (byte?)filler : null); return(new Mapping( Type, mapAttribute.Size, mapAttribute.HasNullFiller ? mapAttribute.NullFiller : filler, list.Select(x => x.Mapper).ToArray())); }
//-------------------------------------------------------------------------------- // IMappingFactory //-------------------------------------------------------------------------------- IMapping IMappingFactory.Create(IComponentContainer components, IDictionary <string, object> parameters) { var context = new BuilderContext(components, parameters, typeParameters); var filler = context.GetParameter <byte>(Parameter.Filler); var list = new List <MapperPosition>(); list.AddRange(typeMapBuilders.Select(x => new MapperPosition(x.Offset, x.CalcSize(), x.CreateMapper(context)))); list.AddRange(memberMapBuilders.Select(x => new MapperPosition(x.Offset, x.CalcSize(), x.CreateMapper(context)))); MapperPositionHelper.Layout( list, size, Type.FullName, validation, useDelimiter ? context.GetParameter <byte[]>(Parameter.Delimiter) : null, autoFiller ? (byte?)filler : null); return(new Mapping(Type, size, nullFiller ?? filler, list.Select(x => x.Mapper).ToArray())); }