protected ValueNode(Node parent, string name, TypeNode typeNode) : base(parent) { Name = name; TypeNode = typeNode; Children = new List<ValueNode>(); }
public ArrayTypeNode(TypeNode parent, Type type) : base(parent, type) { Construct(); }
public ListTypeNode(TypeNode parent, Type type) : base(parent, type) { Construct(); }
public ValueTypeNode(TypeNode parent, Type type) : base(parent, type) { }
public ObjectTypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : base(parent, parentType, memberInfo) { }
public RootTypeNode(TypeNode parent, Type graphType) : base(parent, graphType) { Child = GenerateChild(graphType); }
public ValueValueNode(Node parent, string name, TypeNode typeNode) : base(parent, name, typeNode) { }
public EnumTypeNode(TypeNode parent, Type type) : base(parent, type) { InitializeEnumValues(); }
public UnknownTypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : base(parent, parentType, memberInfo) { }
public UnknownTypeNode(TypeNode parent, Type type) : base(parent, type) { }
public CustomTypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : base(parent, parentType, memberInfo) { }
public CustomTypeNode(TypeNode parent, Type type) : base(parent, type) { }
protected CollectionTypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : base(parent, parentType, memberInfo) { Construct(); }
protected CollectionTypeNode(TypeNode parent, Type type) : base(parent, type) { Construct(); }
protected ContainerTypeNode(TypeNode parent, Type type) : base(parent, type) { }
protected ContainerTypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : base(parent, parentType, memberInfo) { }
protected TypeNode(TypeNode parent) : base(parent) { }
public EnumTypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : base(parent, parentType, memberInfo) { InitializeEnumValues(); }
protected TypeNode(TypeNode parent, Type type) : this(parent) { Type = type; NullableUnderlyingType = Nullable.GetUnderlyingType(Type); }
protected CollectionValueNode(Node parent, string name, TypeNode typeNode) : base(parent, name, typeNode) { }
protected TypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : this(parent) { if (memberInfo == null) return; Name = memberInfo.Name; var propertyInfo = memberInfo as PropertyInfo; var fieldInfo = memberInfo as FieldInfo; if (propertyInfo != null) { Type = propertyInfo.PropertyType; ValueGetter = MagicMethods.MagicFunc(parentType, propertyInfo.GetGetMethod()); var setMethod = propertyInfo.GetSetMethod(); if(setMethod != null) ValueSetter = MagicMethods.MagicAction(parentType, setMethod); } else if (fieldInfo != null) { Type = fieldInfo.FieldType; ValueGetter = fieldInfo.GetValue; ValueSetter = fieldInfo.SetValue; } else throw new NotSupportedException(String.Format("{0} not supported", memberInfo.GetType().Name)); NullableUnderlyingType = Nullable.GetUnderlyingType(Type); var attributes = memberInfo.GetCustomAttributes(true); IgnoreAttribute = attributes.OfType<IgnoreAttribute>().SingleOrDefault(); /* Don't go any further if we're ignoring this. */ if (IsIgnored) return; var fieldOrderAttribute = attributes.OfType<FieldOrderAttribute>().SingleOrDefault(); if (fieldOrderAttribute != null) _order = fieldOrderAttribute.Order; var serializeAsAttribute = attributes.OfType<SerializeAsAttribute>().SingleOrDefault(); if (serializeAsAttribute != null) { _serializedType = serializeAsAttribute.SerializedType; Endianness = serializeAsAttribute.Endianness; if (!String.IsNullOrEmpty(serializeAsAttribute.Encoding)) Encoding = Encoding.GetEncoding(serializeAsAttribute.Encoding); } FieldLengthAttribute = attributes.OfType<FieldLengthAttribute>().SingleOrDefault(); if (FieldLengthAttribute != null) { FieldLengthBinding = new Binding(FieldLengthAttribute, GetBindingLevel(FieldLengthAttribute.Binding)); } FieldCountAttribute = attributes.OfType<FieldCountAttribute>().SingleOrDefault(); if (FieldCountAttribute != null) { FieldCountBinding = new Binding(FieldCountAttribute, FindAncestorLevel(FieldCountAttribute.Binding)); } FieldOffsetAttribute = attributes.OfType<FieldOffsetAttribute>().SingleOrDefault(); if (FieldOffsetAttribute != null) { FieldOffsetBinding = new Binding(FieldOffsetAttribute, GetBindingLevel(FieldOffsetAttribute.Binding)); } var serializeWhenAttributes = attributes.OfType<SerializeWhenAttribute>().ToArray(); SerializeWhenAttributes = new ReadOnlyCollection<SerializeWhenAttribute>(serializeWhenAttributes); if (SerializeWhenAttributes.Count > 0) { SerializeWhenBindings = new ReadOnlyCollection<ConditionalBinding>( serializeWhenAttributes.Select( attribute => new ConditionalBinding(attribute, GetBindingLevel(attribute.Binding))).ToList()); } var subtypeAttributes = attributes.OfType<SubtypeAttribute>().ToArray(); SubtypeAttributes = new ReadOnlyCollection<SubtypeAttribute>(subtypeAttributes); if (SubtypeAttributes.Count > 0) { var bindingGroups = SubtypeAttributes.GroupBy(subtypeAttribute => subtypeAttribute.Binding); if (bindingGroups.Count() > 1) throw new BindingException("Subtypes must all use the same binding configuration."); var firstBinding = SubtypeAttributes[0]; SubtypeBinding = new Binding(firstBinding, GetBindingLevel(firstBinding.Binding)); var valueGroups = SubtypeAttributes.GroupBy(attribute => attribute.Value); if (valueGroups.Count() < SubtypeAttributes.Count) throw new InvalidOperationException("Subtype values must be unique."); if (SubtypeBinding.BindingMode == BindingMode.TwoWay) { var subTypeGroups = SubtypeAttributes.GroupBy(attribute => attribute.Subtype); if (subTypeGroups.Count() < SubtypeAttributes.Count) throw new InvalidOperationException( "Subtypes must be unique for two-way subtype bindings. Set BindingMode to OneWay to disable updates to the binding source during serialization."); } var invalidSubtype = SubtypeAttributes.FirstOrDefault(attribute => !Type.IsAssignableFrom(attribute.Subtype)); if (invalidSubtype != null) throw new InvalidOperationException(String.Format("{0} is not a subtype of {1}", invalidSubtype.Subtype, Type)); } SerializeUntilAttribute = attributes.OfType<SerializeUntilAttribute>().SingleOrDefault(); if (SerializeUntilAttribute != null) { SerializeUntilBinding = new Binding(SerializeUntilAttribute, GetBindingLevel(SerializeUntilAttribute.Binding)); } ItemLengthAttribute = attributes.OfType<ItemLengthAttribute>().SingleOrDefault(); if (ItemLengthAttribute != null) { ItemLengthBinding = new Binding(ItemLengthAttribute, GetBindingLevel(ItemLengthAttribute.Binding)); } ItemSerializeUntilAttribute = attributes.OfType<ItemSerializeUntilAttribute>().SingleOrDefault(); if (ItemSerializeUntilAttribute != null) { ItemSerializeUntilBinding = new Binding(ItemSerializeUntilAttribute, GetBindingLevel(ItemSerializeUntilAttribute.Binding)); } }
public ObjectTypeNode(TypeNode parent, Type type) : base(parent, type) { }
public StreamTypeNode(TypeNode parent, Type type) : base(parent, type) { }
public PrimitveArrayValueNode(Node parent, string name, TypeNode typeNode) : base(parent, name, typeNode) { }
public StreamTypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : base(parent, parentType, memberInfo) { }
public ValueTypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : base(parent, parentType, memberInfo) { }
public PrimitiveListValueNode(Node parent, string name, TypeNode typeNode) : base(parent, name, typeNode) { }
public ListTypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : base(parent, parentType, memberInfo) { Construct(); }
public ArrayTypeNode(TypeNode parent, Type parentType, MemberInfo memberInfo) : base(parent, parentType, memberInfo) { Construct(); }