Rock.Web.UI.Controls.AttributeField.GetRowValue C# (CSharp) Метод

GetRowValue() приватный Метод

Gets the row value.
private GetRowValue ( System.Web.UI.WebControls.GridViewRow row, bool condensed, bool formatAsHtml ) : object
row System.Web.UI.WebControls.GridViewRow The row.
condensed bool if set to true [condensed].
formatAsHtml bool if set to true [format as HTML].
Результат object
        private object GetRowValue( GridViewRow row, bool condensed, bool formatAsHtml )
        {
            // First try to get an IHasAttributes from the grid's object list
            IHasAttributes dataItem = GetAttributeObject( row );
            if ( dataItem == null )
            {
                // If unsuccessful, check to see if row has attributes
                dataItem = row.DataItem as IHasAttributes;
            }

            if ( dataItem != null )
            {
                if ( dataItem.Attributes == null )
                {
                    dataItem.LoadAttributes();
                }

                AttributeCache attrib = null;
                string rawValue = string.Empty;

                bool exists = dataItem.Attributes.ContainsKey( this.DataField );
                if ( exists )
                {
                    attrib = dataItem.Attributes[this.DataField];
                    rawValue = dataItem.GetAttributeValue( this.DataField );
                }
                else
                {
                    if ( AttributeId.HasValue )
                    {
                        attrib = dataItem.Attributes.Where( a => a.Value.Id == AttributeId.Value ).Select( a => a.Value ).FirstOrDefault();
                        if ( attrib != null )
                        {
                            exists = true;
                            rawValue = dataItem.GetAttributeValue( attrib.Key );
                        }
                    }
                }

                if ( exists )
                {
                    if ( formatAsHtml )
                    {
                        string resultHtml = attrib.FieldType.Field.FormatValueAsHtml( null, rawValue, attrib.QualifierValues, condensed );
                        return new HtmlString( resultHtml ?? string.Empty );
                    }
                    else
                    {
                        string result = attrib.FieldType.Field.FormatValue( null, rawValue, attrib.QualifierValues, condensed );
                        return result ?? string.Empty;
                    }
                }
            }

            return null;
        }