2013-10-11 10:28:16 +02:00
|
|
|
|
// ENABLE THE FIX in 7.0.0
|
|
|
|
|
|
// TODO if all goes well, remove the obsolete code eventually
|
|
|
|
|
|
#define FIX_GET_PROPERTY_VALUE
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
using System;
|
2012-10-04 01:31:08 +05:00
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
using System.Collections.Generic;
|
2013-05-07 18:56:24 -10:00
|
|
|
|
using System.Diagnostics;
|
2012-10-04 01:31:08 +05:00
|
|
|
|
using System.Dynamic;
|
|
|
|
|
|
using System.Linq;
|
2013-09-05 17:47:13 +02:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2012-10-04 01:31:08 +05:00
|
|
|
|
using System.Web;
|
|
|
|
|
|
using Umbraco.Core.Dynamics;
|
|
|
|
|
|
using Umbraco.Core.Models;
|
|
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
using System.Reflection;
|
2013-09-05 17:47:13 +02:00
|
|
|
|
using Umbraco.Core.Models.PublishedContent;
|
2013-10-03 17:52:14 +02:00
|
|
|
|
using Umbraco.Core.Strings;
|
2012-10-04 05:40:03 -02:00
|
|
|
|
using ContentType = umbraco.cms.businesslogic.ContentType;
|
2012-10-04 01:31:08 +05:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Models
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The base dynamic model for views
|
|
|
|
|
|
/// </summary>
|
2013-05-07 18:56:24 -10:00
|
|
|
|
[DebuggerDisplay("Content Id: {Id}, Name: {Name}")]
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public class DynamicPublishedContent : DynamicObject, IPublishedContent
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-03-02 01:02:38 +06:00
|
|
|
|
protected internal IPublishedContent PublishedContent { get; private set; }
|
2013-09-17 18:15:19 +02:00
|
|
|
|
private DynamicPublishedContentList _contentList;
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2013-09-17 18:15:19 +02:00
|
|
|
|
// must implement that one if we implement IPublishedContent
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public IEnumerable<IPublishedContent> ContentSet
|
|
|
|
|
|
{
|
2013-09-17 18:15:19 +02:00
|
|
|
|
// that is a definitively non-efficient way of doing it, though it should work
|
|
|
|
|
|
get { return _contentList ?? (_contentList = new DynamicPublishedContentList(PublishedContent.ContentSet)); }
|
2013-09-05 17:47:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PublishedContentType ContentType { get { return PublishedContent.ContentType; } }
|
|
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent(IPublishedContent content)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (content == null) throw new ArgumentNullException("content");
|
|
|
|
|
|
PublishedContent = content;
|
2013-09-17 18:15:19 +02:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2013-09-17 18:15:19 +02:00
|
|
|
|
internal DynamicPublishedContent(IPublishedContent content, DynamicPublishedContentList contentList)
|
|
|
|
|
|
{
|
|
|
|
|
|
PublishedContent = content;
|
|
|
|
|
|
_contentList = contentList;
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
// these two here have leaked in v6 and so we cannot remove them anymore
|
|
|
|
|
|
// without breaking compatibility but... TODO: remove them in v7
|
|
|
|
|
|
public DynamicPublishedContentList ChildrenAsList { get { return Children; } }
|
|
|
|
|
|
public int parentId { get { return PublishedContent.Parent.Id; } }
|
2013-03-02 01:02:38 +06:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#region DynamicObject
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
private readonly ConcurrentDictionary<string, object> _cachedMemberOutput = new ConcurrentDictionary<string, object>();
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
/// <summary>
|
2012-10-04 03:26:56 +05:00
|
|
|
|
/// Attempts to call a method on the dynamic object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="binder"></param>
|
|
|
|
|
|
/// <param name="args"></param>
|
|
|
|
|
|
/// <param name="result"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
|
|
|
|
|
|
{
|
2012-11-18 10:28:53 +05:00
|
|
|
|
var attempt = DynamicInstanceHelper.TryInvokeMember(this, binder, args, new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
typeof(DynamicPublishedContent)
|
|
|
|
|
|
});
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2012-11-18 10:28:53 +05:00
|
|
|
|
if (attempt.Success)
|
2012-10-04 03:26:56 +05:00
|
|
|
|
{
|
2012-11-18 10:28:53 +05:00
|
|
|
|
result = attempt.Result.ObjectResult;
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2012-11-18 10:28:53 +05:00
|
|
|
|
//need to check the return type and possibly cast if result is from an extension method found
|
|
|
|
|
|
if (attempt.Result.Reason == DynamicInstanceHelper.TryInvokeMemberSuccessReason.FoundExtensionMethod)
|
|
|
|
|
|
{
|
2012-11-19 05:47:34 +05:00
|
|
|
|
//we don't need to cast if it is already DynamicPublishedContent
|
|
|
|
|
|
if (attempt.Result.ObjectResult != null && (!(attempt.Result.ObjectResult is DynamicPublishedContent)))
|
2012-10-04 03:26:56 +05:00
|
|
|
|
{
|
2012-11-18 10:28:53 +05:00
|
|
|
|
if (attempt.Result.ObjectResult is IPublishedContent)
|
|
|
|
|
|
{
|
|
|
|
|
|
result = new DynamicPublishedContent((IPublishedContent)attempt.Result.ObjectResult);
|
|
|
|
|
|
}
|
2012-11-19 05:47:34 +05:00
|
|
|
|
else if (attempt.Result.ObjectResult is IEnumerable<DynamicPublishedContent>)
|
|
|
|
|
|
{
|
|
|
|
|
|
result = new DynamicPublishedContentList((IEnumerable<DynamicPublishedContent>)attempt.Result.ObjectResult);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (attempt.Result.ObjectResult is IEnumerable<IPublishedContent>)
|
2012-11-18 10:28:53 +05:00
|
|
|
|
{
|
|
|
|
|
|
result = new DynamicPublishedContentList((IEnumerable<IPublishedContent>)attempt.Result.ObjectResult);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2012-11-18 10:28:53 +05:00
|
|
|
|
return true;
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-18 10:28:53 +05:00
|
|
|
|
//this is the result of an extension method execution gone wrong so we return dynamic null
|
2013-09-17 18:15:19 +02:00
|
|
|
|
if (attempt.Result != null
|
|
|
|
|
|
&& attempt.Result.Reason == DynamicInstanceHelper.TryInvokeMemberSuccessReason.FoundExtensionMethod
|
|
|
|
|
|
&& attempt.Exception is TargetInvocationException)
|
2012-10-04 03:26:56 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
result = DynamicNull.Null;
|
2012-11-18 10:28:53 +05:00
|
|
|
|
return true;
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2012-11-18 10:28:53 +05:00
|
|
|
|
|
|
|
|
|
|
result = null;
|
|
|
|
|
|
return false;
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Attempts to return a custom member (generally based on a string match)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="binder"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
protected virtual Attempt<object> TryGetCustomMember(GetMemberBinder binder)
|
|
|
|
|
|
{
|
2013-09-17 18:15:19 +02:00
|
|
|
|
// as of 4.5 the CLR is case-sensitive which means that the default binder
|
|
|
|
|
|
// will handle those methods only when using the proper casing. So what
|
|
|
|
|
|
// this method does is ensure that any casing is supported.
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
if (binder.Name.InvariantEquals("ChildrenAsList") || binder.Name.InvariantEquals("Children"))
|
|
|
|
|
|
{
|
2013-09-11 08:22:28 +02:00
|
|
|
|
return Attempt<object>.Succeed(Children);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (binder.Name.InvariantEquals("parentId"))
|
|
|
|
|
|
{
|
|
|
|
|
|
var parent = ((IPublishedContent) this).Parent;
|
|
|
|
|
|
if (parent == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new InvalidOperationException(string.Format("The node {0} does not have a parent", Id));
|
|
|
|
|
|
}
|
2013-09-11 08:22:28 +02:00
|
|
|
|
return Attempt<object>.Succeed(parent.Id);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2013-09-17 18:15:19 +02:00
|
|
|
|
|
2013-09-04 17:14:06 +02:00
|
|
|
|
return Attempt<object>.Fail();
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Attempts to return the children by the document type's alias (for example: CurrentPage.NewsItems where NewsItem is the
|
|
|
|
|
|
/// document type alias)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="binder"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// This method will work by both the plural and non-plural alias (i.e. NewsItem and NewsItems)
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
protected virtual Attempt<object> TryGetChildrenByAlias(GetMemberBinder binder)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var filteredTypeChildren = PublishedContent.Children
|
|
|
|
|
|
.Where(x => x.DocumentTypeAlias.InvariantEquals(binder.Name) || x.DocumentTypeAlias.MakePluralName().InvariantEquals(binder.Name))
|
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
if (filteredTypeChildren.Any())
|
|
|
|
|
|
{
|
2013-09-11 08:22:28 +02:00
|
|
|
|
return Attempt<object>.Succeed(
|
2012-10-04 03:26:56 +05:00
|
|
|
|
new DynamicPublishedContentList(filteredTypeChildren.Select(x => new DynamicPublishedContent(x))));
|
|
|
|
|
|
}
|
2013-09-04 17:14:06 +02:00
|
|
|
|
return Attempt<object>.Fail();
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2012-10-04 01:31:08 +05:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Attempts to return a member based on the reflected document property
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="binder"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
protected virtual Attempt<object> TryGetDocumentProperty(GetMemberBinder binder)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2012-10-04 03:26:56 +05:00
|
|
|
|
var reflectedProperty = GetReflectedProperty(binder.Name);
|
|
|
|
|
|
var result = reflectedProperty != null
|
2013-09-25 12:53:47 +02:00
|
|
|
|
? reflectedProperty.Value
|
2012-10-04 03:26:56 +05:00
|
|
|
|
: null;
|
|
|
|
|
|
|
2013-09-04 17:14:06 +02:00
|
|
|
|
return Attempt.If(result != null, result);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2012-10-04 03:26:56 +05:00
|
|
|
|
/// Attempts to return a member based on a user defined umbraco property
|
2012-10-04 01:31:08 +05:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="binder"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2012-10-04 03:26:56 +05:00
|
|
|
|
protected virtual Attempt<object> TryGetUserProperty(GetMemberBinder binder)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
|
|
|
|
|
var name = binder.Name;
|
2013-09-05 17:47:13 +02:00
|
|
|
|
var recurse = false;
|
2012-10-04 01:31:08 +05:00
|
|
|
|
if (name.StartsWith("_"))
|
|
|
|
|
|
{
|
|
|
|
|
|
name = name.Substring(1, name.Length - 1);
|
2013-09-05 17:47:13 +02:00
|
|
|
|
recurse = true;
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
var value = PublishedContent.GetPropertyValue(name, recurse);
|
|
|
|
|
|
return Attempt<object>.SucceedIf(value != null, value);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns the member match methods in the correct order and is used in the TryGetMember method.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
protected virtual IEnumerable<Func<GetMemberBinder, Attempt<object>>> GetMemberMatchMethods()
|
|
|
|
|
|
{
|
|
|
|
|
|
var memberMatchMethods = new List<Func<GetMemberBinder, Attempt<object>>>
|
|
|
|
|
|
{
|
|
|
|
|
|
TryGetCustomMember, //match custom members
|
|
|
|
|
|
TryGetUserProperty, //then match custom user defined umbraco properties
|
|
|
|
|
|
TryGetChildrenByAlias, //then try to match children based on doc type alias
|
|
|
|
|
|
TryGetDocumentProperty //then try to match on a reflected document property
|
|
|
|
|
|
};
|
|
|
|
|
|
return memberMatchMethods;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Try to return an object based on the dynamic member accessor
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="binder"></param>
|
|
|
|
|
|
/// <param name="result"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// TODO: SD: This will alwasy return true so that no exceptions are generated, this is only because this is how the
|
|
|
|
|
|
/// old DynamicNode worked, I'm not sure if this is the correct/expected functionality but I've left it like that.
|
|
|
|
|
|
/// IMO I think this is incorrect and it would be better to throw an exception for something that is not supported!
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
public override bool TryGetMember(GetMemberBinder binder, out object result)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (binder == null) throw new ArgumentNullException("binder");
|
|
|
|
|
|
|
|
|
|
|
|
var name = binder.Name;
|
|
|
|
|
|
|
|
|
|
|
|
//check the cache first!
|
|
|
|
|
|
if (_cachedMemberOutput.TryGetValue(name, out result))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//loop through each member match method and execute it.
|
|
|
|
|
|
//If it is successful, cache the result and return it.
|
|
|
|
|
|
foreach (var attempt in GetMemberMatchMethods()
|
|
|
|
|
|
.Select(m => m(binder))
|
|
|
|
|
|
.Where(attempt => attempt.Success))
|
|
|
|
|
|
{
|
|
|
|
|
|
result = attempt.Result;
|
|
|
|
|
|
//cache the result so we don't have to re-process the whole thing
|
|
|
|
|
|
_cachedMemberOutput.TryAdd(name, result);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//if property access, type lookup and member invoke all failed
|
|
|
|
|
|
//at this point, we're going to return null
|
|
|
|
|
|
//instead, we return a DynamicNull - see comments in that file
|
|
|
|
|
|
//this will let things like Model.ChildItem work and return nothing instead of crashing
|
|
|
|
|
|
|
|
|
|
|
|
//.Where explictly checks for this type
|
|
|
|
|
|
//and will make it false
|
|
|
|
|
|
//which means backwards equality (&& property != true) will pass
|
|
|
|
|
|
//forwwards equality (&& property or && property == true) will fail
|
2013-09-05 17:47:13 +02:00
|
|
|
|
result = DynamicNull.Null;
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
|
|
|
|
|
//alwasy return true if we haven't thrown an exception though I'm wondering if we return 'false' if .Net throws an exception for us??
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns a property defined on the document object as a member property using reflection
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="alias"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private PropertyResult GetReflectedProperty(string alias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetPropertyInternal(alias, PublishedContent, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Return a user defined property
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="alias"></param>
|
|
|
|
|
|
/// <param name="recursive"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
internal PropertyResult GetUserProperty(string alias, bool recursive = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!recursive)
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetPropertyInternal(alias, PublishedContent);
|
|
|
|
|
|
}
|
|
|
|
|
|
var context = this;
|
|
|
|
|
|
var prop = GetPropertyInternal(alias, PublishedContent);
|
2013-02-18 13:22:12 -01:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
while (prop == null || !prop.HasValue)
|
2012-10-04 03:26:56 +05:00
|
|
|
|
{
|
|
|
|
|
|
var parent = ((IPublishedContent) context).Parent;
|
|
|
|
|
|
if (parent == null) break;
|
2013-02-18 13:22:12 -01:00
|
|
|
|
|
|
|
|
|
|
// Update the context before attempting to retrieve the property again.
|
2013-09-05 17:47:13 +02:00
|
|
|
|
context = parent.AsDynamicOrNull();
|
2012-10-04 03:26:56 +05:00
|
|
|
|
prop = context.GetPropertyInternal(alias, context.PublishedContent);
|
|
|
|
|
|
}
|
2013-02-18 13:22:12 -01:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
return prop;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private PropertyResult GetPropertyInternal(string alias, IPublishedContent content, bool checkUserProperty = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (alias.IsNullOrWhiteSpace()) throw new ArgumentNullException("alias");
|
|
|
|
|
|
if (content == null) throw new ArgumentNullException("content");
|
|
|
|
|
|
|
|
|
|
|
|
//if we're looking for a user defined property
|
|
|
|
|
|
if (checkUserProperty)
|
|
|
|
|
|
{
|
|
|
|
|
|
var prop = content.GetProperty(alias);
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
// get wrap the result in a PropertyResult - just so it's an IHtmlString - ?!
|
|
|
|
|
|
return prop == null
|
|
|
|
|
|
? null
|
|
|
|
|
|
: new PropertyResult(prop, PropertyResultType.UserProperty);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//reflect
|
|
|
|
|
|
|
2013-09-17 18:15:19 +02:00
|
|
|
|
// as of 4.5 the CLR is case-sensitive which means that the default binder
|
|
|
|
|
|
// can handle properties only when using the proper casing. So what this
|
|
|
|
|
|
// does is ensure that any casing is supported.
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2014-03-11 14:23:51 +11:00
|
|
|
|
var attempt = content.GetType().GetMemberIgnoreCase(content, alias);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2014-03-11 17:26:14 +11:00
|
|
|
|
return attempt.Success == false || attempt.Result == null
|
2013-09-05 17:47:13 +02:00
|
|
|
|
? null
|
2013-09-23 21:57:22 +02:00
|
|
|
|
: new PropertyResult(alias, attempt.Result, PropertyResultType.ReflectedProperty);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Explicit IPublishedContent implementation
|
|
|
|
|
|
|
|
|
|
|
|
IPublishedContent IPublishedContent.Parent
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Parent; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int IPublishedContent.Id
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Id; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int IPublishedContent.TemplateId
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.TemplateId; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int IPublishedContent.SortOrder
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.SortOrder; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string IPublishedContent.Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Name; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string IPublishedContent.UrlName
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.UrlName; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string IPublishedContent.DocumentTypeAlias
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.DocumentTypeAlias; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int IPublishedContent.DocumentTypeId
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.DocumentTypeId; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string IPublishedContent.WriterName
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.WriterName; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string IPublishedContent.CreatorName
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.CreatorName; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int IPublishedContent.WriterId
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.WriterId; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int IPublishedContent.CreatorId
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.CreatorId; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string IPublishedContent.Path
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Path; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DateTime IPublishedContent.CreateDate
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.CreateDate; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DateTime IPublishedContent.UpdateDate
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.UpdateDate; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Guid IPublishedContent.Version
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Version; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int IPublishedContent.Level
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Level; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IPublishedContent.IsDraft
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.IsDraft; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int IPublishedContent.GetIndex()
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetIndex();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ICollection<IPublishedProperty> IPublishedContent.Properties
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Properties; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<IPublishedContent> IPublishedContent.Children
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Children; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IPublishedProperty IPublishedContent.GetProperty(string alias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetProperty(alias);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region IPublishedContent implementation
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
|
|
|
|
|
public int TemplateId
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.TemplateId; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int SortOrder
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.SortOrder; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Name; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string UrlName
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.UrlName; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string DocumentTypeAlias
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.DocumentTypeAlias; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string WriterName
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.WriterName; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string CreatorName
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.CreatorName; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int WriterId
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.WriterId; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int CreatorId
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.CreatorId; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string Path
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Path; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DateTime CreateDate
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.CreateDate; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int Id
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Id; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DateTime UpdateDate
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.UpdateDate; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Guid Version
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Version; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int Level
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Level; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-12-09 03:22:11 +05:00
|
|
|
|
public string Url
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Url; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PublishedItemType ItemType
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.ItemType; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
// see note in IPublishedContent
|
|
|
|
|
|
//public bool Published
|
|
|
|
|
|
//{
|
|
|
|
|
|
// get { return PublishedContent.Published; }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<IPublishedProperty> Properties
|
2012-10-04 03:26:56 +05:00
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.Properties; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-12-09 03:22:11 +05:00
|
|
|
|
public object this[string propertyAlias]
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent[propertyAlias]; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#endregion
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#region GetProperty
|
2012-10-18 08:00:07 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
// enhanced versions of the extension methods that exist for IPublishedContent,
|
|
|
|
|
|
// here we support the recursive (_) and reflected (@) syntax
|
2012-10-18 08:00:07 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public IPublishedProperty GetProperty(string alias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return alias.StartsWith("_")
|
|
|
|
|
|
? GetProperty(alias.Substring(1), true)
|
|
|
|
|
|
: GetProperty(alias, false);
|
|
|
|
|
|
}
|
2012-10-18 08:00:07 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public IPublishedProperty GetProperty(string alias, bool recurse)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (alias.StartsWith("@")) return GetReflectedProperty(alias.Substring(1));
|
2012-10-18 08:00:07 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
// get wrap the result in a PropertyResult - just so it's an IHtmlString - ?!
|
|
|
|
|
|
var property = PublishedContent.GetProperty(alias, recurse);
|
|
|
|
|
|
return property == null ? null : new PropertyResult(property, PropertyResultType.UserProperty);
|
|
|
|
|
|
}
|
2012-10-18 08:00:07 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#endregion
|
2012-10-18 08:00:07 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
// IPublishedContent extension methods:
|
|
|
|
|
|
//
|
|
|
|
|
|
// all these methods are IPublishedContent extension methods so they should in
|
|
|
|
|
|
// theory apply to DynamicPublishedContent since it is an IPublishedContent and
|
|
|
|
|
|
// we look for extension methods. But that lookup has to be pretty slow.
|
|
|
|
|
|
// Duplicating the methods here makes things much faster.
|
2012-10-18 08:00:07 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#region IPublishedContent extension methods - Template
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public string GetTemplateAlias()
|
2012-10-04 03:26:56 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContentExtensions.GetTemplateAlias(this);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#region IPublishedContent extension methods - HasProperty
|
|
|
|
|
|
|
|
|
|
|
|
public bool HasProperty(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.HasProperty(name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region IPublishedContent extension methods - HasValue
|
|
|
|
|
|
|
|
|
|
|
|
public bool HasValue(string alias)
|
2012-10-04 03:26:56 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.HasValue(alias);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public bool HasValue(string alias, bool recursive)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.HasValue(alias, recursive);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public IHtmlString HasValue(string alias, string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.HasValue(alias, valueIfTrue, valueIfFalse);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public IHtmlString HasValue(string alias, bool recursive, string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.HasValue(alias, recursive, valueIfTrue, valueIfFalse);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public IHtmlString HasValue(string alias, string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.HasValue(alias, valueIfTrue);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public IHtmlString HasValue(string alias, bool recursive, string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.HasValue(alias, recursive, valueIfTrue);
|
2012-10-04 03:26:56 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#region IPublishedContent extension methods - GetPropertyValue
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
// for whatever reason, some methods returning strings were created in DynamicPublishedContent
|
|
|
|
|
|
// and are now considered a "feature" as of v6. So we can't have the proper GetPropertyValue
|
|
|
|
|
|
// methods returning objects, too. And we don't want to change it in v6 as that would be a
|
|
|
|
|
|
// breaking change.
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#if FIX_GET_PROPERTY_VALUE
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public object GetPropertyValue(string alias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetPropertyValue(alias);
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public object GetPropertyValue(string alias, string defaultValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetPropertyValue(alias, defaultValue);
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public object GetPropertyValue(string alias, object defaultValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetPropertyValue(alias, defaultValue);
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public object GetPropertyValue(string alias, bool recurse)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetPropertyValue(alias, recurse);
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public object GetPropertyValue(string alias, bool recurse, object defaultValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetPropertyValue(alias, recurse, defaultValue);
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#else
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public string GetPropertyValue(string alias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetPropertyValue(alias, false);
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public string GetPropertyValue(string alias, string defaultValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
var value = GetPropertyValue(alias);
|
|
|
|
|
|
return value.IsNullOrWhiteSpace() ? defaultValue : value;
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public string GetPropertyValue(string alias, bool recurse, string defaultValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
var value = GetPropertyValue(alias, recurse);
|
|
|
|
|
|
return value.IsNullOrWhiteSpace() ? defaultValue : value;
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public string GetPropertyValue(string alias, bool recursive)
|
|
|
|
|
|
{
|
|
|
|
|
|
var property = GetProperty(alias, recursive);
|
2013-09-25 12:53:47 +02:00
|
|
|
|
if (property == null || property.Value == null) return null;
|
|
|
|
|
|
return property.Value.ToString();
|
2013-09-05 17:47:13 +02:00
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#endif
|
2012-10-04 01:31:08 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#endregion
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#region IPublishedContent extension methods - GetPropertyValue<T>
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public T GetPropertyValue<T>(string alias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetPropertyValue<T>(alias);
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public T GetPropertyValue<T>(string alias, T defaultValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetPropertyValue(alias, defaultValue);
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public T GetPropertyValue<T>(string alias, bool recurse)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetPropertyValue<T>(alias, recurse);
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public T GetPropertyValue<T>(string alias, bool recurse, T defaultValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetPropertyValue(alias, recurse, defaultValue);
|
|
|
|
|
|
}
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#endregion
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#region IPublishedContent extension methods - Search
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList Search(string term, bool useWildCards = true, string searchProvider = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.Search(term, useWildCards, searchProvider));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList SearchDescendants(string term, bool useWildCards = true, string searchProvider = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.SearchDescendants(term, useWildCards, searchProvider));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList SearchChildren(string term, bool useWildCards = true, string searchProvider = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.SearchChildren(term, useWildCards, searchProvider));
|
|
|
|
|
|
}
|
2012-10-04 01:31:08 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public DynamicPublishedContentList Search(Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.Search(criteria, searchProvider));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2012-10-04 01:31:08 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#region IPublishedContent extension methods - AsDynamic
|
|
|
|
|
|
|
|
|
|
|
|
public dynamic AsDynamic()
|
|
|
|
|
|
{
|
|
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public dynamic AsDynamicOrNull()
|
|
|
|
|
|
{
|
|
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region IPublishedContente extension methods - ContentSet
|
|
|
|
|
|
|
|
|
|
|
|
public int Position()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Index();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int Index()
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.GetIndex();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region IPublishedContent extension methods - IsSomething: misc
|
|
|
|
|
|
|
|
|
|
|
|
public bool Visible
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return PublishedContent.IsVisible(); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsVisible()
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.IsVisible();
|
|
|
|
|
|
}
|
2012-10-06 23:41:42 +05:00
|
|
|
|
|
|
|
|
|
|
public bool IsDocumentType(string docTypeAlias)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsDocumentType(docTypeAlias);
|
2012-10-06 23:41:42 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public bool IsNull(string alias, bool recursive)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNull(alias, recursive);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public bool IsNull(string alias)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNull(alias, false);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region IPublishedContent extension methods - IsSomething: position in set
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsFirst()
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsFirst();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsFirst(string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsFirst(valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsFirst(string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsFirst(valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public bool IsNotFirst()
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotFirst();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsNotFirst(string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotFirst(valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsNotFirst(string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotFirst(valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public bool IsPosition(int index)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsPosition(index);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsPosition(int index, string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsPosition(index, valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsPosition(int index, string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsPosition(index, valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public bool IsModZero(int modulus)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsModZero(modulus);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsModZero(int modulus, string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsModZero(modulus, valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsModZero(int modulus, string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsModZero(modulus, valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsNotModZero(int modulus)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotModZero(modulus);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsNotModZero(int modulus, string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotModZero(modulus, valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsNotModZero(int modulus, string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotModZero(modulus, valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public bool IsNotPosition(int index)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotPosition(index);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsNotPosition(int index, string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotPosition(index, valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsNotPosition(int index, string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotPosition(index, valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public bool IsLast()
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsLast();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsLast(string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsLast(valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsLast(string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsLast(valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public bool IsNotLast()
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotLast();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsNotLast(string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotLast(valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsNotLast(string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotLast(valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public bool IsEven()
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsEven();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsEven(string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsEven(valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsEven(string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsEven(valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public bool IsOdd()
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsOdd();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsOdd(string valueIfTrue)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsOdd(valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public HtmlString IsOdd(string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsOdd(valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region IPublishedContent extension methods - IsSomething: equality
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsEqual(DynamicPublishedContent other)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsEqual(other);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsEqual(DynamicPublishedContent other, string valueIfTrue)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsEqual(other, valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsEqual(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsEqual(other, valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public bool IsNotEqual(DynamicPublishedContent other)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotEqual(other);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsNotEqual(DynamicPublishedContent other, string valueIfTrue)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotEqual(other, valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsNotEqual(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsNotEqual(other, valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region IPublishedContent extension methods - IsSomething: ancestors and descendants
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsDescendant(DynamicPublishedContent other)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsDescendant(other);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsDescendant(DynamicPublishedContent other, string valueIfTrue)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsDescendant(other, valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsDescendant(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsDescendant(other, valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public bool IsDescendantOrSelf(DynamicPublishedContent other)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsDescendantOrSelf(other);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsDescendantOrSelf(DynamicPublishedContent other, string valueIfTrue)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsDescendantOrSelf(other, valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsDescendantOrSelf(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsDescendantOrSelf(other, valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public bool IsAncestor(DynamicPublishedContent other)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsAncestor(other);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsAncestor(DynamicPublishedContent other, string valueIfTrue)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsAncestor(other, valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsAncestor(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsAncestor(other, valueIfTrue, valueIfFalse);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public bool IsAncestorOrSelf(DynamicPublishedContent other)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsAncestorOrSelf(other);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsAncestorOrSelf(DynamicPublishedContent other, string valueIfTrue)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsAncestorOrSelf(other, valueIfTrue);
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 03:26:56 +05:00
|
|
|
|
public HtmlString IsAncestorOrSelf(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.IsAncestorOrSelf(other, valueIfTrue, valueIfFalse);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
// all these methods wrap whatever PublishedContent returns in a new
|
|
|
|
|
|
// DynamicPublishedContentList, for dynamic usage.
|
|
|
|
|
|
|
|
|
|
|
|
#region Ancestors
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList Ancestors(int level)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.Ancestors(level));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList Ancestors(string contentTypeAlias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.Ancestors(contentTypeAlias));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList Ancestors()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.Ancestors());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList Ancestors(Func<IPublishedContent, bool> func)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.AncestorsOrSelf(false, func));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent AncestorOrSelf()
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.AncestorOrSelf().AsDynamicOrNull();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent AncestorOrSelf(int level)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.AncestorOrSelf(level).AsDynamicOrNull();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-06-08 18:09:29 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A shortcut method for AncestorOrSelf(1)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// The site homepage
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
public DynamicPublishedContent Site()
|
|
|
|
|
|
{
|
|
|
|
|
|
return AncestorOrSelf(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public DynamicPublishedContent AncestorOrSelf(string contentTypeAlias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.AncestorOrSelf(contentTypeAlias).AsDynamicOrNull();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent AncestorOrSelf(Func<IPublishedContent, bool> func)
|
|
|
|
|
|
{
|
|
|
|
|
|
return PublishedContent.AncestorsOrSelf(true, func).FirstOrDefault().AsDynamicOrNull();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList AncestorsOrSelf(Func<IPublishedContent, bool> func)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.AncestorsOrSelf(true, func));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList AncestorsOrSelf()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.AncestorsOrSelf());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList AncestorsOrSelf(string contentTypeAlias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.AncestorsOrSelf(contentTypeAlias));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList AncestorsOrSelf(int level)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.AncestorsOrSelf(level));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Descendants
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContentList Descendants(string contentTypeAlias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.Descendants(contentTypeAlias));
|
|
|
|
|
|
}
|
|
|
|
|
|
public DynamicPublishedContentList Descendants(int level)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.Descendants(level));
|
|
|
|
|
|
}
|
|
|
|
|
|
public DynamicPublishedContentList Descendants()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.Descendants());
|
|
|
|
|
|
}
|
|
|
|
|
|
public DynamicPublishedContentList DescendantsOrSelf(int level)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.DescendantsOrSelf(level));
|
|
|
|
|
|
}
|
|
|
|
|
|
public DynamicPublishedContentList DescendantsOrSelf(string contentTypeAlias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.DescendantsOrSelf(contentTypeAlias));
|
|
|
|
|
|
}
|
|
|
|
|
|
public DynamicPublishedContentList DescendantsOrSelf()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DynamicPublishedContentList(PublishedContent.DescendantsOrSelf());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Traversal
|
|
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public DynamicPublishedContent Up()
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Up().AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public DynamicPublishedContent Up(int number)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Up(number).AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent Up(string contentTypeAlias)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Up(contentTypeAlias).AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public DynamicPublishedContent Down()
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Down().AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public DynamicPublishedContent Down(int number)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Down(number).AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent Down(string contentTypeAlias)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Down(contentTypeAlias).AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public DynamicPublishedContent Next()
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Next().AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public DynamicPublishedContent Next(int number)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Next(number).AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent Next(string contentTypeAlias)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Next(contentTypeAlias).AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent Previous()
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Previous().AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public DynamicPublishedContent Previous(int number)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Previous(number).AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent Previous(string contentTypeAlias)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Previous(contentTypeAlias).AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public DynamicPublishedContent Sibling(int number)
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Previous(number).AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public DynamicPublishedContent Sibling(string contentTypeAlias)
|
2012-10-04 01:31:08 +05:00
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Previous(contentTypeAlias).AsDynamicOrNull();
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#region Parent
|
|
|
|
|
|
|
2012-10-04 01:31:08 +05:00
|
|
|
|
public DynamicPublishedContent Parent
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2013-09-05 17:47:13 +02:00
|
|
|
|
return PublishedContent.Parent != null ? PublishedContent.Parent.AsDynamicOrNull() : null;
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
#region Children
|
|
|
|
|
|
|
|
|
|
|
|
// we want to cache the dynamic list of children here
|
|
|
|
|
|
// whether PublishedContent.Children itself is cached, is not our concern
|
|
|
|
|
|
|
|
|
|
|
|
private DynamicPublishedContentList _children;
|
2012-10-04 03:26:56 +05:00
|
|
|
|
|
2013-09-05 17:47:13 +02:00
|
|
|
|
public DynamicPublishedContentList Children
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _children ?? (_children = new DynamicPublishedContentList(PublishedContent.Children)); }
|
|
|
|
|
|
}
|
2014-06-09 11:20:00 +02:00
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent FirstChild()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Children.FirstOrDefault<DynamicPublishedContent>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DynamicPublishedContent FirstChild(string alias)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Children.FirstOrDefault<IPublishedContent>(x => x.DocumentTypeAlias == alias) as DynamicPublishedContent;
|
|
|
|
|
|
}
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2013-09-17 18:15:19 +02:00
|
|
|
|
// should probably cleanup what's below
|
2013-09-05 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
#region Where
|
|
|
|
|
|
|
|
|
|
|
|
public HtmlString Where(string predicate, string valueIfTrue)
|
2012-10-04 03:26:56 +05:00
|
|
|
|
{
|
|
|
|
|
|
return Where(predicate, valueIfTrue, string.Empty);
|
|
|
|
|
|
}
|
|
|
|
|
|
public HtmlString Where(string predicate, string valueIfTrue, string valueIfFalse)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Where(predicate))
|
|
|
|
|
|
{
|
|
|
|
|
|
return new HtmlString(valueIfTrue);
|
|
|
|
|
|
}
|
|
|
|
|
|
return new HtmlString(valueIfFalse);
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool Where(string predicate)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Totally gonna cheat here
|
|
|
|
|
|
var dynamicDocumentList = new DynamicPublishedContentList();
|
|
|
|
|
|
dynamicDocumentList.Add(this);
|
|
|
|
|
|
var filtered = dynamicDocumentList.Where<DynamicPublishedContent>(predicate);
|
|
|
|
|
|
if (Queryable.Count(filtered) == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
//this node matches the predicate
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2013-09-05 17:47:13 +02:00
|
|
|
|
}
|
2012-10-04 01:31:08 +05:00
|
|
|
|
}
|