Пример #1
0
        public void DeleteInstance(NdfObject inst)
        {
            Instances.Remove(inst);
            NdfClass cls = inst.Class;

            cls.Instances.Remove(inst);

            if (TopObjects.Contains(inst.Id))
            {
                TopObjects.Remove(inst.Id);
            }
        }
Пример #2
0
        public NdfObject CreateInstanceOf(NdfClass cls, bool isTopLevelInstance = true)
        {
            var newId = (uint)Instances.Count();

            var inst = new NdfObject {
                Class = cls, Id = newId
            };

            AddEmptyProperties(inst);

            Instances.Add(inst);

            if (isTopLevelInstance)
            {
                TopObjects.Add(inst.Id);
                inst.IsTopObject = true;
            }

            return(inst);
        }
Пример #3
0
        public NdfObject CreateInstanceOf(NdfClass cls, bool isTopLevelInstance = true)
        {
            var newId = (uint)Instances.Count();

            var inst = new NdfObject { Class = cls, Id = newId };

            AddEmptyProperties(inst);

            Instances.Add(inst);

            if (isTopLevelInstance)
            {
                TopObjects.Add(inst.Id);
                inst.IsTopObject = true;
            }

            return inst;
        }
Пример #4
0
        /// <summary>
        /// Reads the Classes dictionary.
        /// </summary>
        /// <param name="ms"></param>
        /// <param name="owner"></param>
        /// <returns></returns>
        protected ObservableCollection<NdfClass> ReadClasses(Stream ms, NdfBinary owner)
        {
            var classes = new ObservableCollection<NdfClass>();

            NdfFooterEntry classEntry = owner.Footer.Entries.Single(x => x.Name == "CLAS");

            ms.Seek(classEntry.Offset, SeekOrigin.Begin);

            uint i = 0;
            var buffer = new byte[4];

            while (ms.Position < classEntry.Offset + classEntry.Size)
            {
                var nclass = new NdfClass(owner, i);

                ms.Read(buffer, 0, buffer.Length);
                int strLen = BitConverter.ToInt32(buffer, 0);

                var strBuffer = new byte[strLen];
                ms.Read(strBuffer, 0, strBuffer.Length);

                nclass.Name = Encoding.GetEncoding("ISO-8859-1").GetString(strBuffer);

                i++;
                classes.Add(nclass);
            }

            return classes;
        }