CSLA - G
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 GroupInfo : ReadOnlyBase<GroupInfo>, IDisposable
|
||||
{
|
||||
public event GroupInfoEvent 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<GroupInfo> _CacheList = new List<GroupInfo>();
|
||||
protected static void AddToCache(GroupInfo groupInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(groupInfo)) _CacheList.Remove(groupInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<GroupInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GroupInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
@@ -79,16 +76,6 @@ namespace VEPROMS.CSLA.Library
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
protected Group _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private int _GID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int GID
|
||||
@@ -216,32 +203,19 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()])
|
||||
tmp._GroupMembershipCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
// CSLATODO: Replace base GroupInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current GroupInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check GroupInfo.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 GroupInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyGroupInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyGroupInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _GroupInfoUnique = 0;
|
||||
private static int GroupInfoUnique
|
||||
{ get { return ++_GroupInfoUnique; } }
|
||||
private int _MyGroupInfoUnique = GroupInfoUnique;
|
||||
public int MyGroupInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyGroupInfoUnique; } }
|
||||
private static int GroupInfoUnique => ++_GroupInfoUnique;
|
||||
private readonly int _MyGroupInfoUnique = GroupInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyGroupInfoUnique => _MyGroupInfoUnique;
|
||||
protected GroupInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -250,15 +224,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;
|
||||
~GroupInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -275,10 +245,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listGroupInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(GID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Group Get()
|
||||
{
|
||||
return _Editable = Group.Get(_GID);
|
||||
}
|
||||
public virtual Group Get() => _Editable = Group.Get(_GID);
|
||||
public static void Refresh(Group tmp)
|
||||
{
|
||||
string key = tmp.GID.ToString();
|
||||
@@ -299,8 +266,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static GroupInfo Get(int gid)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Group");
|
||||
try
|
||||
{
|
||||
GroupInfo tmp = GetCachedByPrimaryKey(gid);
|
||||
@@ -339,13 +304,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _GID;
|
||||
public int GID
|
||||
{ get { return _GID; } }
|
||||
public PKCriteria(int gid)
|
||||
{
|
||||
_GID = gid;
|
||||
}
|
||||
private readonly int _GID;
|
||||
public int GID => _GID;
|
||||
public PKCriteria(int gid) => _GID = gid;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -407,7 +368,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension();
|
||||
readonly GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension();
|
||||
[Serializable()]
|
||||
partial class GroupInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -423,10 +384,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 GroupInfo)
|
||||
if (destType == typeof(string) && value is GroupInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((GroupInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user