Exemple #1
0
        public object Deserialize(System.Xml.XmlReader xmlReader)
        {
            if (!xmlReader.IsStartElement("Trigger"))
            {
                throw new System.Exception("Element Trigger expected");
            }

            //xmlReader.MoveToAttribute("AssemblyQualifiedName");
            xmlReader.MoveToAttribute("Type");
            Type type = SerializerHelper.TriggerTypes[xmlReader.Value];            //Type.GetType(xmlReader.Value);

            if (type == null)
            {
                throw new System.Exception("Tipo não identificado.");
            }

            ITrigger trigger = (ITrigger)Activator.CreateInstance(type);

            xmlReader.ReadStartElement();
            SerializerHelper.ReadWhiteSpace(xmlReader);
            while (xmlReader.IsStartElement())
            {
                SerializerHelper.FillProperty(xmlReader, trigger);
                SerializerHelper.ReadWhiteSpace(xmlReader);
            }

            xmlReader.ReadEndElement();
            SerializerHelper.ReadWhiteSpace(xmlReader);
            return(trigger);
        }
Exemple #2
0
 internal Container(System.Xml.XmlReader reader)
     : base(reader)
 {
     m_Elements = new List <T>();
     if (reader.IsEmptyElement)
     {
         XmlHelpers.ThrowException(StringResources.ExpectedContent, reader);
     }
     ReadSubclassAttributes(reader);
     reader.Read();
     while (reader.IsStartElement())
     {
         if (reader.IsStartElement("SubElements") && !reader.IsEmptyElement)
         {
             reader.Read();
             while (reader.IsStartElement())
             {
                 T element = ReadContainerElement(reader);
                 if (element != null)
                 {
                     m_Elements.Add(element);
                 }
             }
             reader.ReadEndElement();
         }
         else
         {
             reader.ReadOuterXml();
         }
     }
     reader.ReadEndElement();
 }
Exemple #3
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            while (!reader.IsStartElement("Blockedip"))
            {
                reader.Read();
            }

            reader.ReadStartElement("Blockedip");
            XmlSerializer ipSerialization = new XmlSerializer(typeof(IPAddr));

            Blockedip = (IPAddr)ipSerialization.Deserialize(reader);
            reader.ReadEndElement();

            while (!reader.IsStartElement("DateBlocked"))
            {
                reader.Read();
            }

            reader.ReadStartElement("DateBlocked");
            DateBlocked = (long)new XmlSerializer(typeof(long)).Deserialize(reader);
            reader.ReadEndElement();

            while (!reader.IsStartElement("Reason"))
            {
                reader.Read();
            }

            reader.ReadStartElement("Reason");
            Reason = (string)new XmlSerializer(typeof(string)).Deserialize(reader);
            reader.ReadEndElement();

            reader.ReadEndElement();
        }
Exemple #4
0
        public void DeserializeXml(IResourceProvider resourceProvider, System.Xml.XmlReader xmlReader)
        {
            const string sShapes     = "Shapes";
            const string sAnimation  = "Animation";
            const string sAnimations = "Animations";

            Name = xmlReader.GetAttribute("Name");

            if (!xmlReader.ReadToDescendant(sShapes))
            {
                throw new InvalidOperationException(String.Format("{0}' element not found", sShapes));
            }

            // Deserialize shapes
            xmlReader.ReadStartElement();

            while (xmlReader.IsStartElement())
            {
                string typeName = string.Format("Odyssey.Graphics.Drawing.{0}", xmlReader.Name);
                try
                {
                    var shape = (Shape)Activator.CreateInstance(Type.GetType(typeName));
                    shape.DeserializeXml(resourceProvider, xmlReader);
                    shapes.Add(shape);
                }
                catch (ArgumentException ex)
                {
                    throw new InvalidOperationException(String.Format("Type '{0}' is not a valid Shape", typeName));
                }
                xmlReader.Read();
            }
            xmlReader.ReadEndElement();

            if (!xmlReader.IsStartElement(sAnimations))
            {
                xmlReader.ReadEndElement();
                return;
            }

            // Deserialize animations
            xmlReader.ReadStartElement(sAnimations);
            while (xmlReader.IsStartElement(sAnimation))
            {
                string        sState = xmlReader.GetAttribute("Name");
                ControlStatus cStatus;
                if (!Enum.TryParse(sState, out cStatus))
                {
                    throw new InvalidOperationException(string.Format("'{0}' is not a valid state", sState));
                }

                var animation = new Animation();
                animation.DeserializeXml(resourceProvider, xmlReader);
                animations.Add(animation);
            }
            xmlReader.ReadEndElement();

            xmlReader.ReadEndElement();
        }
Exemple #5
0
        internal BackgroundSounds(System.Xml.XmlReader reader)
            : base(reader)
        {
            m_Elements = new List <IBackgroundSoundChoice>();
            int id = reader.GetIntegerAttribute("ContainerId");

            m_Container = DataModule.TheElementFactory.CreateParallelContainer(Title + "_Parallel", id);

            if (reader.IsEmptyElement)
            {
                XmlHelpers.ThrowException(StringResources.ExpectedContent, reader);
            }
            reader.Read();
            while (reader.IsStartElement())
            {
                if (reader.IsStartElement("SubElements") && !reader.IsEmptyElement)
                {
                    reader.Read();
                    while (reader.IsStartElement())
                    {
                        if (reader.IsStartElement("BackgroundSoundChoice"))
                        {
                            BackgroundSoundChoice choice          = new BackgroundSoundChoice(reader);
                            IParallelElement      parallelElement = m_Container.AddElement(choice);
                            parallelElement.RepeatCount = -1;
                            choice.ParallelElement      = parallelElement;
                            if (reader.IsStartElement("ParallelElementData"))
                            {
                                AdditionalChoiceData data = ReadAdditionalData(reader);
                                parallelElement.FixedStartDelay                = data.FixedStartDelay;
                                parallelElement.MaximumRandomStartDelay        = data.MaximumRandomStartDelay;
                                parallelElement.FixedIntermediateDelay         = data.FixedIntermediateDelay;
                                parallelElement.MaximumRandomIntermediateDelay = data.MaximumRandomIntermediateDelay;
                                parallelElement.RepeatCount = data.RepeatCount;
                            }
                            m_Elements.Add(choice);
                        }
                        else
                        {
                            reader.ReadOuterXml();
                        }
                    }
                    reader.ReadEndElement();
                }
                else
                {
                    reader.ReadOuterXml();
                }
            }

            reader.ReadEndElement();
        }
Exemple #6
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            while (!reader.IsStartElement("BlockCache") && !reader.EOF)
            {
                reader.Read();
            }

            if (reader.EOF)
            {
                return;
            }

            if (reader.IsEmptyElement && reader.Name == "BlockCache")
            {
                reader.ReadStartElement("BlockCache");
                BlockCache = new SerializableDictionary <IPAddr, BlockedIP>();
            }
            else
            {
                reader.ReadStartElement("BlockCache");
                BlockCache = (SerializableDictionary <IPAddr, BlockedIP>) new XmlSerializer(typeof(SerializableDictionary <IPAddr, BlockedIP>)).Deserialize(reader);
                reader.ReadEndElement();
            }

            while (!reader.IsStartElement("dos_threshold") && !reader.EOF)
            {
                reader.Read();
            }

            if (reader.EOF)
            {
                return;
            }

            reader.ReadStartElement("dos_threshold");
            dos_threshold = (int)new XmlSerializer(typeof(int)).Deserialize(reader);
            reader.ReadEndElement();

            while (!reader.IsStartElement("Save") && !reader.EOF)
            {
                reader.Read();
            }

            if (reader.EOF)
            {
                return;
            }

            reader.ReadStartElement("Save");
            Save = (bool)new XmlSerializer(typeof(bool)).Deserialize(reader);
            reader.ReadEndElement();
        }
Exemple #7
0
        internal MusicByTags(System.Xml.XmlReader reader)
            : base(reader)
        {
            m_Tags = new Dictionary <int, HashSet <int> >();
            bool isOperatorAnd          = reader.GetBooleanAttributeOrDefault("IsOperatorAnd", true);
            int  tagCategoryCombination = reader.GetIntegerAttributeOrDefault("TagCategoryCombination", -1);

            if (tagCategoryCombination >= (int)Data.TagCategoryCombination.UseAnyTag && tagCategoryCombination <= (int)Data.TagCategoryCombination.UseAllTags)
            {
                TagCategoryCombination = (Data.TagCategoryCombination)tagCategoryCombination;
            }
            else
            {
                TagCategoryCombination = isOperatorAnd ? Data.TagCategoryCombination.UseOneTagOfEachCategory : Data.TagCategoryCombination.UseAnyTag;
            }
            FadeTime = reader.GetIntegerAttributeOrDefault("FadeTime", 0);
            if (reader.IsEmptyElement)
            {
                XmlHelpers.ThrowException(StringResources.ExpectedContent, reader);
            }
            reader.Read();
            while (reader.IsStartElement())
            {
                if (reader.IsStartElement("Tags") && !reader.IsEmptyElement)
                {
                    reader.Read();
                    while (reader.IsStartElement())
                    {
                        if (reader.IsStartElement("Tag"))
                        {
                            int category = reader.GetIntegerAttribute("Category");
                            int tag      = reader.GetIntegerAttribute("Tag");
                            AddTag(category, tag);
                            reader.ReadOuterXml();
                        }
                        else
                        {
                            reader.ReadOuterXml();
                        }
                    }
                    reader.ReadEndElement();
                }
                else
                {
                    reader.ReadOuterXml();
                }
            }
            reader.ReadEndElement();
        }
Exemple #8
0
        public static string GetValuesFromXml(string XmlFile, string valueToGet)
        {
            string value    = string.Empty;
            string filePath = Path.Combine(Directory.GetCurrentDirectory(), XmlFile);

            if (File.Exists(filePath))
            {
                using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(XmlFile))
                {
                    var setsettings = new SetSettings();
                    while (reader.Read())
                    {
                        if (reader.IsStartElement())
                        {
                            if (valueToGet == reader.Name.ToString())
                            {
                                value = reader.ReadString();
                            }
                        }
                    }
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(new System.Windows.Forms.Form {
                    TopMost = true
                }, "Nie znaleziono pliku " + filePath, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            return(value);
        }
Exemple #9
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "archetype_id", "Expected local name is 'archetype_id', not " + reader.LocalName);
            this.archetypeId = new OpenEhr.RM.Support.Identification.ArchetypeId();
            this.archetypeId.ReadXml(reader);

            if (reader.LocalName == "template_id")
            {
                this.templateId = new OpenEhr.RM.Support.Identification.TemplateId();
                this.templateId.ReadXml(reader);
            }

            Check.Assert(reader.LocalName == "rm_version", "Expected local name is 'rm_version', not " + reader.LocalName);
            this.rmVersion = reader.ReadElementString("rm_version", RmXmlSerializer.OpenEhrNamespace);

            reader.MoveToContent();

            if (!reader.IsStartElement())
            {
                reader.ReadEndElement();
                reader.MoveToContent();
            }
        }
Exemple #10
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     try
     {
         if (reader.IsEmptyElement)
         {
             reader.ReadStartElement();
         }
         else
         {
             while (!reader.IsStartElement("Addr"))
             {
                 reader.Read();
             }
             reader.ReadStartElement("Addr");
             XmlSerializer stringSerialization = new XmlSerializer(typeof(string));
             IPAddr        ip = IPAddr.Parse((string)stringSerialization.Deserialize(reader));
             this.AddressBytes = ip.AddressBytes;
             reader.ReadEndElement();
             reader.ReadEndElement();
         }
     }
     catch (Exception e)
     {
         LogCenter.Instance.LogException(e);
     }
 }
Exemple #11
0
        protected override void ReadXmlBase(System.Xml.XmlReader reader)
        {
            base.ReadXmlBase(reader);

            if (reader.LocalName == "accuracy")
            {
                // only set accuracy when the value is greater than -1
                float accuracyValue = reader.ReadElementContentAsFloat("accuracy", RmXmlSerializer.OpenEhrNamespace);
                if (accuracyValue < unknownAccuracyValue)
                {
                    throw new ApplicationException("accuracy must be greater or equal to -1");
                }

                this.accuracy = accuracyValue;
            }
            if (reader.LocalName == "accuracy_is_percent")
            {
                this.accuracyIsPercent = reader.ReadElementContentAsBoolean("accuracy_is_percent",
                                                                            RmXmlSerializer.OpenEhrNamespace);
                this.accuracyIsPercentSet = true;
            }

            if (!reader.IsStartElement())
            {
                reader.ReadEndElement();
                reader.MoveToContent();
            }
        }
Exemple #12
0
        public void ReadXml(System.Xml.XmlReader r)
        {
            int depth = r.Depth;

            r.ReadStartElement();
            bool hasRead = false;

            while (r.Depth > depth)
            {
                if (r.IsStartElement())
                {
                    XmlSerializer ser = XmlTypeAssociator <T> .GetSerializer(r);

                    XMLSerializeManager.Report("Deserializing: " + r.Name);
                    Add((T)ser.Deserialize(r));
                    r.MoveToContent();
                }
                else
                {
                    r.Read();
                }
                hasRead = true;
            }
            if (hasRead)
            {
                r.ReadEndElement();
            }
        }
Exemple #13
0
        /// <summary>
        /// List all commands belonging to a specified object
        /// </summary>
        /// <param name="input">Object, that can be converted to an IHelp object</param>

        public void ListAll(object input)
        {
            IHelp ihObject = (IHelp)input;

            if (!File.Exists(ihObject.HelpFile))
            {
                return;
            }

            using (System.Xml.XmlReader xml = System.Xml.XmlReader.Create(ihObject.HelpFile))
            {
                while (xml.Read())
                {
                    if (xml.IsEmptyElement)
                    {
                        continue;
                    }

                    if (xml.IsStartElement())
                    {
                        string element = xml.Name;
                        if (element.StartsWith("cmd_"))
                        {
                            string command = element.Substring(4);
                            command = command.Replace(".", " ");
                            xml.Read();
                            string exp = xml.Value;
                            console.Write(command + " - " + exp + "\r\n");
                        }
                    }
                }
            }

            console.WriteLine("For more detailed help type: help [command_name], to read the required parameters!");
        }
Exemple #14
0
 public static string[] GmailAccount(string configfile)
 {
     string[] ret = new string[2];
     using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(configfile))
     {
         while (reader.Read())
         {
             if (reader.IsStartElement())
             {
                 if (reader.Name == "item")
                 {
                     if (reader["name"] == "Email")
                     {
                         reader.Read();
                         ret[0] = reader.Value.Trim();
                     }
                     else if (reader["name"] == "EmailPass")
                     {
                         reader.Read();
                         ret[1] = reader.Value.Trim();
                     }
                 }
             }
         }
     }
     return(ret);
 }
Exemple #15
0
        /// <summary>
        /// Get Paper Name
        /// </summary>
        /// <param name="oHt">Hashtable</param>
        /// <returns>String</returns>
        public string GetPaperName(string sPpID)
        {
            string    sPaperName = string.Empty;
            DataTable dt         = new DataTable();
            Hashtable oHt        = new Hashtable();

            oHt.Add("PpIDList", sPpID);
            System.Xml.XmlReader      oR = null;
            System.Text.StringBuilder oS = new System.Text.StringBuilder();
            DBObjectPool Pool            = null;

            Pool = DBObjectPool.Instance;
            DBObject oDB = Pool.AcquireDBObject();

            try
            {
                System.Data.SqlClient.SqlCommand cmd = oDB.GenerateCommand("ELGV2_Get_PpName", oHt);
                oR = cmd.ExecuteXmlReader();
                while (!oR.EOF)
                {
                    if (oR.IsStartElement())
                    {
                        oS.Append(oR.ReadOuterXml());
                        oS.Append(Environment.NewLine);
                    }
                }
            }
            finally
            {
                Pool.ReleaseDBObject(oDB);
            }
            return(oS.ToString());
        }
Exemple #16
0
        public static List <SelectListItem> CommentTypeList()
        {
            var    items = new List <SelectListItem>();
            string path  = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;

            using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(path + @"\ReadWrite\commenttype.xml"))
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        //return only when you have START tag
                        switch (reader.Name.ToString())
                        {
                        case "typename":
                            var itemtext = reader.ReadString();
                            items.Add(new SelectListItem {
                                Text = itemtext, Value = itemtext
                            });
                            break;
                        }
                    }
                }
            }
            return(items);
        }
Exemple #17
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            r           = new Report();
            r.Width     = Int32.Parse(reader.GetAttribute("Width"));
            r.Height    = Int32.Parse(reader.GetAttribute("Height"));
            r.BackColor = System.Drawing.Color.FromName(reader.GetAttribute("BGColor"));
            int  c = Int32.Parse(reader.GetAttribute("BandsCount"));
            Band b;

            reader.ReadStartElement();
            string s;

            for (int i = 0; i < c; ++i)
            {
                s = reader.Name;
                while (!reader.IsStartElement("Band"))
                {
                    reader.Skip();
                    s = reader.Name;
                }
                s = reader.Name;

                b = new Band();
                b.ReadXml(reader);
                r.Bands.Add(b);
                r.Controls.Add(b);
            }
            reader.ReadEndElement();
            r.AddControlsEvents();
        }
Exemple #18
0
        /// <summary>
        /// Lê comando.
        /// </summary>
        /// <param name="p_reader">Objeto XML.</param>
        private void ReadCommand(System.Xml.XmlReader p_reader)
        {
            System.Xml.XmlReader v_item;

            this.v_cmd = new Spartacus.Database.Command();

            while (p_reader.Read())
            {
                if (p_reader.IsStartElement())
                {
                    switch (p_reader.Name)
                    {
                    case "sql":
                        this.v_cmd.v_text = p_reader.ReadString();
                        break;

                    case "parameter":
                        v_item = p_reader.ReadSubtree();
                        this.ReadParameter(v_item);
                        v_item.Close();
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Exemple #19
0
        /// <summary>
        /// Lê rodapé do relatório.
        /// </summary>
        /// <param name="p_reader">Objeto XML.</param>
        private void ReadFooter(System.Xml.XmlReader p_reader)
        {
            System.Xml.XmlReader v_item;

            while (p_reader.Read())
            {
                if (p_reader.IsStartElement())
                {
                    switch (p_reader.Name)
                    {
                    case "height":
                        this.v_footer.SetHeight(p_reader.ReadString());
                        break;

                    case "object":
                        v_item = p_reader.ReadSubtree();
                        this.ReadFooterObject(v_item);
                        v_item.Close();
                        break;

                    default:
                        break;
                    }
                }
            }

            this.v_footer.v_border = this.v_settings.v_reportfooterborder;
        }
Exemple #20
0
 internal ILightEffects CreateLightEffects(System.Xml.XmlReader reader)
 {
     if (!reader.IsStartElement("LightEffects"))
     {
         XmlHelpers.ThrowException(String.Format(StringResources.ExpectedElement, "LightEffects"), reader);
     }
     return(new LightEffects(reader));
 }
Exemple #21
0
 protected override ParallelElement ReadContainerElement(System.Xml.XmlReader reader)
 {
     if (!reader.IsStartElement("Parallel"))
     {
         XmlHelpers.ThrowException(String.Format(StringResources.ExpectedElement, "Parallel"), reader);
     }
     return(new ParallelElement(reader));
 }
Exemple #22
0
 internal IMusicByTags CreateMusicByTags(System.Xml.XmlReader reader)
 {
     if (!reader.IsStartElement("MusicByTags"))
     {
         XmlHelpers.ThrowException(String.Format(StringResources.ExpectedElement, "MusicByTags"), reader);
     }
     return(new MusicByTags(reader));
 }
Exemple #23
0
 internal IReferenceElement CreateReferenceElement(System.Xml.XmlReader reader)
 {
     if (!reader.IsStartElement("ReferenceElement"))
     {
         XmlHelpers.ThrowException(String.Format(StringResources.ExpectedElement, "ReferenceElement"), reader);
     }
     return(new ReferenceElement(reader));
 }
Exemple #24
0
 internal IElementContainer <IChoiceElement> CreateChoiceContainer(System.Xml.XmlReader reader)
 {
     if (!reader.IsStartElement("ChoiceContainer"))
     {
         XmlHelpers.ThrowException(String.Format(StringResources.ExpectedElement, "ChoiceContainer"), reader);
     }
     return(new ChoiceContainer(reader));
 }
Exemple #25
0
 internal ISequentialContainer CreateSequentialContainer(System.Xml.XmlReader reader)
 {
     if (!reader.IsStartElement("SequentialContainer"))
     {
         XmlHelpers.ThrowException(String.Format(StringResources.ExpectedElement, "SequentialContainer"), reader);
     }
     return(new SequentialContainer(reader));
 }
        void IXmlExportable.FromXml(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (this.IsReadOnly)
            {
                throw new InvalidOperationException("Object is read-only.");
            }

            reader.Read();

            //
            // Add entries into the collection as <item> elements
            // with child <value> elements are found.
            //

            while (reader.IsStartElement("item"))
            {
                string name   = reader.GetAttribute("name");
                bool   isNull = reader.IsEmptyElement;

                reader.Read(); // <item>

                if (!isNull)
                {
                    while (reader.IsStartElement("value")) // <value ...>
                    {
                        string value = reader.GetAttribute("string");
                        Add(name, value);
                        reader.Read();
                    }

                    reader.ReadEndElement(); // </item>
                }
                else
                {
                    Add(name, null);
                }
            }

            reader.ReadEndElement();
        }
Exemple #27
0
 internal ITrigger CreateTrigger(System.Xml.XmlReader reader)
 {
     if (reader.IsStartElement("KeyTrigger"))
     {
         return(new KeyTrigger(reader));
     }
     else if (reader.IsStartElement("ElementFinishTrigger"))
     {
         return(new ElementFinishTrigger(reader));
     }
     else if (reader.IsStartElement("NoTrigger"))
     {
         return(new NoTrigger(reader));
     }
     else
     {
         return(null);
     }
 }
Exemple #28
0
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="XmlReader" /> stream from which the object is deserialized.</param>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            System.Xml.XmlReader shareReader = reader;
            if (reader.IsStartElement())
            {
                shareReader = reader.ReadSubtree();
            }

            while (shareReader.Read())
            {
                while (shareReader.IsStartElement())
                {
                    switch (shareReader.Name)
                    {
                    case IdElementName:
                        this.Id = shareReader.ReadString();
                        break;

                    case TimestampElementName:
                        this.Timestamp = long.Parse(shareReader.ReadString());
                        break;

                    case CommentElementName:
                        this.Comment = shareReader.ReadString();
                        break;

                    case ContentElementName:
                        ShareContent content = new ShareContent();
                        content.ReadXml(shareReader.ReadSubtree());
                        this.Content = content;
                        break;

                    case VisibilityElementName:
                        Visibility visibility = new Visibility();
                        visibility.ReadXml(shareReader);
                        this.Visibility = visibility;
                        break;

                    case SourceElementName:
                        this.Source = Utility.Utilities.DeserializeXml <ShareSource>(shareReader.ReadOuterXml());
                        break;

                    case AuthorElementName:
                        this.Author = Utility.Utilities.DeserializeXml <Person>(string.Format("<person>{0}</person>", shareReader.ReadInnerXml()));
                        break;

                    default:
                        shareReader.Read();
                        break;
                    }
                }
            }

            shareReader.Close();
        }
        public void FromXML(System.Xml.XmlReader reader)
        {
            _source = new List <MemFeature>();

            reader.MoveToContent();
            if (reader.IsStartElement("Layer"))
            {
                reader.ReadStartElement("Layer");
                _layerName    = reader.GetAttribute("Name");
                _keyFieldName = reader.GetAttribute("KeyField");

                while (reader.IsStartElement("Feature"))
                {
                    MemFeature feature = CreateFeature();
                    feature.FromXML(reader);
                    Add(feature);
                }

                reader.ReadEndElement();
            }
        }
Exemple #30
0
        private void ReadReportsInfo()
        {
            var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Demo.Reports.xml");

            System.Xml.XmlReader tr = System.Xml.XmlReader.Create(stream);

            StiTreeViewItem categoryNode    = null;
            BitmapImage     browserCategory = new BitmapImage(new Uri("/Demo;component/Images/browserCategory.png", UriKind.RelativeOrAbsolute));
            BitmapImage     browserReport   = new BitmapImage(new Uri("/Demo;component/Images/browserReport.png", UriKind.RelativeOrAbsolute));

            tr.Read();
            while (!tr.EOF)
            {
                if (tr.IsStartElement())
                {
                    if (tr.Name == "Category")
                    {
                        categoryNode = new StiTreeViewItem();
                        Image img = new Image();
                        img.Width           = 16;
                        img.Height          = 16;
                        img.Source          = browserCategory;
                        categoryNode.Header = GetTreeViewContent(tr.GetAttribute("name"), img);
                        categoryNode.Tag    = tr.GetAttribute("name");
                        reportsDescription[categoryNode.Tag] = tr.GetAttribute("description");
                        treeViewReports.Items.Add(categoryNode);
                    }
                    else if (tr.Name == "Report")
                    {
                        StiTreeViewItem reportNode = new StiTreeViewItem();
                        Image           img        = new Image();
                        img.Width         = 16;
                        img.Height        = 16;
                        img.Source        = browserReport;
                        reportNode.Header = GetTreeViewContent(tr.GetAttribute("name"), img);
                        reportNode.Tag    = tr.GetAttribute("file");
                        reportNode.Cursor = Cursors.Hand;
                        tr.Read();
                        reportsDescription[reportNode.Tag] = tr.Value;
                        categoryNode.Items.Add(reportNode);
                    }
                }
                tr.Read();
            }

            tr.Close();
            stream.Close();
            stream.Dispose();
            tr     = null;
            stream = null;

            ((StiTreeViewItem)treeViewReports.Items[0]).IsExpanded = true;
        }
        void IXmlExportable.FromXml(XmlReader r)
        {
            if (r == null) throw new ArgumentNullException("reader");
            if (this.IsReadOnly) throw new InvalidOperationException("Object is read-only.");

            r.Read();

            // Add entries into the collection as <item> elements
            // with child <value> elements are found.
            while (r.IsStartElement("item"))
            {
                string name = r.GetAttribute("name");
                bool isNull = r.IsEmptyElement;

                r.Read(); // <item>

                if (!isNull)
                {

                    while (r.IsStartElement("value")) // <value ...>
                    {
                        string value = r.GetAttribute("string");
                        Add(name, value);
                        r.Read();
                    }

                    r.ReadEndElement(); // </item>
                }
                else
                {
                    Add(name, null);
                }
            }

            r.ReadEndElement();
        }