CSLA - R - Group 1
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 RevisionInfo : ReadOnlyBase<RevisionInfo>, IDisposable
|
||||
{
|
||||
public event RevisionInfoEvent 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<RevisionInfo> _CacheList = new List<RevisionInfo>();
|
||||
protected static void AddToCache(RevisionInfo revisionInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(revisionInfo)) _CacheList.Remove(revisionInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<RevisionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RevisionInfo>>();
|
||||
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 Revision _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private int _RevisionID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int RevisionID
|
||||
@@ -261,32 +245,19 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (RevisionInfo tmp in _CacheByPrimaryKey[_RevisionID.ToString()])
|
||||
tmp._RevisionVersionCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
// CSLATODO: Replace base RevisionInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current RevisionInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check RevisionInfo.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 RevisionInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyRevisionInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyRevisionInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _RevisionInfoUnique = 0;
|
||||
private static int RevisionInfoUnique
|
||||
{ get { return ++_RevisionInfoUnique; } }
|
||||
private int _MyRevisionInfoUnique = RevisionInfoUnique;
|
||||
public int MyRevisionInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyRevisionInfoUnique; } }
|
||||
private static int RevisionInfoUnique => ++_RevisionInfoUnique;
|
||||
private readonly int _MyRevisionInfoUnique = RevisionInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyRevisionInfoUnique => _MyRevisionInfoUnique;
|
||||
protected RevisionInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -295,15 +266,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;
|
||||
~RevisionInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -320,10 +287,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listRevisionInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(RevisionID.ToString()); // remove the list
|
||||
}
|
||||
public virtual Revision Get()
|
||||
{
|
||||
return _Editable = Revision.Get(_RevisionID);
|
||||
}
|
||||
public virtual Revision Get() => _Editable = Revision.Get(_RevisionID);
|
||||
public static void Refresh(Revision tmp)
|
||||
{
|
||||
string key = tmp.RevisionID.ToString();
|
||||
@@ -347,8 +311,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static RevisionInfo Get(int revisionID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Revision");
|
||||
try
|
||||
{
|
||||
RevisionInfo tmp = GetCachedByPrimaryKey(revisionID);
|
||||
@@ -387,13 +349,9 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _RevisionID;
|
||||
public int RevisionID
|
||||
{ get { return _RevisionID; } }
|
||||
public PKCriteria(int revisionID)
|
||||
{
|
||||
_RevisionID = revisionID;
|
||||
}
|
||||
private readonly int _RevisionID;
|
||||
public int RevisionID => _RevisionID;
|
||||
public PKCriteria(int revisionID) => _RevisionID = revisionID;
|
||||
}
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
@@ -458,7 +416,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
RevisionInfoExtension _RevisionInfoExtension = new RevisionInfoExtension();
|
||||
readonly RevisionInfoExtension _RevisionInfoExtension = new RevisionInfoExtension();
|
||||
[Serializable()]
|
||||
partial class RevisionInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -474,10 +432,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 RevisionInfo)
|
||||
if (destType == typeof(string) && value is RevisionInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((RevisionInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user