dbresource.cs

来自「NHibernate NET开发者所需的」· CS 代码 · 共 84 行

CS
84
字号
using System.Collections.Generic;

namespace NHibernate.Test.NHSpecificTest.NH1408
{
	public abstract class DbResource : Entity
	{
		private readonly IList<DbResourceKey> keys = new List<DbResourceKey>();
		private string rawValue;

		protected virtual string RawValue
		{
			get { return rawValue; }
			set { rawValue = value; }
		}

		public virtual IEnumerable<DbResourceKey> Keys
		{
			get { return keys; }
		}

		public abstract object Value { get; set; }

		public virtual void AddKey(DbResourceKey key)
		{
			if (keys.Contains(key))
			{
				return;
			}
			keys.Add(key);
			key.Resource = this;
		}
	}

	internal class StringDbResource : DbResource
	{
		protected StringDbResource() {}

		public StringDbResource(string key, string language, string value)
		{
			AddKey(new DbResourceKey(key, language));
			Value = value;
		}

		public override object Value
		{
			get { return RawValue; }
			set { RawValue = (string) value; }
		}
	}

	internal class IntDbResource : DbResource
	{
		protected IntDbResource() {}

		public IntDbResource(string key, int xml)
		{
			AddKey(new DbResourceKey(key));
			Value = xml;
		}

		public override object Value
		{
			get { return int.Parse(RawValue); }
			set { RawValue = ((int) value).ToString(); }
		}
	}

	internal class DecimalDbResource : DbResource
	{
		protected DecimalDbResource() {}

		public DecimalDbResource(string key, decimal xml)
		{
			AddKey(new DbResourceKey(key));
			Value = xml;
		}

		public override object Value
		{
			get { return decimal.Parse(RawValue); }
			set { RawValue = ((decimal) value).ToString(); }
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?