public void ReadXml(System.Xml.XmlReader xreader)
        {
            MachineValues   = new List<DeviceInfo>();
            var xml         = xreader.ReadOuterXml();
            var xdoc        = new XmlDocument();

            xdoc.LoadXml(xml);

            var machineNode = xdoc.SelectSingleNode("//machinevalues");

            for(int i = 0; i < machineNode.ChildNodes.Count; i += 3)
            {
                var di          = new DeviceInfo();
                var nameNode    = machineNode.ChildNodes[i];
                var typeNode    = machineNode.ChildNodes[i + 1];
                var valueNode   = machineNode.ChildNodes[i + 2];

                di.Name         = nameNode.InnerText;
                di.Type         = (DeviceType)int.Parse(typeNode.InnerText);
                di.Value        = valueNode.InnerText;

                MachineValues.Add(di);
            }

            var tokenNode   = xdoc.SelectSingleNode("//token");
            this.Token      = tokenNode.InnerText;
        }
        protected override bool OnDeserializeUnrecognizedElement(string elementName, System.Xml.XmlReader reader)
        {
            if (OptionElements == null)
                OptionElements = new NameValueCollection();

            OptionElements.Add(elementName, reader.ReadOuterXml());
            return true;
        }
        public override object Deserialize(System.Xml.XmlReader reader, SerializationContext state)
        {
            var document = new XmlDocument();

            document.LoadXml(reader.ReadOuterXml());

            return document.FirstChild;
        }
Esempio n. 4
0
        protected override bool OnDeserializeUnrecognizedElement(string elementName, System.Xml.XmlReader reader)
        {
            if (OptionElements == null)
                OptionElements = new NameValueCollection();

            //Because ConfigurationElement.DeserializeElemenet() method only accept outerXml and in MS.NET, it accept innerXml,
            //so there is a hack over here
            OptionElements.Add(elementName, Platform.IsMono ? reader.ReadOuterXml() : reader.ReadInnerXml());

            return true;
        }
Esempio n. 5
0
 protected override void DeserializeSection(System.Xml.XmlReader reader)
 {
     string xml = reader.ReadOuterXml();
     var doc = XDocument.Load(reader);
     var nodes = from node in doc.Document.Root.Descendants()
                 select node;
     foreach (var n in nodes) {
         var settingsDict = settings as IDictionary<String, object>;
         settingsDict[n.Name.LocalName] = n.Value.Trim();
     }
     int i = 0;
     //base.DeserializeSection(reader);
 }
 void IFlickrParsable.Load(System.Xml.XmlReader reader)
 {
     ResponseXml = reader.ReadOuterXml();
 }
        public void ReadXml(System.Xml.XmlReader reader)
        {

            var data = reader.ReadOuterXml();

            if (data.Contains("PT_FreeText"))
            {
                XmlDocument doc = new XmlDocument();
                var nsmgr = new XmlNamespaceManager(doc.NameTable);
                nsmgr.AddNamespace("gmd", "http://www.isotc211.org/2005/gmd");
                nsmgr.AddNamespace("gco", "http://www.isotc211.org/2005/gco");
                doc.LoadXml(data);
                string otherConstraints = "";
                string otherConstraintsEnglish = "";
                var otherConstraintsNode = doc.SelectSingleNode("//gmd:otherConstraints/gco:CharacterString", nsmgr);
                if (otherConstraintsNode != null)
                    otherConstraints = otherConstraintsNode.InnerText;
                var otherConstraintsEnglishNode = doc.SelectSingleNode("//gmd:otherConstraints/gmd:PT_FreeText/gmd:textGroup/gmd:LocalisedCharacterString[@locale='#ENG']", nsmgr);
                if (otherConstraintsEnglishNode != null)
                    otherConstraintsEnglish = otherConstraintsEnglishNode.InnerText;
                MD_RestrictionOther = CreateFreeTextElement(otherConstraints, otherConstraintsEnglish);

            }
            else if (data.Contains("gmx:Anchor"))
            {
                XmlDocument doc = new XmlDocument();
                var nsmgr = new XmlNamespaceManager(doc.NameTable);
                nsmgr.AddNamespace("gmd", "http://www.isotc211.org/2005/gmd");
                nsmgr.AddNamespace("gmx", "http://www.isotc211.org/2005/gmx");
                nsmgr.AddNamespace("xlink", "http://www.w3.org/1999/xlink");
                doc.LoadXml(data);
                string otherConstraints = "";
                string otherConstraintsLink = "";
                var otherConstraintsNode = doc.SelectSingleNode("//gmd:otherConstraints/gmx:Anchor", nsmgr);
                if (otherConstraintsNode != null)
                    otherConstraints = otherConstraintsNode.InnerText;
                var otherConstraintsLinkNode = doc.SelectSingleNode("//gmd:otherConstraints/gmx:Anchor/@xlink:href", nsmgr);
                if (otherConstraintsLinkNode != null)
                    otherConstraintsLink = otherConstraintsLinkNode.InnerText;

                MD_RestrictionOther = new Anchor_Type { Value = otherConstraints, href = otherConstraintsLink };
            }
            else if (data.Contains("gco:CharacterString"))
            {
                XmlDocument doc = new XmlDocument();
                var nsmgr = new XmlNamespaceManager(doc.NameTable);
                nsmgr.AddNamespace("gmd", "http://www.isotc211.org/2005/gmd");
                nsmgr.AddNamespace("gco", "http://www.isotc211.org/2005/gco");
                doc.LoadXml(data);
                string otherConstraints = "";
                var otherConstraintsNode = doc.SelectSingleNode("//gmd:otherConstraints/gco:CharacterString", nsmgr);
                if (otherConstraintsNode != null)
                    otherConstraints = otherConstraintsNode.InnerText;

                MD_RestrictionOther = new CharacterString_PropertyType { CharacterString = otherConstraints };
            }

        }
        public void ReadXml(System.Xml.XmlReader reader)
        {
            var data = reader.ReadOuterXml();

            XmlDocument doc = new XmlDocument();
            var ns = new XmlNamespaceManager(doc.NameTable);
            ns.AddNamespace("gmd", "http://www.isotc211.org/2005/gmd");
            ns.AddNamespace("gmx", "http://www.isotc211.org/2005/gmx");
            ns.AddNamespace("xlink", "http://www.w3.org/1999/xlink");
            ns.AddNamespace("gco", "http://www.isotc211.org/2005/gco");
            doc.LoadXml(data);

                var anchor = doc.SelectSingleNode("//gmd:keyword/gmx:Anchor", ns);

                XmlElement node = doc.DocumentElement as XmlElement;

                if ((node != null) && node.HasAttribute("xsi:type") 
                    && node.Attributes["xsi:type"].Value == "gmd:PT_FreeText_PropertyType")
                {
                    string keywordString = "";
                    string keywordEnglish = "";
                    var keywordNode = doc.SelectSingleNode("//gmd:keyword/gco:CharacterString", ns);
                    if (keywordNode != null)
                        keywordString = keywordNode.InnerText;
                    var keywordEnglishNode = doc.SelectSingleNode("//gmd:keyword/gmd:PT_FreeText/gmd:textGroup/gmd:LocalisedCharacterString[@locale='#ENG']", ns);
                    if (keywordEnglishNode != null)
                        keywordEnglish = keywordEnglishNode.InnerText;

                    keyword = CreateFreeTextElement(keywordString, keywordEnglish);
                }

                else if (anchor != null)
                {
                    string keyWordString = anchor.InnerText;
                    string keyWordLink = "";
                    var keyWordsLinkNode = anchor.SelectSingleNode("//gmd:keyword/gmx:Anchor/@xlink:href", ns);
                    if (keyWordsLinkNode != null)
                        keyWordLink = keyWordsLinkNode.InnerText;

                    keyword = new Anchor_Type { Value = keyWordString, href = keyWordLink };
                }
                else
                {
                    string keyWordString = "";
                    var keyWordNode = doc.SelectSingleNode("//gmd:keyword/gco:CharacterString", ns);
                    if (keyWordNode != null)
                        keyWordString = keyWordNode.InnerText;

                    keyword = new CharacterString_PropertyType { CharacterString = keyWordString };
                }
        }
Esempio n. 9
0
 protected override void DeserializeElement(System.Xml.XmlReader reader, bool serializeCollectionKey)
 {
     string x = reader.ReadOuterXml();
     XmlDocument _dom = new XmlDocument();
     _dom.PreserveWhitespace = false;
     _dom.LoadXml(x);
     parseNode(_dom.DocumentElement, reader);
 }
Esempio n. 10
0
        void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            var xdoc = XDocument.Parse(reader.ReadOuterXml());

            _name = xdoc.Root.Attribute("n").Value;
            _readonly = Convert.ToBoolean(xdoc.Root.Attribute("o").Value);

            var it = xdoc.Root.Attribute("pt");

            if (it != null)
            {
                _iPersistParentType = Type.GetType(it.Value);
            }
            foreach (var item in xdoc.Root.Element("d").Elements("i"))
            {
                var typ = Type.GetType(item.Attribute("t").Value);
                var key = item.Attribute("k").Value;

                var xser = new System.Xml.Serialization.XmlSerializer(typ);
                var val = xser.Deserialize(item.FirstNode.CreateReader());
                _dict.Add(key, val);
            }
        }
        /// <summary>
        /// Generates a CalendarEvent object from it's XML representation
        /// </summary>
        /// <param name="reader">XmlReader posistioned at the start node
        /// of the CalendarEvent XML</param>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            string xsTypes =
                "http://schemas.microsoft.com/exchange/services/2006/types";

            // Store the LocalName of the element we are currently at.
            // This should be "CalendarEvent".
            //
            // This also serves as our key to our position in the stream.
            // Once we reach an EndElement with this name, then we
            // are done with our portion of the XmlStream.
            //
            string toplevelElementName = reader.LocalName;
            reader.Read();

            while (true)
            {
                // Check to see if we are done processing
                if ((reader.NodeType == XmlNodeType.EndElement) &&
                    (0 == String.Compare(reader.LocalName, toplevelElementName)))
                {
                    // We are done, consume this EndElement and stop processing
                    reader.Read();
                    break;
                }

                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    // This means we are at the closing tag of
                    // </CalendarEventDetails>
                    // No data here to process.
                    reader.Read();
                    continue;
                }

                // Consume StartTime or EndTime
                if ((0 == String.Compare(reader.LocalName, "StartTime")) ||
                    (0 == String.Compare(reader.LocalName, "EndTime")))
                {
                    // Store the localName, we'll need this to determine if this is
                    // the StartTime or EndTime field later.
                    string localName = reader.LocalName;

                    // StartTime or EndTime is the reason we needed to implement
                    // IXmlSerializable, the server will always append a UTC offset
                    // to the CalendarEvent date/time strings, and this offset
                    // can not be trusted.  The 'time' of the event is
                    // always valid if treated as Local time.
                    //
                    // We will use a Regular Expression to extract whatever was
                    // supplied as a local time only
                    //
                    string timeValue = reader.ReadElementContentAsString();
                    System.Text.RegularExpressions.Regex regex =
                        new System.Text.RegularExpressions.Regex(
                            @"(?<untimezoned>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})",
                            System.Text.RegularExpressions.RegexOptions.Compiled);

                    string nonUTCOffsettedString =
                        regex.Match(timeValue).Result("${untimezoned}");
                    DateTime parsedDateTime = DateTime.Parse(nonUTCOffsettedString);

                    // Set to the appropriate field
                    if (0 == String.Compare(localName, "StartTime"))
                    {
                        this.startTimeField = parsedDateTime;
                    }
                    else
                    {
                        this.endTimeField = parsedDateTime;
                    }
                }

                // Consume BusyType
                if (0 == String.Compare(reader.LocalName, "BusyType"))
                {
                    string value = reader.ReadElementContentAsString();
                    this.busyTypeField =
                        (LegacyFreeBusyType)Enum.Parse(
                            typeof(LegacyFreeBusyType), value);
                }

                // Consume CalendarEventDetails, we are going to create an
                // XmlSerializer for this to allow that type's default
                // serialization process to occur.
                if (0 == String.Compare(reader.LocalName,
                    "CalendarEventDetails"))
                {
                    using (System.IO.StringReader strdr =
                        new System.IO.StringReader(reader.ReadOuterXml()))
                    {
                        XmlSerializer xmls =
                            new XmlSerializer(
                                typeof(CalendarEventDetails), xsTypes);

                        this.calendarEventDetailsField =
                            (CalendarEventDetails)xmls.Deserialize(strdr);
                    }
                }
            }
        }
        public void ReadXml(System.Xml.XmlReader reader)
        {
            var wasEmpty = reader.IsEmptyElement;
            reader.Read();
            if (wasEmpty)
            {
                return;
            }

            reader.MoveToContent();
            reader.ReadStartElement("Jobs");
            var jobsXml = reader.ReadOuterXml();
            // Create metadatacontainer to fill
            var names = alljobtypes.Select(x => x.Name);
            this.Jobs = (from t in XDocument.Parse(jobsXml).Descendants("Job")
                         where names.Contains(t.Attribute(XName.Get("type", "http://www.w3.org/2001/XMLSchema-instance")).Value)
                         select this.genericSerializer.Deserialize<Job>(t.CreateReader(), jobTypes)).ToList();
            reader.ReadEndElement();

            reader.ReadStartElement("Clients");
            this.Clients = this.genericSerializer.Deserialize<ListOfUniqueType<Client>>(reader, clientTypes);
            reader.ReadEndElement();

            reader.ReadStartElement("Hosts");
            this.Hosts = this.genericSerializer.Deserialize<List<Host>>(reader);
            reader.ReadEndElement();

            reader.ReadStartElement("Templates");
            this.Templates = this.genericSerializer.Deserialize<List<Template>>(reader);
            reader.ReadEndElement();

            //Read Closing Element
            reader.ReadEndElement();
        }
Esempio n. 13
0
 protected override void DeserializeElement(System.Xml.XmlReader reader, bool serializeCollectionKey)
 {
     string xml = reader.ReadOuterXml();
     XDocument doc = XDocument.Parse(xml);
     rootNode = GathererConfigNode.ConvertFrom((XElement)doc.FirstNode, null);
 }
Esempio n. 14
0
        public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result)
        {
            // Parse base (ANY) from the stream
            ANYFormatter baseFormatter = new ANYFormatter();
            string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name;

            // Parse ED
            ED retVal = baseFormatter.Parse<ED>(s, result);

            // Now parse our data out... Attributes
            if (s.GetAttribute("representation") != null)
                retVal.Representation = (EncapsulatedDataRepresentation)Util.FromWireFormat(s.GetAttribute("representation"), typeof(EncapsulatedDataRepresentation));
            if (s.GetAttribute("mediaType") != null)
                retVal.MediaType = s.GetAttribute("mediaType");
            if (s.GetAttribute("language") != null)
                retVal.Language = s.GetAttribute("language");
            if (s.GetAttribute("compression") != null)
                retVal.Compression = (EncapsulatedDataCompression?)Util.FromWireFormat(s.GetAttribute("compression"), typeof(EncapsulatedDataCompression));
            if (s.GetAttribute("integrityCheckAlgorithm") != null)
            {
                switch(s.GetAttribute("integrityCheckAlgorithm"))
                {
                    case "SHA-1":
                        retVal.IntegrityCheckAlgorithm = EncapsulatedDataIntegrityAlgorithm.SHA1;
                        break;
                    case "SHA-256":
                        retVal.IntegrityCheckAlgorithm = EncapsulatedDataIntegrityAlgorithm.SHA256;
                        break;
                }
            }
            if (s.GetAttribute("integrityCheck") != null)
                retVal.IntegrityCheck = Convert.FromBase64String(s.GetAttribute("integrityCheck"));

            // Elements and inner data
            #region Elements
            string innerData = "";
            if (!s.IsEmptyElement)
            {
                // Exit markers
                int sDepth = s.Depth;
                string sName = s.Name;

                s.Read();
                // Read until exit condition is fulfilled
                while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName))
                {
                    string oldName = s.Name; // Name
                    try
                    {
                        if (s.LocalName == "thumbnail") // Format using ED
                        {
                            EDFormatter edFormatter = new EDFormatter();
                            edFormatter.Host = this.Host;
                            retVal.Thumbnail = (ED)edFormatter.Parse(s, result); // Parse ED
                        }
                        else if (s.LocalName == "reference") // Format using TEL
                        {
                            TELFormatter telFormatter = new TELFormatter();
                            telFormatter.Host = this.Host;
                            retVal.Reference = (TEL)telFormatter.Parse(s, result);
                        }
                        else if (s.NodeType == System.Xml.XmlNodeType.Text ||
                            s.NodeType == System.Xml.XmlNodeType.CDATA)
                            innerData += s.Value;
                        else if (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName) &&
                            (s.NodeType == System.Xml.XmlNodeType.Element || s.NodeType == System.Xml.XmlNodeType.EndElement))
                        {
                            retVal.Representation = EncapsulatedDataRepresentation.XML;
                            innerData += s.ReadOuterXml();
                        }
                    }
                    catch (MessageValidationException e)
                    {
                        result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, s.ToString(), e));
                    }
                    finally
                    {
                        if (s.Name == oldName) s.Read();
                    }
                }
            }
            #endregion

            Encoding textEncoding = System.Text.Encoding.UTF8;
            // Parse the innerData string into something meaningful
            if(innerData.Length > 0)
                if (retVal.Representation == EncapsulatedDataRepresentation.B64)
                    retVal.Data = Convert.FromBase64String(innerData);
                else
                    retVal.Data = textEncoding.GetBytes(innerData);

            // Finally, the hash, this will validate the data
            if(!retVal.ValidateIntegrityCheck())
                result.AddResultDetail(new ResultDetail(ResultDetailType.Warning,
                    string.Format("Encapsulated data with content starting with '{0}' failed integrity check!", retVal.ToString().PadRight(10, ' ').Substring(0, 10)),
                    s.ToString(),
                    null));

            // Validate
            baseFormatter.Validate(retVal, pathName, result);

            return retVal;
        }
Esempio n. 15
0
 protected override void InitializeElementProperties(System.Xml.XmlReader reader, ref object obj, ITypeSerializationInfo info, XmlSerializationContext context)
 {
     int currentDepth = reader.Depth;
     while (reader.Depth < currentDepth || reader.Read())
     {
         if (reader.Depth == currentDepth)
         {
             break;
         }
         else if (reader.Depth < currentDepth)
         {
             return;
         }
         if (reader.NodeType == XmlNodeType.Element)
         {
             var found = false;
             foreach (IPropertySerializationInfo p in info.ElementProperties)
             {
                 if (IsPropertyElement(reader, p))
                 {
                     ReadElementFromProperty(reader, obj, context, p);
                     found = true;
                     break;
                 }
             }
             if (!found)
             {
                 foreach (IPropertySerializationInfo p in info.AttributeProperties)
                 {
                     if (IsPropertyElement(reader, p))
                     {
                         ReadElementFromProperty(reader, obj, context, p);
                         found = true;
                         break;
                     }
                 }
                 if (!found)
                 {
                     OnUnknownElement(new UnknownElementEventArgs(obj, reader.ReadOuterXml()));
                 }
             }
         }
     }
 }
 /// <summary>
 /// 读入Rsa配置信息
 /// </summary>
 /// <param name="reader">XmlReader</param>
 /// <param name="serializeCollectionKey"></param>
 protected override void DeserializeElement(System.Xml.XmlReader reader, bool serializeCollectionKey)
 {
     lock (typeof(SignInRsaKeyValueConfigurationElement))
     {
         if (SignInRsaKeyValueConfigurationElement.sValue == string.Empty)
             SignInRsaKeyValueConfigurationElement.sValue = reader.ReadOuterXml();
         else
             reader.ReadOuterXml();
     }
 }
Esempio n. 17
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     var localName = reader.Name;
     this.Content = reader.ReadOuterXml();
     return;
     //return;
     //while (reader.Read())
     //{
     //    if (reader.Name == localName && reader.NodeType == XmlNodeType.EndElement)
     //    {
     //        reader.Read();
     //        break;
     //    }
     //}
 }
        /// <summary>
        /// Generates a Suggestion object from it's XML representation
        /// </summary>
        /// <param name="reader">XmlReader posistioned at the start node
        /// of the Suggestion XML</param>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            string xsTypes =
                "http://schemas.microsoft.com/exchange/services/2006/types";

            // Store the LocalName of the element we are currently at.
            // This should be "Suggestion".
            //
            // This also serves as our key to our position in the stream.
            // Once we reach an EndElement with this name, then we
            // are done with our portion of the XmlStream.
            //
            string toplevelElementName = reader.LocalName;
            reader.Read();

            while (true)
            {
                // Check to see if we are done processing
                if ((reader.NodeType == XmlNodeType.EndElement) &&
                    (0 == String.Compare(reader.LocalName, toplevelElementName)))
                {
                    // We are done, consume this EndElement and stop processing
                    reader.Read();
                    break;
                }

                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    // This likely means we are at the closing tag of
                    // </AttendeeConflictDataArray>
                    // No data here to process.
                    reader.Read();
                    continue;
                }

                // Consume MeetingTime
                if (0 == String.Compare(reader.LocalName, "MeetingTime"))
                {
                    // MeetingTime is the primary reason we needed to implement
                    // IXmlSerializable, the server will always append a UTC offset
                    // to the date/time string in the MeetingTime element.  This
                    // offset can not be trusted.  The 'time' of the suggestion is
                    // always valid if treated as Local time.
                    //
                    // We will use a Regular Expression to extract whatever was
                    // supplied as a local time only
                    //
                    string meetingTimeValue = reader.ReadElementContentAsString();
                    System.Text.RegularExpressions.Regex regex =
                        new System.Text.RegularExpressions.Regex(
                            @"(?<untimezoned>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})",
                            System.Text.RegularExpressions.RegexOptions.Compiled);

                    string nonUTCOffsettingString =
                        regex.Match(meetingTimeValue).Result("${untimezoned}");
                    this.meetingTimeField = DateTime.Parse(nonUTCOffsettingString);
                }

                // Consume IsWorkTime
                if (0 == String.Compare(reader.LocalName, "IsWorkTime"))
                {
                    this.isWorkTimeField = reader.ReadElementContentAsBoolean();
                }

                // Consume SuggestionQuality
                if (0 == String.Compare(reader.LocalName, "SuggestionQuality"))
                {
                    string value = reader.ReadElementContentAsString();
                    this.suggestionQualityField =
                        (SuggestionQuality)Enum.Parse(typeof
                            (SuggestionQuality), value);
                }

                // Consume AttendeeConflictDataArray
                if (0 == String.Compare(reader.LocalName,
                    "AttendeeConflictDataArray"))
                {
                    // Unfortunately, the XmlSerializer can't just de-serialize an
                    // array of items, therefore we need to look at the types of
                    // each indivudal elements of the array and de-serialize them
                    // based on their type.
                    XmlDocument xmld = new XmlDocument();
                    string outerXml = reader.ReadOuterXml();
                    xmld.LoadXml(outerXml);

                    if (!xmld.HasChildNodes)
                    {
                        // This an an empty AttendeeConflictDataArray, so were done.
                        this.attendeeConflictDataArrayField =
                            new AttendeeConflictData[0];
                        continue;
                    }

                    XmlNodeList attendeeConflictNodes = xmld.FirstChild.ChildNodes;
                    List<AttendeeConflictData> attendeeConflictDataList =
                        new List<AttendeeConflictData>(attendeeConflictNodes.Count);

                    foreach (XmlNode xmln in attendeeConflictNodes)
                    {
                        if (0 == String.Compare(xmln.Name,
                            "IndividualAttendeeConflictData"))
                        {
                            using (System.IO.StringReader strdr =
                                new System.IO.StringReader(xmln.OuterXml))
                            {
                                XmlSerializer xmls =
                                    new XmlSerializer(
                                        typeof(IndividualAttendeeConflictData),
                                        xsTypes);

                                attendeeConflictDataList.Add(
                                    (IndividualAttendeeConflictData)
                                    xmls.Deserialize(strdr));
                            }
                        }
                        if (0 == String.Compare(xmln.Name,
                            "GroupAttendeeConflictData"))
                        {
                            using (System.IO.StringReader strdr =
                                new System.IO.StringReader(xmln.OuterXml))
                            {
                                XmlSerializer xmls =
                                    new XmlSerializer(
                                        typeof(GroupAttendeeConflictData),
                                        xsTypes);

                                attendeeConflictDataList.Add(
                                    (GroupAttendeeConflictData)
                                    xmls.Deserialize(strdr));
                            }
                        }
                        if (0 == String.Compare(xmln.Name,
                            "UnknownAttendeeConflictData"))
                        {
                            using (System.IO.StringReader strdr =
                                new System.IO.StringReader(xmln.OuterXml))
                            {
                                XmlSerializer xmls =
                                    new XmlSerializer(
                                        typeof(UnknownAttendeeConflictData),
                                        xsTypes);

                                attendeeConflictDataList.Add(
                                    (UnknownAttendeeConflictData)
                                    xmls.Deserialize(strdr));
                            }
                        }
                        if (0 == String.Compare(xmln.Name,
                            "TooBigGroupAttendeeConflictData"))
                        {
                            using (System.IO.StringReader strdr =
                                new System.IO.StringReader(xmln.OuterXml))
                            {
                                XmlSerializer xmls =
                                    new XmlSerializer(
                                        typeof(TooBigGroupAttendeeConflictData),
                                        xsTypes);

                                attendeeConflictDataList.Add(
                                    (TooBigGroupAttendeeConflictData)
                                    xmls.Deserialize(strdr));
                            }
                        }
                    }

                    // Convert our list of AttendeeConflictData to an array
                    this.attendeeConflictDataArrayField =
                        attendeeConflictDataList.ToArray();
                }
            }
        }
Esempio n. 19
0
    public void ReadXml(System.Xml.XmlReader reader)
    {
      reader.ReadStartElement("ConnectionData");
      reader.MoveToContent();

      while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
      {
        switch (reader.LocalName)
        {
          case "Authentication":
            Authentication newAuth;
            if (Enum.TryParse<Authentication>(reader.ReadElementString(reader.LocalName), out newAuth))
              this.Authentication = newAuth;
            break;
          case "Color":
            this.Color = FromHex(reader.ReadElementString(reader.LocalName));
            break;
          case "ConnectionName":
            this.ConnectionName = reader.ReadElementString(reader.LocalName);
            break;
          case "Database":
            this.Database = reader.ReadElementString(reader.LocalName);
            break;
          case "Password":
            var encrypted = reader.ReadElementString(reader.LocalName);
            string password;
            var success = TryDecryptWindows(encrypted, out password)
              || TryDecryptStatic(encrypted, out password);
            this.Password = password;
            break;
          case "Url":
            this.Url = reader.ReadElementString(reader.LocalName);
            break;
          case "UserName":
            this.UserName = reader.ReadElementString(reader.LocalName);
            break;
          case "Type":
            ConnectionType newType;
            if (Enum.TryParse<ConnectionType>(reader.ReadElementString(reader.LocalName), out newType))
              this.Type = newType;
            break;
          case "Confirm":
            Boolean newConfirm;
            if (Boolean.TryParse(reader.ReadElementString(reader.LocalName), out newConfirm))
              this.Confirm = newConfirm;
            break;
          default:
            reader.ReadOuterXml();
            reader.MoveToContent();
            break;
        }
      }

      if (this.Color == System.Drawing.Color.Empty)
      {
        var idx = (int)(((long)this.ConnectionName.GetHashCode() - int.MinValue) % _tabColors.Length);
        this.Color = _tabColors[idx];
      }
      reader.ReadEndElement();
    }
Esempio n. 20
0
 protected override void DeserializeElement(System.Xml.XmlReader reader, bool serializeCollectionKey)
 {
     string outerXml = reader.ReadOuterXml();
     var contentXmlReader = System.Xml.XmlReader.Create(new StringReader(outerXml));
     if (contentXmlReader.Read())
     {
         object content = contentXmlReader.ReadElementContentAsObject();
         if ((content != null) && ((content is string) ? !string.IsNullOrEmpty((string)content) : true))
         {
             Value = content;
             string xmlDocument = Regex.Replace(outerXml, "(^<Parameter.*?>)(.*?)(</Parameter>)$", "$1$3");
             var elementXmlReader = System.Xml.XmlReader.Create(new StringReader(xmlDocument));
             if (elementXmlReader.Read())
             {
                 base.DeserializeElement(elementXmlReader, serializeCollectionKey);
             }
         }
         else
         {
             string xmlDocument = outerXml;
             var elementXmlReader = System.Xml.XmlReader.Create(new StringReader(xmlDocument));
             if (elementXmlReader.Read())
             {
                 base.DeserializeElement(elementXmlReader, serializeCollectionKey);
             }
         }
     }
 }