Ejemplo n.º 1
0
        /// <summary>
        /// Loads a new instance of the EdgeServerRules class from Xml.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        internal 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);
        }
Ejemplo n.º 2
0
        internal static EdgeServerConfig Load(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            var result = new EdgeServerConfig();

            reader.GoToElement();
            reader.ReadStartElement();
            if (!reader.IsEmptyElement)
            {
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                    case "EdgeServerRules":
                        if (!reader.IsEmptyElement)
                        {
                            result.EdgeServerRulesCollection.Add(EdgeServerRules.Load(reader));
                        }
                        else
                        {
                            reader.Skip();
                        }
                        break;

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

            return(result);
        }
        /// <summary>
        /// Loads a new instance of the EdgeServerRules class from Xml.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        internal 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;
        }