Exemple #1
0
        /// <summary>
        /// Create a configuration object from a configuration file
        /// </summary>
        /// <param name="parent">Parent object</param>
        /// <param name="configContext">Profile context</param>
        /// <param name="section">Configuration node</param>
        /// <returns>configuration object</returns>
        public object Create(object parent, object configContext, XmlNode section)
        {
            var options = new FastDfsSChemeOptions();

            FormatFromConfig(options, section);

            var AuthSection = section.SelectSingleNode(DefaultAuthoriteNode);

            if (AuthSection != null)
            {
                if (!Enum.TryParse(AuthSection.Attributes["Type"]?.Value, out AuthoritionType type))
                {
                    throw new Exception(UnKnownAuthoriteType);
                }
                options.AuthoritionComponent = AuthoritionComponentFactory.CreateAuthoritionComponent(type, AuthSection);
            }

            return(options);
        }
Exemple #2
0
        /// <summary>
        /// Create a configuration object from a configuration file
        /// </summary>
        /// <param name="section">Configuration node</param>
        /// <returns>configuration object</returns>
        internal static FastDfsSChemeOptions Create(IConfigurationSection section)
        {
            var options = new FastDfsSChemeOptions();

            FormatFromConfig(options, section);

            var AuthSection = section.GetSection(DefaultAuthoriteNode);

            if (AuthSection != null)
            {
                if (!Enum.TryParse(AuthSection.GetSection("Type")?.Value, out AuthoritionType type))
                {
                    throw new Exception(UnKnownAuthoriteType);
                }
                options.AuthoritionComponent = AuthoritionComponentFactory.CreateAuthoritionComponent(type, AuthSection);
            }

            return(options);
        }