Exemplo n.º 1
0
        private static SerializableStructure ForceCreateComplexStructure(SerializableType type, int depth)
        {
            SerializableStructure @base = type.Base == null ? null : ForceCreateComplexStructure(type.Base, depth);

            if (type.Fields.Count > 0 && depth <= MaxDepthLevel)
            {
                List <SerializableField> fields = new List <SerializableField>();
                foreach (Field field in type.Fields)
                {
                    if (depth == MaxDepthLevel)
                    {
                        if (field.Type.Type == PrimitiveType.Complex)
                        {
                            continue;
                        }
                        if (field.IsArray)
                        {
                            continue;
                        }
                    }

                    ISerializableStructure fieldStructure = field.Type.Type == PrimitiveType.Complex ? CreateComplexStructure(field.Type, depth + 1) : null;
                    SerializableField      sField         = new SerializableField(field.Type.Type, fieldStructure, field.IsArray, field.Name);
                    fields.Add(sField);
                }
                return(new SerializableStructure(type, @base, fields.ToArray()));
            }
            else
            {
                return(new SerializableStructure(type, @base, EmptyFields));
            }
        }
        protected static SerializableField[] CreateFields(SerializableStructure copy)
        {
            List <SerializableField> fields = new List <SerializableField>();

            foreach (SerializableField field in copy.Fields)
            {
                SerializableField fieldCopy = field.CreateCopy();
                fields.Add(fieldCopy);
            }
            return(fields.ToArray());
        }
Exemplo n.º 3
0
 private SerializableField(SerializableField copy) :
     this(copy.Type, copy.ComplexType, copy.IsArray, copy.Name)
 {
 }
 internal SerializableStructure(SerializableType type, int depth)
 {
     Depth  = depth;
     Type   = type ?? throw new ArgumentNullException(nameof(type));
     Fields = new SerializableField[type.FieldCount];
 }