Exemplo n.º 1
0
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);
            var nodes            = treeNode.GetMappedChildNodes();
            var definitionOrStmt = nodes[0].ChildNodes;
            var importCount      = 0;
            var definitionCount  = 0;
            var stmtCount        = 0;

            foreach (var node in definitionOrStmt)
            {
                if (node.Term.Name[0] == '$')//Chapus medio alto para saber si es import
                {
                    ImportList.Add(AddChild("Import: " + importCount, node));
                    importCount++;
                }
                else if (node.Term.Name[0] == '#')//Chapus medio alto para saber si es definition
                {
                    DefinitonList.Add(AddChild("Definition: " + definitionCount, node));
                    definitionCount++;
                }
                else
                {
                    StmtList.Add(AddChild("stmt " + stmtCount, node));
                    stmtCount++;
                }
            }
        }
        public void AddBookToBill()
        {
            if (SelectedBook is null)
            {
                ShowMessage(new Models.Message("Thông báo", "Chưa chọn sách"));
                return;
            }
            ImportItem item  = new ImportItem(SelectedBook, Amount, CoverPrice, ImportPrice);
            ImportItem check = ImportList.FirstOrDefault(x => x.BookId == item.BookId && x.CoverPrice == item.CoverPrice && x.ImportPrice == item.ImportPrice);

            if (check is null)
            {
                ImportList.Add(item);
            }
            else
            {
                check.Amount += item.Amount;
            }
            TotalBooks += item.Amount;
            TotalPrice += item.TotalPrice;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize the <see cref="Package"/> by reading from the given filename.
        /// </summary>
        /// <param name="state">The <see cref="State"/> this <see cref="Package"/> is to exist within.</param>
        /// <param name="fileName">The name of the file to open that contains the <see cref="Package"/>.</param>
        /// <param name="reader">The <see cref="BinaryReader"/> to read from.</param>
        public Package(State state, string fileName, BinaryReader reader)
        {
            if (state == null)
                throw new ArgumentNullException("state");
            if (reader == null)
                throw new ArgumentNullException("reader");

            if (reader.ReadInt32() != Magic)
                throw new Exception("Unreal package magic test failed.");
            Reader = reader;

            FileName = fileName;
            Export = new Unreal.Export(this, -1);
            Export.Name = Path.GetFileNameWithoutExtension(fileName);
            Export.LoadedObject = this;

            StateValue = state;
            FileVersion = reader.ReadUInt16();
            LicenseMode = reader.ReadUInt16();
            Flags = (PackageFlag)reader.ReadUInt32();
            var nameCount = reader.ReadInt32();
            var nameOffset = reader.ReadUInt32();
            var exportCount = reader.ReadInt32();
            var exportOffset = reader.ReadUInt32();
            var importCount = reader.ReadInt32();
            var importOffset = reader.ReadUInt32();
            if (FileVersion >= 68)
                Guid = new Guid(reader.ReadBytes(16));

            Imports = new ImportList(importCount);
            for (var index = 0; index < importCount; index++)
                Imports.Add(new Import(this, index));

            Exports = new ExportList(exportCount);
            for (var index = 0; index < exportCount; index++)
                Exports.Add(new Export(this, index));

            Names = new NameList(nameCount);
            reader.BaseStream.Position = nameOffset;
            for (var index = 0; index < nameCount; index++)
                Names.Add(new Name(this, reader));

            reader.BaseStream.Position = exportOffset;
            for (var index = 0; index < exportCount; index++)
                Exports[index].Load(reader);

            reader.BaseStream.Position = importOffset;
            for (var index = 0; index < importCount; index++)
                Imports[index].Load(reader);

            FilteredExports = new ExportList(exportCount);
            foreach (var export in Exports) {
                /*if(export.ObjectClassReference != null && export.ObjectClassReference.Name.EndsWith("Property")) {
                    if(((((Alexandria.Engines.Unreal.Core.Property)export.Object).PropertyFlags) & Alexandria.Engines.Unreal.Core.PropertyFlag.Test) != 0)
                        FilteredExports.Add(export);
                }*/
                if (export.ObjectClassReference == null || !export.ObjectClassReference.Name.EndsWith("Property"))
                    FilteredExports.Add(export);
            }

            Game = DetermineGame(FileVersion, LicenseMode, IsEncrypted);
        }