|
From: <dar...@us...> - 2009-01-27 04:23:21
|
Revision: 4004
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4004&view=rev
Author: darioquintana
Date: 2009-01-27 04:23:01 +0000 (Tue, 27 Jan 2009)
Log Message:
-----------
Refactoring: DelayedEnumerator and FutureValue moved as outer classes to reuse code.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs
trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs
trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs
Added: trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs 2009-01-27 04:23:01 UTC (rev 4004)
@@ -0,0 +1,42 @@
+using System.Collections;
+using System.Collections.Generic;
+
+namespace NHibernate.Impl
+{
+ internal class DelayedEnumerator<T> : IEnumerable<T>
+ {
+ public delegate IList GetResult();
+
+ private readonly GetResult result;
+
+ public DelayedEnumerator(GetResult result)
+ {
+ this.result = result;
+ }
+
+ public IEnumerable<T> Enumerable
+ {
+ get
+ {
+ foreach (T item in result())
+ {
+ yield return item;
+ }
+ }
+ }
+
+ #region IEnumerable<T> Members
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)Enumerable).GetEnumerator();
+ }
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ return Enumerable.GetEnumerator();
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-27 03:49:11 UTC (rev 4003)
+++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-27 04:23:01 UTC (rev 4004)
@@ -50,77 +50,5 @@
int currentIndex = index;
return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]);
}
-
- #region Nested type: FutureValue
-
- private class FutureValue<T> : IFutureValue<T>
- {
- public delegate IList GetResult();
-
- private readonly GetResult getResult;
-
- public FutureValue(GetResult result)
- {
- getResult = result;
- }
-
- public T Value
- {
- get
- {
- var result = getResult();
-
- if (result.Count == 0)
- {
- return default(T);
- }
-
- return (T)result[0];
- }
- }
- }
-
- #endregion
-
- #region Nested type: DelayedEnumerator
-
- private class DelayedEnumerator<T> : IEnumerable<T>
- {
- public delegate IList GetResult();
-
- private readonly GetResult result;
-
- public DelayedEnumerator(GetResult result)
- {
- this.result = result;
- }
-
- public IEnumerable<T> Enumerable
- {
- get
- {
- foreach (T item in result())
- {
- yield return item;
- }
- }
- }
-
- #region IEnumerable<T> Members
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable)Enumerable).GetEnumerator();
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- return Enumerable.GetEnumerator();
- }
-
- #endregion
- }
-
- #endregion
}
}
Modified: trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs 2009-01-27 03:49:11 UTC (rev 4003)
+++ trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs 2009-01-27 04:23:01 UTC (rev 4004)
@@ -50,77 +50,5 @@
int currentIndex = index;
return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]);
}
-
- #region Nested type: FutureValue
-
- private class FutureValue<T> : IFutureValue<T>
- {
- public delegate IList GetResult();
-
- private readonly GetResult getResult;
-
- public FutureValue(GetResult result)
- {
- getResult = result;
- }
-
- public T Value
- {
- get
- {
- var result = getResult();
-
- if (result.Count == 0)
- {
- return default(T);
- }
-
- return (T)result[0];
- }
- }
- }
-
- #endregion
-
- #region Nested type: DelayedEnumerator
-
- private class DelayedEnumerator<T> : IEnumerable<T>
- {
- public delegate IList GetResult();
-
- private readonly GetResult result;
-
- public DelayedEnumerator(GetResult result)
- {
- this.result = result;
- }
-
- public IEnumerable<T> Enumerable
- {
- get
- {
- foreach (T item in result())
- {
- yield return item;
- }
- }
- }
-
- #region IEnumerable<T> Members
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable)Enumerable).GetEnumerator();
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- return Enumerable.GetEnumerator();
- }
-
- #endregion
- }
-
- #endregion
}
}
Added: trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs 2009-01-27 04:23:01 UTC (rev 4004)
@@ -0,0 +1,31 @@
+using System.Collections;
+
+namespace NHibernate.Impl
+{
+ internal class FutureValue<T> : IFutureValue<T>
+ {
+ public delegate IList GetResult();
+
+ private readonly GetResult getResult;
+
+ public FutureValue(GetResult result)
+ {
+ getResult = result;
+ }
+
+ public T Value
+ {
+ get
+ {
+ var result = getResult();
+
+ if (result.Count == 0)
+ {
+ return default(T);
+ }
+
+ return (T)result[0];
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-27 03:49:11 UTC (rev 4003)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-27 04:23:01 UTC (rev 4004)
@@ -458,8 +458,10 @@
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
<Compile Include="Id\SelectGenerator.cs" />
<Compile Include="IFutureValue.cs" />
+ <Compile Include="Impl\DelayedEnumerator.cs" />
<Compile Include="Impl\FutureQueryBatch.cs" />
<Compile Include="Impl\FutureCriteriaBatch.cs" />
+ <Compile Include="Impl\FutureValue.cs" />
<Compile Include="Properties\BackFieldStrategy.cs" />
<Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" />
<Compile Include="Bytecode\IAccessOptimizer.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|