diff --git a/PROMS/MyGeneration/csla_21/CSLA_Objects.csgen b/PROMS/MyGeneration/csla_21/CSLA_Objects.csgen index 56e40e50..e9aa512b 100644 --- a/PROMS/MyGeneration/csla_21/CSLA_Objects.csgen +++ b/PROMS/MyGeneration/csla_21/CSLA_Objects.csgen @@ -464,7 +464,7 @@ public class GeneratedTemplate : DotNetScriptTemplate [TypeConverter(typeof(<%=_className%>Converter))]<% } %> - public partial class <%=_className%> : BusinessListBase<<%=_className%>, <%=_subclassName%>><%=sInterface%>, IVEHasBrokenRules + public partial class <%=_className%> : BusinessListBase<<%=_className%>, <%=_subclassName%>><%=sInterface%>, IVEHasBrokenRules , IDisposable {<% Log4Net(); if (_chkPartBM)vlnBusinessMethodsFKList(fk,sAlias); @@ -489,7 +489,7 @@ public class GeneratedTemplate : DotNetScriptTemplate [TypeConverter(typeof(<%=_className%>Converter))]<% } %> - public partial class <%=_className%> : BusinessBase<<%=_className%>><%=sInterface%>, IVEHasBrokenRules + public partial class <%=_className%> : BusinessBase<<%=_className%>><%=sInterface%>, IVEHasBrokenRules, IDisposable {<% Log4Net(); if (_chkPartBM)vlnBusinessMethodsFKItem(fk,sAlias); @@ -563,8 +563,28 @@ public class GeneratedTemplate : DotNetScriptTemplate this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i)); } } + private bool _Disposed = false; + 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; } } + ~<%=_className%>() + { + _CountFinalized++; + } public void Dispose() { + if (_Disposed) return; + _CountDisposed++; + _Disposed = true; foreach (<%=_subclassName%> tmp in this) { tmp.Changed -= new <%=_subclassName%>Event(tmp_Changed); @@ -1420,8 +1440,28 @@ namespace <%=_nameSpace%> {/* require use of factory methods */ AddToCache(this); } + private bool _Disposed = false; + 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; } } + ~<%=_className%>() + { + _CountFinalized++; + } public void Dispose() { + if (_Disposed) return; + _CountDisposed++; + _Disposed = true; RemoveFromDictionaries(); } private void RemoveFromDictionaries() @@ -1774,14 +1814,19 @@ namespace <%=_nameSpace%> { <%=sCheck%> } - private void BuildRefreshList() + private void ClearRefreshList() { <%=sReset%> + } + private void BuildRefreshList() + { + ClearRefreshList(); AddToRefreshList(<%=sRefreshRelated1%>); } private void ProcessRefreshList() { <%=sProcess%> + ClearRefreshList(); } #endregion<% } @@ -3289,6 +3334,29 @@ private void vlnDataPortalFetch(string sPrefix,IColumns cols,string sql,bool get MarkAsChild(); Fetch(dr<%=sExtra2%>); } + private bool _Disposed = false; + 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; } } + ~<%=sFkClassListName%>() + { + _CountFinalized++; + } + public void Dispose() + { + if (_Disposed) return; + _CountDisposed++; + _Disposed = true; + } #endregion<% } private void vlnDataAccessPortalFKList(IForeignKey fk,string sAlias) @@ -4049,6 +4117,29 @@ private void vlnDataPortalFetch(string sPrefix,IColumns cols,string sql,bool get MarkAsChild(); Fetch(dr); } + private bool _Disposed = false; + 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; } } + ~<%=sFkClassName%>() + { + _CountFinalized++; + } + public void Dispose() + { + if (_Disposed) return; + _CountDisposed++; + _Disposed = true; + } #endregion<% } private void vlnDataAccessPortalFKItem(IForeignKey fk,string sAlias) @@ -4630,8 +4721,28 @@ private void vlnDataPortalFetch(string sPrefix,IColumns cols,string sql,bool get {/* require use of factory methods */ AddToCache(this); } + private bool _Disposed = false; + 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; } } + ~<%=_className%>() + { + _CountFinalized++; + } public void Dispose() { + if (_Disposed) return; + _CountDisposed++; + _Disposed = true; RemoveFromCache(this); if (!_CacheByPrimaryKey.ContainsKey(<%=sRefKeys%>)) return; List<<%=_className%>> list<%=_className%> = _CacheByPrimaryKey[<%=sRefKeys%>]; // Get the list of items