Take care of FIXMEs
This commit is contained in:
@@ -34,14 +34,13 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
if (_constructors.ContainsKey(typeName))
|
||||
throw new InvalidOperationException(string.Format("More that one type want to be a model for content type {0}.", typeName));
|
||||
|
||||
// should work everywhere, potentially slow?
|
||||
// should work everywhere, but slow
|
||||
//_constructors[typeName] = constructor;
|
||||
|
||||
// note: would it be even faster with a dynamic method?
|
||||
// much faster with a dynamic method but potential MediumTrust issues
|
||||
// here http://stackoverflow.com/questions/16363838/how-do-you-call-a-constructor-via-an-expression-tree-on-an-existing-object
|
||||
// but MediumTrust issue?
|
||||
|
||||
// fixme - must make sure that works in medium trust
|
||||
// fast enough and works in MediumTrust
|
||||
// read http://boxbinary.com/2011/10/how-to-run-a-unit-test-in-medium-trust-with-nunitpart-three-umbraco-framework-testing/
|
||||
var exprArg = Expression.Parameter(typeof(IPublishedContent), "content");
|
||||
var exprNew = Expression.New(constructor, exprArg);
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
: base(content)
|
||||
{ }
|
||||
|
||||
// note: because we implement IOrderedEnumerable, we don't need to implement the ThenBy nor
|
||||
// ThenByDescending methods here, only CreateOrderedEnumerable and that does it.
|
||||
|
||||
#region IOrderedEnumerable<T>
|
||||
|
||||
public IOrderedEnumerable<T> CreateOrderedEnumerable<TKey>(Func<T, TKey> keySelector, IComparer<TKey> comparer, bool descending)
|
||||
@@ -25,39 +28,5 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// fixme wtf?!
|
||||
#if IMPLEMENT_LINQ_EXTENSIONS
|
||||
|
||||
// BEWARE!
|
||||
// here, Source.Whatever() will invoke the System.Linq.Enumerable extension method
|
||||
// and not the extension methods that we may have defined on IEnumerable<T> or
|
||||
// IOrderedEnumerable<T>, provided that they are NOT within the scope at compile time.
|
||||
|
||||
#region Wrap methods returning IOrderedEnumerable<T>
|
||||
|
||||
public PublishedContentOrderedSet<T> ThenBy<TKey>(Func<T, TKey> keySelector)
|
||||
{
|
||||
return new PublishedContentOrderedSet<T>(((IOrderedEnumerable<T>)Source).ThenBy(keySelector));
|
||||
}
|
||||
|
||||
public PublishedContentOrderedSet<T> ThenBy<TKey>(Func<T, TKey> keySelector, IComparer<TKey> comparer)
|
||||
{
|
||||
return new PublishedContentOrderedSet<T>(((IOrderedEnumerable<T>)Source).ThenBy(keySelector, comparer));
|
||||
}
|
||||
|
||||
public PublishedContentOrderedSet<T> ThenByDescending<TKey>(Func<T, TKey> keySelector)
|
||||
{
|
||||
return new PublishedContentOrderedSet<T>(((IOrderedEnumerable<T>)Source).ThenByDescending(keySelector));
|
||||
}
|
||||
|
||||
public PublishedContentOrderedSet<T> ThenByDescending<TKey>(Func<T, TKey> keySelector, IComparer<TKey> comparer)
|
||||
{
|
||||
return new PublishedContentOrderedSet<T>(((IOrderedEnumerable<T>)Source).ThenByDescending(keySelector, comparer));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,26 +48,20 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
// wrap an item, ie create the actual clone for this set
|
||||
private T MapContentAsT(T t)
|
||||
{
|
||||
// fixme - cleanup
|
||||
return MapContent(t) /*.Content*/ as T;
|
||||
return MapContent(t) as T;
|
||||
}
|
||||
|
||||
// fixme - cleanup
|
||||
internal IPublishedContentExtended /*Handle*/ MapContent(T t)
|
||||
internal IPublishedContentExtended MapContent(T t)
|
||||
{
|
||||
IPublishedContentExtended extend;
|
||||
if (_xContent.TryGetValue(t, out extend) == false)
|
||||
{
|
||||
// fixme - cleanup
|
||||
extend = PublishedContentExtended.Extend(t, this);
|
||||
//extend = t.Extend(this);
|
||||
var asT = extend as T;
|
||||
//var asT = extend.Content as T;
|
||||
if (asT == null)
|
||||
throw new InvalidOperationException(string.Format("Failed extend a published content of type {0}."
|
||||
+ "Got {1} when expecting {2}.", t.GetType().FullName, extend /*.Content*/ .GetType().FullName, typeof(T).FullName));
|
||||
_xContent[t] = extend;
|
||||
}
|
||||
if (_xContent.TryGetValue(t, out extend)) return extend;
|
||||
|
||||
extend = PublishedContentExtended.Extend(t, this);
|
||||
var asT = extend as T;
|
||||
if (asT == null)
|
||||
throw new InvalidOperationException(string.Format("Failed extend a published content of type {0}."
|
||||
+ "Got {1} when expecting {2}.", t.GetType().FullName, extend.GetType().FullName, typeof(T).FullName));
|
||||
_xContent[t] = extend;
|
||||
return extend;
|
||||
}
|
||||
|
||||
@@ -82,7 +76,7 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
var extend = MapContent(t);
|
||||
extend.SetIndex(index++);
|
||||
return extend /*.Content*/ as T; // fixme - cleanup
|
||||
return extend as T;
|
||||
}).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user