CSLA - R to Z
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 RoUsageInfo : ReadOnlyBase<RoUsageInfo>, IDisposable
|
||||
{
|
||||
public event RoUsageInfoEvent 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<RoUsageInfo> _CacheList = new List<RoUsageInfo>();
|
||||
protected static void AddToCache(RoUsageInfo roUsageInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(roUsageInfo)) _CacheList.Remove(roUsageInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<RoUsageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RoUsageInfo>>();
|
||||
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 RoUsage _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private int _ROUsageID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int ROUsageID
|
||||
@@ -175,32 +159,19 @@ namespace VEPROMS.CSLA.Library
|
||||
return _MyRODb;
|
||||
}
|
||||
}
|
||||
// CSLATODO: Replace base RoUsageInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current RoUsageInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check RoUsageInfo.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 RoUsageInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyRoUsageInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyRoUsageInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _RoUsageInfoUnique = 0;
|
||||
private static int RoUsageInfoUnique
|
||||
{ get { return ++_RoUsageInfoUnique; } }
|
||||
private int _MyRoUsageInfoUnique = RoUsageInfoUnique;
|
||||
public int MyRoUsageInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyRoUsageInfoUnique; } }
|
||||
private static int RoUsageInfoUnique => ++_RoUsageInfoUnique;
|
||||
private readonly int _MyRoUsageInfoUnique = RoUsageInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyRoUsageInfoUnique => _MyRoUsageInfoUnique;
|
||||
protected RoUsageInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -209,15 +180,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;
|
||||
~RoUsageInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -234,10 +201,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listRoUsageInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list
|
||||
}
|
||||
public virtual RoUsage Get()
|
||||
{
|
||||
return _Editable = RoUsage.Get(_ROUsageID);
|
||||
}
|
||||
public virtual RoUsage Get() => _Editable = RoUsage.Get(_ROUsageID);
|
||||
public static void Refresh(RoUsage tmp)
|
||||
{
|
||||
string key = tmp.ROUsageID.ToString();
|
||||
@@ -250,22 +214,22 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_ContentID != tmp.ContentID)
|
||||
{
|
||||
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for old value
|
||||
MyContent?.RefreshContentRoUsages(); // 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.RefreshContentRoUsages(); // Update List for new value
|
||||
MyContent?.RefreshContentRoUsages(); // Update List for new value
|
||||
_ROID = tmp.ROID;
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
if (_RODbID != tmp.RODbID)
|
||||
{
|
||||
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for old value
|
||||
MyRODb?.RefreshRODbRoUsages(); // Update List for old value
|
||||
_RODbID = tmp.RODbID; // Update the value
|
||||
}
|
||||
_MyRODb = null; // Reset list so that the next line gets a new list
|
||||
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for new value
|
||||
MyRODb?.RefreshRODbRoUsages(); // Update List for new value
|
||||
_RoUsageInfoExtension.Refresh(this);
|
||||
OnChange();// raise an event
|
||||
}
|
||||
@@ -285,11 +249,11 @@ namespace VEPROMS.CSLA.Library
|
||||
_UserID = tmp.UserID;
|
||||
if (_RODbID != tmp.RODbID)
|
||||
{
|
||||
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for old value
|
||||
MyRODb?.RefreshRODbRoUsages(); // Update List for old value
|
||||
_RODbID = tmp.RODbID; // Update the value
|
||||
}
|
||||
_MyRODb = null; // Reset list so that the next line gets a new list
|
||||
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for new value
|
||||
MyRODb?.RefreshRODbRoUsages(); // Update List for new value
|
||||
_RoUsageInfoExtension.Refresh(this);
|
||||
OnChange();// raise an event
|
||||
}
|
||||
@@ -305,11 +269,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_ContentID != tmp.ContentID)
|
||||
{
|
||||
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for old value
|
||||
MyContent?.RefreshContentRoUsages(); // 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.RefreshContentRoUsages(); // Update List for new value
|
||||
MyContent?.RefreshContentRoUsages(); // Update List for new value
|
||||
_ROID = tmp.ROID;
|
||||
_Config = tmp.Config;
|
||||
_DTS = tmp.DTS;
|
||||
@@ -319,8 +283,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static RoUsageInfo Get(int rOUsageID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a RoUsage");
|
||||
try
|
||||
{
|
||||
RoUsageInfo tmp = GetCachedByPrimaryKey(rOUsageID);
|
||||
@@ -359,13 +321,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _ROUsageID;
|
||||
public int ROUsageID
|
||||
{ get { return _ROUsageID; } }
|
||||
public PKCriteria(int rOUsageID)
|
||||
{
|
||||
_ROUsageID = rOUsageID;
|
||||
}
|
||||
private readonly int _ROUsageID;
|
||||
public int ROUsageID => _ROUsageID;
|
||||
public PKCriteria(int rOUsageID) => _ROUsageID = rOUsageID;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -426,7 +384,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
RoUsageInfoExtension _RoUsageInfoExtension = new RoUsageInfoExtension();
|
||||
readonly RoUsageInfoExtension _RoUsageInfoExtension = new RoUsageInfoExtension();
|
||||
[Serializable()]
|
||||
partial class RoUsageInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -442,10 +400,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 RoUsageInfo)
|
||||
if (destType == typeof(string) && value is RoUsageInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((RoUsageInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user