Created
April 4, 2013 09:44
-
-
Save mattbrailsford/5309142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class UmbracoHelperExtensions | |
{ | |
// These extensions methods are here to bypass an issue with Umbraco.TypedContent method | |
// wherby if an item is in the trashcan, a YSOD is thrown. The issue has been reported here | |
// http://issues.umbraco.org/issue/U4-1300 | |
// Once fixed, any uses of TypeContent2 can just be replaced with TypedContent calls | |
public static IEnumerable<IPublishedContent> TypedContent2(this UmbracoHelper helper, IEnumerable<string> ids) | |
{ | |
return helper.TypedContent2(ids.ToArray()); | |
} | |
public static IEnumerable<IPublishedContent> TypedContent2(this UmbracoHelper helper, IEnumerable<int> ids) | |
{ | |
return helper.TypedContent2(ids.ToArray()); | |
} | |
public static IEnumerable<IPublishedContent> TypedContent2(this UmbracoHelper helper, params string[] ids) | |
{ | |
int parsedId; | |
return helper.TypedContent2(ids.Select(x => int.TryParse(x, out parsedId) ? parsedId : 0).ToArray()); | |
} | |
public static IEnumerable<IPublishedContent> TypedContent2(this UmbracoHelper helper, params int[] ids) | |
{ | |
return ids.Select(helper.TypedContent) | |
.Select(tc => tc.GetType() == typeof(DynamicNull) ? null : tc); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment