Rock.Web.UI.Controls.AttributeEditor.SetAttributeProperties C# (CSharp) Method

SetAttributeProperties() public method

Sets the attribute properties.
public SetAttributeProperties ( Rock attribute, Type objectType = null ) : void
attribute Rock The attribute.
objectType System.Type Type of the object.
return void
        public void SetAttributeProperties( Rock.Model.Attribute attribute, Type objectType = null )
        {
            if ( attribute != null )
            {
                this.AttributeId = attribute.Id;
                this.AttributeGuid = attribute.Guid;
                this.Name = attribute.Name;
                this.Key = attribute.Key;
                this.IconCssClass = attribute.IconCssClass;
                this.CategoryIds = attribute.Categories.Select( c => c.Id ).ToList();
                this.Description = attribute.Description;
                this.FieldTypeId = attribute.FieldTypeId;
                this.Required = attribute.IsRequired;
                this.ShowInGrid = attribute.IsGridColumn;
                this.AllowSearch = attribute.AllowSearch;

                var qualifiers = new Dictionary<string, ConfigurationValue>();
                if ( attribute.AttributeQualifiers != null )
                {
                    foreach ( Rock.Model.AttributeQualifier qualifier in attribute.AttributeQualifiers )
                    {
                        qualifiers.Add( qualifier.Key, new ConfigurationValue( qualifier.Value ) );
                    }
                }

                this.Qualifiers = qualifiers;
                this.DefaultValue = attribute.DefaultValue;
            }

            if ( objectType != null )
            {
                this.AttributeEntityTypeId = Rock.Web.Cache.EntityTypeCache.Read( objectType ).Id;

                ObjectPropertyNames = new List<string>();
                foreach ( var propInfo in objectType.GetProperties() )
                {
                    ObjectPropertyNames.Add( propInfo.Name );
                }
            }
        }