示例#1
0
        public GffRootStruct CreateRoot()
        {
            var rootFrame = _gbase.StructArray[(int)GffRootStruct.RootIndex];
            var root      = new GffRootStruct(_gbase.Header.Type);

            PopulateStruct(root, GetStructFieldIndices(rootFrame));
            return(root);
        }
示例#2
0
 public void Load(string path)
 {
     Initialize();
     if (File.Exists(path) && Path.GetExtension(path) == Ext)
     {
         Xdoc.Load(path);
     }
     Xroot      = Xdoc.SelectSingleNode("/" + EStruct);
     RootStruct = (GffRootStruct)CreateComponent(Xroot);
 }
示例#3
0
        public MemoryStream Save(GffRootStruct root)
        {
            _bw  = new LatinBinaryWriter(new MemoryStream());
            _rt  = root;
            _ext = root.Extention;
            DfaF = new DoubleDictionary <GffFieldFrame, GffComponent>();
            DsaS = new DoubleDictionary <GffStructFrame, GffStruct>();

            CreateFrames(_rt);
            FillFrames();
            WriteData();

            var res = _bw.BaseStream;

            _bw.Close();
            return((MemoryStream)res);
        }
示例#4
0
        private GffComponent CreateComponent(XmlNode node)
        {
            GffComponent cpnt = null;

            switch (node.Name)
            {
            case EStruct:
                switch (GetStructClass(node))
                {
                case SclassInField:
                    cpnt = new GffInFieldStruct(GetLabel(node), GetStructType(node));
                    break;

                case SclassInList:
                    cpnt = new GffInListStruct(GetStructType(node));
                    break;

                case SclassRoot:
                    cpnt = new GffRootStruct(GetExtention(node));
                    break;
                }
                break;

            case EList:
                cpnt = new GffList(GetLabel(node));
                break;

            case EField:
                cpnt = new GffField(GetLabel(node), GetFieldType(node), GetFieldValue(node));
                break;
            }
            var composite = cpnt as GffComposite;

            if (composite == null)
            {
                return(cpnt);
            }
            var cpsit = composite;

            foreach (XmlNode child in node.ChildNodes)
            {
                cpsit.Add(CreateComponent(child));
            }
            return(cpnt);
        }
示例#5
0
        public void Save(GffRootStruct root, string path)
        {
            Initialize();
            _rootStruct = root;
            FileStream fs;

            if (File.Exists(path))
            {
                fs = new FileStream(path, FileMode.Truncate);
            }
            else
            {
                fs = new FileStream(path, FileMode.Create);
            }
            Xdoc.AppendChild(Xdoc.CreateXmlDeclaration("1.0", LatinEncoding.Name, "yes"));
            Write(Xdoc, _rootStruct);
            Xdoc.Save(fs);
            fs.Close();
        }
 public void Save(GffRootStruct root, string path)
 {
     _xwrite.Save(root, path);
 }
示例#7
0
 public void Save(GffRootStruct root, string path)
 {
     File.WriteAllBytes(path, Save(root).ToArray());
 }
示例#8
0
 public Stream Save(GffRootStruct root)
 {
     return(_wr.Save(root));
 }