Exemple #1
0
            private void ObjectAdd(MorePropertyData prop, object obj, IFudgeField field, IFudgeDeserializer deserializer)
            {
                // Handles both reference and inline
                object subObject = deserializer.FromField(field, prop.PropertyData.Type);

                prop.PropertyData.Setter(obj, subObject);
            }
Exemple #2
0
            private void ExtractProperties(IEnumerable <TypeData.PropertyData> properties)
            {
                foreach (var prop in properties)
                {
                    var propData = new MorePropertyData {
                        PropertyData = prop
                    };
                    switch (prop.Kind)
                    {
                    case TypeData.TypeKind.FudgePrimitive:
                        propData.Adder      = this.PrimitiveAdd;
                        propData.Serializer = this.PrimitiveSerialize;
                        break;

                    case TypeData.TypeKind.Inline:
                        if (propData.PropertyData.HasPublicSetter)
                        {
                            propData.Adder = this.ObjectAdd;
                        }
                        else
                        {
                            // Must be a list
                            propData.Adder = ReflectionUtil.CreateInstanceMethodDelegate <Action <MorePropertyData, object, IFudgeField, IFudgeDeserializer> >(this, "ListAppend", new Type[] { prop.TypeData.SubType });
                        }
                        propData.Serializer = this.InlineSerialize;
                        break;

                    case TypeData.TypeKind.Reference:
                        propData.Adder      = this.ObjectAdd;
                        propData.Serializer = this.ReferenceSerialize;
                        break;
                    }
                    propMap.Add(prop.SerializedName, propData);
                }
            }
Exemple #3
0
            private void ListAppend <T>(MorePropertyData prop, object obj, IFudgeField field, IFudgeDeserializer deserializer) where T : class
            {
                IList <T> newList     = deserializer.FromField <IList <T> >(field);
                IList <T> currentList = (IList <T>)prop.PropertyData.Getter(obj);

                foreach (T item in newList)
                {
                    currentList.Add(item);
                }
            }
Exemple #4
0
            public void Serialize(object obj, IAppendingFudgeFieldContainer msg, IFudgeSerializer serializer)
            {
                beforeAfterMethodHelper.CallBeforeSerialize(obj);
                foreach (var entry in propMap)
                {
                    string           name = entry.Key;
                    MorePropertyData prop = entry.Value;
                    object           val  = prop.PropertyData.Getter(obj);

                    if (val != null)
                    {
                        prop.Serializer(prop, val, msg, serializer);
                    }
                }
                beforeAfterMethodHelper.CallAfterSerialize(obj);
            }
Exemple #5
0
 private void ReferenceSerialize(MorePropertyData prop, object val, IAppendingFudgeFieldContainer msg, IFudgeSerializer serializer)
 {
     // Serializer will in-line or not as appropriate
     msg.Add(prop.PropertyData.SerializedName, null, prop.PropertyData.TypeData.FieldType, val);
 }
Exemple #6
0
 private void InlineSerialize(MorePropertyData prop, object val, IAppendingFudgeFieldContainer msg, IFudgeSerializer serializer)
 {
     serializer.WriteInline(msg, prop.PropertyData.SerializedName, val);
 }
Exemple #7
0
            private void PrimitiveAdd(MorePropertyData prop, object obj, IFudgeField field, IFudgeDeserializer deserializer)
            {
                object val = context.TypeHandler.ConvertType(field.Value, prop.PropertyData.Type);

                prop.PropertyData.Setter(obj, val);
            }
Exemple #8
0
 private void PrimitiveSerialize(MorePropertyData prop, object val, IAppendingFudgeFieldContainer msg, IFudgeSerializer serializer)
 {
     msg.Add(prop.PropertyData.SerializedName, val);
 }