Example #1
0
        public WidgetProps ParseXml(string xmlfilename)
        {
            WidgetProps props = null;
            string elemType = "";
            string elemName = "";
            object elemValue = null;
            string elemCategory = "";
            string elemDesc = "";
            bool elemBrowsable = true;
            bool elemReadOnly = false;
            string elemEditor = "";
            string elemTypeConv = "";

            // Parse XML file
            System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
            System.IO.Stream str = a.GetManifestResourceStream("mkdb.Properties.wxprops.xsd");
            xsd_settings = new XmlReaderSettings();
            xsd_settings.ValidationType = ValidationType.Schema;
            xsd_settings.Schemas.Add("wxprops", new XmlTextReader(str));
            // xsd_settings.Schemas.Add("props", xsdfilename);

            using (r = XmlReader.Create(xmlfilename, xsd_settings))
              			while (r.Read())
              			{
                switch (r.NodeType)
                {
              				case XmlNodeType.Element:
                        if (r.Name == "Catalog")
                        {
                            // Set Name
                            if (props == null)
                            {
                                props = new WidgetProps();
                            }
                            props.Name = r["Name"];
                            // this.name = r["Name"];
                            // this.basecontainername = r["Base"];
                        }
                        if (r.Name == "Category")
                        {
                            elemCategory = GetElemString(r);
                        }
                        if (r.Name == "Property")
                        {
                            // Parse the data...
                            elemType = "";
                            elemName = r["Name"];
                            elemValue = null;
                            elemDesc = "";
                            elemBrowsable = true;
                            elemReadOnly = false;
                            elemEditor = "";
                            elemTypeConv = "";
                        }
                        if (r.Name == "Type") elemType = GetElemString(r);
                        if (r.Name == "Description") elemDesc = GetElemString(r);
                        if (r.Name == "Editor") elemEditor = GetElemString(r);
                        if (r.Name == "TypeConverter") elemTypeConv = GetElemString(r);
                        if (r.Name == "Value") GetElemValue(r, elemType, out elemValue);
                        break;
              				case XmlNodeType.EndElement:
                        if (r.Name == "Property")
                        {
                            // We should have all the info...
                            // build this GenericProperty
                            int attCount = 2;
                            if (elemEditor != "") attCount++;
                            if (elemTypeConv != "") attCount++;
                            Attribute[] attr = new Attribute[attCount];
                            attr[0] = new BrowsableAttribute(elemBrowsable);
                            attr[1] = new ReadOnlyAttribute(elemReadOnly);
                            attCount = 2;
                            if (elemEditor != "")
                            {
                                attr[attCount++] = new EditorAttribute(elemEditor, "UITypeEditor");
                            }
                            if (elemTypeConv != "")
                            {
                                attr[attCount++] = new TypeConverterAttribute(elemTypeConv);
                            }
                            if (elemValue == null)
                            {
                                GetElemDefault(r, elemType, elemValue);
                            }
                            props.Properties.AddProperty(new GenericProperty(elemName, elemValue, elemCategory,
                                                                             elemDesc, attr));
                        }
                        if (r.Name == "Category")
                        {
                            elemCategory = "";
                        }
                        break;

              				case XmlNodeType.Text:
              				case XmlNodeType.CDATA:
              				case XmlNodeType.Comment:
              				case XmlNodeType.XmlDeclaration:
                        break;

              				case XmlNodeType.DocumentType:
                        break;

              				default: break;
                }
              			}
            _wplist.Add(props);
            return props;
        }
Example #2
0
 public void RemoveCatalog(WidgetProps item)
 {
     _wplist.Remove(item);
 }
Example #3
0
 public int AddCatalog(WidgetProps item)
 {
     return _wplist.Add(item);
 }