CSLA - E & F

This commit is contained in:
2026-09-09 14:08:28 -04:00
parent a69a2270a6
commit f2b064f459
25 changed files with 1535 additions and 3501 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 FormatInfo : ReadOnlyBase<FormatInfo>, IDisposable
{
public event FormatInfoEvent 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<FormatInfo> _CacheList = new List<FormatInfo>();
protected static void AddToCache(FormatInfo formatInfo)
{
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
{
while (_CacheList.Contains(formatInfo)) _CacheList.Remove(formatInfo); // In RemoveFromCache
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, List<FormatInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FormatInfo>>();
private static void ConvertListToDictionary()
{
@@ -81,21 +78,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 Format _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _FormatID;
[System.ComponentModel.DataObjectField(true, true)]
public int FormatID
@@ -342,32 +326,19 @@ namespace VEPROMS.CSLA.Library
foreach (FormatInfo tmp in _CacheByPrimaryKey[_FormatID.ToString()])
tmp._ChildFormatCount = -1; // This will cause the data to be requeried
}
// CSLATODO: Replace base FormatInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FormatInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check FormatInfo.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 FormatInfo</returns>
protected override object GetIdValue()
{
return MyFormatInfoUnique; // Absolutely Unique ID
}
protected override object GetIdValue() => MyFormatInfoUnique; // Absolutely Unique ID
#endregion
#region Factory Methods
private static int _FormatInfoUnique = 0;
private static int FormatInfoUnique
{ get { return ++_FormatInfoUnique; } }
private int _MyFormatInfoUnique = FormatInfoUnique;
public int MyFormatInfoUnique // Absolutely Unique ID - Info
{ get { return _MyFormatInfoUnique; } }
private static int FormatInfoUnique => ++_FormatInfoUnique;
private readonly int _MyFormatInfoUnique = FormatInfoUnique;
// Absolutely Unique ID - Info
public int MyFormatInfoUnique => _MyFormatInfoUnique;
protected FormatInfo()
{/* require use of factory methods */
AddToCache(this);
@@ -376,15 +347,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;
~FormatInfo()
{
_CountFinalized++;
@@ -417,11 +384,11 @@ namespace VEPROMS.CSLA.Library
{
if (_ParentID != tmp.ParentID)
{
if (MyParent != null) MyParent.RefreshChildFormats(); // Update List for old value
MyParent?.RefreshChildFormats(); // Update List for old value
_ParentID = tmp.ParentID; // Update the value
}
_MyParent = null; // Reset list so that the next line gets a new list
if (MyParent != null) MyParent.RefreshChildFormats(); // Update List for new value
MyParent?.RefreshChildFormats(); // Update List for new value
_Name = tmp.Name;
_Description = tmp.Description;
_Data = tmp.Data;
@@ -434,8 +401,6 @@ namespace VEPROMS.CSLA.Library
}
public static FormatInfo Get(int formatID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Format");
try
{
FormatInfo tmp = GetCachedByPrimaryKey(formatID);
@@ -474,13 +439,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteria
{
private int _FormatID;
public int FormatID
{ get { return _FormatID; } }
public PKCriteria(int formatID)
{
_FormatID = formatID;
}
private readonly int _FormatID;
public int FormatID => _FormatID;
public PKCriteria(int formatID) => _FormatID = formatID;
}
public static string _Failed = null;
public static string Failed
@@ -564,7 +525,7 @@ namespace VEPROMS.CSLA.Library
#endregion
// Standard Refresh
#region extension
FormatInfoExtension _FormatInfoExtension = new FormatInfoExtension();
readonly FormatInfoExtension _FormatInfoExtension = new FormatInfoExtension();
[Serializable()]
partial class FormatInfoExtension : extensionBase { }
[Serializable()]
@@ -580,10 +541,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 FormatInfo)
if (destType == typeof(string) && value is FormatInfo info)
{
// Return the ToString value
return ((FormatInfo)value).ToString();
return info.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}