コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public bool IsEqual(DynamicPublishedContent other)
 {
     return(this.PublishedContent.IsEqual(other));
 }
コード例 #5
0
 public HtmlString IsEqual(DynamicPublishedContent other, string valueIfTrue)
 {
     return(this.PublishedContent.IsEqual(other, valueIfTrue));
 }
コード例 #6
0
		public bool IsNotEqual(DynamicPublishedContent other)
		{
			return this.PublishedContent.IsNotEqual(other);
		}
コード例 #7
0
		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);
		}
コード例 #8
0
 public HtmlString IsDescendantOrSelf(DynamicPublishedContent other, string valueIfTrue)
 {
     return(PublishedContent.IsDescendantOrSelf(other, valueIfTrue));
 }
コード例 #9
0
 public bool IsAncestorOrSelf(DynamicPublishedContent other)
 {
     return(PublishedContent.IsAncestorOrSelf(other));
 }
コード例 #10
0
 public bool IsNotEqual(DynamicPublishedContent other)
 {
     return(PublishedContent.IsNotEqual(other));
 }
コード例 #11
0
		public bool IsDescendantOrSelf(DynamicPublishedContent other)
		{
			return this.PublishedContent.IsDescendantOrSelf(other);
		}
コード例 #12
0
		public HtmlString IsAncestorOrSelf(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
		{
			return this.PublishedContent.IsAncestorOrSelf(other, valueIfTrue, valueIfFalse);
		}		
コード例 #13
0
		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;
		}
コード例 #14
0
		public bool IsAncestorOrSelf(DynamicPublishedContent other)
		{
			return this.PublishedContent.IsAncestorOrSelf(other);
		}
コード例 #15
0
		public HtmlString IsAncestor(DynamicPublishedContent other, string valueIfTrue)
		{
			return this.PublishedContent.IsAncestor(other, valueIfTrue);
		}
コード例 #16
0
		public HtmlString IsDescendantOrSelf(DynamicPublishedContent other, string valueIfTrue)
		{
			return this.PublishedContent.IsDescendantOrSelf(other, valueIfTrue);
		}
コード例 #17
0
 public bool IsDescendant(DynamicPublishedContent other)
 {
     return(this.PublishedContent.IsDescendant(other));
 }
コード例 #18
0
 public HtmlString IsDescendant(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
 {
     return(PublishedContent.IsDescendant(other, valueIfTrue, valueIfFalse));
 }
コード例 #19
0
 public bool IsAncestor(DynamicPublishedContent other)
 {
     return(this.PublishedContent.IsAncestor(other));
 }
コード例 #20
0
		public HtmlString IsNotEqual(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
		{
			return this.PublishedContent.IsNotEqual(other, valueIfTrue, valueIfFalse);
		}
コード例 #21
0
 public HtmlString IsNotEqual(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
 {
     return(PublishedContent.IsNotEqual(other, valueIfTrue, valueIfFalse));
 }
コード例 #22
0
		public static dynamic AsDynamic(this IPublishedContent doc)
		{
			if (doc == null) throw new ArgumentNullException("doc");
			var dd = new DynamicPublishedContent(doc);
			return dd.AsDynamic();
		}
コード例 #23
0
 public bool IsDescendantOrSelf(DynamicPublishedContent other)
 {
     return(PublishedContent.IsDescendantOrSelf(other));
 }
コード例 #24
0
		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);
		}
コード例 #25
0
 public HtmlString IsAncestor(DynamicPublishedContent other, string valueIfTrue)
 {
     return(PublishedContent.IsAncestor(other, valueIfTrue));
 }
コード例 #26
0
		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);
		}
コード例 #27
0
 public HtmlString IsAncestorOrSelf(DynamicPublishedContent other, string valueIfTrue, string valueIfFalse)
 {
     return(PublishedContent.IsAncestorOrSelf(other, valueIfTrue, valueIfFalse));
 }
コード例 #28
0
ファイル: UmbracoCustom.cs プロジェクト: smashraid/Work
 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;
 }