示例#1
0
        public static string ToXml(CGItemCollection cgItems)
        {
            XElement     root   = cgItems.ToXElement(CGItemsTagName);
            StringWriter writer = new StringWriter();

            root.Save(writer);
            return(writer.ToString());
        }
示例#2
0
        public CGItemCollection Clone()
        {
            var result = new CGItemCollection();

            foreach (var item in this)
            {
                result.Add(item.Clone());
            }
            return(result);
            //throw new NotImplementedException();
        }
示例#3
0
        public static CGItemCollection FromXElement(XElement element)
        {
            CGItemCollection items = new CGItemCollection();

            foreach (var child in element.Elements())
            {
                var temp = Type.GetType(child.Attribute("type").Value);
                try
                {
                    CGItem item = (CGItem)Activator.CreateInstance(temp);
                    item.Init(child /*element*/);
                    items.Add(item);
                }
                catch
                {
                }
            }
            return(items);
            //throw new NotImplementedException();
        }