IsStartElement() public method

public IsStartElement ( ) : bool
return bool
        /// <summary>
        /// Reads the match.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="reader">The reader.</param>
        /// <returns></returns>
        /// <exception cref="System.Xml.XmlException">MatchId IsNullOrEmpty</exception>
        protected override XacmlMatch ReadMatch(XmlReader reader) {
            Contract.Requires<ArgumentNullException>(reader != null, "reader");
            Contract.Requires<XmlException>(reader.IsStartElement(XacmlConstants.ElementNames.Match, this.version.NamespacePolicy));

            var gaMatchId = reader.GetAttribute("MatchId");
            if (string.IsNullOrEmpty(gaMatchId)) {
                throw Diagnostic.DiagnosticTools.ExceptionUtil.ThrowHelperError(new XmlException("MatchId IsNullOrEmpty"));
            }

            reader.ReadStartElement(XacmlConstants.ElementNames.Match, this.version.NamespacePolicy);

            var attributeValue = ReadAttributeValue(reader);

            XacmlMatch result;
            if (reader.IsStartElement(XacmlConstants.ElementNames.AttributeDesignator, this.version.NamespacePolicy)) {
                var attributeDesignator = this.ReadAttributeDesignator(reader) as XacmlAttributeDesignator;
                result = new XacmlMatch(new Uri(gaMatchId, UriKind.RelativeOrAbsolute), attributeValue, attributeDesignator);
            }
            else {
                XacmlAttributeSelector attributeSelector = ReadAttributeSelector(reader);
                result = new XacmlMatch(new Uri(gaMatchId, UriKind.RelativeOrAbsolute), attributeValue, attributeSelector);
            }

            reader.ReadEndElement();
            return result;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 分析集合大小
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected ChannelSearchOutlineInfo AnalysisCount(System.Xml.XmlReader reader)
        {
            ChannelSearchOutlineInfo channelSearchOutLineInfo = new ChannelSearchOutlineInfo();

            if (reader.ReadToFollowing("count"))
            {
                channelSearchOutLineInfo.Count = reader.ReadElementContentAsInt();
                if (reader.IsStartElement("page_count"))
                {
                    channelSearchOutLineInfo.PageCount = reader.ReadElementContentAsInt();
                    if (reader.IsStartElement("countInPage"))
                    {
                        channelSearchOutLineInfo.CountInPage = reader.ReadElementContentAsInt();
                        if (reader.IsStartElement("page"))
                        {
                            channelSearchOutLineInfo.CurrentPage = reader.ReadElementContentAsInt();
                            ///*
                            // * 总个数是否小于每页的个数,小于的话第一页返回总个数,其余页返回0
                            // * 不小于判断是哪页,其余页返回每页个数,最后一页算一下还剩下多少页
                            // */
                            //return count > countInPage ?
                            //    (pageIndex > pageCount ? 0 : (pageIndex == pageCount) ? count - (pageIndex - 1) * countInPage : countInPage) :
                            //    (pageIndex > 1 ? 0 : count);
                        }
                    }
                }
            }
            return(channelSearchOutLineInfo);
        }
		private static MetadataFileType DetermineFileType(XmlReader reader)
		{
			try
			{
				if (reader.IsStartElement("definitions", "http://schemas.xmlsoap.org/wsdl/"))
				{
					return MetadataFileType.Wsdl;
				}
				if (reader.IsStartElement("schema", "http://www.w3.org/2001/XMLSchema"))
				{
					return MetadataFileType.Xsd;
				}
				if (reader.IsStartElement("Policy", "http://schemas.xmlsoap.org/ws/2004/09/policy") || reader.IsStartElement("Policy", "http://www.w3.org/ns/ws-policy"))
				{
					return MetadataFileType.Policy;
				}
				if (reader.IsStartElement("EndpointReference", "http://schemas.xmlsoap.org/ws/2004/08/addressing"))
				{
					return MetadataFileType.Epr;
				}
				return MetadataFileType.UnknownXml;
			}
			catch (XmlException)
			{
				return MetadataFileType.NonXml;
			}
		}
        /// <summary>
        /// Reads the settings provided from stream 
        /// </summary> 
        /// <param name="xmlReader"></param> 
        /// <returns></returns> 
        public static AnalyticsSettings DeserializeAnalyticsSettings(XmlReader xmlReader)
        {
            // Read the root and check if it is empty or invalid xmlReader.Read();
            xmlReader.ReadStartElement(SettingsSerializerHelper.RootPropertiesElementName);

            AnalyticsSettings settings = new AnalyticsSettings();

            while (true)
            {
                if (xmlReader.IsStartElement(SettingsSerializerHelper.LoggingElementName))
                {
                    DeserializeLoggingElement(xmlReader, settings);
                }
                else if (xmlReader.IsStartElement(SettingsSerializerHelper.MetricsElementName))
                {
                    DeserializeMetricsElement(xmlReader, settings);
                }
                else
                {
                    break;
                }
            }

            xmlReader.ReadEndElement();

            return settings;
        }
Exemplo n.º 5
0
        internal BasicFileElement(System.Xml.XmlReader reader)
            : base(reader)
        {
            FilePath = reader.GetNonEmptyAttribute("Path");
            String soundType = reader.GetNonEmptyAttribute("SoundType");

            SoundFileType = soundType == "Music" ? SoundFileType.Music : SoundFileType.SoundEffect;
            if (reader.IsEmptyElement)
            {
                reader.Read();
            }
            else
            {
                reader.Read();
                while (reader.IsStartElement())
                {
                    if (reader.IsStartElement("Effects"))
                    {
                        m_Effects = new Effects(reader);
                    }
                    else
                    {
                        reader.ReadOuterXml();
                    }
                }
                reader.ReadEndElement();
            }
            if (m_Effects == null)
            {
                m_Effects = new Effects();
            }
        }
Exemplo n.º 6
0
 public void ReadXml(XmlReader reader)
 {
     int sequenceCount = 0;
       bool isEmpty = reader.IsEmptyElement;
       reader.ReadStartElement();
       if (isEmpty)
     return;
       while (reader.NodeType == XmlNodeType.Element)
       {
     if (sequenceCount == 0 || reader.IsStartElement("title"))
     {
       PitchSequences.Add(new PitchSequence());
       sequenceCount++;
     }
     if (reader.IsStartElement("title"))
       PitchSequences[sequenceCount - 1].Title = reader.ReadElementString();
     else if (reader.IsStartElement("pitch"))
     {
       var pitch = new Pitch();
       pitch.ReadXml(reader);
       PitchSequences[sequenceCount - 1].Pitches.Add(pitch);
     }
     else
       reader.ReadOuterXml();
       }
       reader.ReadEndElement();
 }
Exemplo n.º 7
0
        protected override SecurityKeyIdentifier ReadKeyIdentifierCore(XmlReader reader)
        {
            var result = new SecurityKeyIdentifier();

            reader.ReadStartElement("KeyInfo", SignedXml.XmlDsigNamespaceUrl);

            while (reader.IsStartElement())
            {
                if (reader.IsStartElement("X509Data", SignedXml.XmlDsigNamespaceUrl))
                {
                    foreach (var clause in ReadX509Data(reader))
                    {
                        result.Add(clause);
                    }
                }
                else
                {
                    if (reader.IsStartElement("KeyName", SignedXml.XmlDsigNamespaceUrl))
                    {
                        result.Add(ReadKeyNameClause(reader));
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
            }

            reader.ReadEndElement();

            return result;
        }
Exemplo n.º 8
0
        protected virtual void ReadXml(XmlReader reader, SyndicationFeed result)
        {
            if (result == null)
                throw new ArgumentNullException("result");
            else if (reader == null)
                throw new ArgumentNullException("reader");

            reader.ReadStartElement();              // Read in <RDF>
            reader.ReadStartElement("channel");     // Read in <channel>
            while (reader.IsStartElement())         // Process <channel> children
            {
                if (reader.IsStartElement("title"))
                    result.Title = new TextSyndicationContent(reader.ReadElementString());
                else if (reader.IsStartElement("link"))
                    result.Links.Add(new SyndicationLink(new Uri(reader.ReadElementString())));
                else if (reader.IsStartElement("description"))
                    result.Description = new TextSyndicationContent(reader.ReadElementString());
                else
                    reader.Skip();
            }
            reader.ReadEndElement();                // Read in </channel>

            while (reader.IsStartElement())
            {
                if (reader.IsStartElement("item"))
                {
                    result.Items = this.ReadItems(reader, result);

                    break;
                }
                else
                    reader.Skip();
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 分析集合大小
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected virtual int AnalysisCount(System.Xml.XmlReader reader)
        {
            if (reader.ReadToFollowing("count"))
            {
                var count = reader.ReadElementContentAsInt();
                if (reader.IsStartElement("page_count"))
                {
                    var pageCount = reader.ReadElementContentAsInt();
                    if (reader.IsStartElement("countInPage"))
                    {
                        var countInPage = reader.ReadElementContentAsInt();
                        if (reader.IsStartElement("page"))
                        {
                            var pageIndex = reader.ReadElementContentAsInt();

                            /*
                             * 总个数是否小于每页的个数,小于的话第一页返回总个数,其余页返回0
                             * 不小于判断是哪页,其余页返回每页个数,最后一页算一下还剩下多少页
                             */
                            return(count > countInPage ?
                                   (pageIndex > pageCount ? 0 : (pageIndex == pageCount) ? count - (pageIndex - 1) * countInPage : countInPage) :
                                   (pageIndex > 1 ? 0 : count));
                        }
                    }
                }
            }
            return(20);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">
        /// The <see cref="System.Xml.XmlReader" /> stream from which the object is
        /// deserialized.
        /// </param>
        public void ReadXml(XmlReader reader)
        {
            if (!reader.IsStartElement("Manager"))
            {
                throw new XmlException("Expected <Manager> element");
            }

            bool isEmptyElement = reader.IsEmptyElement;
            reader.ReadStartElement("Manager");

            if (!isEmptyElement)
            {
                if (!reader.IsStartElement("Variables"))
                {
                    throw new XmlException("Expected <Variables> subelement in <Manager> element");
                }

                isEmptyElement = reader.IsEmptyElement;
                reader.ReadStartElement("Variables");

                if (!isEmptyElement)
                {
                    while (reader.IsStartElement("Variable"))
                    {
                        Variable variable = new Variable();
                        variable.ReadXml(reader);
                        this.Variables.Add(variable);
                    }

                    reader.ReadEndElement(); // Variables
                }

                reader.ReadEndElement(); // Manager
            }
        }
        //public static Oids.Oid Deserialize(XmlReader reader, Oids.Oid oid)
        /// <summary>
        /// Deserializes Oid from an XML stream.
        /// </summary>
        /// <param name="reader">XML stream.</param>
        /// <returns>Oid.</returns>
        public static Oids.Oid Deserialize(XmlReader reader)
        {
            Oids.Oid lResult = null;
            if (reader.IsStartElement(DTD.TagOID))
            {
                string lClassName = reader.GetAttribute(DTD.OID.TagClass);
                List<KeyValuePair<ModelType,object>> lFields = new List<KeyValuePair<ModelType,object>>();

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    do
                    {
                    #region Process tag <OID.Field>.
                    if (reader.IsStartElement(DTD.OID.TagOIDField))
                    {
                        if (!reader.IsEmptyElement)
                        {
                            ModelType lType = Convert.StringTypeToMODELType(reader.GetAttribute(DTD.OID.TagType));
                            lFields.Add(new KeyValuePair<ModelType, object>(lType, Convert.XmlToType(lType, reader.ReadString())));
                        }
                        else
                        {
                            throw new ArgumentException("Xml Reader have one OID.Field with empty Element.", "XmlReader reader");
                        }
                    }
                    #endregion Process tag <OID.Field>.
                    else
                    {
                        #region Process tag <?>
                        reader.Skip();
                        if (reader.NodeType == XmlNodeType.None)
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                        #endregion Process tag <?>
                    }
                    } while (reader.Read());
                }
                else
                {
                    reader.Skip();
                }

                if(lClassName.Length > 0)
                {
                    lResult = ServerConnection.CreateOid(lClassName,lFields);
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the OID in Start Element.", "XmlReader reader");
            }
            return lResult;
        }
        public static ServiceResponse Deserialize(XmlReader reader, ServiceResponse serviceResponse)
        {
            if (reader.IsStartElement(DTD.Response.TagServiceResponse))
            {
                if (serviceResponse == null)
                {
                    serviceResponse = new ServiceResponse();
                }

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    do
                    {
                        #region <ERROR>
                        if (reader.IsStartElement(DTD.Response.ServiceResponse.TagError))
                        {
                            if(int.Parse(reader.GetAttribute(DTD.Error.TagNumber))!=0)
                            {
                                throw XMLErrorSerializer.Deserialize(reader.ReadSubtree());
                            }
                            else
                            {
                                reader.Skip();
                            }
                        }
                        #endregion <ERROR>

                        #region <OID>
                        if (reader.IsStartElement(DTD.TagOID))
                        {
                            serviceResponse.Oid = XMLAdaptorOIDSerializer.Deserialize(reader.ReadSubtree());
                        }
                        #endregion <OID>

                        #region <Arguments>
                        if (reader.IsStartElement(DTD.Response.ServiceResponse.TagArguments))
                        {
                            serviceResponse.Arguments = XMLArgumentsSerializer.Deserialize(reader.ReadSubtree());
                        }
                        #endregion <Arguments>
                    } while (reader.Read());
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the Service.Response in Start Element.", "XmlReader reader");
            }
            return serviceResponse;
        }
        /// <summary>
        /// Override of the base class that reads a child element inside the RST
        /// </summary>
        /// <param name="reader">Reader pointing at an element to read inside the RST.</param>
        /// <param name="rst">The RequestSecurityToken element that is being populated from the reader.</param>
        /// <param name="context">Current Serialization context.</param>
        /// <exception cref="ArgumentNullException">Either reader or rst or context parameter is null.</exception>
        /// <exception cref="WSTrustSerializationException">Unable to deserialize the current parameter.</exception>
        public override void ReadXmlElement(XmlReader reader, RequestSecurityToken rst, WSTrustSerializationContext context)
        {
            if (reader == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
            }

            if (rst == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("rst");
            }

            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            // special case SecondaryParameters, they cannot be embeded as per WS-Trust 1.3
            if (reader.IsStartElement(WSTrust13Constants.ElementNames.SecondaryParameters, WSTrust13Constants.NamespaceURI))
            {
                rst.SecondaryParameters = this.ReadSecondaryParameters(reader, context);
                return;
            }

            if (reader.IsStartElement(WSTrust13Constants.ElementNames.KeyWrapAlgorithm, WSTrust13Constants.NamespaceURI))
            {
                rst.KeyWrapAlgorithm = reader.ReadElementContentAsString();
                if (!UriUtil.CanCreateValidUri(rst.KeyWrapAlgorithm, UriKind.Absolute))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WSTrustSerializationException(SR.GetString(SR.ID3135, WSTrust13Constants.ElementNames.KeyWrapAlgorithm, WSTrust13Constants.NamespaceURI, rst.KeyWrapAlgorithm)));
                }

                return;
            }

            if (reader.IsStartElement(WSTrust13Constants.ElementNames.ValidateTarget, WSTrust13Constants.NamespaceURI))
            {
                if (!reader.IsEmptyElement)
                {
                    rst.ValidateTarget = new SecurityTokenElement(WSTrustSerializationHelper.ReadInnerXml(reader), context.SecurityTokenHandlers);
                }

                if (rst.ValidateTarget == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WSTrustSerializationException(SR.GetString(SR.ID3221)));
                }

                return;
            }

            WSTrustSerializationHelper.ReadRSTXml(reader, rst, context, WSTrustConstantsAdapter.Trust13);
        }
Exemplo n.º 14
0
 public PackDefinition(XmlReader reader)
 {
     Items = new List<IPackItem>();
     while (true)
     {
         if (reader.IsStartElement("pick"))
             Items.Add(new Pick(reader));
         else if (reader.IsStartElement("options"))
             Items.Add(new OptionsList(reader));
         else
             return;
     }
 }
Exemplo n.º 15
0
        private static FeedFactory GetFeedFactory(XmlReader reader) {
            if (reader.IsStartElement("rss", String.Empty) ||
                reader.IsStartElement("rdf:RDF")) {
                return new RssFeedFactory();
            }

            if (reader.IsStartElement("atom", "http://www.w3.org/2005/Atom") ||
                reader.IsStartElement("feed", "http://www.w3.org/2005/Atom")) {
                return new AtomFeedFactory();
            }

            return null;
        }
        /// <summary>
        ///   Reads the next blueprint from the specified reader.
        /// </summary>
        /// <param name="reader">Reader to read the next blueprint from.</param>
        /// <returns>Read blueprint.</returns>
        public Blueprint Read(XmlReader reader)
        {
            reader.Read();
            reader.Read();

            var blueprintId = reader[BlueprintIdAttributeName];
            var blueprint = new Blueprint(blueprintId);

            // Read blueprint id.
            reader.ReadStartElement(BlueprintElementName);
            {
                // Read property values.
                reader.ReadStartElement(PropertyValuesElementName);
                {
                    while (reader.IsStartElement(PropertyElementName))
                    {
                        var key = reader[PropertyKeyAttributeName];
                        var typeName = reader[PropertyTypeAttributeName];
                        var type = Type.GetType(typeName);

                        reader.ReadStartElement(PropertyElementName);
                        {
                            var value =
                                new XmlSerializer(type, new XmlRootAttribute(PropertyValueElementName)).Deserialize(
                                    reader);

                            // Add to blueprint.
                            blueprint.PropertyValues.Add(key, value);
                        }
                        reader.ReadEndElement();
                    }
                }
                reader.ReadEndElement();

                // Read components.
                reader.ReadStartElement(ComponentsElementName);
                {
                    while (reader.IsStartElement(ComponentElementName))
                    {
                        var component = reader.ReadElementContentAsString();

                        // Add to blueprint.
                        blueprint.ComponentTypes.Add(component);
                    }
                }
                reader.ReadEndElement();
            }
            reader.ReadEndElement();

            return blueprint;
        }
        /// <summary>
        /// Deserializes an ChangedItem from an XML file.
        /// </summary>
        /// <param name="reader">XMLReader where the ChangedItem is.</param>
        /// <returns>ChangedItem.</returns>
        public static ChangedItem Deserialize(XmlReader reader)
        {
            ChangedItem lResult = null;
            if (reader.IsStartElement(DTD.Error.ChangedItems.TagChangedItem))
            {
                lResult = new ChangedItem();
                string stringModelType = reader.GetAttribute(DTD.Error.ChangedItems.ChangedItem.TagType);
                ModelType modelType = Convert.StringTypeToMODELType(stringModelType);

                if (modelType == ModelType.Oid)
                {
                    lResult.Type = Convert.MODELTypeToStringType(ModelType.Oid);
                    lResult.ClassName = stringModelType;
                }
                else
                {
                    lResult.Type = stringModelType;
                    lResult.ClassName = string.Empty;
                }
                lResult.Name = reader.GetAttribute(DTD.Error.ChangedItems.ChangedItem.TagName);

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();

                    if (reader.IsStartElement(DTD.Error.ChangedItems.ChangedItem.TagChangedItemOldValue))
                    {
                        lResult.OldValue =  XMLChangedItemValueSerializer.Deserialize(reader.ReadSubtree(),lResult.Type, lResult.ClassName);
                        reader.ReadEndElement();
                    }

                    if (reader.IsStartElement(DTD.Error.ChangedItems.ChangedItem.TagChangedItemNewValue))
                    {
                        lResult.NewValue = XMLChangedItemValueSerializer.Deserialize(reader.ReadSubtree(), lResult.Type, lResult.ClassName);
                        reader.ReadEndElement();
                    }
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the ChangedItem in Start Element.", "XmlReader reader");
            }
            return lResult;
        }
Exemplo n.º 18
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToElement();
            reader.ReadStartElement();
            Type instanceType = base.GetType().BaseType;

            while (reader.IsStartElement())
            {
                if (reader.HasAttributes)
                {
                    XmlNodeType nodeType = reader.NodeType;

                    Type t = typeof(FileProcessingJournalEntryData <>);
                    t = t.MakeGenericType(Type.GetType(reader.GetAttribute("type")));
                    string name = reader.GetAttribute("name");

                    var ser = XmlSerializerCache.GetOrAdd(t, name);

                    object obj = ser.Deserialize(reader.ReadSubtree());
                    reader.ReadEndElement();
                    this.EntryData.Add((FileProcessingJournalEntryDataBase)obj);
                }
                else
                {
                    PropertyInfo Prop = instanceType.GetProperty(reader.Name);
                    if (Prop != null)
                    {
                        var h = reader.ReadElementContentAsObject(Prop.Name, "");
                        Prop.SetValue(this, Convert.ChangeType(h, Prop.PropertyType), null);
                    }
                }
            }
        }
Exemplo n.º 19
0
        public void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();

            Repeat = Convert.ToInt32(reader["Repeat"], CultureInfo.InvariantCulture);

            if (reader.IsEmptyElement) {
                reader.ReadStartElement();
                return;
            }

            reader.ReadStartElement();
            while (!reader.EOF) {
                if (reader.IsStartElement()) {
                    switch (reader.Name) {
                        case "Frames":
                            ReadFramesXml(reader);
                            break;

                        default:
                            reader.Skip();
                            break;
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement) {
                    reader.ReadEndElement();
                    break;
                }
                else
                    reader.Read();
            }
        }
Exemplo n.º 20
0
        // ReSharper restore InconsistentNaming

        #region Overrides of XmlObject

        public override void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                        case "Format":
                            Format.Add(reader.ReadElementContentAsString());
                            break;
                        case "DCPType":
                            var tmp = new DCPType();
                            tmp.ReadXml(reader);
                            DCPType.Add(tmp);
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                else
                {
                    reader.Read();
                }
            }
        }
Exemplo n.º 21
0
        void AddString(XmlReader reader, Hashtable strings)
        {
            string key = reader.Name;

            if (strings.ContainsKey(key))
                throw new InvalidDataException("Already contains key (" + key + ")");

            reader.Read();

            while (reader.IsStartElement())
            {
                string name = reader.Name;
                string value = reader.ReadElementString();

                if (string.IsNullOrEmpty(value))
                    continue;

                if (name == culture.Name)
                    strings.Add(key, value);

                if (name == "default" && culture.Equals(CultureInfo.InvariantCulture))
                    strings.Add(key, value);
            }

            reader.ReadEndElement();
        }
Exemplo n.º 22
0
        private Ingestion DeserializeMetadatasets(System.Xml.XmlReader reader)
        {
            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name == "metadata-set")
                    {
                        string        strGuid = reader.GetAttribute("guid");
                        CFMetadataSet set     = new CFMetadataSet();
                        set.Content    = reader.ReadOuterXml();
                        set.Guid       = strGuid;
                        set.MappedGuid = strGuid;
                        MetadataSets.Add(set);
                    }
                    else
                    {
                        throw new FormatException("Invalid XML element: " + reader.Name);
                    }
                }

                if (reader.NodeType == System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.Name == "metadata-sets")
                    {
                        return(this);
                    }
                }
            }

            return(this);
        }
Exemplo n.º 23
0
 public virtual void ReadXml(XmlReader reader)
 {
     var viewSpecLists = new Dictionary<string, ViewSpecList>();
     if (reader.IsEmptyElement)
     {
         reader.Read();
     }
     else
     {
         reader.Read();
         while (true)
         {
             if (reader.IsStartElement("views")) // Not L10N
             {
                 string groupName = reader.GetAttribute("name"); // Not L10N
                 // ReSharper disable AssignNullToNotNullAttribute
                 viewSpecLists.Add(groupName, ViewSpecList.Deserialize(reader));
                 // ReSharper restore AssignNullToNotNullAttribute
             }
             else if (reader.NodeType == XmlNodeType.EndElement)
             {
                 reader.ReadEndElement();
                 break;
             }
             else
             {
                 reader.Read();
             }
         }
     }
     _viewSpecLists = viewSpecLists;
 }
Exemplo n.º 24
0
        public Ingestion Deserialize(Stream input)
        {
            bool isIngestion = false;

            using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(input))
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        if (!isIngestion)
                        {
                            if (reader.Name != "ingestion")
                            {
                                throw new FormatException("Invalid XML relationship element.");
                            }

                            isIngestion = true;

                            string overwrite = reader.GetAttribute("overwrite");
                            if (!string.IsNullOrWhiteSpace(overwrite))
                            {
                                Overwrite = bool.Parse(overwrite);
                            }
                            else
                            {
                                Overwrite = false;
                            }
                        }

                        switch (reader.Name)
                        {
                        case "ingestion":
                            break;

                        case "metadata-sets":
                            DeserializeMetadatasets(reader);
                            break;

                        case "aggregations":
                            DeserializeAggregations(reader);
                            break;

                        case "relationships":
                            DeserializeRelationships(reader);
                            break;

                        case "entity-types":
                            DeserializeEntityTypes(reader);
                            break;

                        default:
                            throw new FormatException("Invalid XML element: " + reader.Name);
                        }
                    }
                }
            }

            return(this);
        }
		Dictionary<string, List<CallerInfo>> ReadValidCertificates(XmlReader parser) {
			var validCertificates = new Dictionary<string, List<CallerInfo>>();
			try {
				while (parser.Read()) {
					if (parser.IsStartElement() && parser.Name == "signing_certificate") {
						var name = parser[0];
						var packageName = parser[2];
						var isRelease = Convert.ToBoolean(parser[1]);
						var certificate = parser.ReadString();
						if (certificate != null)
							certificate = certificate.Replace("\\s|\\n", "");

						var info = new CallerInfo(name, packageName, isRelease, certificate);

						List<CallerInfo> infos; 
						validCertificates.TryGetValue(certificate, out infos);
						if (infos == null) {
							infos = new List<CallerInfo>();
							validCertificates.Add(certificate, infos);
						}
						LogHelper.Verbose(Tag, "Adding allowed caller: ", info.Name,
							" package=", info.PackageName, " release=", info.Release,
							" certificate=", certificate);
						infos.Add(info);
					}
				}
			} catch (XmlException e) {
				LogHelper.Error(Tag, e, "Could not read allowed callers from XML.");
			} catch (IOException e) {
				LogHelper.Error(Tag, e, "Could not read allowed callers from XML.");
			}
			return validCertificates;
		}
Exemplo n.º 26
0
        public void ReadFromXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) { reader.Read(); return; }

            semesterStart = DateTime.Parse(reader.GetAttribute("semesterStart"));

            reader.Read();
            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name == "weekday")
                    {
                        var weekday = new ScheduleWeekday();
                        weekday.ReadFromXml(reader);
                        weekdays.Add(weekday);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                else
                {
                    reader.Read();
                    break;
                }
            }
        }
Exemplo n.º 27
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.MoveToAttribute("Disabled"))
            {
                Disabled = reader.Value == "1";
            }

            reader.ReadStartElement("RuleList");
            while (reader.IsStartElement())
            {
                IXmlSerializable r = null;
                switch (reader.Name)
                {
                case "RegExpRule":
                    r = new RegExpRule();
                    break;

                case "HostRule":
                    r = new HostRule();
                    break;

                case "PathRule":
                    r = new PathRule();
                    break;
                }
                if (r != null)
                {
                    r.ReadXml(reader.ReadSubtree());
                    this.Add((IRule)r);
                }
                reader.ReadEndElement();
            }
        }
Exemplo n.º 28
0
        public override void ReadXml(XmlReader reader)
        {
            if (CheckEmptyNode(reader, "HTTP", Namespace))
                return;

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                        case "Get":
                            Get = new Get();
                            Get.ReadXml(reader);
                            break;
                        case "Post":
                            _postField = new Post();
                            Post.ReadXml(reader);
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                else
                    reader.Read();
            }
        }
Exemplo n.º 29
0
        public override void ReadXml(XmlReader reader)
        {
            if (CheckEmptyNode(reader, "DataURL", Namespace))
                return;

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                        case "Format":
                            Format = reader.ReadElementContentAsString();
                            break;
                        case "OnlineResource":
                            OnlineResource = new OnlineResource();
                            OnlineResource.ReadXml(reader);
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                else
                {
                    reader.Read();
                }
            }
        }
        protected override SecurityToken ReadTokenCore(XmlReader reader, SecurityTokenResolver tokenResolver)
        {

            if (reader == null) throw new ArgumentNullException("reader");

            if (reader.IsStartElement(Constants.CreditCardTokenName, Constants.CreditCardTokenNamespace))
            {
                string id = reader.GetAttribute(Constants.Id, Constants.WsUtilityNamespace);

                reader.ReadStartElement();

                // read the credit card number
                string creditCardNumber = reader.ReadElementString(Constants.CreditCardNumberElementName, Constants.CreditCardTokenNamespace);

                // read the expiration date
                string expirationTimeString = reader.ReadElementString(Constants.CreditCardExpirationElementName, Constants.CreditCardTokenNamespace);
                DateTime expirationTime = XmlConvert.ToDateTime(expirationTimeString, XmlDateTimeSerializationMode.Utc);

                // read the issuer of the credit card
                string creditCardIssuer = reader.ReadElementString(Constants.CreditCardIssuerElementName, Constants.CreditCardTokenNamespace);
                reader.ReadEndElement();

                CreditCardInfo cardInfo = new CreditCardInfo(creditCardNumber, creditCardIssuer, expirationTime);

                return new CreditCardToken(cardInfo, id);
            }
            else
            {
                return WSSecurityTokenSerializer.DefaultInstance.ReadToken(reader, tokenResolver);
            }
        }
Exemplo n.º 31
0
        public void ReadXml(XmlReader reader)
        {
            bool isEmpty = reader.IsEmptyElement;

            AddAttributeExtensions(reader);

            reader.ReadStartElement();

            if (!isEmpty)
            {
                while (reader.IsStartElement())
                {
                    if (reader.LocalName == Backlink.ELEMENT_NAME)
                    {
                        if (BacklinkItems == null)
                        {
                            BacklinkItems = new List<Backlink>();
                        }
                        var backlink = new Backlink();
                        backlink.ReadXml(reader);

                        BacklinkItems.Add(backlink);
                    }
                    else
                    {
                        ElementExtensions.Add((XElement)XNode.ReadFrom(reader));
                    }
                }
            }
            reader.ReadEndElement();
        }
Exemplo n.º 32
0
        /// <summary>
        /// Decodes an <see cref="Error"/> object from its XML representation.
        /// </summary>
        public static Error Decode(XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException("reader");
            if (!reader.IsStartElement()) throw new ArgumentException("Reader is not positioned at the start of an element.", "reader");

            //
            // Read out the attributes that contain the simple
            // typed state.
            //

            var error = new Error();
            ReadXmlAttributes(reader, error);

            //
            // Move past the element. If it's not empty, then
            // read also the inner XML that contains complex
            // types like collections.
            //

            var isEmpty = reader.IsEmptyElement;
            reader.Read();

            if (!isEmpty)
            {
                ReadInnerXml(reader, error);
                reader.ReadEndElement();
            }

            return error;
        }
Exemplo n.º 33
0
        public Searchers(XmlReader reader)
        {
            this.Choices = new List<Choice>();
            this.CurrentSearch = "";

            reader.Read();
            if (reader.Name != "TheSearchers")
                return; // bail out

            reader.Read();
            while (!reader.EOF)
            {
                if ((reader.Name == "TheSearchers") && !reader.IsStartElement())
                    break; // all done

                if (reader.Name == "Current")
                    this.CurrentSearch = reader.ReadElementContentAsString();
                else if (reader.Name == "Choice")
                {
                    string url = reader.GetAttribute("URL");
                    if (url == null)
                        url = reader.GetAttribute("URL2");
                    else
                    {
                        // old-style URL, replace "!" with "{ShowName}+{Season}+{Episode}"
                        url = url.Replace("!", "{ShowName}+{Season}+{Episode}");
                    }
                    this.Add(reader.GetAttribute("Name"), url);
                    reader.ReadElementContentAsString();
                }
                else
                    reader.ReadOuterXml();
            }
        }
Exemplo n.º 34
0
        /// <summary>
        /// Reads the error data in XML attributes.
        /// </summary>

        private static void ReadXmlAttributes(XmlReader reader, Error error)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (!reader.IsStartElement())
            {
                throw new ArgumentException("Reader is not positioned at the start of an element.", "reader");
            }

            error.ApplicationName = reader.GetAttribute("application");
            error.HostName        = reader.GetAttribute("host");
            error.Type            = reader.GetAttribute("type");
            error.Message         = reader.GetAttribute("message");
            error.Source          = reader.GetAttribute("source");
            error.Detail          = reader.GetAttribute("detail");
            error.User            = reader.GetAttribute("user");
            string timeString = Mask.NullString(reader.GetAttribute("time"));

            error.Time = timeString.Length == 0 ? new DateTime() : XmlConvert.ToDateTime(timeString);
            string statusCodeString = Mask.NullString(reader.GetAttribute("statusCode"));

            error.StatusCode         = statusCodeString.Length == 0 ? 0 : XmlConvert.ToInt32(statusCodeString);
            error.WebHostHtmlMessage = reader.GetAttribute("webHostHtmlMessage");
        }
Exemplo n.º 35
0
        public void ReadFromXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) { reader.Read(); return; }

            num = int.Parse(reader.GetAttribute("number"));

            reader.Read();
            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name == "class")
                    {
                        var sClass = new ScheduleClass();
                        sClass.ReadFromXml(reader);
                        classes.Add(sClass);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                else
                {
                    reader.Read();
                    break;
                }
            }
        }
Exemplo n.º 36
0
        public bool Read(XmlReader reader)
        {
            if(reader.IsStartElement() && reader.Name == "Fixture") {
                Fixture fixture = new Fixture();

                //...Any attributes go here...
                fixture.AllowFrameSkip = bool.Parse(reader.GetAttribute("allowFrameSkip"));
                fixture.Name = reader.GetAttribute("name");
                // This needs to hold off until after channels are loaded.
                string fixtureDefinitionName = reader.GetAttribute("fixtureDefinitionName");

                if(reader.ElementsExistWithin("Fixture")) { // Entity element
                    // Channels
                    if(reader.ElementsExistWithin("Channels")) { // Container element for child entity
                        ChannelReader<OutputChannel> channelReader = new ChannelReader<OutputChannel>();
                        while(channelReader.Read(reader)) {
                            fixture.InsertChannel(channelReader.Channel);
                        }
                        reader.ReadEndElement(); // Channels
                    }

                    // With channels loaded, the fixture template reference can be set.
                    fixture.FixtureDefinitionName = fixtureDefinitionName;

                    reader.ReadEndElement(); // Fixture

                    this.Fixture = fixture;
                }
                return true;
            }
            return false;
        }
Exemplo n.º 37
0
 public string Task1()
 {
     reader = XmlReader.Create(FILE_NAME);
     decimal in_v = 0;
     decimal out_v = 0;
     while (reader.Read())
     {
         if (reader.IsStartElement())
         {
             switch (reader.Name)
             {
                 case IN_V:
                     if(reader.Read())
                         in_v += Convert.ToDecimal(reader.Value.Trim());
                     break;
                 case OUT_V:
                     if (reader.Read())
                         out_v += Convert.ToDecimal(reader.Value.Trim());
                     break;
             }
         }
     }
     reader.Close();
     return IN_V + in_v.ToString() + "\n" + OUT_V + out_v.ToString();
 }
Exemplo n.º 38
0
        protected override System.IdentityModel.Tokens.SecurityToken ReadTokenCore( XmlReader reader, SecurityTokenResolver tokenResolver )
        {
            if ( reader == null )
                throw new ArgumentNullException( "reader" );

            if ( reader.IsStartElement( Constants.UsernameTokenName, Constants.UsernameTokenNamespace ) )
            {
                //string id = reader.GetAttribute( Constants.IdAttributeName, Constants.WsUtilityNamespace );

                reader.ReadStartElement();

                // read the user name
                string userName = reader.ReadElementString( Constants.UsernameElementName, Constants.UsernameTokenNamespace );

                // read the password hash
                string password = reader.ReadElementString( Constants.PasswordElementName, Constants.UsernameTokenNamespace );

                // read nonce
                string nonce = reader.ReadElementString( Constants.NonceElementName, Constants.UsernameTokenNamespace );

                // read created
                string created = reader.ReadElementString( Constants.CreatedElementName, Constants.WsUtilityNamespace );

                reader.ReadEndElement();

                var info = new Info( userName, password );

                return new SecurityToken( info, nonce, created );
            }

            return DefaultInstance.ReadToken( reader, tokenResolver );
        }
Exemplo n.º 39
0
        /// <summary>
        /// Updates an existing <see cref="NameValueCollection" /> object from
        /// its XML representation.
        /// </summary>

        private static void UpcodeTo(XmlReader reader, NameValueCollection collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            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");
                        collection.Add(name, value);
                        reader.Read();
                    }

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

            reader.ReadEndElement();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DDEProtocolParameters"/> class.
 /// </summary>
 public override void ReadSettings(System.Xml.XmlReader pSettings)
 {
     if (!pSettings.IsStartElement(m_TagClass))
     {
         throw new XmlException
                   (string.Format("Expected element {0} not found at current position of the configuration file", m_TagClass));
     }
     pSettings.ReadStartElement(m_TagClass);
 }
Exemplo n.º 41
0
        public override bool CanRead(System.Xml.XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            return(reader.IsStartElement("RDF", this.RdfNamespaceUri));
        }
Exemplo n.º 42
0
 /// <summary>
 /// this function  reads settings from xml stream
 /// </summary>
 /// <param name="pSettings">XmlReader strea</param>
 public virtual void ReadSettings(System.Xml.XmlReader pSettings)
 {
     if (!pSettings.IsStartElement(m_TagClass))
     {
         throw new XmlException
                   (string.Format("Expected element {0} not found at current position of the configuration file", m_TagClass));
     }
     ppInterfameGap    = XmlHelper.ReadTimeFromMicroseconds(pSettings, m_Tag_InterfameGap);
     ppNumberOfRetries = (ushort)XmlHelper.ReadStandardIntegerValue(pSettings, m_Tag_NumberOfRetries);
     ppTimeoutResponse = XmlHelper.ReadTimeFromMicroseconds(pSettings, m_Tag_TimeoutResponse);
     pSettings.ReadStartElement(m_TagClass);
 } /// <summary>
Exemplo n.º 43
0
 void ICommunicationLayerId.SetSettings(System.Xml.XmlReader pSettings)
 {
     if (!pSettings.IsStartElement(m_Tag_Class))
     {
         throw new XmlException
                   (string.Format("Expected element {0} not found at current position of the configuration file", m_Tag_Class));
     }
     //m_LayerName = XmlHelper.ReadattributeString( pSettings, m_Tag_LayerName );
     pSettings.ReadStartElement(m_Tag_Class);
     base.SetSettings(pSettings);
     m_RSCommunicationLayerDescription.SetSettings(this.PortName, this.BaudRate);
 }
Exemplo n.º 44
0
 void ICommunicationLayerId.SetSettings(System.Xml.XmlReader pSettings)
 {
     if (!pSettings.IsStartElement(m_Tag_Class))
     {
         throw new XmlException
                   (string.Format("Expected element {0} not found at current position of the configuration file", m_Tag_Class));
     }
     m_ServerDDE = XmlHelper.ReadattributeString(pSettings, m_Tag_ServerDDE);
     m_DDECommunicationLayerDescription.SetSettings(m_ServerDDE);
     m_RequestTimeout = XmlHelper.ReadStandardIntegerValue(pSettings, m_Tag_RequestTimeout);
     m_PokeTimeout    = XmlHelper.ReadStandardIntegerValue(pSettings, m_Tag_PokeTimeout);
     pSettings.ReadStartElement(m_Tag_Class);
 }
Exemplo n.º 45
0
 /// <summary cref="SetSettings">
 /// Sets all the settings of the data provider used for operation. This string should be returned from <see cref="GetSettings"/>.
 /// </summary>
 /// <param name="pSettings">
 /// All the settings are needed to instantiate the data provider and underling <see>ICommunicationLayer</see></param>
 protected virtual void SetSettings(System.Xml.XmlReader pSettings)
 {
     if (!pSettings.IsStartElement(m_Tag_Class))
     {
         throw new XmlException
                   (string.Format("Expected element {0} not found at current position of the configuration file", m_Tag_Class));
     }
     m_BaudRate  = XmlHelper.ReadStandardIntegerValue(pSettings, m_Tag_BaudRate);
     m_COMNumber = (byte)XmlHelper.ReadStandardIntegerValue(pSettings, m_Tag_COMNumber);
     m_DataBits  = XmlHelper.ReadStandardIntegerValue(pSettings, m_Tag_DataBits);
     m_Parity    = (Parity)XmlHelper.ReadStandardIntegerValue(pSettings, m_Tag_Parity);
     m_StopBits  = (StopBits)XmlHelper.ReadStandardIntegerValue(pSettings, m_Tag_StopBits);
     pSettings.ReadStartElement(m_Tag_Class);
 }
Exemplo n.º 46
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.IsEmptyElement || !reader.Read())
     {
         return;
     }
     while (reader.NodeType != XmlNodeType.EndElement)
     {
         if (reader.IsStartElement("item"))
         {
             ReadProp(reader);
         }
         else if (reader.IsStartElement(__ChildRelation))
         {
             ReadSubProp(reader, p => mChildRelation = p.ToList());
         }
         else if (reader.IsStartElement(__ObjectRelation))
         {
             ReadSubProp(reader, p => mObjectRelation = p.ToList());
         }
     }
     reader.ReadEndElement();
 }
        public bool FromXml(ref System.Xml.XmlReader xr)
        {
            bool results = false;

            try
            {
                while (xr.Read())
                {
                    if (xr.IsStartElement())
                    {
                        if (!xr.IsEmptyElement)
                        {
                            switch (xr.Name)
                            {
                            case "Bvin":
                                xr.Read();
                                this.Bvin = xr.ReadString();
                                break;

                            case "TabTitle":
                                xr.Read();
                                this.TabTitle = xr.ReadString();
                                break;

                            case "HtmlData":
                                xr.Read();
                                this.HtmlData = xr.ReadString();
                                break;

                            case "SortOrder":
                                xr.Read();
                                this.SortOrder = int.Parse(xr.ReadString());
                                break;
                            }
                        }
                    }
                }

                results = true;
            }

            catch (XmlException XmlEx)
            {
                EventLog.LogEvent(XmlEx);
                results = false;
            }

            return(results);
        }
Exemplo n.º 48
0
        /// <summary>
        /// Decodes an <see cref="Error"/> object from its XML representation.
        /// </summary>

        public static Error Decode(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            //
            // Reader must be positioned on an element!
            //

            if (!reader.IsStartElement())
            {
                throw new ArgumentException("Reader is not positioned at the start of an element.", "reader");
            }

            //
            // Read out the attributes that contain the simple
            // typed state.
            //

            Error error = new Error();

            ReadXmlAttributes(reader, error);

            //
            // Move past the element. If it's not empty, then
            // read also the inner XML that contains complex
            // types like collections.
            //

            bool isEmpty = reader.IsEmptyElement;

            reader.Read();

            if (!isEmpty)
            {
                ReadInnerXml(reader, error);
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    reader.Skip();
                }
                reader.ReadEndElement();
            }

            return(error);
        }
Exemplo n.º 49
0
        /// <summary>
        /// Reads the error data in child nodes.
        /// </summary>

        private static void ReadInnerXml(XmlReader reader, Error error)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            //
            // Loop through the elements, reading those that we
            // recognize. If an unknown element is found then
            // this method bails out immediately without
            // consuming it, assuming that it belongs to a subclass.
            //

            while (reader.IsStartElement())
            {
                //
                // Optimization Note: This block could be re-wired slightly
                // to be more efficient by not causing a collection to be
                // created if the element is going to be empty.
                //

                NameValueCollection collection;

                switch (reader.Name)
                {
                case "serverVariables": collection = error.ServerVariables; break;

                case "queryString": collection = error.QueryString; break;

                case "form": collection = error.Form; break;

                case "cookies": collection = error.Cookies; break;

                default: reader.Skip(); continue;
                }

                if (reader.IsEmptyElement)
                {
                    reader.Read();
                }
                else
                {
                    UpcodeTo(reader, collection);
                }
            }
        }
Exemplo n.º 50
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            bool isEmpty = reader.IsEmptyElement;

            if (reader.HasAttributes)
            {
                for (int i = 0; i < reader.AttributeCount; i++)
                {
                    reader.MoveToNextAttribute();

                    if (reader.NamespaceURI == "")
                    {
                        if (reader.LocalName == "ref")
                        {
                            this.Ref = reader.Value;
                        }
                        else if (reader.LocalName == "href")
                        {
                            this.Href = new Uri(reader.Value);
                        }
                        else if (reader.LocalName == "source")
                        {
                            this.Source = new Uri(reader.Value);
                        }
                        else if (reader.LocalName == "type")
                        {
                            this.MediaType = reader.Value;
                        }
                        else
                        {
                            this.AttributeExtensions.Add(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI), reader.Value);
                        }
                    }
                }
            }

            reader.ReadStartElement();

            if (!isEmpty)
            {
                while (reader.IsStartElement())
                {
                    ElementExtensions.Add((XElement)XElement.ReadFrom(reader));
                }
                reader.ReadEndElement();
            }
        }
Exemplo n.º 51
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     XmlUtilities.GetTypePropertyDic(GetType(), ref _propertyTypeDic, ref _propertyInfoDic);
     // reader stays on record
     reader.ReadToFollowing("param-list");
     try
     {
         reader.Read();
         while (reader.IsStartElement())
         {
             ReadProperty(reader);
         } // while
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public bool Detect(Stream stream)
        {
            try
            {
                System.Xml.XmlReader reader = XmlReader.Create(stream, new XmlReaderSettings()
                {
                });
                if (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        if (reader.Name == "configuration")
                        {
                            return(true);
                        }
                    }
                }
            }
            catch { }

            return(false);
        }
Exemplo n.º 53
0
        private IEnumerable <GraphQueryObject> ConvertSolrXml(string solrXml, IDictionary <string, string> categories)
        {
            MemoryStream memStream = new MemoryStream();

            byte[] data = Encoding.Default.GetBytes(solrXml);
            memStream.Write(data, 0, data.Length);
            memStream.Position = 0;

            using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(memStream))
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement() && reader.Name == "lst" && reader.GetAttribute("name") == "facets")
                    {
                        foreach (GraphQueryObject facet in ReadFacet(reader, categories))
                        {
                            // We add another yield here since we are inside a 'using' method. We do not want out reader to close before we are done itterating over the data.
                            yield return(facet);
                        }
                    }
                }
            }
        }
Exemplo n.º 54
0
        /// <summary>
        /// Deserialize from XML
        /// </summary>
        /// <param name="reader">   XML reader</param>
        void IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            ChessBoard.MovePosS movePos;
            bool bIsEmpty;

            m_listMovePos.Clear();
            if (reader.MoveToContent() != XmlNodeType.Element || reader.LocalName != "MoveList")
            {
                throw new SerializationException("Unknown format");
            }
            else
            {
                bIsEmpty     = reader.IsEmptyElement;
                m_iPosInList = Int32.Parse(reader.GetAttribute("PositionInList"));
                if (bIsEmpty)
                {
                    reader.Read();
                }
                else
                {
                    if (reader.ReadToDescendant("Move"))
                    {
                        while (reader.IsStartElement())
                        {
                            movePos = new ChessBoard.MovePosS();
                            movePos.OriginalPiece = (ChessBoard.PieceE)Enum.Parse(typeof(ChessBoard.SerPieceE), reader.GetAttribute("OriginalPiece"));
                            movePos.StartPos      = (byte)Int32.Parse(reader.GetAttribute("StartingPosition"));
                            movePos.EndPos        = (byte)Int32.Parse(reader.GetAttribute("EndingPosition"));
                            movePos.Type          = (ChessBoard.MoveTypeE)Enum.Parse(typeof(ChessBoard.MoveTypeE), reader.GetAttribute("MoveType"));
                            m_listMovePos.Add(movePos);
                            reader.ReadStartElement("Move");
                        }
                    }
                    reader.ReadEndElement();
                }
            }
        }
Exemplo n.º 55
0
        protected override object AnalysisData(System.Xml.XmlReader reader)
        {
            PlayInfos = new Dictionary <int, PlayInfo>(6);
            var ci = new CultureInfo("en-US");

            while (reader.Read())
            {
                if (reader.Name == "channel" &&
                    reader.NodeType == XmlNodeType.Element)
                {
                    var totalDuraiton = double.Parse(reader["dur"]);

                    while (reader.Read())
                    {
                        if (reader.Name == "file" &&
                            reader.NodeType == XmlNodeType.Element)
                        {
                            reader.Read();
                            while (reader.IsStartElement("item"))
                            {
                                var info    = new PlayInfo();
                                var bitrate = reader["bitrate"];
                                var ft      = reader["ft"];
                                if (bitrate == null || ft == null)
                                {
                                    continue;
                                }
                                info.Bitrate       = Convert.ToInt32(bitrate);
                                info.ft            = Convert.ToInt32(ft);
                                info.Rid           = reader["rid"];
                                info.TotalDuration = totalDuraiton;
                                PlayInfos.Add(info.ft, info);
                                reader.ReadToNextSibling("item");
                            }
                        }
                        if (reader.NodeType == XmlNodeType.EndElement &&
                            reader.Name == "file")
                        {
                            break;
                        }
                    }
                }

                if (reader.Name == "dt" &&
                    reader.NodeType == XmlNodeType.Element)
                {
                    var ft = Convert.ToInt32(reader["ft"]);
                    reader.Read();
                    if (!PlayInfos.ContainsKey(ft))
                    {
                        continue;
                    }

                    var info = PlayInfos[ft];
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element &&
                            !reader.IsEmptyElement)
                        {
                            var nodeName = reader.Name;
                            if (nodeName != "key")
                            {
                                reader.Read();
                            }
                            switch (nodeName)
                            {
                            case "sh":
                                info.Sh = reader.Value;
                                break;

                            case "st":
                                info.St = DateTime.ParseExact(reader.Value, "ddd MMM dd HH:mm:ss yyyy UTC", ci);
                                break;

                            case "bwt":
                                info.Bwt = Convert.ToInt32(reader.Value);
                                break;

                            case "key":
                                info.Expire = DateTime.ParseExact(reader["expire"], "ddd MMM dd HH:mm:ss yyyy UTC", ci);
                                reader.Read();
                                info.Key = reader.Value;
                                break;

                            default:
                                break;
                            }
                        }
                        if (reader.NodeType == XmlNodeType.EndElement &&
                            reader.Name == "dt")
                        {
                            break;
                        }
                    }
                }
            }

            return(1);
        }
Exemplo n.º 56
0
 public override bool CanDeserialize(System.Xml.XmlReader xmlReader)
 {
     return(xmlReader.IsStartElement("discovery", "http://schemas.xmlsoap.org/disco/"));
 }
Exemplo n.º 57
0
 private bool IsJsonWebSecurityToken(System.Xml.XmlReader reader)
 {
     return(reader.IsStartElement("BinarySecurityToken", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd") && reader.GetAttribute("ValueType", null) == "http://oauth.net/grant_type/jwt/1.0/bearer");
 }
Exemplo n.º 58
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            try
            {
                string objectType = reader.GetAttribute("type");
                if (objectType != null && objectType.Trim().Length > 0)
                {
                    if (objectType == "MixedCollection")
                    {
                        int index = 0;
                        reader.Read();
                        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                        {
                            if (reader.IsStartElement("Item"))
                            {
                                objectType = reader.GetAttribute("type");
                                Type type = ChoType.GetType(objectType);
                                if (type == null)
                                {
                                    throw new ApplicationException(String.Format("Can't find {0} class.", objectType));
                                }

                                reader.ReadStartElement("Item");

                                try
                                {
                                    index++;
                                    XmlSerializer xmlSerializer = new XmlSerializer(type);
                                    Add(xmlSerializer.Deserialize(reader));
                                }
                                catch (Exception ex)
                                {
                                    throw new XmlException(String.Format("Failed to deserialize {0} array item.", index), ex);
                                }

                                reader.ReadEndElement();
                            }
                        }
                        reader.ReadEndElement();
                    }
                    else
                    {
                        Type type = ChoType.GetType(objectType);

                        if (type == null)
                        {
                            throw new ApplicationException(String.Format("Can't find {0} class.", objectType));
                        }

                        reader.Read();
                        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                        {
                            //if (reader.IsStartElement(type.Name))
                            //{
                            XmlSerializer xmlSerializer = new XmlSerializer(ChoType.GetType(objectType));
                            Add(xmlSerializer.Deserialize(reader));
                            //}
                        }
                        reader.ReadEndElement();
                    }
                }
                else
                {
                    reader.Skip();
                }
            }
            catch (Exception)
            {
                //ChoStreamProfile.WriteLine(ChoReservedFileName.SerializationIssues.ToString(), ChoApplicationException.ToString(ex));
                throw;
            }
        }
Exemplo n.º 59
0
        public bool FromXml(ref System.Xml.XmlReader xr)
        {
            bool results = false;

            try
            {
                while (xr.Read())
                {
                    if (xr.IsStartElement())
                    {
                        if (!xr.IsEmptyElement)
                        {
                            switch (xr.Name)
                            {
                            case "Bvin":
                                xr.Read();
                                Bvin = xr.ReadString();
                                break;

                            case "ControlName":
                                xr.Read();
                                ControlName = xr.ReadString();
                                break;

                            case "SortOrder":
                                xr.Read();
                                SortOrder = int.Parse(xr.ReadString());
                                break;

                            case "ColumnId":
                                xr.Read();
                                ColumnId = xr.ReadString();
                                break;

                            case "SerializedSettings":
                                xr.Read();
                                string json = xr.ReadString();
                                this.BaseSettings = MerchantTribe.Web.Json.ObjectFromJson <ContentBlockSettings>(json);
                                break;

                            case "Lists":
                                xr.Read();
                                string jsonlist = xr.ReadString();
                                this.Lists = MerchantTribe.Web.Json.ObjectFromJson <ContentBlockSettingList>(jsonlist);
                                break;
                            }
                        }
                    }
                }

                results = true;
            }

            catch (XmlException XmlEx)
            {
                EventLog.LogEvent(XmlEx);
                results = false;
            }

            return(results);
        }
Exemplo n.º 60
0
        private IEnumerable <GroupByObject> ReadFacet2(System.Xml.XmlReader reader /*, IDictionary<string, string> categories*/)
        {
            int     level    = 1;
            decimal yVal     = 0;
            int     count    = 0;
            string  category = string.Empty;

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name == "lst")
                    {
                        ++level;
                    }
                    else if ((reader.Name == "int" || reader.Name == "long" || reader.Name == "double") && level == 3)
                    {
                        string name = reader.GetAttribute("name");
                        reader.Read();
                        string value = reader.ReadContentAsString();

                        if (name == "count")
                        {
                            count = int.Parse(value);
                        }
                        else if (name == "sumYValues")
                        {
                            try
                            {
                                yVal = Convert.ToDecimal(double.Parse(value));
                            }
                            catch (Exception fex)
                            {
                                throw new FormatException(string.Format("Unable to parse string \"{0}\" into decimal.", value), fex);
                            }
                        }
                    }
                    else if (level == 5 && category != null)
                    {
                        string name = reader.GetAttribute("name");
                        reader.Read();
                        string value = reader.ReadContentAsString();

                        if (!string.IsNullOrWhiteSpace(value))
                        {
                            if (name == "val")
                            {
                                category = value;
                            }
                            else if (name == "count")
                            {
                                count = int.Parse(value);
                            }
                            else if (name == "sumYValuesArg")
                            {
                                yVal = Convert.ToDecimal(double.Parse(value));
                            }
                        }
                    }
                }
                else if (reader.NodeType == System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.Name == "lst")
                    {
                        --level;

                        if (level < 1)
                        {
                            break;
                        }

                        else if (level == 4)// && category != null)
                        {
                            yield return(new GroupByObject()
                            {
                                Total = yVal,
                                GroupByName = category,//categories.ContainsKey(category) ? categories[category] : category,
                                Count = count
                            });

                            yVal     = 0.0m;
                            category = string.Empty;
                            count    = 0;
                        }
                    }
                }
            }
        }