예제 #1
0
 public ClassFolder()
 {
     _isBrowsable       = true;
     _dataMode          = ClassFolderDataMode.Integrated;
     items              = new ArrayList();
     extensions         = new Dictionary <Type, ClassFolderExtension>();
     readOnlyExtensions = new ReadOnlyDictionary <Type, ClassFolderExtension>(extensions);
     _isExpanded        = true;
     builder            = ClassFolderBuilder.Default;
 }
예제 #2
0
        public ClassFolder(XmlTextReader r, string version) : this()
        {
            if (r.Name != "ClassFolder")
            {
                throw new Exception(string.Format("Source file does not match NitroCast DTD; " +
                                                  "expected 'ClassModel', found '{0}'.", r.Name));
            }

            base.ParseXml(r);

            if (r.Name == "Builder")
            {
                ClassFolderBuilder.Builders.TryGetValue(r.ReadElementString("Builder"), out builder);
            }

            _isExpanded         = bool.Parse(r.ReadElementString("IsExpanded"));
            _isItemListExpanded = bool.Parse(r.ReadElementString("IsItemListExpanded"));

            if (r.Name == "IsReadOnly")
            {
                _isReadOnly = bool.Parse(r.ReadElementString("IsReadOnly"));
            }
            else
            {
                _isReadOnly = false;
            }

            if (r.Name == "IsBrowsable")
            {
                _isBrowsable = bool.Parse(r.ReadElementString("IsBrowsable"));
            }
            else
            {
                _isBrowsable = true;
            }

            if (r.Name == "IsPartition")
            {
                _isPartition = bool.Parse(r.ReadElementString("IsPartition"));
            }
            else
            {
                _isPartition = false;
            }

            if (r.Name == "DataMode")
            {
                _dataMode = (ClassFolderDataMode)Enum.Parse(typeof(ClassFolderDataMode), r.ReadElementString("DataMode"), true);
            }
            else
            {
                _dataMode = ClassFolderDataMode.Integrated;
            }

            if (r.Name == "Items")
            {
                if (!r.IsEmptyElement)
                {
                    r.Read();

                    while ((r.Name == "FieldEntry" |
                            r.Name == "ChildEntry" |
                            r.Name == "EnumField"))
                    {
                        //r.Read();
                        switch (r.LocalName)
                        {
                        case "FieldEntry":
                            ValueField vf = new ValueField(r, version);
                            vf.ParentFolder = this;
                            items.Add(vf);
                            break;

                        case "ChildEntry":
                            ReferenceField rf = new ReferenceField(r, version);
                            rf.ParentFolder = this;
                            items.Add(rf);
                            break;

                        case "EnumField":
                            EnumField ef = new EnumField(r, version);
                            ef.ParentFolder = this;
                            items.Add(ef);
                            break;
                        }
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            if (r.Name == "Extensions")
            {
                if (!r.IsEmptyElement)
                {
                    r.Read();

                    while (r.Name == "Extension")
                    {
                        ClassFolderExtension newExtension = (ClassFolderExtension)
                                                            ObjectExtension.Build(r, version);
                        extensions.Add(newExtension.GetType(), newExtension);
                        r.ReadEndElement();
                    }

                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            r.ReadEndElement();
        }