/// <summary>
 /// 加载
 /// </summary>
 public override void LoadState(IMemento memento)
 {
     SectorBarDesps.Clear();
     for (int Index = 0; Index < memento.ChildCount; Index++)
     {
         IMemento childMemento  = memento.GetChild(Index);
         String   sectorBarType = childMemento.GetString("BarType") ?? String.Empty;
         if (String.IsNullOrEmpty(sectorBarType))
         {
             continue;
         }
         else
         {
             List <SectorBarButtonDescription> btnDesp = new List <SectorBarButtonDescription>();
             for (int subIndex = 0; subIndex < childMemento.ChildCount; subIndex++)
             {
                 IMemento subChild = childMemento.GetChild(subIndex);
                 SectorBarButtonDescription barBtn = new SectorBarButtonDescription();
                 barBtn.LoadState(subChild);
                 btnDesp.Add(barBtn);
             }
             SectorBarDesps[sectorBarType] = btnDesp;
         }
     }
 }
        /// <summary>
        /// 加载
        /// </summary>
        public override void LoadState(IMemento memento)
        {
            Name      = memento.GetString("Name");
            Text      = memento.GetString("Text");
            RefSector = memento.GetString("RefSector");
            String typeInfo = memento.GetString("MenuBoxItemType");

            Assembly assembly = LoadAssembly(typeInfo.Split(',')[1]);

            MenuBoxItemType = assembly.GetType(typeInfo.Split(',')[0]);

            SectorList.Clear();
            for (int Index = 0; Index < memento.ChildCount; Index++)
            {
                IMemento     childMemento = memento.GetChild(Index);
                MenuListItem menuListItem = new MenuListItem();
                menuListItem.LoadState(childMemento);

                //确保只有一个是选中状态
                if (menuListItem.IsChecked)
                {
                    foreach (MenuListItem item in SectorList)
                    {
                        item.IsChecked = false;
                    }
                }

                SectorList.Add(menuListItem);
            }
        }
Exemple #3
0
        /// <summary>
        /// 写入
        /// </summary>
        public void Write(IMemento memento, Stream stream)
        {
            //1. 写入根结点内容
            XmlDocument    xmlDocument    = new XmlDocument();
            XmlDeclaration xmlDeclaration = xmlDocument.CreateXmlDeclaration("1.0", "gb2312", "yes");

            xmlDocument.PrependChild(xmlDeclaration);

            XmlElement rootNode = xmlDocument.CreateElement(memento.Name);

            xmlDocument.AppendChild(rootNode);

            //2. 写入根结点属性信息
            for (int index = 0; index <= memento.GetAttributeCount() - 1; index++)
            {
                XmlAttribute attributeNode = xmlDocument.CreateAttribute(memento.GetAttributeName(index));
                attributeNode.Value = memento.GetAttributeValue(index);
                rootNode.SetAttributeNode(attributeNode);
            }

            //3. 写入子结点内容
            for (int index = 0; index <= memento.ChildCount - 1; index++)
            {
                IMemento childMemento = memento.GetChild(index);
                ProcessMemento(childMemento, rootNode, xmlDocument);
            }
            xmlDocument.Save(stream);
        }
 /// <summary>
 /// 加载
 /// </summary>
 public override void LoadState(IMemento memento)
 {
     Name       = memento.GetString("Name");
     SectorName = memento.GetString("SectorName");
     SectorID   = memento.GetString("SectorID");
     VTabFlag   = memento.GetString("VTabFlag");
     if (memento.ChildCount > 0)
     {
         SectorMenuBoxStripDes = new SectorMenuBoxStripDescription();
         SectorMenuBoxStripDes.LoadState(memento.GetChild(0));
     }
 }
        /// <summary>
        /// 加载
        /// </summary>
        public override void LoadState(IMemento memento)
        {
            Name = memento.GetString("Name");
            String   typeInfo = memento.GetString("MenuBoxStripType");
            Assembly assembly = Assembly.Load(typeInfo.Split(',')[1]);

            MenuBoxStripType = assembly.GetType(typeInfo.Split(',')[0]);

            MenuBoxItemList.Clear();
            for (int Index = 0; Index < memento.ChildCount; Index++)
            {
                IMemento          childMemento      = memento.GetChild(Index);
                SectorMenuBoxItem sectorMenuBoxItem = new SectorMenuBoxItem();
                sectorMenuBoxItem.LoadState(childMemento);
                MenuBoxItemList.Add(sectorMenuBoxItem);
            }
        }
        public override void LoadState(IMemento memento)
        {
            _StockMarkInfo.Clear();

            String versionInfo = memento.GetString("Version");

            if (_CurrentVersion.Equals(versionInfo, StringComparison.OrdinalIgnoreCase))
            {
                for (int index = 0; index < memento.ChildCount; index++)
                {
                    IMemento      subIMemento = memento.GetChild(index);
                    StockMarkInfo markInfo    = new StockMarkInfo();
                    markInfo.LoadState(subIMemento);

                    _StockMarkInfo[markInfo.Code] = markInfo;
                }
            }
        }
Exemple #7
0
        private void ProcessMemento(IMemento memento, XmlNode parentNode, XmlDocument xmlDocument)
        {
            //1.增加结点
            XmlElement newNode = xmlDocument.CreateElement(memento.Name);

            parentNode.AppendChild(newNode);

            //2.设置属性信息
            for (int index = 0; index <= memento.GetAttributeCount() - 1; index++)
            {
                XmlAttribute attributeNode = xmlDocument.CreateAttribute(memento.GetAttributeName(index));
                attributeNode.Value = memento.GetAttributeValue(index);
                newNode.SetAttributeNode(attributeNode);
            }

            //3.递归进行ChildMemento处理
            for (int index = 0; index <= memento.ChildCount - 1; index++)
            {
                IMemento childMemento = memento.GetChild(index);
                ProcessMemento(childMemento, newNode, xmlDocument);
            }
        }