CSLA - R - Group 1

This commit is contained in:
2026-09-11 16:03:51 -04:00
parent d9f8f6cb37
commit d238d6aed2
33 changed files with 2101 additions and 4829 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 RODbInfo : ReadOnlyBase<RODbInfo>, IDisposable
{
public event RODbInfoEvent 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<RODbInfo> _CacheList = new List<RODbInfo>();
protected static void AddToCache(RODbInfo rODbInfo)
{
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(rODbInfo)) _CacheList.Remove(rODbInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<RODbInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RODbInfo>>();
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 RODb _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _RODbID;
[System.ComponentModel.DataObjectField(true, true)]
public int RODbID
@@ -306,32 +290,19 @@ namespace VEPROMS.CSLA.Library
foreach (RODbInfo tmp in _CacheByPrimaryKey[_RODbID.ToString()])
tmp._RODbRoUsageCount = -1; // This will cause the data to be requeried
}
// CSLATODO: Replace base RODbInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODbInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check RODbInfo.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 RODbInfo</returns>
protected override object GetIdValue()
{
return MyRODbInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyRODbInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _RODbInfoUnique = 0;
private static int RODbInfoUnique
{ get { return ++_RODbInfoUnique; } }
private int _MyRODbInfoUnique = RODbInfoUnique;
public int MyRODbInfoUnique // Absolutely Unique ID - Info
{ get { return _MyRODbInfoUnique; } }
private static int RODbInfoUnique => ++_RODbInfoUnique;
private readonly int _MyRODbInfoUnique = RODbInfoUnique;
// Absolutely Unique ID - Info
public int MyRODbInfoUnique => _MyRODbInfoUnique;
protected RODbInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -340,15 +311,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;
~RODbInfo()
{
_CountFinalized++;
@@ -365,10 +332,7 @@ namespace VEPROMS.CSLA.Library
if (listRODbInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(RODbID.ToString()); // remove the list
}
public virtual RODb Get()
{
return _Editable = RODb.Get(_RODbID);
}
public virtual RODb Get() => _Editable = RODb.Get(_RODbID);
public static void Refresh(RODb tmp)
{
string key = tmp.RODbID.ToString();
@@ -390,8 +354,6 @@ namespace VEPROMS.CSLA.Library
}
public static RODbInfo Get(int rODbID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a RODb");
try
{
RODbInfo tmp = GetCachedByPrimaryKey(rODbID);
@@ -430,13 +392,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _RODbID;
public int RODbID
{ get { return _RODbID; } }
public PKCriteria(int rODbID)
{
_RODbID = rODbID;
}
private readonly int _RODbID;
public int RODbID => _RODbID;
public PKCriteria(int rODbID) => _RODbID = rODbID;
}
private void ReadData(SafeDataReader dr)
{
@@ -501,7 +459,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
RODbInfoExtension _RODbInfoExtension = new RODbInfoExtension();
readonly RODbInfoExtension _RODbInfoExtension = new RODbInfoExtension();
[Serializable()]
partial class RODbInfoExtension : extensionBase { }
[Serializable()]
@@ -517,10 +475,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 RODbInfo)
if (destType == typeof(string) && value is RODbInfo info)
{
// Return the ToString value
return ((RODbInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}