Beispiel #1
0
 /// <summary>
 /// 将“settingDefinitionGroup”添加为此组的子组。
 /// </summary>
 /// <param name="child">要添加的子项</param>
 /// <returns>此子组可以添加更多子组</returns>
 public SettingDefinitionGroup AddChild(SettingDefinitionGroup child)
 {
     if (child.Parent != null)
     {
         throw new SharePlatformException("设置组 " + child.Name + " 已经有一个父级(" + child.Parent.Name + ").");
     }
     return(this);
 }
        /// <summary>
        /// 创建一个新的“settingdefinition”对象。
        /// </summary>
        /// <param name="name">设置的唯一名称</param>
        /// <param name="defaultValue">设置的默认值</param>
        /// <param name="displayName">权限的显示名称</param>
        /// <param name="group">此设置的组</param>
        /// <param name="description">此设置的简要说明</param>
        /// <param name="scopes">此设置的范围。默认值:“settingscopes.application”。</param>
        /// <param name="isVisibleToClients">客户能看到这个设置和它的值吗?默认值:假</param>
        /// <param name="isInherited">此设置是从父作用域继承的吗?默认:True。</param>
        /// <param name="customData">可用于存储与此设置相关的自定义对象</param>
        /// <param name="clientVisibilityProvider">设置的客户端可见性定义。默认:不可见</param>
        public SettingDefinition(
            string name,
            string defaultValue,
            ILocalizableString displayName = null,
            SettingDefinitionGroup group   = null,
            ILocalizableString description = null,
            SettingScopes scopes           = SettingScopes.Application,
            bool isVisibleToClients        = false,
            bool isInherited  = true,
            object customData = null,
            ISettingClientVisibilityProvider clientVisibilityProvider = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            Name               = name;
            DefaultValue       = defaultValue;
            DisplayName        = displayName;
            Group              = @group;
            Description        = description;
            Scopes             = scopes;
            IsVisibleToClients = isVisibleToClients;
            IsInherited        = isInherited;
            CustomData         = customData;

            ClientVisibilityProvider = new HiddenSettingClientVisibilityProvider();

            if (isVisibleToClients)
            {
                ClientVisibilityProvider = new VisibleSettingClientVisibilityProvider();
            }
            else if (clientVisibilityProvider != null)
            {
                ClientVisibilityProvider = clientVisibilityProvider;
            }
        }