private PropertyResult GetPropertyInternal(string alias, ExamineBackedMedia content)
        {
            bool propertyExists = false;
            var  prop           = content.GetProperty(alias, out propertyExists);

            if (prop != null)
            {
                return(new PropertyResult(prop)
                {
                    ContextAlias = content.NodeTypeAlias, ContextId = content.Id
                });
            }
            else
            {
                if (alias.Substring(0, 1).ToUpper() == alias.Substring(0, 1) && !propertyExists)
                {
                    prop = content.GetProperty(alias.Substring(0, 1).ToLower() + alias.Substring((1)), out propertyExists);
                    if (prop != null)
                    {
                        return(new PropertyResult(prop)
                        {
                            ContextAlias = content.NodeTypeAlias, ContextId = content.Id
                        });
                    }
                    else
                    {
                        object result = null;
                        try
                        {
                            result = content.GetType().InvokeMember(alias,
                                                                    System.Reflection.BindingFlags.GetProperty |
                                                                    System.Reflection.BindingFlags.Instance |
                                                                    System.Reflection.BindingFlags.Public |
                                                                    System.Reflection.BindingFlags.NonPublic,
                                                                    null,
                                                                    content,
                                                                    null);
                        }
                        catch (MissingMethodException)
                        {
                        }
                        if (result != null)
                        {
                            return(new PropertyResult(alias, string.Format("{0}", result), Guid.Empty)
                            {
                                ContextAlias = content.NodeTypeAlias, ContextId = content.Id
                            });
                        }
                    }
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        public PropertyResult GetProperty(string alias, out bool propertyExists)
        {
            if (IsNull())
            {
                propertyExists = false;
                return(null);
            }
            PropertyResult property      = null;
            IProperty      innerProperty = null;

            if (Type == DynamicBackingItemType.Content)
            {
                innerProperty = content.GetProperty(alias, out propertyExists);
                if (innerProperty != null)
                {
                    property = new PropertyResult(innerProperty);
                    property.ContextAlias = content.NodeTypeAlias;
                    property.ContextId    = content.Id;
                }
            }
            else
            {
                string[] internalProperties = new string[] {
                    "id", "nodeName", "updateDate", "writerName", "path", "nodeTypeAlias",
                    "parentID", "__NodeId", "__IndexType", "__Path", "__NodeTypeAlias",
                    "__nodeName", "umbracoBytes", "umbracoExtension", "umbracoFile", "umbracoWidth",
                    "umbracoHeight"
                };
                if (media.WasLoadedFromExamine && !internalProperties.Contains(alias) && !media.Values.ContainsKey(alias))
                {
                    //examine doesn't load custom properties
                    innerProperty = media.LoadCustomPropertyNotFoundInExamine(alias, out propertyExists);
                    if (innerProperty != null)
                    {
                        property = new PropertyResult(innerProperty);
                        property.ContextAlias = media.NodeTypeAlias;
                        property.ContextId    = media.Id;
                    }
                }
                else
                {
                    innerProperty = media.GetProperty(alias, out propertyExists);
                    if (innerProperty != null)
                    {
                        property = new PropertyResult(innerProperty);
                        property.ContextAlias = media.NodeTypeAlias;
                        property.ContextId    = media.Id;
                    }
                }
            }
            return(property);
        }
Exemplo n.º 3
0
 private PropertyResult GetPropertyInternal(string alias, ExamineBackedMedia content)
 {
     bool propertyExists = false;
     var prop = content.GetProperty(alias, out propertyExists);
     if (prop != null)
     {
         return new PropertyResult(prop) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id };
     }
     else
     {
         if (alias.Substring(0, 1).ToUpper() == alias.Substring(0, 1) && !propertyExists)
         {
             prop = content.GetProperty(alias.Substring(0, 1).ToLower() + alias.Substring((1)), out propertyExists);
             if (prop != null)
             {
                 return new PropertyResult(prop) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id };
             }
             else
             {
                 object result = null;
                 try
                 {
                     result = content.GetType().InvokeMember(alias,
                                               System.Reflection.BindingFlags.GetProperty |
                                               System.Reflection.BindingFlags.Instance |
                                               System.Reflection.BindingFlags.Public,
                                               null,
                                               content,
                                               null);
                 }
                 catch (MissingMethodException)
                 {
                 }
                 if (result != null)
                 {
                     return new PropertyResult(alias, string.Format("{0}", result)) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id };
                 }
             }
         }
     }
     return null;
 }