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, }); }
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); }
public ReadingContext(VersionKey version) { Template = null; Argument = 0; Parent = null; Version = version; VersionInterpreter = new Interpreter(version.AsState()); }
public ReadingContext(string template, long argument, NiObjectSchema parent, VersionKey version, Interpreter versionInterpreter) { Template = template; Argument = argument; Parent = parent; Version = version; VersionInterpreter = versionInterpreter; }
TypeBuilder BuildNiObjectType(ModuleBuilder moduleBuilder, NiObjectSchema schema) { var name = schema.Name.ToPascalCase(); var attr = TypeAttributes.Public; var niObjectBuilder = moduleBuilder.DefineType(name, attr); return(niObjectBuilder); }
public List <FieldSchema> GetFields(NiObjectSchema niObjectSchema) { if (NiObjectFields.TryGetValue(niObjectSchema, out var fields)) { return(fields); } throw new Exception(); }
public Type SetParentBySchema(TypeBuilder typeBuilder, NiObjectSchema schema) { if (schema.Inherits != null) { typeBuilder.SetParent(SchemaTypes.SchemaTypesByName[schema.Inherits]); } return(typeBuilder.BaseType); }
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); }
public ReadingContext Extend(NiObjectSchema parent) { return(new ReadingContext(Template, Argument, parent, Version, VersionInterpreter)); }
public Interpreter.State BuildNiObjectState(NiObjectSchema compound) { return(null); }