コード例 #1
0
        NiObjectData ReadNiObject(NiObjectSchema niObject,
                                  ReadingContext parentContext)
        {
            var fields       = Inheritance.GetFields(niObject);
            var state        = Document.ParameterLookup.BuildNiObjectState(niObject);
            var interpreter  = new Interpreter(state);
            var childContext = parentContext.Extend(niObject);
            var niObjectData = new Dictionary <string, Data>();

            foreach (var fieldSchema in fields)
            {
                var fieldData = ReadField(fieldSchema, interpreter, childContext);
                if (fieldData == null)
                {
                    continue;
                }
                //state.Set(fieldSchema, Oldvalue.From(fieldData));
                niObjectData[fieldSchema.Name] = fieldData;
            }

            return(new NiObjectData()
            {
                Name = niObject.Name,
                Fields = niObjectData,
                Schema = niObject,
            });
        }
コード例 #2
0
        public bool CheckIncludedInType(FieldSchema fieldSchema, NiObjectSchema parent)
        {
            if (parent == null)
            {
                return(true);
            }

            if (NiObjectInheritance.TryGetValue(parent, out var inheritance))
            {
                if (fieldSchema.OnlyT != null)
                {
                    if (!inheritance.Any(inheritedNi => inheritedNi.Name == fieldSchema.OnlyT))
                    {
                        return(false);
                    }
                }

                if (fieldSchema.ExcludeT != null)
                {
                    if (inheritance.Any(inheritedNi => inheritedNi.Name == fieldSchema.ExcludeT))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            return(true);
        }
コード例 #3
0
 public ReadingContext(VersionKey version)
 {
     Template           = null;
     Argument           = 0;
     Parent             = null;
     Version            = version;
     VersionInterpreter = new Interpreter(version.AsState());
 }
コード例 #4
0
 public ReadingContext(string template, long argument, NiObjectSchema parent, VersionKey version, Interpreter versionInterpreter)
 {
     Template           = template;
     Argument           = argument;
     Parent             = parent;
     Version            = version;
     VersionInterpreter = versionInterpreter;
 }
コード例 #5
0
        TypeBuilder BuildNiObjectType(ModuleBuilder moduleBuilder, NiObjectSchema schema)
        {
            var name            = schema.Name.ToPascalCase();
            var attr            = TypeAttributes.Public;
            var niObjectBuilder = moduleBuilder.DefineType(name, attr);

            return(niObjectBuilder);
        }
コード例 #6
0
 public List <FieldSchema> GetFields(NiObjectSchema niObjectSchema)
 {
     if (NiObjectFields.TryGetValue(niObjectSchema, out var fields))
     {
         return(fields);
     }
     throw new Exception();
 }
コード例 #7
0
        public Type SetParentBySchema(TypeBuilder typeBuilder, NiObjectSchema schema)
        {
            if (schema.Inherits != null)
            {
                typeBuilder.SetParent(SchemaTypes.SchemaTypesByName[schema.Inherits]);
            }

            return(typeBuilder.BaseType);
        }
コード例 #8
0
        public List <NiObjectSchema> GetInheritenceChain(
            NiObjectSchema schema,
            Dictionary <string, NiObjectSchema> niObjects)
        {
            if (schema.Inherits == null)
            {
                return new List <NiObjectSchema>()
                       {
                           schema
                       }
            }
            ;

            var chain = GetInheritenceChain(niObjects[schema.Inherits], niObjects);

            chain.Add(schema);
            return(chain);
        }
コード例 #9
0
 public ReadingContext Extend(NiObjectSchema parent)
 {
     return(new ReadingContext(Template, Argument, parent, Version, VersionInterpreter));
 }
コード例 #10
0
 public Interpreter.State BuildNiObjectState(NiObjectSchema compound)
 {
     return(null);
 }