示例#1
0
        private MemberTypeAttribute CreateDefaultMemberTypeAttribute(Type typeMemberType)
        {
            MemberTypeAttribute retVal = new MemberTypeAttribute();

            retVal.Name      = typeMemberType.Name;
            retVal.IconUrl   = DocumentTypeDefaultValues.IconUrl;
            retVal.Thumbnail = DocumentTypeDefaultValues.Thumbnail;

            return(retVal);
        }
示例#2
0
        /// <summary>
        /// Get's the member type attribute or returns attribute with default values if attribute is not found
        /// </summary>
        /// <param name="typeMemberType">An member type type</param>
        /// <returns></returns>
        private MemberTypeAttribute GetMemberTypeAttribute(Type typeMemberType)
        {
            MemberTypeAttribute retVal = Util.GetAttribute <MemberTypeAttribute>(typeMemberType);

            if (retVal == null)
            {
                retVal = this.CreateDefaultMemberTypeAttribute(typeMemberType);
            }

            return(retVal);
        }
示例#3
0
        private void SynchronizeMemberType(Type typeMemberType, Type basetypeMemberType)
        {
            MemberTypeAttribute memberTypeAttr = this.GetMemberTypeAttribute(typeMemberType);

            string memberTypeName  = string.IsNullOrEmpty(memberTypeAttr.Name) ? typeMemberType.Name : memberTypeAttr.Name;
            string memberTypeAlias = MemberTypeManager.GetMemberTypeAlias(typeMemberType);

            try
            {
                this.AddToSynchronized(typeMemberType.Name, memberTypeAlias, typeMemberType);
            }
            catch (ArgumentException exc)
            {
                throw new Exception(string.Format("Member type with alias '{0}' already exists! Please use unique class names as class name is used as alias. Member type causing the problem: '{1}' (assembly: '{2}'). Error message: {3}",
                                                  memberTypeAlias, typeMemberType.FullName, typeMemberType.Assembly.FullName, exc.Message));
            }


            _memberTypes.Add(memberTypeAlias, typeMemberType);

            MemberType memberType = MemberType.GetByAlias(memberTypeAlias);

            if (memberType == null)
            {
                memberType = MemberType.MakeNew(new umbraco.BusinessLogic.User(0), memberTypeAttr.Name);
            }

            memberType.Alias       = memberTypeAlias;
            memberType.IconUrl     = memberTypeAttr.IconUrl;
            memberType.Thumbnail   = memberTypeAttr.Thumbnail;
            memberType.Description = memberTypeAttr.Description;

            SynchronizeMemberTypeProperties(typeMemberType, memberType);

            memberType.Save();
        }