Exemplo n.º 1
0
        public DataReader(SchemaDocument document,
                          ReadBasicData readBasicFunc,
                          TryReadCompoundData readCompoundFunc = null)
        {
            Document              = document;
            ReadBasicFunc         = readBasicFunc;
            ReadExtraCompoundFunc = readCompoundFunc;

            Inheritance = document.InheritanceLookup;
            Expressions = document.ExpressionLookup;
        }
Exemplo n.º 2
0
        public SchemaDocument(XElement element)
        {
            SchemaVersion = NIFVersion.Parse(element.Attribute("version").Value);

            var elementsByName = element.Elements()
                                 .ToLookup(e => e.Name);

            Tokens = elementsByName["token"]
                     .Select(e => new TokenSchema(e))
                     .ToList();
            Versions = elementsByName["version"]
                       .Select(e => new VersionSchema(e))
                       .ToList();

            NiObjects = elementsByName["niobject"]
                        .Select(e => new NiObjectSchema(e))
                        .ToDictionary(s => s.Name);
            Compounds = elementsByName["compound"]
                        .Select(e => new CompoundSchema(e))
                        .ToDictionary(s => s.Name);
            Basics = elementsByName["basic"]
                     .Select(e => new BasicSchema(e))
                     .ToDictionary(s => s.Name);
            Enums = elementsByName["enum"]
                    .Select(e => new EnumSchema(e))
                    .ToDictionary(s => s.Name);
            Bitfields = elementsByName["bitfield"]
                        .Select(e => new BitFieldSchema(e))
                        .ToDictionary(s => s.Name);
            Bitflags = elementsByName["bitflags"]
                       .Select(e => new BitflagsSchema(e))
                       .ToDictionary(s => s.Name);

            TokenLookup       = new TokenLookup(Tokens.Concat(StaticTokens));
            InheritanceLookup = new InheritanceLookup(NiObjects);
            ExpressionLookup  = new ExpressionLookup(NiObjects.Values, Compounds.Values, TokenLookup);
            ParameterLookup   = new ParameterLookup(Compounds.Values, ExpressionLookup);
            TypeLookup        = new TypeLookup(Compounds.Values, NiObjects.Values);
        }