Beispiel #1
0
        internal static void ApplyXmlStreamObjectAttributes(XmlNode node, XmlStreamObject xso)
        {
            if (node.Attributes["_category"] != null)
            {
                xso.Category = node.Attributes["_category"].Value;
            }

            if (node.Attributes["_description"] != null)
            {
                xso.Description = node.Attributes["_description"].Value;
            }

            if (node.Attributes["_displayname"] != null)
            {
                xso.DisplayName = node.Attributes["_displayname"].Value;
            }

            if (node.Attributes["_isreadonly"] != null)
            {
                xso.IsReadOnly = Convert.ToBoolean(node.Attributes["_isreadonly"].Value);
            }

            if (node.Attributes["_visible"] != null)
            {
                xso.Visible = Convert.ToBoolean(node.Attributes["_visible"].Value);
            }
        }
Beispiel #2
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptor[] newProps = new PropertyDescriptor[_propertyCollection.Count];
            for (int i = 0; i < _propertyCollection.Count; i++)
            {
                CustomProperty prop = (CustomProperty)_propertyCollection[i];

                List <Attribute> propAttributes = new List <Attribute>();
                if (prop.propValueObject is XmlStreamObject)
                {
                    XmlStreamObject xso = (XmlStreamObject)prop.propValueObject;
                    if (!String.IsNullOrEmpty(xso.DisplayName))
                    {
                        propAttributes.Add(new DisplayNameAttribute(xso.DisplayName));
                    }

                    if (!xso.Visible)
                    {
                        propAttributes.Add(new BrowsableAttribute(false));
                    }
                }
                if (prop.propValueObject is XmlStreamOption)
                {
                    propAttributes.Add(new TypeConverterAttribute(typeof(StringListConverter)));
                }

                newProps[i] = new CustomPropertyDescriptor(ref prop, propAttributes.ToArray());
            }

            return(new PropertyDescriptorCollection(newProps));
        }
Beispiel #3
0
 private void CreateXmlStreamObjectAttributes(XmlNode node, XmlStreamObject xso)
 {
     node.Attributes.Append(
         CreateAttribute("_category", xso.Category));
     node.Attributes.Append(
         CreateAttribute("_description", xso.Description));
     node.Attributes.Append(
         CreateAttribute("_displayname", xso.DisplayName));
     node.Attributes.Append(
         CreateAttribute("_isreadonly", xso.IsReadOnly.ToString()));
     node.Attributes.Append(
         CreateAttribute("_visible", xso.Visible.ToString()));
 }
Beispiel #4
0
        private void Save(string key, object val, bool encrypt)
        {
            XmlNode node = this.CreateNode(key);

            _parent.Node.AppendChild(node);
            if (PlugInManager.IsPlugin(val))
            {
                node.Attributes.Append(
                    this.CreateAttribute("GUID", PlugInManager.PlugInID(val).ToString()));
                node.Attributes.Append(
                    this.CreateAttribute("type", val.ToString()));
            }
            if (val is IPersistable)
            {
                _parent.Node = node;
                ((IPersistable)val).Save(this);
                _parent.Node = node.ParentNode;
                return;
            }
            if (val is IPersistableLoadAsync)
            {
                _parent.Node = node;
                ((IPersistableLoadAsync)val).Save(this);
                _parent.Node = node.ParentNode;
                return;
            }
            if (val is XmlStreamObject)
            {
                if (((XmlStreamObject)val).Value == null)
                {
                    return;
                }

                CreateXmlStreamObjectAttributes(node, (XmlStreamObject)val);

                if (val is XmlStreamOption &&
                    ((XmlStreamOption)val).Options != null)
                {
                    XmlStreamOption streamObject = (XmlStreamOption)val;

                    node.Attributes.Append(
                        this.CreateAttribute("type", typeof(XmlStreamOption).ToString()));

                    _parent.Node = node;
                    Save("Value", streamObject.Value);
                    foreach (object option in streamObject.Options)
                    {
                        Save("Option", option);
                    }
                    _parent.Node = node.ParentNode;
                }
                else if (val is XmlStreamStringArray &&
                         ((XmlStreamStringArray)val).Value is Array)
                {
                    XmlStreamStringArray streamObject = (XmlStreamStringArray)val;

                    node.Attributes.Append(
                        this.CreateAttribute("type", typeof(XmlStreamStringArray).ToString()));
                    _parent.Node = node;
                    foreach (object Value in (Array)streamObject.Value)
                    {
                        Save("Value", Value.ToString());
                    }
                    _parent.Node = node.ParentNode;
                }
                else
                {
                    XmlStreamObject streamObject = (XmlStreamObject)val;

                    node.Attributes.Append(
                        this.CreateAttribute("type", typeof(XmlStreamObject).ToString()));

                    _parent.Node = node;
                    Save("Value", streamObject.Value);
                    _parent.Node = node.ParentNode;
                }
                return;
            }

            if (val != null)
            {
                if (node.Attributes["type"] == null)
                {
                    node.Attributes.Append(
                        this.CreateAttribute("type", val.GetType().ToString()));
                }
                if (val.GetType() == typeof(double))
                {
                    node.Attributes.Append(
                        this.CreateAttribute("value", ((double)val).ToString(_parent.NumberFormat)));
                }
                else if (val.GetType() == typeof(float))
                {
                    node.Attributes.Append(
                        this.CreateAttribute("value", ((float)val).ToString(_parent.NumberFormat)));
                }
                else if (val.GetType() == typeof(decimal))
                {
                    node.Attributes.Append(
                        this.CreateAttribute("value", ((decimal)val).ToString(_parent.NumberFormat)));
                }
                else
                {
                    string v = val.ToString();
                    if (encrypt == true)
                    {
                        v = Crypto.Encrypt(v, "3f9932916f9746e1a3df048cc70dd30a");
                        node.Attributes.Append(this.CreateAttribute("encryption_type", "1"));
                    }
                    node.Attributes.Append(
                        this.CreateAttribute("value", v));
                }
            }
            //object f=Activator.CreateInstance(System.Type.GetType("System.String",false,true));
            //f=null;
        }