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; }
/// <exception cref="System.IO.IOException"/> private void WriteVersion() { DataOutputStream @out = this.writer.PrepareAppendKey(-1); VersionKey.Write(@out); @out.Close(); @out = this.writer.PrepareAppendValue(-1); @out.WriteInt(Version); @out.Close(); }
public SchemaFieldBuilder(SchemaDocumentBuilder documentBuilder, VersionKey version) { Doc = documentBuilder; var state = version.AsState(); var interpreter = new Interpreter(state); var compoundFields = documentBuilder.Document .Compounds.Values .Select(c => (c.Name, c.Fields)); var niObjectFields = documentBuilder.Document .NiObjects.Values .Select(ni => (ni.Name, ni.Fields)); IncludedFieldsByTypeName = compoundFields.Concat(niObjectFields) .ToDictionary( p => p.Name, p => p.Fields .Where(f => IsFieldIncluded(f, interpreter, version)) .ToList() ); FieldTypes = IncludedFieldsByTypeName .SelectMany(kvp => kvp.Value.Select(field => (field, documentBuilder.SchemaTypes.GetFieldType(field)))) .ToDictionary(ft => ft.field, ft => ft.Item2); FieldTypes = IncludedFieldsByTypeName .SelectMany(kvp => kvp.Value.Select(field => (field, documentBuilder.SchemaTypes.GetFieldType(field)))) .ToDictionary(ft => ft.field, ft => ft.Item2); FieldBuilders = IncludedFieldsByTypeName .SelectMany(kvp => kvp.Value.Select(field => (field, BuildField(kvp.Key, field)))) .ToDictionary(p => p.field, p => p.Item2); }
static VersionInfo() { List <VersionKey> VersionList = new List <VersionKey>(); string[] lineSplit = Resources.VersionData.Split('\n'); foreach (string versionLine in lineSplit) { string[] tabSplit = versionLine.Split('\t'); VersionKey vk = new VersionKey(); vk.VersionName = tabSplit[0]; vk.ProtocolVersion = int.Parse(tabSplit[1]); if (tabSplit.Length == 3) { vk.BaseVersionName = tabSplit[2]; } else { vk.BaseVersionName = vk.VersionName; } VersionList.Add(vk); //Console.WriteLine(vk.ProtocolVersion + " " + vk.VersionName + " " + vk.BaseVersionName); } Versions = VersionList.ToArray(); }
/// <summary> /// Writes types for each niObject, compound, enum, bitflag and bitfield /// into a reflection module, as well as building constructors for each /// type. /// </summary> /// <param name="moduleBuilder">The module to write the types to</param> /// <param name="document">The base schema document that described the types in NIF.xml/BlockStructure format</param> /// <param name="basics">A map of basic type names to their primitive values</param> /// <param name="version">The specific version of the document to use</param> public SchemaDocumentBuilder(ModuleBuilder moduleBuilder, SchemaDocument document, Dictionary <string, Type> basics, VersionKey version) { Document = document; SchemaBasicReader = new SchemaBasicReaderBuilder(moduleBuilder, document, basics); SchemaTypes = new SchemaTypeBuilder(document, moduleBuilder, SchemaBasicReader); SchemaFields = new SchemaFieldBuilder(this, version); SchemaInheritance = new SchemaInheritanceBuilder(SchemaTypes); SchemaEnum = new SchemaEnumBuilder(SchemaTypes); SchemaConstructors = new SchemaConstructorBuilder(document, SchemaTypes, SchemaFields, SchemaBasicReader); SchemaILBuilder = new SchemaConstructorILBuilder(this); foreach (var enumBuilder in SchemaTypes.BuiltEnumsByName.Values) { enumBuilder.CreateTypeInfo(); } foreach (var typeBuilder in SchemaTypes.BuiltTypesByName.Values) { typeBuilder.CreateTypeInfo(); } }
public Data ReadData(string type, VersionKey version) { return(ReadData(type, new ReadingContext(version))); }
public T Get(VersionKey id) { return(_context.Set <T>().Find(id.Id, id.Version)); }