CSLA - M through P
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 PartInfo : ReadOnlyBase<PartInfo>, IDisposable
|
||||
{
|
||||
public event PartInfoEvent 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<PartInfo> _CacheList = new List<PartInfo>();
|
||||
protected static void AddToCache(PartInfo partInfo)
|
||||
{
|
||||
@@ -45,6 +41,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
while (_CacheList.Contains(partInfo)) _CacheList.Remove(partInfo); // In RemoveFromCache
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
private static Dictionary<string, List<PartInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PartInfo>>();
|
||||
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 Part _Editable;
|
||||
private IVEHasBrokenRules HasBrokenRules
|
||||
{
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_Editable != null)
|
||||
hasBrokenRules = _Editable.HasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
}
|
||||
private int _ContentID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int ContentID
|
||||
@@ -166,32 +150,19 @@ namespace VEPROMS.CSLA.Library
|
||||
return _UserID;
|
||||
}
|
||||
}
|
||||
// CSLATODO: Replace base PartInfo.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current PartInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// CSLATODO: Check PartInfo.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 PartInfo</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return MyPartInfoUnique; // Absolutely Unique ID
|
||||
}
|
||||
protected override object GetIdValue() => MyPartInfoUnique; // Absolutely Unique ID
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private static int _PartInfoUnique = 0;
|
||||
private static int PartInfoUnique
|
||||
{ get { return ++_PartInfoUnique; } }
|
||||
private int _MyPartInfoUnique = PartInfoUnique;
|
||||
public int MyPartInfoUnique // Absolutely Unique ID - Info
|
||||
{ get { return _MyPartInfoUnique; } }
|
||||
private static int PartInfoUnique => ++_PartInfoUnique;
|
||||
private readonly int _MyPartInfoUnique = PartInfoUnique;
|
||||
// Absolutely Unique ID - Info
|
||||
public int MyPartInfoUnique => _MyPartInfoUnique;
|
||||
protected PartInfo()
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
@@ -200,15 +171,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;
|
||||
~PartInfo()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -227,10 +194,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (listPartInfo.Count == 0) // If there are no items left in the list
|
||||
_CacheByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list
|
||||
}
|
||||
public virtual Part Get()
|
||||
{
|
||||
return _Editable = Part.Get(_ContentID, _FromType);
|
||||
}
|
||||
public virtual Part Get() => _Editable = Part.Get(_ContentID, _FromType);
|
||||
public static void Refresh(Part tmp)
|
||||
{
|
||||
string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
|
||||
@@ -243,11 +207,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_ItemID != tmp.ItemID)
|
||||
{
|
||||
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value
|
||||
MyItem?.RefreshItemParts(); // Update List for old value
|
||||
_ItemID = tmp.ItemID; // Update the value
|
||||
}
|
||||
_MyItem = null; // Reset list so that the next line gets a new list
|
||||
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value
|
||||
MyItem?.RefreshItemParts(); // Update List for new value
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
_PartInfoExtension.Refresh(this);
|
||||
@@ -265,11 +229,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (_ItemID != tmp.ItemID)
|
||||
{
|
||||
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value
|
||||
MyItem?.RefreshItemParts(); // Update List for old value
|
||||
_ItemID = tmp.ItemID; // Update the value
|
||||
}
|
||||
_MyItem = null; // Reset list so that the next line gets a new list
|
||||
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value
|
||||
MyItem?.RefreshItemParts(); // Update List for new value
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
_PartInfoExtension.Refresh(this);
|
||||
@@ -292,8 +256,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static PartInfo Get(int contentID, int fromType)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a Part");
|
||||
try
|
||||
{
|
||||
PartInfo tmp = GetCachedByPrimaryKey(contentID, fromType);
|
||||
@@ -332,12 +294,10 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
protected class PKCriteria
|
||||
{
|
||||
private int _ContentID;
|
||||
public int ContentID
|
||||
{ get { return _ContentID; } }
|
||||
private int _FromType;
|
||||
public int FromType
|
||||
{ get { return _FromType; } }
|
||||
private readonly int _ContentID;
|
||||
public int ContentID => _ContentID;
|
||||
private readonly int _FromType;
|
||||
public int FromType => _FromType;
|
||||
public PKCriteria(int contentID, int fromType)
|
||||
{
|
||||
_ContentID = contentID;
|
||||
@@ -402,7 +362,7 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
// Standard Refresh
|
||||
#region extension
|
||||
PartInfoExtension _PartInfoExtension = new PartInfoExtension();
|
||||
readonly PartInfoExtension _PartInfoExtension = new PartInfoExtension();
|
||||
[Serializable()]
|
||||
partial class PartInfoExtension : extensionBase { }
|
||||
[Serializable()]
|
||||
@@ -418,10 +378,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 PartInfo)
|
||||
if (destType == typeof(string) && value is PartInfo info)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((PartInfo)value).ToString();
|
||||
return info.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user