/// <summary>
 /// Initializes a new instance of the <see cref="DateFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 /// <param name="allowCurrentOption">if set to <c>true</c> [allow current option].</param>
 public DateFieldAttribute( string name, string description = "", bool required = true, string defaultValue = "", string category = "",
     int order = 0, string key = null, bool allowCurrentOption = false )
     : base( name, description, required, defaultValue, category, order, key, typeof( DateFieldType ).FullName )
 {
     var displayCurrentConfigValue = new Field.ConfigurationValue( allowCurrentOption.ToString() );
     FieldConfigurationValues.Add( "displayCurrentOption", displayCurrentConfigValue );
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 /// <param name="isPassword">if set to <c>true</c> [is password].</param>
 /// <param name="fieldTypeClass">The field type class.</param>
 public TextFieldAttribute( string name, string description = "", bool required = true, string defaultValue = "", string category = "", 
     int order = 0, string key = null, bool isPassword = false, string fieldTypeClass = null  )
     : base(name, description, required, defaultValue, category, order, key, fieldTypeClass)
 {
     var isPasswordValue = new Field.ConfigurationValue( isPassword.ToString() );
     FieldConfigurationValues.Add( IS_PASSWORD_KEY, isPasswordValue );
 }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentFieldAttribute" /> class.
        /// </summary>
        /// <param name="mefContainerAssemblyName">Name of the mef container assembly.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public ComponentsFieldAttribute( string mefContainerAssemblyName, string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null )
            : base(name, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.ComponentsFieldType ).FullName)
        {
            var configValue = new Field.ConfigurationValue( mefContainerAssemblyName );
            FieldConfigurationValues.Add( "container", configValue );

            if ( string.IsNullOrWhiteSpace( Name ) )
            {
                try
                {
                    Type containerType = Type.GetType( mefContainerAssemblyName );
                    var entityType = EntityTypeCache.Read( containerType );
                    if ( entityType != null )
                    {
                        Name = entityType.FriendlyName;
                    }
                }
                catch { }
            }

            if ( string.IsNullOrWhiteSpace( Name ) )
            {
                Name = mefContainerAssemblyName;
            }

            if ( string.IsNullOrWhiteSpace( Key ) )
            {
                Key = Name.Replace( " ", string.Empty );
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ValueListFieldAttribute"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="valuePrompt">The text to display as a prompt in the label textbox.</param>
        /// <param name="definedTypeGuid">An Optional Defined Type Guid to select values from, otherwise values will be free-form text fields..</param>
        /// <param name="customValues">Optional list of options to use for the values.  Format is either 'value1,value2,value3,...', or 'value1:text1,value2:text2,value3:text3,...'.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <param name="fieldTypeClass">The field type class.</param>
        internal ValueListFieldAttribute( string name = "", string description = "", bool required = true, string defaultValue = "", string valuePrompt = "", 
            string definedTypeGuid = "", string customValues = "", string category = "", int order = 0, string key = null, string fieldTypeClass = null )
            : base( name, description, required, defaultValue, category, order, key, fieldTypeClass )
         {
            if ( !string.IsNullOrWhiteSpace( valuePrompt ) )
            {
                var configValue = new Field.ConfigurationValue( valuePrompt );
                FieldConfigurationValues.Add( VALUE_PROMPT_KEY, configValue );
            }

            Guid? guid = definedTypeGuid.AsGuidOrNull();
            if ( guid.HasValue )
            {
                var definedType = Rock.Web.Cache.DefinedTypeCache.Read( guid.Value );
                if ( definedType != null )
                {
                    var definedTypeConfigValue = new Field.ConfigurationValue( definedType.Id.ToString() );
                    FieldConfigurationValues.Add( DEFINED_TYPE_KEY, definedTypeConfigValue );
                }
            }

            if ( !string.IsNullOrWhiteSpace( customValues ) )
            {
                var configValue = new Field.ConfigurationValue( customValues );
                FieldConfigurationValues.Add( CUSTOM_VALUES, configValue );
            }
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefinedValueFieldAttribute" /> class.
        /// </summary>
        /// <param name="groupTypeGuid">The group type GUID.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public GroupRoleFieldAttribute( string groupTypeGuid = "", string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null )
            : base(name, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.GroupRoleFieldType ).FullName)
        {
            if ( !string.IsNullOrWhiteSpace( groupTypeGuid ) )
            {
                Guid guid = Guid.Empty;
                if ( Guid.TryParse( groupTypeGuid, out guid ) )
                {
                    var groupType = Rock.Web.Cache.GroupTypeCache.Read( guid );
                    if ( groupType != null )
                    {
                        var configValue = new Field.ConfigurationValue( groupType.Id.ToString() );
                        FieldConfigurationValues.Add( "grouptype", configValue );

                        if ( string.IsNullOrWhiteSpace( Name ) )
                        {
                            Name = groupType.Name + " Role";
                            if ( string.IsNullOrWhiteSpace( Key ) )
                            {
                                Key = Name.Replace( " ", string.Empty );
                            }
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkflowAttributeAttribute" /> class.
 /// </summary>
 /// <param name="textLabel">The text label.</param>
 /// <param name="attributeLabel">The attribute label.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 /// <param name="fieldTypeClassNames">The field type class names.</param>
 public WorkflowTextOrAttributeAttribute( string textLabel, string attributeLabel, string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null, string[] fieldTypeClassNames = null )
     : base( textLabel + "|" + attributeLabel, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.WorkflowTextOrAttributeFieldType ).FullName )
 {
     if ( fieldTypeClassNames != null && fieldTypeClassNames.Length > 0 )
     {
         var workflowTypeConfigValue = new Field.ConfigurationValue( fieldTypeClassNames.ToList().AsDelimited("|") );
         FieldConfigurationValues.Add( ATTRIBUTE_FIELD_TYPES_KEY, workflowTypeConfigValue );
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TextFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <param name="numberOfRows">The number of rows.</param>
        /// <param name="allowHtml">if set to <c>true</c> [allow HTML].</param>
        public MemoFieldAttribute( string name, string description = "", bool required = true, string defaultValue = "", string category = "", 
            int order = 0, string key = null, int numberOfRows = 3, bool allowHtml = false )
            : base( name, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.MemoFieldType ).FullName)
        {
            var rowConfig = new Field.ConfigurationValue( numberOfRows.ToString() );
            FieldConfigurationValues.Add( NUMBER_OF_ROWS, rowConfig );

            var htmlConfig = new Field.ConfigurationValue( allowHtml.ToString() );
            FieldConfigurationValues.Add( ALLOW_HTML, htmlConfig );
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueListFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="keyPrompt">The text to display as a prompt in the key textbox.</param>
 /// <param name="valuePrompt">The text to display as a prompt in the label textbox.</param>
 /// <param name="definedTypeGuid">An Optional Defined Type Guid to select values from, otherwise values will be free-form text fields..</param>
 /// <param name="customValues">Optional list of options to use for the values.  Format is either 'value1,value2,value3,...', or 'value1:text1,value2:text2,value3:text3,...'.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 /// <param name="fieldTypeClass">The field type class.</param>
 public KeyValueListFieldAttribute( string name = "", string description = "", bool required = true, string defaultValue = "", 
     string keyPrompt = "", string valuePrompt = "", string definedTypeGuid = "", string customValues = "", 
     string category = "", int order = 0, string key = null, string fieldTypeClass = null )
    : base( name, description, required, defaultValue, valuePrompt, definedTypeGuid, customValues, category, order, key, 
     typeof( Rock.Field.Types.KeyValueListFieldType ).FullName )
 {
     if ( !string.IsNullOrWhiteSpace( keyPrompt ) )
     {
         var configValue = new Field.ConfigurationValue( keyPrompt );
         FieldConfigurationValues.Add( KEY_PROMPT_KEY, configValue );
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkflowAttributeAttribute" /> class.
 /// </summary>
 /// <param name="textLabel">The text label.</param>
 /// <param name="attributeLabel">The attribute label.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 /// <param name="workflowTypeGuid">The workflow type unique identifier.</param>
 public WorkflowTextOrAttributeAttribute( string textLabel, string attributeLabel, string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null, string workflowTypeGuid = "" )
     : base( textLabel + "|" + attributeLabel, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.WorkflowTextOrAttributeFieldType ).FullName )
 {
     if ( !string.IsNullOrWhiteSpace( workflowTypeGuid ) )
     {
         var workflowType = Rock.Web.Cache.DefinedTypeCache.Read( workflowTypeGuid.AsGuid() );
         if ( workflowType != null )
         {
             var workflowTypeConfigValue = new Field.ConfigurationValue( workflowType.Id.ToString() );
             FieldConfigurationValues.Add( WORKFLOW_TYPE_KEY, workflowTypeConfigValue );
         }
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefinedValueFieldAttribute" /> class.
        /// </summary>
        /// <param name="groupTypeGuid">The group type GUID.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public GroupLocationTypeFieldAttribute( string groupTypeGuid, string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null )
            : base( name, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.GroupLocationTypeFieldType ).FullName )
        {
            var configValue = new Field.ConfigurationValue( groupTypeGuid );
            FieldConfigurationValues.Add( "groupTypeGuid", configValue );

            if ( string.IsNullOrWhiteSpace( Name ) )
            {
                Name = "Group Location Type";
            }

            if ( string.IsNullOrWhiteSpace( Key ) )
            {
                Key = Name.Replace( " ", string.Empty );
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AttributeFieldAttribute" /> class.
        /// </summary>
        /// <param name="entityTypeGuid">The entity type GUID.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="allowMultiple">if set to <c>true</c> [allow multiple].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public AttributeFieldAttribute( string entityTypeGuid, string name = "", string description = "", bool required = true, bool allowMultiple = false, string defaultValue = "", string category = "", int order = 0, string key = null )
            : base( name, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.AttributeFieldType ).FullName )
        {
            var entityTypeConfigValue = new Field.ConfigurationValue( entityTypeGuid );
            FieldConfigurationValues.Add( ENTITY_TYPE_KEY, entityTypeConfigValue );

            var allowMultipleConfigValue = new Field.ConfigurationValue( allowMultiple.ToString() );
            FieldConfigurationValues.Add( ALLOW_MULTIPLE_KEY, allowMultipleConfigValue );

            if ( string.IsNullOrWhiteSpace( Name ) )
            {
                var entityType = Rock.Web.Cache.EntityTypeCache.Read( new Guid( entityTypeGuid ) );
                name = ( entityType != null ? entityType.Name : "Entity" ) + " Attribute";
            }

            if ( string.IsNullOrWhiteSpace( Key ) )
            {
                Key = Name.Replace( " ", string.Empty );
            }
        }
예제 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefinedValueFieldAttribute" /> class.
 /// </summary>
 /// <param name="workflowTypeGuid">The group type GUID.</param>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 public WorkflowFieldAttribute( string workflowTypeGuid = "", string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null )
     : base(name, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.WorkflowFieldType ).FullName)
 {
     if ( !string.IsNullOrWhiteSpace( workflowTypeGuid ) )
     {
         Guid guid = Guid.Empty;
         if ( Guid.TryParse( workflowTypeGuid, out guid ) )
         {
             using ( var rockContext = new Rock.Data.RockContext() )
             {
                 var workflowType = new Rock.Model.WorkflowTypeService( rockContext ).Get( guid );
                 if ( workflowType != null )
                 {
                     var configValue = new Field.ConfigurationValue( workflowType.Id.ToString() );
                     FieldConfigurationValues.Add( "workflowtype", configValue );
                 }
             }
         }
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefinedValueRangeFieldAttribute"/> class.
        /// </summary>
        /// <param name="definedTypeGuid">The defined type unique identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public DefinedValueRangeFieldAttribute( string definedTypeGuid, string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null )
            : base(name, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.DefinedValueRangeFieldType ).FullName)
        {
            var definedType = Rock.Web.Cache.DefinedTypeCache.Read( new Guid( definedTypeGuid ) );
            if ( definedType != null )
            {
                var definedTypeConfigValue = new Field.ConfigurationValue( definedType.Id.ToString() );
                FieldConfigurationValues.Add( DEFINED_TYPE_KEY, definedTypeConfigValue );

                if ( string.IsNullOrWhiteSpace( Name ) )
                {
                    Name = definedType.Name;
                }

                if ( string.IsNullOrWhiteSpace( Key ) )
                {
                    Key = Name.Replace( " ", string.Empty );
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefinedValueRangeFieldAttribute"/> class.
        /// </summary>
        /// <param name="definedTypeGuid">The defined type unique identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public DefinedValueRangeFieldAttribute(string definedTypeGuid, string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.DefinedValueRangeFieldType).FullName)
        {
            var definedType = Rock.Web.Cache.DefinedTypeCache.Read(new Guid(definedTypeGuid));

            if (definedType != null)
            {
                var definedTypeConfigValue = new Field.ConfigurationValue(definedType.Id.ToString());
                FieldConfigurationValues.Add(DEFINED_TYPE_KEY, definedTypeConfigValue);

                if (string.IsNullOrWhiteSpace(Name))
                {
                    Name = definedType.Name;
                }

                if (string.IsNullOrWhiteSpace(Key))
                {
                    Key = Name.Replace(" ", string.Empty);
                }
            }
        }
예제 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AttributeFieldAttribute" /> class.
        /// </summary>
        /// <param name="entityTypeGuid">The entity type GUID.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="allowMultiple">if set to <c>true</c> [allow multiple].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public AttributeFieldAttribute(string entityTypeGuid, string name = "", string description = "", bool required = true, bool allowMultiple = false, string defaultValue = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.AttributeFieldType).FullName)
        {
            var entityTypeConfigValue = new Field.ConfigurationValue(entityTypeGuid);

            FieldConfigurationValues.Add(ENTITY_TYPE_KEY, entityTypeConfigValue);

            var allowMultipleConfigValue = new Field.ConfigurationValue(allowMultiple.ToString());

            FieldConfigurationValues.Add(ALLOW_MULTIPLE_KEY, allowMultipleConfigValue);

            if (string.IsNullOrWhiteSpace(Name))
            {
                var entityType = EntityTypeCache.Get(new Guid(entityTypeGuid));
                name = (entityType != null ? entityType.Name : "Entity") + " Attribute";
            }

            if (string.IsNullOrWhiteSpace(Key))
            {
                Key = Name.Replace(" ", string.Empty);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GroupLocationTypeFieldAttribute" /> class.
        /// </summary>
        /// <param name="groupTypeGuid">The group type GUID.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public GroupLocationTypeFieldAttribute(string name, string groupTypeGuid = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.GroupLocationTypeFieldType).FullName)
        {
            /*
             * 07/13/2020 - Shaun
             * This is a workaround because the original constructor for this
             * class was built to accept groupTypeGuid as the only parameter,
             * so if any plugins were using the constructor in this manner,
             * they would be passing the guid into the name parameter, so we
             * will check there, first.
             *
             * Reason: Maintaining backwards compatibility for plugins.
             */
            Guid?groupType = name.AsGuidOrNull();

            if (groupType == null)
            {
                groupType = groupTypeGuid.AsGuidOrNull();
            }
            else
            {
                // If the name parameter was a guid, then the name and guid are out-of-order and we need to swap them.
                Name = groupTypeGuid;
            }

            if (groupType != null)
            {
                var configValue = new Field.ConfigurationValue(groupType.ToString());
                FieldConfigurationValues.Add("groupTypeGuid", configValue);
            }

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = "Group Location Type";
            }
        }
예제 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CampusFieldAttribute"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultCampusId">The default campus identifier.</param>
 /// <param name="includeInactive">if set to <c>true</c> [include inactive].</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 public CampusFieldAttribute( string name = "Campus", string description = "", bool required = true, string defaultCampusId = "", bool includeInactive = false, string category = "", int order = 0, string key = null )
     : base(name, description, required, defaultCampusId, category, order, key, typeof( Rock.Field.Types.CampusFieldType ).FullName)
 {
     var includeInactiveConfigValue = new Field.ConfigurationValue( includeInactive.ToString() );
     FieldConfigurationValues.Add( INCLUDE_INACTIVE_KEY, includeInactiveConfigValue );
 }
예제 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BinaryFileFieldAttribute"/> class.
 /// </summary>
 /// <param name="binaryFileTypeGuid">The guid of the type of files</param>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultBinaryFileGuid">The default binary file guid.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 public BinaryFileFieldAttribute( string binaryFileTypeGuid, string name = "Binary File", string description = "", bool required = true, string defaultBinaryFileGuid = "", string category = "", int order = 0, string key = null )
     : base(name, description, required, defaultBinaryFileGuid, category, order, key, typeof( Rock.Field.Types.BinaryFileFieldType ).FullName)
 {
     var configValue = new Field.ConfigurationValue( binaryFileTypeGuid );
     FieldConfigurationValues.Add( BINARY_FILE_TYPE, configValue );
 }
예제 #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityTypeFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="includeGlobalAttributeOption">if set to <c>true</c> [include global attribute option].</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 public EntityTypeFieldAttribute(string name, bool includeGlobalAttributeOption, string description = "", bool required = true, string category = "", int order = 0, string key = null)
     : base( name, description, required, "", category, order, key, typeof( Rock.Field.Types.EntityTypeFieldType ).FullName )
 {
     var configValue = new Field.ConfigurationValue( includeGlobalAttributeOption.ToString() );
     FieldConfigurationValues.Add( "includeglobal", configValue );
 }
예제 #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AttributeFieldAttribute"/> class.
        /// </summary>
        /// <param name="entityTypeGuid">The entity type unique identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="entityTypeQualifierColumn">The entity type qualifier column.</param>
        /// <param name="entityTypeQualifierValue">The entity type qualifier value.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="allowMultiple">if set to <c>true</c> [allow multiple].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public AttributeFieldAttribute( string entityTypeGuid, string entityTypeQualifierColumn, string entityTypeQualifierValue, string name, string description = "", bool required = true, bool allowMultiple = false, string defaultValue = "", string category = "", int order = 0, string key = null )
            : base(name, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.AttributeFieldType ).FullName)
        {
            var entityTypeConfigValue = new Field.ConfigurationValue( entityTypeGuid );
            FieldConfigurationValues.Add( ENTITY_TYPE_KEY, entityTypeConfigValue );

            var allowMultipleConfigValue = new Field.ConfigurationValue( allowMultiple.ToString() );
            FieldConfigurationValues.Add( ALLOW_MULTIPLE_KEY, allowMultipleConfigValue );

            var entityTypeQualifierColumnConfigValue = new Field.ConfigurationValue( entityTypeQualifierColumn );
            FieldConfigurationValues.Add( QUALIFIER_COLUMN_KEY, entityTypeQualifierColumnConfigValue );

            if ( entityTypeQualifierColumn.EndsWith( "Id" ) && entityTypeQualifierValue.AsGuid() != Guid.Empty )
            {
                EntityTypeCache itemEntityType = EntityTypeCache.Read( "Rock.Model." + entityTypeQualifierColumn.Left( entityTypeQualifierColumn.Length - 2 ) );
                if ( itemEntityType.AssemblyName != null )
                {
                    // get the actual type of what is being followed
                    Type entityType = itemEntityType.GetEntityType();
                    if ( entityType != null )
                    {
                        var dbContext = Reflection.GetDbContextForEntityType( entityType );
                        if ( dbContext != null )
                        {
                            var serviceInstance = Reflection.GetServiceForEntityType( entityType, dbContext );
                            if ( serviceInstance != null )
                            {
                                MethodInfo getMethod = serviceInstance.GetType().GetMethod( "Get", new Type[] { typeof( Guid ) } );
                                var entity = getMethod.Invoke( serviceInstance, new object[] { entityTypeQualifierValue.AsGuid() } ) as Rock.Data.IEntity;
                                if ( entity != null )
                                {
                                    FieldConfigurationValues.Add( QUALIFIER_VALUE_KEY, new Field.ConfigurationValue( entity.Id.ToString() ) );
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                var entityTypeQualifierValueConfigValue = new Field.ConfigurationValue( entityTypeQualifierValue );
                FieldConfigurationValues.Add( QUALIFIER_VALUE_KEY, entityTypeQualifierValueConfigValue );
            }

            if ( string.IsNullOrWhiteSpace( Name ) )
            {
                var entityType = Rock.Web.Cache.EntityTypeCache.Read( new Guid( entityTypeGuid ) );
                name = ( entityType != null ? entityType.Name : "Entity" ) + " Attribute";
            }

            if ( string.IsNullOrWhiteSpace( Key ) )
            {
                Key = Name.Replace( " ", string.Empty );
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefinedValueFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 public ConnectionOpportunityFieldAttribute( string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null )
     : base(name, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.ConnectionOpportunityFieldType ).FullName)
 {
     var includeInactiveConfigValue = new Field.ConfigurationValue( "False" );
     FieldConfigurationValues.Add( INCLUDE_INACTIVE_KEY, includeInactiveConfigValue );
 }