protected virtual Udi PathToUdi(string entityPath)
        {
            if (entityPath.IndexOf(':') == -1)
            {
                return(null);
            }

            var entityType = entityPath.Substring(0, entityPath.IndexOf(':'));
            var objectType = UdiEntityTypeHelper.ToUmbracoObjectType(entityType);

            var names = entityPath.Substring(entityPath.IndexOf(':') + 1).ToDelimitedList("/");

            int parentId = -1;

            IEntitySlim next = null;

            foreach (var name in names)
            {
                next = FindItem(parentId, name, objectType);
                if (next == null)
                {
                    return(null);
                }

                parentId = next.Id;
            }

            if (next != null)
            {
                return(Udi.Create(entityType, next.Key));
            }


            return(null);
        }
Esempio n. 2
0
        public virtual IPublishedContent Get(Udi udi)
        {
            var guidUdi = udi as GuidUdi;

            if (guidUdi == null)
            {
                return(null);
            }

            var umbracoType = UdiEntityTypeHelper.ToUmbracoObjectType(udi.EntityType);

            var entityService = Current.Services.EntityService;

            switch (umbracoType)
            {
            case UmbracoObjectTypes.Member:
                // TODO: need to implement Get(guid)!
                var memberAttempt = entityService.GetId(guidUdi.Guid, umbracoType);
                if (memberAttempt.Success)
                {
                    return(GetById(memberAttempt.Result));
                }
                break;
            }

            return(null);
        }
Esempio n. 3
0
 public static UmbracoObjectTypes ToUmbracoObjectType(string entityType)
 {
     try
     {
         return(UdiEntityTypeHelper.ToUmbracoObjectType(entityType));
     }
     catch (NotSupportedException)
     {
         // this gets thrown, when its not a known type, but for
         // use we want to carry on with Unknown
         return(UmbracoObjectTypes.Unknown);
     }
 }