/// <summary> /// 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) { var runtimeCache = ApplicationContext.Current != null ? ApplicationContext.Current.ApplicationCache.RuntimeCache : new NullCacheProvider(); var attempt = DynamicInstanceHelper.TryInvokeMember(runtimeCache, this, binder, args, new[] { typeof(DynamicPublishedContent) }); if (attempt.Success) { result = attempt.Result.ObjectResult; //need to check the return type and possibly cast if result is from an extension method found if (attempt.Result.Reason == DynamicInstanceHelper.TryInvokeMemberSuccessReason.FoundExtensionMethod) { //we don't need to cast if it is already DynamicPublishedContent if (attempt.Result.ObjectResult != null && (!(attempt.Result.ObjectResult is DynamicPublishedContent))) { if (attempt.Result.ObjectResult is IPublishedContent) { result = new DynamicPublishedContent((IPublishedContent)attempt.Result.ObjectResult); } else if (attempt.Result.ObjectResult is IEnumerable <DynamicPublishedContent> ) { result = new DynamicPublishedContentList((IEnumerable <DynamicPublishedContent>)attempt.Result.ObjectResult); } else if (attempt.Result.ObjectResult is IEnumerable <IPublishedContent> ) { result = new DynamicPublishedContentList((IEnumerable <IPublishedContent>)attempt.Result.ObjectResult); } } } return(true); } //this is the result of an extension method execution gone wrong so we return dynamic null if (attempt.Result != null && attempt.Result.Reason == DynamicInstanceHelper.TryInvokeMemberSuccessReason.FoundExtensionMethod && attempt.Exception is TargetInvocationException) { result = DynamicNull.Null; return(true); } result = null; return(false); }
/// <summary> /// Получить значение свойства глобальных настроек по его имени /// </summary> /// <param name="nameProperty">Имя свойства</param> /// <returns>Значение свойтсва</returns> public static string GetPropertyByName(string propertyName) { string propertyValue = ""; if(sysSiteSettings == null) { // переинициализация sysSiteSettings = umbraco.ContentSingleAtXPath(pathSysSiteSettings); } try { // возвращаем свойство propertyValue = sysSiteSettings.GetPropertyValue(propertyName).ToString(); } catch(Exception e) { Helper.LogError(e); throw; } return propertyValue; }
public override object GetData(ITabContext context) { var plugin = Plugin.Create("Function", "Param", "Type"); try { string url = System.Web.HttpContext.Current.Request.Url.AbsoluteUri; int NodeId = 0; if (System.Web.HttpContext.Current.Request["glimpse7GetCheatSheet"] == "true") { return(UmbracoFn.showMethods(typeof(DynamicPublishedContent))); } if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request["glimpse7GetContentById"])) { Int32.TryParse(System.Web.HttpContext.Current.Request["glimpse7GetContentById"], out NodeId); } else if (umbraco.presentation.UmbracoContext.Current.PageId != null) { NodeId = umbraco.presentation.UmbracoContext.Current.PageId.Value; } else { return(UmbracoFn.showMethodsValue(typeof(DynamicPublishedContent), "content")); } var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); IPublishedContent content = umbracoHelper.TypedContent(NodeId); var node = new Umbraco.Web.Models.DynamicPublishedContent(content); return(UmbracoFn.showMethodsValue(node, "content")); } catch (Exception ex) { plugin.AddRow().Column(umbraco.presentation.UmbracoContext.Current.PageId); } return(plugin); }
public bool IsEqual(DynamicPublishedContent other) { return(this.PublishedContent.IsEqual(other)); }
public HtmlString IsEqual(DynamicPublishedContent other, string valueIfTrue) { return(this.PublishedContent.IsEqual(other, valueIfTrue)); }
public bool IsNotEqual(DynamicPublishedContent other) { return this.PublishedContent.IsNotEqual(other); }
public static HtmlString IsAncestorOrSelf(this IPublishedContent content, DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { var descendants = content.DescendantsOrSelf(); return content.IsHelper(n => descendants.FirstOrDefault(descendant => descendant.Id == other.Id) != null, valueIfTrue, valueIfFalse); }
public HtmlString IsDescendantOrSelf(DynamicPublishedContent other, string valueIfTrue) { return(PublishedContent.IsDescendantOrSelf(other, valueIfTrue)); }
public bool IsAncestorOrSelf(DynamicPublishedContent other) { return(PublishedContent.IsAncestorOrSelf(other)); }
public bool IsNotEqual(DynamicPublishedContent other) { return(PublishedContent.IsNotEqual(other)); }
public bool IsDescendantOrSelf(DynamicPublishedContent other) { return this.PublishedContent.IsDescendantOrSelf(other); }
public HtmlString IsAncestorOrSelf(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { return this.PublishedContent.IsAncestorOrSelf(other, valueIfTrue, valueIfFalse); }
private object ExecuteExtensionMethod(object[] args, string name) { object result = null; var methodTypesToFind = new[] { typeof(DynamicPublishedContent) }; //find known extension methods that match the first type in the list MethodInfo toExecute = null; foreach (var t in methodTypesToFind) { toExecute = ExtensionMethodFinder.FindExtensionMethod(t, args, name, false); if (toExecute != null) break; } if (toExecute != null) { var genericArgs = (new[] { this }).Concat(args); result = toExecute.Invoke(null, genericArgs.ToArray()); } else { throw new MissingMethodException(); } if (result != null) { if (result is IPublishedContent) { result = new DynamicPublishedContent((IPublishedContent)result); } if (result is IEnumerable<IPublishedContent>) { result = new DynamicPublishedContentList((IEnumerable<IPublishedContent>)result); } if (result is IEnumerable<DynamicPublishedContent>) { result = new DynamicPublishedContentList((IEnumerable<DynamicPublishedContent>)result); } } return result; }
public bool IsAncestorOrSelf(DynamicPublishedContent other) { return this.PublishedContent.IsAncestorOrSelf(other); }
public HtmlString IsAncestor(DynamicPublishedContent other, string valueIfTrue) { return this.PublishedContent.IsAncestor(other, valueIfTrue); }
public HtmlString IsDescendantOrSelf(DynamicPublishedContent other, string valueIfTrue) { return this.PublishedContent.IsDescendantOrSelf(other, valueIfTrue); }
public bool IsDescendant(DynamicPublishedContent other) { return(this.PublishedContent.IsDescendant(other)); }
public HtmlString IsDescendant(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { return(PublishedContent.IsDescendant(other, valueIfTrue, valueIfFalse)); }
public bool IsAncestor(DynamicPublishedContent other) { return(this.PublishedContent.IsAncestor(other)); }
public HtmlString IsNotEqual(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { return this.PublishedContent.IsNotEqual(other, valueIfTrue, valueIfFalse); }
public HtmlString IsNotEqual(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { return(PublishedContent.IsNotEqual(other, valueIfTrue, valueIfFalse)); }
public static dynamic AsDynamic(this IPublishedContent doc) { if (doc == null) throw new ArgumentNullException("doc"); var dd = new DynamicPublishedContent(doc); return dd.AsDynamic(); }
public bool IsDescendantOrSelf(DynamicPublishedContent other) { return(PublishedContent.IsDescendantOrSelf(other)); }
public static HtmlString IsDescendantOrSelf(this IPublishedContent content, DynamicPublishedContent other, string valueIfTrue) { var ancestors = content.AncestorsOrSelf(); return content.IsHelper(n => ancestors.FirstOrDefault(ancestor => ancestor.Id == other.Id) != null, valueIfTrue); }
public HtmlString IsAncestor(DynamicPublishedContent other, string valueIfTrue) { return(PublishedContent.IsAncestor(other, valueIfTrue)); }
public static bool IsAncestorOrSelf(this IPublishedContent content, DynamicPublishedContent other) { var descendants = content.DescendantsOrSelf(); return content.IsHelper(n => descendants.FirstOrDefault(descendant => descendant.Id == other.Id) != null); }
public HtmlString IsAncestorOrSelf(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse) { return(PublishedContent.IsAncestorOrSelf(other, valueIfTrue, valueIfFalse)); }
public static string GetSliderUrl(DynamicPublishedContent image) { string result = string.Empty; IPublishedContentProperty externalUrlProperty = image.GetProperty("externalUrl"); if (externalUrlProperty != null) { result = externalUrlProperty.Value.ToString(); } IPublishedContentProperty internalUrlProperty = image.GetProperty("internalUrl"); if (internalUrlProperty != null) { if (internalUrlProperty.Value.ToString() != string.Empty) { result = new Document(Convert.ToInt32(internalUrlProperty.Value)).ToNode().NiceUrl; } } return result; }