Example #1
0
            public TypedValue Data(ComponentDataList list, TGIBlockList tgiBlocks)
            {
                if (!ComponentDataMap.ContainsKey(element))
                {
                    return(null);
                }
                if (!list.ContainsKey(ComponentDataMap[element]))
                {
                    return(null);
                }
                ComponentDataType cd = list[ComponentDataMap[element]];

                System.Reflection.PropertyInfo pi = cd.GetType().GetProperty("Data");
                if (pi == null || !pi.CanRead)
                {
                    return(null);
                }
                if (element == Component.Footprint || element == Component.Model || element == Component.Tree)
                {
                    return(new TypedValue(typeof(TGIBlock), tgiBlocks[(int)pi.GetValue(cd, null)], "X"));
                }
                else
                {
                    return(new TypedValue(pi.PropertyType, pi.GetValue(cd, null), "X"));
                }
            }
Example #2
0
        void Parse(Stream s)
        {
            long         tgiPosn, tgiSize;
            BinaryReader r = new BinaryReader(s);

            format  = r.ReadUInt32();
            tgiPosn = r.ReadUInt32() + s.Position;
            tgiSize = r.ReadUInt32();

            components    = new ComponentList(OnResourceChanged, s);
            componentData = new ComponentDataList(OnResourceChanged, s);
            unknown1      = r.ReadByte();

            tgiBlocks = new TGIBlockList(OnResourceChanged, s, tgiPosn, tgiSize);

            componentData.ParentTGIBlocks = tgiBlocks;
        }
Example #3
0
        protected override Stream UnParse()
        {
            long         posn;
            MemoryStream s = new MemoryStream();
            BinaryWriter w = new BinaryWriter(s);

            w.Write(format);

            posn = s.Position;
            w.Write((uint)0);
            w.Write((uint)0);

            if (components == null)
            {
                components = new ComponentList(OnResourceChanged);
            }
            components.UnParse(s);

            if (tgiBlocks == null)
            {
                tgiBlocks = new TGIBlockList(OnResourceChanged);
            }
            if (componentData == null)
            {
                componentData = new ComponentDataList(OnResourceChanged, tgiBlocks);
            }
            componentData.UnParse(s);

            w.Write(unknown1);

            tgiBlocks.UnParse(s, posn);

            s.Flush();

            return(s);
        }