CSLA - M through P

This commit is contained in:
2026-09-11 09:50:40 -04:00
parent e41a4ea65d
commit d9f8f6cb37
20 changed files with 1196 additions and 2757 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 OwnerInfo : ReadOnlyBase<OwnerInfo>, IDisposable
{
public event OwnerInfoEvent 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<OwnerInfo> _CacheList = new List<OwnerInfo>();
protected static void AddToCache(OwnerInfo ownerInfo)
{
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(ownerInfo)) _CacheList.Remove(ownerInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<OwnerInfo>> _CacheByPrimaryKey = new Dictionary<string, List<OwnerInfo>>();
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 Owner _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _OwnerID;
[System.ComponentModel.DataObjectField(true, true)]
public int OwnerID
@@ -135,32 +119,19 @@ namespace VEPROMS.CSLA.Library
return _DTSStart;
}
}
// CSLATODO: Replace base OwnerInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current OwnerInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check OwnerInfo.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 OwnerInfo</returns>
protected override object GetIdValue()
{
return MyOwnerInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyOwnerInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _OwnerInfoUnique = 0;
private static int OwnerInfoUnique
{ get { return ++_OwnerInfoUnique; } }
private int _MyOwnerInfoUnique = OwnerInfoUnique;
public int MyOwnerInfoUnique // Absolutely Unique ID - Info
{ get { return _MyOwnerInfoUnique; } }
private static int OwnerInfoUnique => ++_OwnerInfoUnique;
private readonly int _MyOwnerInfoUnique = OwnerInfoUnique;
// Absolutely Unique ID - Info
public int MyOwnerInfoUnique => _MyOwnerInfoUnique;
protected OwnerInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -169,15 +140,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;
~OwnerInfo()
{
_CountFinalized++;
@@ -194,10 +161,7 @@ namespace VEPROMS.CSLA.Library
if (listOwnerInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(OwnerID.ToString()); // remove the list
}
public virtual Owner Get()
{
return _Editable = Owner.Get(_OwnerID);
}
public virtual Owner Get() => _Editable = Owner.Get(_OwnerID);
public static void Refresh(Owner tmp)
{
string key = tmp.OwnerID.ToString();
@@ -217,8 +181,6 @@ namespace VEPROMS.CSLA.Library
}
public static OwnerInfo Get(int ownerID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Owner");
try
{
OwnerInfo tmp = GetCachedByPrimaryKey(ownerID);
@@ -257,13 +219,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _OwnerID;
public int OwnerID
{ get { return _OwnerID; } }
public PKCriteria(int ownerID)
{
_OwnerID = ownerID;
}
private readonly int _OwnerID;
public int OwnerID => _OwnerID;
public PKCriteria(int ownerID) => _OwnerID = ownerID;
}
private void ReadData(SafeDataReader dr)
{
@@ -322,7 +280,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
OwnerInfoExtension _OwnerInfoExtension = new OwnerInfoExtension();
readonly OwnerInfoExtension _OwnerInfoExtension = new OwnerInfoExtension();
[Serializable()]
partial class OwnerInfoExtension : extensionBase { }
[Serializable()]
@@ -338,10 +296,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 OwnerInfo)
if (destType == typeof(string) && value is OwnerInfo info)
{
// Return the ToString value
return ((OwnerInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}