- nettiergeneratorsample.zip
- database
- sample
- BusinessLogic
- Common
- Config
- DalFactory
- GUI
- WinGUI
- IDAL
- Model
- MsSqlDal
- OP_CACHE.ATR
- OP_CACHE.IDX
- Sample.sln
- Security
- TierModel
- Tools
- EnterpriseLibrary
- Microsoft.Practices.EnterpriseLibrary.Caching.dll
- Microsoft.Practices.EnterpriseLibrary.Caching.XML
- Microsoft.Practices.EnterpriseLibrary.Common.dll
- Microsoft.Practices.EnterpriseLibrary.Common.XML
- Microsoft.Practices.ObjectBuilder.dll
- Microsoft.Practices.ObjectBuilder.XML
- TierGenerator
- nettiergenerator.zip
- netTierGenerator
- BusinessLogic
- Common
- Common.csproj
- Data
- Exception
- OP_CACHE.ATR
- OP_CACHE.IDX
- Properties
- Util
- Config
- Console
- DalFactory
- IDal
- Model
- MsSqlDal
- netTierGenerator.sln
- OP_CACHE.ATR
- OP_CACHE.IDX
- TierGenerator
- TierModel
|
using System;
using System.Globalization;
using System.Xml;
namespace Sample.Common.History
{
public class HistoryDeserializedInfoMember
{
#region members
private string entityType;
private string type;
private string value;
#endregion members
#region properties
public string EntityType
{
get { return this.entityType; }
set { this.entityType = value; }
}
public string Type
{
get { return this.type; }
set { this.type = value; }
}
public string Value
{
get { return this.value; }
set { this.value = value; }
}
#endregion properties
public HistoryDeserializedInfoMember(string type, string entityType, string value)
{
this.type = type;
this.entityType = entityType;
this.value = value;
}
#region public methods
public object GetValue()
{
if (String.IsNullOrEmpty(this.Value))
{
return null;
}
Type valueType = System.Type.GetType(this.Type, false, true);
if (valueType != null)
{
if (valueType.IsEnum)
{
return Enum.Parse(valueType, this.Value);
}
else if (valueType == typeof(DateTime))
{
long ticks;
if (Int64.TryParse(this.Value, out ticks))
{
return new DateTime(ticks, DateTimeKind.Utc).ToLocalTime();
}
else
{
return XmlConvert.ToDateTime(this.Value, XmlDateTimeSerializationMode.Local);
//DateTime datetime;
//if (DateTime.TryParse(this.Value, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeLocal, out datetime))
//{
// return datetime;
//}
}
}
else if (valueType.GetInterface(typeof(IConvertible).FullName) != null)
{
return Convert.ChangeType(this.Value, valueType, CultureInfo.InvariantCulture);
}
else if (valueType == typeof(Guid) || valueType == typeof(Guid?))
{
try
{
return new Guid(this.Value);
}
catch { }
}
}
return null;
}
#endregion public methods
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.