Example #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));
            }
            else
            {
                return(new SerializableStructure(type, @base, EmptyFields));
            }
        }
        protected static SerializableStructure CreateBase(SerializableStructure copy)
        {
            if (copy.Base == null)
            {
                return(null);
            }

            return((SerializableStructure)copy.Base.CreateDuplicate());
        }
        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());
        }
Example #4
0
 private static ISerializableStructure CreateComplexStructure(SerializableType type, int depth)
 {
     if (IsEngineStruct(type.Namespace, type.Name))
     {
         return(SerializableStructure.EngineTypeToScriptStructure(type.Name));
     }
     if (type.IsEnginePointer())
     {
         return(new SerializablePointer(type));
     }
     return(ForceCreateComplexStructure(type, depth));
 }
 protected SerializableStructure(SerializableStructure copy) :
     this(copy.Type, CreateBase(copy), CreateFields(copy))
 {
 }
 internal SerializableStructure(SerializableType type, SerializableStructure @base, IReadOnlyList <SerializableField> fields)
 {
     Type   = type ?? throw new ArgumentNullException(nameof(type));
     Base   = @base;
     Fields = fields ?? throw new ArgumentNullException(nameof(fields));
 }