示例#1
0
 public ReadingContext(VersionKey version)
 {
     Template           = null;
     Argument           = 0;
     Parent             = null;
     Version            = version;
     VersionInterpreter = new Interpreter(version.AsState());
 }
示例#2
0
 public ReadingContext(string template, long argument, NiObjectSchema parent, VersionKey version, Interpreter versionInterpreter)
 {
     Template           = template;
     Argument           = argument;
     Parent             = parent;
     Version            = version;
     VersionInterpreter = versionInterpreter;
 }
示例#3
0
            /// <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();
            }
示例#4
0
        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);
        }
示例#5
0
            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();
            }
示例#6
0
        /// <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();
            }
        }
示例#7
0
 public Data ReadData(string type, VersionKey version)
 {
     return(ReadData(type, new ReadingContext(version)));
 }
示例#8
0
 public T Get(VersionKey id)
 {
     return(_context.Set <T>().Find(id.Id, id.Version));
 }