当前位置: 首页>>代码示例>>C#>>正文


C# XmlReader.GoToElement方法代码示例

本文整理汇总了C#中System.Xml.XmlReader.GoToElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.GoToElement方法的具体用法?C# XmlReader.GoToElement怎么用?C# XmlReader.GoToElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlReader的用法示例。


在下文中一共展示了XmlReader.GoToElement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

        public static MonitoringConfig Load(XmlReader reader)
        {
            MonitoringConfig result = new MonitoringConfig();

            reader.GoToElement();
            reader.ReadStartElement();
            if (!reader.IsEmptyElement)
            {
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "Diagnostics":
                            result.DiagnosticsConfig = DiagnosticsConfig.Load(reader);
                            break;
                        case "Logging":
                            result.LoggingConfig = LoggingConfig.Load(reader);
                            break;
                        case "AdditionalData":
                            string kvps = reader.ReadElementContentAsString();
                            foreach (var item in kvps.Split(','))
                            {
                                var kvp = item.Split('=');
                                result.AdditionalData.Add(kvp[0], kvp[1]);
                            }
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
            }

            return result;
        }
开发者ID:rhlbenjamin,项目名称:azure-media-services-samples,代码行数:35,代码来源:MonitoringConfig.cs

示例2: Load

        /// <summary>
        /// Loads a new instance of the EdgeServerRules class from Xml.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static EdgeServerRules Load(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            var result = new EdgeServerRules();

            reader.GoToElement();
            if (!reader.IsEmptyElement)
            {
                result.Domain = reader.GetAttribute("Domain");
                reader.ReadStartElement();
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "EdgeResolverUrlPattern":
                            result.EdgeResolverUrlPattern = reader.ReadElementContentAsString();
                            break;
                        case "EdgeRegEx":
                            result.EdgeRegex = reader.ReadElementContentAsString();
                            break;
                        case "ClientIpRegEx":
                            result.ClientIPRegex = reader.ReadElementContentAsString();
                            break;
                        case "ClientIpHeader":
                            result.ClientIPHeader = reader.ReadElementContentAsString();
                            break;
                        case "EdgeResolverHeaders":
                            result.EdgeResolverHeaders = reader.ReadElementContentAsString().Split(',');
                            break;
                        case "EdgeHeader":
                            result.EdgeHeader = reader.ReadElementContentAsString();
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            else
                reader.Skip();

            return result;
        }
开发者ID:rhlbenjamin,项目名称:azure-media-services-samples,代码行数:51,代码来源:EdgeServerRules.cs

示例3: Load

        /// <summary>
        /// Loads the configuration from Xml.
        /// </summary>
        /// <param name="reader">An XmlReader containing your configuration data.</param>
        /// <returns>A new instance of a LoggingConfig object.</returns>
        public static LoggingConfig Load(XmlReader reader)
        {
            var result = new LoggingConfig();

            reader.GoToElement();

            if (!reader.IsEmptyElement)
            {
                result.MaxExceptionLength = null;   // assume no limit is intended if param is omitted

                reader.ReadStartElement();
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "LogUnhandledExceptions":
                            result.LogUnhandledExceptions = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "PreventUnhandledExceptions":
                            result.PreventUnhandledExceptions = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "MaxExceptionLength":
                            result.MaxExceptionLength = reader.ReadElementContentAsInt();
                            break;
                        case "QueryStringParam":
                            result.QueryStringParam = reader.ReadElementContentAsString();
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            else
                reader.Skip();

            return result;
        }
开发者ID:Ginichen,项目名称:Silverlight-Player-for-PlayReady-with-Token-Auth,代码行数:44,代码来源:LoggingConfig.cs

示例4: Load

        /// <summary>
        /// Creates an instance of the TracingConfig from an Xml file.
        /// </summary>
        public static TracingConfig Load(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            var result = new TracingConfig();

            reader.GoToElement();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "TracingConfigFile":
                            result.TracingConfigFile = reader.ReadElementContentAsString();
                            break;
                        case "PollingMilliseconds":
                            result.PollingInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                            break;
                        case "RecordCpuLoad":
                            result.RecordCpuLoad = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            else
                reader.Skip();

            return result;
        }
开发者ID:rhlbenjamin,项目名称:azure-media-services-samples,代码行数:39,代码来源:TracingConfig.cs

示例5: Load

        public static IBatchAgent Load(XmlReader reader)
        {
            IBatchAgent result = null;

            reader.GoToElement();

            if (!reader.IsEmptyElement)
            {
                string url = null;
                SerializationFormat serializationFormat = SerializationFormat.Unknown;
                bool isRelative = false;
                bool isWCF = true;
                bool binaryBinding = false;
                bool compress = false;
                int maxOpenTimeSeconds = 5;
                int maxSendTimeSeconds = 5;
                int maxRecvTimeSeconds = 5;
                int serviceVersion = 3;

                reader.ReadStartElement();
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "Url":
                            url = reader.ReadElementContentAsString();
                            break;
                        case "WCF":
                            isWCF = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "relative":
                            isRelative = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "binaryBinding":
                            binaryBinding = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "maxOpenTimeSeconds":
                            maxOpenTimeSeconds = reader.ReadElementContentAsInt();
                            break;
                        case "maxSendTimeSeconds":
                            maxSendTimeSeconds = reader.ReadElementContentAsInt();
                            break;
                        case "maxRecvTimeSeconds":
                            maxRecvTimeSeconds = reader.ReadElementContentAsInt();
                            break;
                        case "version":
                            serviceVersion = reader.ReadElementContentAsInt();
                            break;
                        case "compression":
                            compress = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "serializationFormat":

                            var value = reader.ReadElementContentAsString();

                            if (value.Equals("xml", StringComparison.OrdinalIgnoreCase))
                                serializationFormat = SerializationFormat.Xml;
                            else if (value.Equals("json", StringComparison.OrdinalIgnoreCase))
                                serializationFormat = SerializationFormat.Json;
                            else if (value.Equals("httpquerystring", StringComparison.OrdinalIgnoreCase))
                                serializationFormat = SerializationFormat.HttpQueryString;

                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                reader.ReadEndElement();

                // actually create the Uri
                Uri serviceUri = null;
                if (url != null)
                {
                    if (isRelative)
#if SILVERLIGHT && !WINDOWS_PHONE
                        serviceUri = new Uri(System.Windows.Application.Current.Host.Source, url);
#else
                        throw new NotImplementedException();
#endif
                    else
                        serviceUri = new Uri(url);
                }

                if (isWCF)
                {
                    throw new NotImplementedException();
                    //TODO: result = new WCFDataClient(serviceUri, binaryBinding, maxOpenTimeSeconds, maxSendTimeSeconds, maxRecvTimeSeconds, serviceVersion);
                }
                else
                {
                    result = new RESTDataClient(serviceUri, maxSendTimeSeconds + maxRecvTimeSeconds, compress, serializationFormat, serviceVersion);
                }
            }
开发者ID:bondarenkod,项目名称:pf-arm-deploy-error,代码行数:94,代码来源:BatchAgentFactory.cs

示例6: Deserialize

        /// <summary>
        ///  Helper method to deserialize a batch serailized via the default serialization
        /// </summary>
        /// <returns>The deserialized batch</returns>
        public static Batch Deserialize(XmlReader xmlReader)
        {
            if (xmlReader.GoToElement())
            {
                Batch result = new Batch();
                LogBase.DeserializeData(xmlReader, result);

                xmlReader.ReadStartElement();

                List<Log> logs = new List<Log>();
                while (xmlReader.GoToSibling())
                {
                    switch (xmlReader.LocalName)
                    {
                        case Log.LogNodeName:
                            var log = Log.Deserialize(xmlReader);
                            logs.Add(log);
                            break;

                        default:
                            xmlReader.Skip();
                            break;
                    }
                }
                result.Logs = logs;
                xmlReader.ReadEndElement();
                return result;
            }
            else
                throw new Exception("Batch is empty");
        }
开发者ID:rhlbenjamin,项目名称:azure-media-services-samples,代码行数:35,代码来源:Batch.cs

示例7: Load

        public static QualityConfig Load(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            QualityConfig result = new QualityConfig();

            reader.GoToElement();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "DroppedFrames":
                            result.DroppedFrames = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "RenderedFrames":
                            result.RenderedFrames = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "ProcessCPULoad":
                            result.ProcessCpuLoad = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "SystemCPULoad":
                            result.SystemCpuLoad = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "Bitrate":
                            result.Bitrate = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "BitrateMax":
                            result.BitrateMax = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "BitrateMaxDuration":
                            result.BitrateMaxDuration = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "PerceivedBandwidth":
                            result.PerceivedBandwidth = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "VideoBufferSize":
                            result.VideoBufferSize = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "AudioBufferSize":
                            result.AudioBufferSize = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "Buffering":
                            result.Buffering = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "BitrateChangeCount":
                            result.BitrateChangeCount = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "VideoDownloadLatency":
                            result.VideoDownloadLatency = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "AudioDownloadLatency":
                            result.AudioDownloadLatency = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "DvrOperationCount":
                            result.DvrOperationCount = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "FullScreenChangeCount":
                            result.FullScreenChangeCount = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "HttpErrorCount":
                            result.HttpErrorCount = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;

                        default:
                            reader.Skip();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            else
                reader.Skip();

            return result;
        }
开发者ID:Ginichen,项目名称:Silverlight-Player-for-PlayReady-with-Token-Auth,代码行数:79,代码来源:QualityConfig.cs

示例8: Load

        /// <summary>
        /// Creates an instance of the main diagnostic config object from an XmlReader
        /// </summary>
        public static DiagnosticsConfig Load(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            var result = new DiagnosticsConfig();
            List<EdgeServerRules> edgeServerRuleCollection = null;

            reader.GoToElement();
            reader.ReadStartElement();
            if (!reader.IsEmptyElement)
            {
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "TraceMonitor":
                            result.TracingConfig = TracingConfig.Load(reader);
                            break;

                        case "EdgeServerRules":
                            if (!reader.IsEmptyElement)
                            {
                                if (edgeServerRuleCollection == null)
                                {
                                    edgeServerRuleCollection = new List<EdgeServerRules>();
                                    result.EdgeServerRuleCollection = edgeServerRuleCollection;
                                }
                                edgeServerRuleCollection.Add(EdgeServerRules.Load(reader));
                            }
                            else
                                reader.Skip();
                            break;

                        case "Diagnostics":
                            if (!reader.IsEmptyElement)
                            {
                                reader.ReadStartElement();
                                while (reader.GoToSibling())
                                {
                                    switch (reader.LocalName)
                                    {
                                        case "TrackQuality":
                                            result.TrackQuality = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                            break;
                                        case "TrackDownloadErrors":
                                            result.TrackDownloadErrors = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                            break;
                                        case "AggregationIntervalMilliseconds":
                                            result.AggregationInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                                            break;
                                        case "TrackQualitySnapshot":
                                            result.TrackQualitySnapshot = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                            break;
                                        case "SnapshotIntervalMilliseconds":
                                            result.SnapshotInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                                            break;
                                        case "LatencyAlertThreshold":
                                            result.LatencyAlertThreshold = reader.ReadElementContentAsFloat();
                                            break;
                                        case "RecordTraceLogs":
                                            result.RecordTraceLogs = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                            break;
                                        case "QualityTracking":
                                            result.QualityConfig = QualityConfig.Load(reader);
                                            break;
                                        default:
                                            reader.Skip();
                                            break;
                                    }
                                }
                                reader.ReadEndElement();
                            }
                            else
                                reader.Skip();
                            break;

                        default:
                            reader.Skip();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            else
                reader.Skip();

            return result;
        }
开发者ID:Ginichen,项目名称:Silverlight-Player-for-PlayReady-with-Token-Auth,代码行数:92,代码来源:DiagnosticsConfig.cs

示例9: Load

        public static BatchingConfig Load(XmlReader reader)
        {
            BatchingConfig result = new BatchingConfig();

            reader.GoToElement();
            reader.ReadStartElement();
            if (!reader.IsEmptyElement)
            {
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "Application":
                            if (!reader.IsEmptyElement)
                            {
                                reader.ReadStartElement();
                                while (reader.GoToSibling())
                                {
                                    switch (reader.LocalName)
                                    {
                                        case "Id":
                                            result.ApplicationId = new Guid(reader.ReadElementContentAsString());
                                            break;
                                        case "Name":
                                            result.ApplicationName = reader.ReadElementContentAsString();
                                            break;
                                        case "Version":
                                            result.ApplicationVersion = reader.ReadElementContentAsString();
                                            break;
                                        case "Enabled":
                                            result.LoggingEnabled = reader.ReadElementContentAsBoolean();
                                            break;
                                        default:
                                            reader.Skip();
                                            break;
                                    }
                                }
                                reader.ReadEndElement();
                            }
                            else
                                reader.Skip();
                            break;
                            
                        case "Queue":
                            if (!reader.IsEmptyElement)
                            {
                                reader.ReadStartElement();
                                while (reader.GoToSibling())
                                {
                                    switch (reader.LocalName)
                                    {
                                        case "maxLength":
                                            result.MaxQueueLength = reader.ReadElementContentAsInt();
                                            break;
                                        case "maxBatchLength":
                                            result.MaxBatchLength = reader.ReadElementContentAsInt();
                                            break;
                                        case "maxSendErrors":
                                            result.MaxSendErrors = reader.ReadElementContentAsInt();
                                            break;
                                        case "maxSendErrorsThrottled":
                                            result.MaxSendErrorsThrottled = reader.ReadElementContentAsInt();
                                            break;
                                        case "pollingIntervalSeconds":
                                            result.QueuePollingInterval = TimeSpan.FromSeconds(reader.ReadElementContentAsInt());
                                            break;
                                        case "pollingIntervalThrottledSeconds":
                                            result.QueuePollingIntervalThrottled = TimeSpan.FromSeconds(reader.ReadElementContentAsInt());
                                            break;
                                        case "maxRetries":
                                            result.MaxRetries = reader.ReadElementContentAsInt();
                                            break;
                                        default:
                                            reader.Skip();
                                            break;
                                    }
                                }
                                reader.ReadEndElement();
                            }
                            else
                                reader.Skip();
                            break;

                        case "Session":
                            if (!reader.IsEmptyElement)
                            {
                                reader.ReadStartElement();
                                while (reader.GoToSibling())
                                {
                                    switch (reader.LocalName)
                                    {
                                        case "maxSessionLogs":
                                            result.MaxSessionLogs = reader.ReadElementContentAsInt();
                                            break;
                                        default:
                                            reader.Skip();
                                            break;
                                    }
                                }
                                reader.ReadEndElement();
//.........这里部分代码省略.........
开发者ID:Ginichen,项目名称:Silverlight-Player-for-PlayReady-with-Token-Auth,代码行数:101,代码来源:BatchingConfig.cs


注:本文中的System.Xml.XmlReader.GoToElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。