Exemplo n.º 1
0
        public XmlBase Copy()
        {
            XmlBase retVal = new XmlBase();

            retVal.CopyProperties(this);

            return(retVal);
        }
Exemplo n.º 2
0
        protected static void OnItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString());
            }
            XmlBase me = sender as XmlBase;

            if (me != null)
            {
                if (e.NewValue != e.OldValue)
                {
                    me.Changed = true;
                }
            }
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString());
            }
        }
Exemplo n.º 3
0
 public void AcceptChanges()
 {
     Original = this.Copy();
     Changed  = false;
 }
Exemplo n.º 4
0
        public static XmlElement GetXmlNode(XmlElement elem, XmlBase item, XmlDocument workDocument)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString());
            }
            XmlAttribute attrib = null;

            //Now need to append attributes.
            if (elem != null && item != null && workDocument != null)
            {
                foreach (PropertyInfo prop in item.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
                {
                    bool CanProcess = false;
                    foreach (System.Attribute attr in prop.GetCustomAttributes(true))
                    {
                        if (attr is XmlBaseAttribute)
                        {
                            CanProcess = true;
                            break;
                        }
                    }
                    if (CanProcess)
                    {
                        if (prop.PropertyType.BaseType == typeof(XmlBase))
                        {
                            XmlBase wrk = (XmlBase)prop.GetValue(item, null);
                            if (wrk != null)
                            {
                                elem.AppendChild(GetXmlNode(workDocument.CreateElement(prop.Name), wrk, workDocument));
                            }
                        }
                        else
                        {
                            if (prop.ImplementsIList())
                            {
                                IList propList = (IList)prop.GetValue(item, null);

                                if (propList != null && propList.Count > 0)
                                {
                                    XmlElement elemCollection = workDocument.CreateElement(prop.Name);
                                    elem.AppendChild(elemCollection);
                                    foreach (XmlBase xx in propList)
                                    {
                                        if (xx != null)
                                        {
                                            elemCollection.AppendChild(GetXmlNode(workDocument.CreateElement(xx.MyClass), xx, workDocument));
                                        }
                                    }
                                }
                            }
                            else
                            {
                                attrib = workDocument.CreateAttribute(prop.Name);
                                object val = prop.GetValue(item, null);
                                if (val != null)
                                {
                                    attrib.Value = val.ToString();

                                    elem.Attributes.Append(attrib);
                                }
                            }
                        }
                    }
                }
                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString());
                }
            }
            return(elem);
        }