Пример #1
0
        RuntimeTypeModel CreateModel()
        {
            RuntimeTypeModel model = RuntimeTypeModel.Create();

            model.Add(typeof(ObjectArrayContainerClass), true);
            model.Add(typeof(BaseClassArrayContainerClass), true);
            model.Add(typeof(Base), true);
            model[typeof(Base)].AddSubType(100, typeof(Derived));

            return(model);
        }
Пример #2
0
        /// <summary>
        /// Creates the type model.
        /// </summary>
        /// <returns></returns>
        private static RuntimeTypeModel CreateTypeModel()
        {
            RuntimeTypeModel typeModel = TypeModel.Create();

            typeModel.Add(typeof(List <string>), true);
            typeModel.Add(typeof(KeyValuePair <uint, uint>), true);
            typeModel.Add(typeof(List <KeyValuePair <uint, uint> >), true);
            typeModel.Add(typeof(List <KeyValuePair <uint, List <KeyValuePair <uint, uint> > > >), true);

            return(typeModel);
        }
Пример #3
0
 private void RegisterHardCodedTypes()
 {
     model.Add(typeof(UnityEngine.Light), true);
     model.Add(typeof(UnityEngine.BoxCollider), true);
     model.Add(typeof(UnityEngine.SphereCollider), true);
     model.Add(typeof(UnityEngine.MeshCollider), true);
     model.Add(typeof(UnityEngine.Vector3), false).SetSurrogate(typeof(NitroxVector3));
     model.Add(typeof(UnityEngine.Quaternion), false).SetSurrogate(typeof(NitroxQuaternion));
     model.Add(typeof(UnityEngine.Transform), false).SetSurrogate(typeof(NitroxTransform));
     model.Add(typeof(UnityEngine.GameObject), false).SetSurrogate(typeof(UnityStubs.GameObject));
 }
Пример #4
0
        private static void ConfigureTypeModel(RuntimeTypeModel model)
        {
            var objectMetaType = model.Add(typeof(object), false);

            var metaType = model.Add(typeof(Point), false);

            metaType.AddField(2, "X");
            metaType.AddField(3, "Y");

            objectMetaType.AddSubType(1, typeof(Point));
        }
Пример #5
0
        public static void Main()
        {
            WriteHeading(".NET version");
#if !COREFX
            Console.WriteLine(Environment.Version);
#endif
            RuntimeTypeModel orderModel = TypeModel.Create();
            orderModel.Add(typeof(OrderHeader), true);
            orderModel.Add(typeof(OrderDetail), true);
#if !COREFX
            orderModel.Compile("OrderSerializer", "OrderSerializer.dll");
#endif
            RuntimeTypeModel model = BuildMeta();
            Customer         cust1 = new Customer();
            CustomerStruct   cust2 = new CustomerStruct();
            cust2.Id   = cust1.Id = 123;
            cust2.Name = cust1.Name = "Fred";
#if !FX11
            cust1.HasValue = cust2.HasValue = true;
            cust1.HowMuch  = cust2.HowMuch = 0.123;
#endif
            WriteCustomer(model, "Runtime - class", cust1);
            WriteCustomer(model, "Runtime - struct", cust2);

#if FEAT_COMPILER && !FX11
            model.CompileInPlace();
            WriteCustomer(model, "InPlace- class", cust1);
            WriteCustomer(model, "InPlace - struct", cust2);
#endif
#if FEAT_COMPILER
#if !COREFX
            TypeModel compiled = model.Compile("CustomerModel", "CustomerModel.dll");
            //PEVerify.Verify("CustomerModel.dll");
            WriteCustomer(compiled, "Compiled - class", cust2);
            WriteCustomer(compiled, "Compiled - struct", cust2);
#endif

            /*
             * CustomerModel serializer = new CustomerModel();
             * using (MemoryStream ms = new MemoryStream())
             * {
             *  Customer cust = new Customer();
             *  cust.Id = 123;
             *  cust.Name = "Fred";
             *  serializer.Serialize(ms, cust);
             *  ms.Position = 0;
             *  Customer clone = (Customer)serializer.Deserialize(ms, null, typeof(Customer));
             *  Console.WriteLine(clone.Id);
             *  Console.WriteLine(clone.Name);
             * }
             */
#endif
        }
Пример #6
0
 public static RuntimeTypeModel GetModel()
 {
     if (_model == null)
     {
         _model = RuntimeTypeModel.Default;
         _model.Add(typeof(DTOs.ExternalId), true).Add("Context", "Id");
         _model.Add(typeof(DTOs.Permission), true).Add("Id", "Application", "Description");
         _model.Add(typeof(DTOs.EffectiveAuthorization), true).Add("TenantId", "User", "Permission", "Target");
         _model.Add(typeof(DTOs.EffectiveAuthorizationGrantedEvent), true).Add("FromDateTime", "EffectiveAuthorization");
     }
     return(_model);
 }
Пример #7
0
        /// <summary>
        /// Creates a new v2 serializer.
        /// </summary>
        /// <param name="compress">Flag telling this serializer to compress it's data.</param>
        public CHEdgeDataDataSourceSerializer(bool compress)
        {
            _compress = compress;

            RuntimeTypeModel typeModel = TypeModel.Create();
            typeModel.Add(typeof(SerializableGraphTileMetas), true); // the tile metadata.
            typeModel.Add(typeof(SerializableGraphTile), true); // one tile of data.
            typeModel.Add(typeof(SerializableTags), true); // a list of tags.
            typeModel.Add(typeof(SerializableGraphArcs), true); // a list of arcs.

            _runtimeTypeModel = typeModel;
        }
Пример #8
0
 /// <summary>
 /// Creates the type model.
 /// </summary>
 /// <returns></returns>
 private static RuntimeTypeModel CreateTypeModel()
 {
     if (_typeModel == null)
     {
         _typeModel = TypeModel.Create();
         _typeModel.Add(typeof(List <string>), true);
         _typeModel.Add(typeof(KeyValuePair <uint, uint>), true);
         _typeModel.Add(typeof(List <KeyValuePair <uint, uint> >), true);
         _typeModel.Add(typeof(List <KeyValuePair <uint, List <KeyValuePair <uint, uint> > > >), true);
     }
     return(_typeModel);
 }
        protected void RegisterTypes(RuntimeTypeModel model)
        {
            Type[] serializableTypes = Reflection.GetAllFromCurrentAssembly().Where(type => type.IsDefined(typeof(ProtoContractAttribute), false)).ToArray();

            foreach (Type type in serializableTypes)
            {
                if (type.IsGenericType())
                {
                    continue;
                }

                try
                {
                    model.Add(type, true);
                    // model.Add(type.MakeArrayType(), true).UseConstructor = false;
                }
                catch (Exception e)
                {
#if UNITY_EDITOR
                    UnityEngine.Debug.LogErrorFormat("model.Add({0}, true) failed {1}", type.FullName, e);
#endif
                    throw;
                }
            }

            Type[] primitiveTypes = new[] {
                typeof(bool),
                typeof(char),
                typeof(byte),
                typeof(short),
                typeof(int),
                typeof(long),
                typeof(ushort),
                typeof(uint),
                typeof(ulong),
                typeof(string),
                typeof(float),
                typeof(double),
                typeof(decimal),
                typeof(Coordinate[])
            };

            foreach (Type type in primitiveTypes)
            {
                if (type.IsGenericType())
                {
                    continue;
                }
                model.Add(typeof(PrimitiveContract <>).MakeGenericType(type), true);
                //model.Add(typeof(PrimitiveContract<>).MakeGenericType(type).MakeArrayType(), true).UseConstructor = false;
            }
        }
Пример #10
0
        private static Serializer CreateSerializer(RuntimeTypeModel model)
        {
            var recordMetadata = model.Add(typeof(OperationCommittedRecord), true);

            recordMetadata.AddSubType(10, typeof(OperationCommittedRecord <TOperation>));
            model.Add(typeof(EpochSurrogate), true);
            model.Add(typeof(Epoch), true).SetSurrogate(typeof(EpochSurrogate));

            Debug.WriteLine(
                model.GetSchema(typeof(OperationCommittedRecord <TOperation>)));

            return(new Serializer(model));
        }
Пример #11
0
        RuntimeTypeModel CreateModel()
        {
            ProtoCompatibilitySettingsValue c = ProtoCompatibilitySettingsValue.FullCompatibility;

            c.SuppressValueEnhancedFormat = false;
            RuntimeTypeModel model = TypeModel.Create(false, c);

            model.Add(typeof(ObjectArrayContainerClass), true);
            model.Add(typeof(BaseClassArrayContainerClass), true);
            model.Add(typeof(Base), true);
            model[typeof(Base)].AddSubType(100, typeof(Derived));

            return(model);
        }
Пример #12
0
        /// <summary>
        /// Creates a new PBF stream target.
        /// </summary>
        public PBFOsmStreamTarget(Stream stream)
        {
            _stream = stream;

            _currentEntities    = new List <Osm.OsmGeo>();
            _reverseStringTable = new Dictionary <string, int>();
            _buffer             = new MemoryStream();

            _runtimeTypeModel = RuntimeTypeModel.Create();
            _runtimeTypeModel.Add(_blobHeaderType, true);
            _runtimeTypeModel.Add(_blobType, true);
            _runtimeTypeModel.Add(_primitiveBlockType, true);
            _runtimeTypeModel.Add(_headerBlockType, true);
        }
Пример #13
0
        public static void AddType(Type t, Action <object, string> action)
        {
            ushort number = GetInt16HashCode(t.FullName);

            if (t.IsDefined(typeof(SynchronizableAttribute), false))
            {
                model.Add(t, true);
                type.AddSubType(number, t);
            }

            typesDictionary.Add(t, number);
            types.Add(number, t);
            typesActions.Add(number, action);
        }
        /// <summary>
        /// Deserializes a scene with a style index.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="lazy"></param>
        /// <returns></returns>
        public Scene2DStyledSource Deserialize(Stream stream, bool lazy = true)
        {
            // read index bytes.
            byte[] indexSizeBytes = new byte[4];
            stream.Read(indexSizeBytes, 0, 4);
            int length = BitConverter.ToInt32(indexSizeBytes, 0);

            // move to the index position.
            RuntimeTypeModel typeModel = TypeModel.Create();

            typeModel.Add(typeof(Scene2DStyledIndex), true); // the styles index.

            typeModel.Add(typeof(Icon2DStyle), true);
            typeModel.Add(typeof(Image2DStyle), true);
            typeModel.Add(typeof(Line2DStyle), true);
            typeModel.Add(typeof(Point2DStyle), true);
            typeModel.Add(typeof(Polygon2DStyle), true);
            typeModel.Add(typeof(Text2DStyle), true);
            typeModel.Add(typeof(LineText2DStyle), true);

            // deserialize the index.
            byte[] indexBytes = new byte[length];
            stream.Read(indexBytes, 0, length);
            MemoryStream       cappedStream = new MemoryStream(indexBytes);
            Scene2DStyledIndex styleIndex   =
                typeModel.Deserialize(cappedStream, null, typeof(Scene2DStyledIndex)) as Scene2DStyledIndex;

            // initialize the serializer.
            Scene2DRTreeSerializer serializer = new Scene2DRTreeSerializer(true, styleIndex);

            return(new Scene2DStyledSource(
                       serializer.Deserialize(new LimitedStream(stream), true)));
        }
        /// <summary>
        /// Serializes a stream with a style index.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="index"></param>
        public void Serialize(Stream stream, RTreeMemoryIndex <Scene2DEntry> index)
        {
            Scene2DStyledIndex     styleIndex = new Scene2DStyledIndex();
            Scene2DRTreeSerializer serializer = new Scene2DRTreeSerializer(true, styleIndex);

            // serialize the tree and fill the styleindex.
            MemoryStream rTreeStream = new MemoryStream();

            serializer.Serialize(rTreeStream, index);

            // serialize the index.
            MemoryStream     indexStream = new MemoryStream();
            RuntimeTypeModel typeModel   = TypeModel.Create();

            typeModel.Add(typeof(Scene2DStyledIndex), true);

            typeModel.Add(typeof(Icon2DStyle), true);
            typeModel.Add(typeof(Image2DStyle), true);
            typeModel.Add(typeof(Line2DStyle), true);
            typeModel.Add(typeof(Point2DStyle), true);
            typeModel.Add(typeof(Polygon2DStyle), true);
            typeModel.Add(typeof(Text2DStyle), true);
            typeModel.Add(typeof(LineText2DStyle), true);

            typeModel.Serialize(indexStream, styleIndex);

            // write to the final stream.
            byte[] indexSizeBytes = BitConverter.GetBytes((int)indexStream.Length);
            stream.Write(indexSizeBytes, 0, indexSizeBytes.Length);
            indexStream.Seek(0, SeekOrigin.Begin);
            indexStream.WriteTo(stream);
            rTreeStream.WriteTo(stream);
            indexStream.Dispose();
            rTreeStream.Dispose();
        }
Пример #16
0
        public ProtobufSerializerFactory()
        {
            _runtimeTypeModel = TypeModel.Create();

            _runtimeTypeModel.Add(typeof(SomeMessage), true)
            .Add(1, "Text");

            _runtimeTypeModel.Add(typeof(RootObject), true)
            .Add(1, "BigObjects");

            _runtimeTypeModel.Add(typeof(BigObject), true)
            .Add(1, "Integer")
            .Add(2, "String");
        }
        private void Initialize()
        {
            if (_Model.GetTypes() != null)
            {
                return;
            }

            _Model.Add(_primaryType, true);
            foreach (var knownType in _secondaryTypes)
            {
                _Model.Add(knownType, true);
            }

            _Model.CompileInPlace();
        }
        public static RuntimeTypeModel AddRpcTypes(this RuntimeTypeModel typeModel)
        {
            if (typeModel is null)
            {
                throw new ArgumentNullException(nameof(typeModel));
            }

            var mt = typeModel.Add(typeof(RpcConnectionInfo), true);

            mt.UseConstructor = false;

            typeModel.Add(typeof(EventArgs), true);

            return(typeModel);
        }
Пример #19
0
        public void InitialStartup(ref int progress)
        {
            RuntimeTypeModel current = RuntimeTypeModel.Create();

            foreach (ITeachSerialization item in this.Teachers)
            {
                item.Teach(current);//Point teacher ain't loading
                progress++;
            }

            MetaType baseMessageType = current.Add(typeof(BaseMessage), true);

            // = ReflectionUtil.LoadAllInterface<IHasSubclasses>(Assembly.GetAssembly(typeof(BaseMessage)));
            List <IHasSubclasses> ToProcess = new List <IHasSubclasses>();

            ToProcess.AddRange(ReflectionUtil.LoadAllInterface <IHasSubclasses>(Assembly.GetAssembly(typeof(Tile))));

            foreach (IHasSubclasses item in ToProcess)
            {
                MetaType meta = current.Add(item.GetBaseType(), true);

                foreach (KeyValuePair <Type, int> subs in item.GetSubclassInformation())
                {
                    meta.AddSubType(subs.Value, subs.Key);
                }
            }

            //Must start at 2 because Protobuf-net can't have members and inheritance attributes with the same ID. I think. :D
            int i      = 2;
            int length = this.Messages.Count + 2;

            while (i < length)
            {
                current.Add(this.Messages[i - 2], true);
                baseMessageType.AddSubType(i, this.Messages[i - 2]);

                BaseMessage sample = (BaseMessage)Activator.CreateInstance(this.Messages[i - 2]);
                ProtoUtil.IDToMessage.Add(sample.ID, this.Messages[i - 2]);

                i++;
                progress++;
            }

            //ProtoUtil.TypeModel = RuntimeTypeModel.Default.
            //ProtoUtil.TypeModel = current.Compile();
            //ProtoUtil.TypeModel
            ProtoUtil.TypeModel = current;
        }
        protected void RegisterTypes(RuntimeTypeModel model)
        {
            Type[] serializableTypes = Reflection.GetAllFromCurrentAssembly()
                                       .Where(type => type.IsDefined(typeof(ProtoContractAttribute), false)).ToArray();

            foreach (Type type in serializableTypes)
            {
                if (type.IsGenericType())
                {
                    continue;
                }

                model.Add(type, true);
                model.Add(typeof(PrimitiveContract <>).MakeGenericType(type.MakeArrayType()), true);
                model.Add(typeof(List <>).MakeGenericType(type), true);
            }

            Type[] primitiveTypes = new[] {
                typeof(bool),
                typeof(char),
                typeof(byte),
                typeof(short),
                typeof(int),
                typeof(long),
                typeof(ushort),
                typeof(uint),
                typeof(ulong),
                typeof(string),
                typeof(float),
                typeof(double),
                typeof(decimal)
            };


            foreach (Type type in primitiveTypes)
            {
                if (type.IsGenericType())
                {
                    continue;
                }
                model.Add(typeof(List <>).MakeGenericType(type), true);
            }

#if !UNITY_WINRT
            Dictionary <System.Type, ISerializationSurrogate> surrogates = SerializationSurrogates.GetSurrogates();
            foreach (KeyValuePair <System.Type, ISerializationSurrogate> surrogate in surrogates)
#else
            Dictionary <System.Type, object> surrogates = SerializationSurrogates.GetSurrogates();
            foreach (KeyValuePair <System.Type, object> surrogate in surrogates)
#endif
            {
                model.Add(surrogate.Value.GetType(), true);
                model.Add(surrogate.Key, false).SetSurrogate(surrogate.Value.GetType());

                model.Add(typeof(PrimitiveContract <>).MakeGenericType(surrogate.Key.MakeArrayType()), true);
                model.Add(typeof(List <>).MakeGenericType(surrogate.Key), true);
            }
        }
Пример #21
0
        public static void Configure(RuntimeTypeModel model)
        {
            var type = model.Add(typeof(AgGateway.ADAPT.ApplicationDataModel.Documents.WorkOrder), Constants.UseDefaults);

            type.AddField(254, nameof(AgGateway.ADAPT.ApplicationDataModel.Documents.WorkOrder.StatusUpdates));
            type.AddField(532, nameof(AgGateway.ADAPT.ApplicationDataModel.Documents.WorkOrder.WorkItemIds));
        }
    protected ProtobufRuntimeModelSerializer(IEnumerable <Type> types, IDictionary <Type, IEnumerable <Type> >?subTypes = null)
    {
        Model = RuntimeTypeModel.Create();
        foreach (var type in types)
        {
            var metaType = Model.Add(type, false)
                           .Add(type
                                .GetProperties()
                                .Select(property => property.Name)
                                .OrderBy(name => name)
                                .ToArray());

            if (subTypes != null && subTypes.ContainsKey(type))
            {
                var subFieldNumber = 100;
                foreach (var subType in subTypes[type].OrderBy(x => x.Name))
                {
                    metaType.AddSubType(subFieldNumber++, subType);
                }
            }
        }

        // TODO: uncomment this for better performance.
        ////Model.Compile();
    }
Пример #23
0
        public static void Configure(RuntimeTypeModel model)
        {
            var type = model.Add(typeof(AgGateway.ADAPT.ApplicationDataModel.Guidance.APlus), Constants.UseDefaults);

            type.AddField(1, nameof(AgGateway.ADAPT.ApplicationDataModel.Guidance.APlus.Point));
            type.AddField(2, nameof(AgGateway.ADAPT.ApplicationDataModel.Guidance.APlus.Heading));
        }
Пример #24
0
        public static void Configure(RuntimeTypeModel model)
        {
            var type = model.Add(typeof(AgGateway.ADAPT.ApplicationDataModel.Logistics.Contact), Constants.UseDefaults);

            type.AddField(1, nameof(AgGateway.ADAPT.ApplicationDataModel.Logistics.Contact.Number));
            type.AddField(2, nameof(AgGateway.ADAPT.ApplicationDataModel.Logistics.Contact.Type));
        }
Пример #25
0
        public static void Configure(RuntimeTypeModel model)
        {
            var type = model.Add(typeof(AgGateway.ADAPT.ApplicationDataModel.Products.Product), Constants.UseDefaults);

            type.AddField(1, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.Id));
            type.AddField(15, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.BrandId));
            type.AddField(16, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.Category));
            type.AddField(2, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.ContextItems));
            type.AddField(17, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.Density));
            type.AddField(18, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.Description));
            type.AddField(19, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.Form));
            type.AddField(20, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.HasCropProtection));
            type.AddField(21, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.HasCropNutrition));
            type.AddField(22, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.HasCropVariety));
            type.AddField(23, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.HasHarvestCommodity));
            type.AddField(24, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.ManufacturerId));
            type.AddField(3, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.ProductComponents));
            type.AddField(25, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.ProductType));
            type.AddField(26, nameof(AgGateway.ADAPT.ApplicationDataModel.Products.Product.Status));

            type.AddSubType(101, typeof(AgGateway.ADAPT.ApplicationDataModel.Products.GenericProduct));
            type.AddSubType(102, typeof(AgGateway.ADAPT.ApplicationDataModel.Products.HarvestedCommodityProduct));
            type.AddSubType(103, typeof(AgGateway.ADAPT.ApplicationDataModel.Products.CropProtectionProduct));
            type.AddSubType(104, typeof(AgGateway.ADAPT.ApplicationDataModel.Products.CropVarietyProduct));
            type.AddSubType(105, typeof(AgGateway.ADAPT.ApplicationDataModel.Products.CropNutritionProduct));
            type.AddSubType(106, typeof(AgGateway.ADAPT.ApplicationDataModel.Products.MixProduct));
        }
Пример #26
0
        public static void Configure(RuntimeTypeModel model)
        {
            var type = model.Add(typeof(AgGateway.ADAPT.ApplicationDataModel.Prescriptions.RxRate), Constants.UseDefaults);

            type.AddField(1, nameof(AgGateway.ADAPT.ApplicationDataModel.Prescriptions.RxRate.Rate));
            type.AddField(2, nameof(AgGateway.ADAPT.ApplicationDataModel.Prescriptions.RxRate.RxProductLookupId));
        }
Пример #27
0
        public static void Configure(RuntimeTypeModel model)
        {
            var type = model.Add(typeof(AgGateway.ADAPT.ApplicationDataModel.Documents.StampedMeteredValues), Constants.UseDefaults);

            type.AddField(682, nameof(AgGateway.ADAPT.ApplicationDataModel.Documents.StampedMeteredValues.Values));
            type.AddField(683, nameof(AgGateway.ADAPT.ApplicationDataModel.Documents.StampedMeteredValues.Stamp));
        }
Пример #28
0
        public static void Configure(RuntimeTypeModel model)
        {
            var type = model.Add(typeof(AgGateway.ADAPT.ADMPlugin.Models.SerializableRasterData <AgGateway.ADAPT.ApplicationDataModel.Representations.NumericValue>), Constants.UseDefaults);

            type.AddField(1, nameof(AgGateway.ADAPT.ADMPlugin.Models.SerializableRasterData <AgGateway.ADAPT.ApplicationDataModel.Representations.NumericValue> .values));
            type.AddField(2, nameof(AgGateway.ADAPT.ADMPlugin.Models.SerializableRasterData <AgGateway.ADAPT.ApplicationDataModel.Representations.NumericValue> .Representation)).AsReference = Constants.UseAsReference;
        }
Пример #29
0
        public static void Configure(RuntimeTypeModel model)
        {
            var type = model.Add(typeof(AgGateway.ADAPT.ApplicationDataModel.ReferenceLayers.ShapeLookup), Constants.UseDefaults);

            type.AddField(1, nameof(AgGateway.ADAPT.ApplicationDataModel.ReferenceLayers.ShapeLookup.Shape));
            type.AddField(2, nameof(AgGateway.ADAPT.ApplicationDataModel.ReferenceLayers.ShapeLookup.SpatialAttribute));
        }
        public static RuntimeTypeModel WithTypeSurrogate <TType, TTypeSurrogate>(this RuntimeTypeModel model)
        {
            ValidateModel(model);

            model.Add(typeof(TType), false).SetSurrogate(typeof(TTypeSurrogate));
            return(model);
        }