CLSA - Ds
This commit is contained in:
@@ -13,8 +13,6 @@ using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
namespace VEPROMS.CSLA.Library
|
||||
@@ -28,14 +26,12 @@ namespace VEPROMS.CSLA.Library
|
||||
public partial class DetailInfo : ReadOnlyBase<DetailInfo>, IDisposable
|
||||
{
|
||||
public event DetailInfoEvent Changed;
|
||||
private void OnChange()
|
||||
{
|
||||
if (Changed != null) Changed(this);
|
||||
}
|
||||
private void OnChange() => Changed?.Invoke(this);
|
||||
#region Log4Net
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
#region Collection
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static List<DetailInfo> _CacheList = new List<DetailInfo>();
|
||||
protected static void AddToCache(DetailInfo detailInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(detailInfo)) _CacheList.Remove(detailInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<DetailInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DetailInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
@@ -74,21 +71,8 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Business Methods
|
||||
private string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
public string ErrorMessage => _ErrorMessage;
|
||||
protected Detail _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private int _DetailID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int DetailID
|
||||
@@ -164,32 +148,19 @@ namespace VEPROMS.CSLA.Library
|
||||
return _UserID;
|
||||
}
|
||||
}
|
||||
// CSLATODO: Replace base DetailInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current DetailInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check DetailInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current DetailInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyDetailInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyDetailInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _DetailInfoUnique = 0;
|
||||
private static int DetailInfoUnique
|
||||
{ get { return ++_DetailInfoUnique; } }
|
||||
private int _MyDetailInfoUnique = DetailInfoUnique;
|
||||
public int MyDetailInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyDetailInfoUnique; } }
|
||||
private static int DetailInfoUnique => ++_DetailInfoUnique;
|
||||
private readonly int _MyDetailInfoUnique = DetailInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyDetailInfoUnique => _MyDetailInfoUnique;
|
||||
protected DetailInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -198,15 +169,11 @@ namespace VEPROMS.CSLA.Library
|
||||
private static int _CountCreated = 0;
|
||||
private static int _CountDisposed = 0;
|
||||
private static int _CountFinalized = 0;
|
||||
private static int IncrementCountCreated
|
||||
{ get { return ++_CountCreated; } }
|
||||
private int _CountWhenCreated = IncrementCountCreated;
|
||||
public static int CountCreated
|
||||
{ get { return _CountCreated; } }
|
||||
public static int CountNotDisposed
|
||||
{ get { return _CountCreated - _CountDisposed; } }
|
||||
public static int CountNotFinalized
|
||||
{ get { return _CountCreated - _CountFinalized; } }
|
||||
private static int IncrementCountCreated => ++_CountCreated;
|
||||
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||
public static int CountCreated => _CountCreated;
|
||||
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||
~DetailInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -223,10 +190,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listDetailInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(DetailID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Detail Get()
|
||||
{
|
||||
return _Editable = Detail.Get(_DetailID);
|
||||
}
|
||||
public virtual Detail Get() => _Editable = Detail.Get(_DetailID);
|
||||
public static void Refresh(Detail tmp)
|
||||
{
|
||||
string key = tmp.DetailID.ToString();
|
||||
@@ -239,11 +203,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_ContentID != tmp.ContentID)
|
||||
{
|
||||
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for old value
|
||||
MyContent?.RefreshContentDetails(); // Update List for old value
|
||||
_ContentID = tmp.ContentID; // Update the value
|
||||
}
|
||||
_MyContent = null; // Reset list so that the next line gets a new list
|
||||
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for new value
|
||||
MyContent?.RefreshContentDetails(); // Update List for new value
|
||||
_ItemType = tmp.ItemType;
|
||||
_Text = tmp.Text;
|
||||
_Config = tmp.Config;
|
||||
@@ -272,8 +236,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static DetailInfo Get(int detailID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Detail");
|
||||
try
|
||||
{
|
||||
DetailInfo tmp = GetCachedByPrimaryKey(detailID);
|
||||
@@ -312,13 +274,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _DetailID;
|
||||
public int DetailID
|
||||
{ get { return _DetailID; } }
|
||||
public PKCriteria(int detailID)
|
||||
{
|
||||
_DetailID = detailID;
|
||||
}
|
||||
private readonly int _DetailID;
|
||||
public int DetailID => _DetailID;
|
||||
public PKCriteria(int detailID) => _DetailID = detailID;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -379,7 +337,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension();
|
||||
readonly DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension();
|
||||
[Serializable()]
|
||||
partial class DetailInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -395,10 +353,10 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||
{
|
||||
if (destType == typeof(string) && value is DetailInfo)
|
||||
if (destType == typeof(string) && value is DetailInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((DetailInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user