CSLA - R to Z
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 UserInfo : ReadOnlyBase<UserInfo>, IDisposable
|
||||
{
|
||||
public event UserInfoEvent 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<UserInfo> _CacheList = new List<UserInfo>();
|
||||
protected static void AddToCache(UserInfo userInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(userInfo)) _CacheList.Remove(userInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<UserInfo>> _CacheByPrimaryKey = new Dictionary<string, List<UserInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
@@ -74,10 +71,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Business Methods
|
||||
private string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
public string ErrorMessage => _ErrorMessage;
|
||||
protected User _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
@@ -252,32 +246,19 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (UserInfo tmp in _CacheByPrimaryKey[_UID.ToString()])
|
||||
tmp._UserMembershipCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
// CSLATODO: Replace base UserInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current UserInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check UserInfo.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 UserInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyUserInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyUserInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _UserInfoUnique = 0;
|
||||
private static int UserInfoUnique
|
||||
{ get { return ++_UserInfoUnique; } }
|
||||
private int _MyUserInfoUnique = UserInfoUnique;
|
||||
public int MyUserInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyUserInfoUnique; } }
|
||||
private static int UserInfoUnique => ++_UserInfoUnique;
|
||||
private readonly int _MyUserInfoUnique = UserInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyUserInfoUnique => _MyUserInfoUnique;
|
||||
protected UserInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -286,15 +267,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;
|
||||
~UserInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -311,10 +288,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listUserInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(UID.ToString()); // remove the list
|
||||
}
|
||||
public virtual User Get()
|
||||
{
|
||||
return _Editable = User.Get(_UID);
|
||||
}
|
||||
public virtual User Get() => _Editable = User.Get(_UID);
|
||||
public static void Refresh(User tmp)
|
||||
{
|
||||
string key = tmp.UID.ToString();
|
||||
@@ -343,8 +317,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static UserInfo Get(int uid)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a User");
|
||||
try
|
||||
{
|
||||
UserInfo tmp = GetCachedByPrimaryKey(uid);
|
||||
@@ -383,13 +355,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _UID;
|
||||
public int UID
|
||||
{ get { return _UID; } }
|
||||
public PKCriteria(int uid)
|
||||
{
|
||||
_UID = uid;
|
||||
}
|
||||
private readonly int _UID;
|
||||
public int UID => _UID;
|
||||
public PKCriteria(int uid) => _UID = uid;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -458,7 +426,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
UserInfoExtension _UserInfoExtension = new UserInfoExtension();
|
||||
readonly UserInfoExtension _UserInfoExtension = new UserInfoExtension();
|
||||
[Serializable()]
|
||||
partial class UserInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -474,10 +442,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 UserInfo)
|
||||
if (destType == typeof(string) && value is UserInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((UserInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user