CSLA - R to Z

This commit is contained in:
2026-09-14 15:30:10 -04:00
parent d238d6aed2
commit 1c6f3e3e3c
32 changed files with 1978 additions and 4455 deletions
@@ -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 RoleInfo : ReadOnlyBase<RoleInfo>, IDisposable
{
public event RoleInfoEvent 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<RoleInfo> _CacheList = new List<RoleInfo>();
protected static void AddToCache(RoleInfo roleInfo)
{
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(roleInfo)) _CacheList.Remove(roleInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<RoleInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RoleInfo>>();
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 Role _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _RID;
[System.ComponentModel.DataObjectField(true, true)]
public int RID
@@ -207,32 +191,19 @@ namespace VEPROMS.CSLA.Library
foreach (RoleInfo tmp in _CacheByPrimaryKey[_RID.ToString()])
tmp._RolePermissionCount = -1; // This will cause the data to be requeried
}
// CSLATODO: Replace base RoleInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RoleInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check RoleInfo.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 RoleInfo</returns>
protected override object GetIdValue()
{
return MyRoleInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyRoleInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _RoleInfoUnique = 0;
private static int RoleInfoUnique
{ get { return ++_RoleInfoUnique; } }
private int _MyRoleInfoUnique = RoleInfoUnique;
public int MyRoleInfoUnique // Absolutely Unique ID - Info
{ get { return _MyRoleInfoUnique; } }
private static int RoleInfoUnique => ++_RoleInfoUnique;
private readonly int _MyRoleInfoUnique = RoleInfoUnique;
// Absolutely Unique ID - Info
public int MyRoleInfoUnique => _MyRoleInfoUnique;
protected RoleInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -241,15 +212,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;
~RoleInfo()
{
_CountFinalized++;
@@ -266,10 +233,7 @@ namespace VEPROMS.CSLA.Library
if (listRoleInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(RID.ToString()); // remove the list
}
public virtual Role Get()
{
return _Editable = Role.Get(_RID);
}
public virtual Role Get() => _Editable = Role.Get(_RID);
public static void Refresh(Role tmp)
{
string key = tmp.RID.ToString();
@@ -289,8 +253,6 @@ namespace VEPROMS.CSLA.Library
}
public static RoleInfo Get(int rid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Role");
try
{
RoleInfo tmp = GetCachedByPrimaryKey(rid);
@@ -329,13 +291,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _RID;
public int RID
{ get { return _RID; } }
public PKCriteria(int rid)
{
_RID = rid;
}
private readonly int _RID;
public int RID => _RID;
public PKCriteria(int rid) => _RID = rid;
}
private void ReadData(SafeDataReader dr)
{
@@ -396,7 +354,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
RoleInfoExtension _RoleInfoExtension = new RoleInfoExtension();
readonly RoleInfoExtension _RoleInfoExtension = new RoleInfoExtension();
[Serializable()]
partial class RoleInfoExtension : extensionBase { }
[Serializable()]
@@ -412,10 +370,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 RoleInfo)
if (destType == typeof(string) && value is RoleInfo info)
{
// Return the ToString value
return ((RoleInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}