Ejemplo n.º 1
0
        protected object ConvertFromProperty(cTSOProperty property, ISerializationContext context)
        {
            var _struct = GetStruct(property.StructType);

            if (_struct == null)
            {
                return(null);
            }

            if (!ModelsByName.ContainsKey(_struct.Name))
            {
                return(null);
            }

            var modelType = ModelsByName[_struct.Name];
            var instance  = ModelActivator.NewInstance(modelType);

            foreach (var field in property.StructFields)
            {
                var fieldDef = _struct.Fields.FirstOrDefault(x => x.ID == field.StructFieldID);
                if (fieldDef == null)
                {
                    continue;
                }

                var clazzProperty = modelType.GetProperty(fieldDef.Name);
                if (clazzProperty == null)
                {
                    continue;
                }
                clazzProperty.SetValue(instance, field.Value);
            }

            return(instance);
        }
 protected virtual VALUE LazyLoad(KEY key, VALUE oldVal)
 {
     return(ModelActivator.NewInstance <VALUE>());
 }
Ejemplo n.º 3
0
 protected virtual VALUE CreateInstance(KEY key)
 {
     return(ModelActivator.NewInstance <VALUE>());
 }