DeserializeFromXML() 공개 메소드

public DeserializeFromXML ( XmlNode node ) : void
node System.Xml.XmlNode
리턴 void
예제 #1
0
        public override void DeserializeFromXML(XmlNode node)
        {
            base.DeserializeFromXML(node);
            foreach (XmlNode xn in node.ChildNodes)
            {
                if (xn.Name == "Tone" &&
                    xn.Attributes["Name"] != null &&
                    xn.Attributes["Name"].Value == "DarkTone")
                {
                    mDarkTone.DeserializeFromXML(xn);
                }
                if (xn.Name == "Tone" &&
                    xn.Attributes["Name"] != null &&
                    xn.Attributes["Name"].Value == "LightTone")
                {
                    mLightTone.DeserializeFromXML(xn);
                }
                if (xn.Name == "Point" &&
                    xn.Attributes["Name"] != null &&
                    xn.Attributes["Name"].Value == "AutoDarkCenter")
                {
                    mAutoDarkCenter.DeserializeFromXML(xn);
                }
                if (xn.Name == "Point" &&
                    xn.Attributes["Name"] != null &&
                    xn.Attributes["Name"].Value == "AutoLightCenter")
                {
                    mAutoLightCenter.DeserializeFromXML(xn);
                }
            }

            double res = 0;

            if (node.Attributes["Edge"] != null)
            {
                if (double.TryParse(node.Attributes["Edge"].Value, NumberStyles.Float, nfi, out res))
                {
                    mEdge = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse Edge value");
                }
            }

            res = 0;
            if (node.Attributes["Softness"] != null)
            {
                if (double.TryParse(node.Attributes["Softness"].Value, NumberStyles.Float, nfi, out res))
                {
                    mSoftness = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse Softness value");
                }
            }

            res = 0;
            if (node.Attributes["AutoDarkRadius"] != null)
            {
                if (double.TryParse(node.Attributes["AutoDarkRadius"].Value, NumberStyles.Float, nfi, out res))
                {
                    mAutoDarkRadius = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AutoDarkRadius value");
                }
            }

            res = 0;
            if (node.Attributes["AutoLightRadius"] != null)
            {
                if (double.TryParse(node.Attributes["AutoLightRadius"].Value, NumberStyles.Float, nfi, out res))
                {
                    mAutoLightRadius = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AutoLightRadius value");
                }
            }

            bool bres = false;

            if (node.Attributes["AutoDarkTone"] != null)
            {
                if (bool.TryParse(node.Attributes["AutoDarkTone"].Value, out bres))
                {
                    mAutoDarkTone = bres;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AutoDarkTone value");
                }
            }

            bres = false;
            if (node.Attributes["AutoLightTone"] != null)
            {
                if (bool.TryParse(node.Attributes["AutoLightTone"].Value, out bres))
                {
                    mAutoLightTone = bres;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AutoLightTone value");
                }
            }

            OnChanged();
        }