<commit_before>﻿/*
 * Authors:
 *   钟峰(<NAME>) <<EMAIL>>
 *
 * Copyright (C) 2014-2016 Zongsoft Corporation <http://www.zongsoft.com>
 *
 * This file is part of Zongsoft.Externals.Redis.
 *
 * Zongsoft.Externals.Redis is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Zongsoft.Externals.Redis is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Zongsoft.Externals.Redis; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

using System;
using System.Collections.Generic;

using Zongsoft.Options;
using Zongsoft.Options.Configuration;

namespace Zongsoft.Externals.Redis.Configuration
{
	public class RedisConfiguration : OptionConfigurationElement, IRedisConfiguration
	{
		#region 常量定义
		private const string XML_CONNECTIONPATH_ATTRIBUTE = "connectionPath";
		#endregion

		#region 公共属性
		[OptionConfigurationProperty(XML_CONNECTIONPATH_ATTRIBUTE, Behavior = OptionConfigurationPropertyBehavior.IsRequired)]
		public string ConnectionPath
		{
			get
			{
				return (string)this[XML_CONNECTIONPATH_ATTRIBUTE];
			}
			set
			{
				if(string.IsNullOrWhiteSpace(value))
					throw new ArgumentNullException();

				this[XML_CONNECTIONPATH_ATTRIBUTE] = value;
			}
		}

		public string ConnectionString
		{
			get
			{
				if(string.IsNullOrWhiteSpace(this.ConnectionPath))
					return null;

				var connectionString = Zongsoft.ComponentModel.ApplicationContextBase.Current.OptionManager.GetOptionValue(this.ConnectionPath) as ConnectionStringElement;

				if(connectionString == null)
					throw new OptionConfigurationException($"Not found connection string by '{this.ConnectionPath}' configuration path.");

				return connectionString.Value;
			}
		}
		#endregion
	}
}<commit_msg>refactor: 因为核心库中的应用上下文类的变更，而调整到最新的版本。 :violin:<commit_after>﻿/*
 * Authors:
 *   钟峰(<NAME>) <<EMAIL>>
 *
 * Copyright (C) 2014-2016 Zongsoft Corporation <http://www.zongsoft.com>
 *
 * This file is part of Zongsoft.Externals.Redis.
 *
 * Zongsoft.Externals.Redis is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Zongsoft.Externals.Redis is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Zongsoft.Externals.Redis; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

using System;
using System.Collections.Generic;

using Zongsoft.Options;
using Zongsoft.Options.Configuration;

namespace Zongsoft.Externals.Redis.Configuration
{
	public class RedisConfiguration : OptionConfigurationElement, IRedisConfiguration
	{
		#region 常量定义
		private const string XML_CONNECTIONPATH_ATTRIBUTE = "connectionPath";
		#endregion

		#region 公共属性
		[OptionConfigurationProperty(XML_CONNECTIONPATH_ATTRIBUTE, Behavior = OptionConfigurationPropertyBehavior.IsRequired)]
		public string ConnectionPath
		{
			get
			{
				return (string)this[XML_CONNECTIONPATH_ATTRIBUTE];
			}
			set
			{
				if(string.IsNullOrWhiteSpace(value))
					throw new ArgumentNullException();

				this[XML_CONNECTIONPATH_ATTRIBUTE] = value;
			}
		}

		public string ConnectionString
		{
			get
			{
				if(string.IsNullOrWhiteSpace(this.ConnectionPath))
					return null;

				var connectionString = Zongsoft.Services.ApplicationContext.Current.Options.GetOptionValue(this.ConnectionPath) as ConnectionStringElement;

				if(connectionString == null)
					throw new OptionConfigurationException($"Not found connection string by '{this.ConnectionPath}' configuration path.");

				return connectionString.Value;
			}
		}
		#endregion
	}
}
{'fraction_non_alphanumeric': 0.0752053928797135, 'fraction_numerical': 0.008847693279966295, 'mean_word_length': 4.413911060433295, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6705769', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1341, 'n_words': 436}