/// <summary> Invokes the <see cref="BocCustomColumnDefinitionCell.Init"/> method for each custom column. </summary>
 private void InitCustomColumns()
 {
     foreach (var keyValuePair in _customColumnControls.Where(p => p.Value.Any()))
     {
         var customColumn = keyValuePair.Key;
         var args         = new BocCustomCellArguments(this, customColumn);
         customColumn.CustomCell.Init(args);
     }
 }
 /// <summary> Override this method to create the <see cref="T:Control"/> of a custom cell. </summary>
 /// <param name="arguments"> The <see cref="BocCustomCellArguments"/>. </param>
 /// <returns> A <see cref="T:Control"/>. Must not return <see langword="null"/>. </returns>
 /// <remarks>
 ///   This method is called for each cell containing a <see cref="T:Control"/>.
 ///   <note type="inheritinfos"> Do not call the base implementation when overriding this method. </note>
 /// </remarks>
 protected virtual Control CreateControl(BocCustomCellArguments arguments)
 {
     throw new NotImplementedException(
               string.Format(
                   "{0}: An implementation of 'CreateControl' is required if the 'BocCustomColumnDefinition.Mode' property "
                   + "is set to '{1}' or '{2}'.",
                   GetType().Name,
                   BocCustomColumnDefinitionMode.ControlInEditedRow,
                   BocCustomColumnDefinitionMode.ControlsInAllRows));
 }
        internal Control CreateControlInternal(BocCustomCellArguments arguments)
        {
            InitArguments(arguments);
            Control control = CreateControl(arguments);

            if (control == null)
            {
                throw new NullReferenceException(
                          string.Format(
                              "{0}.CreateControl(BocCustomCellArguments) evaluated null, but a Control was expected.", GetType()));
            }
            return(control);
        }
        private void InitArguments(BocCustomCellArguments arguments)
        {
            _arguments = arguments;

            string propertyValuePairs = arguments.ColumnDefinition.CustomCellArgument;

            if (!string.IsNullOrEmpty(propertyValuePairs))
            {
                NameValueCollection        values = new NameValueCollection();
                StringUtility.ParsedItem[] items  = StringUtility.ParseSeparatedList(propertyValuePairs, ',');
                for (int i = 0; i < items.Length; i++)
                {
                    string[] pair = items[i].Value.Split(new[] { '=' }, 2);
                    if (pair.Length == 2)
                    {
                        string key   = pair[0].Trim();
                        string value = pair[1].Trim(' ', '\"');
                        values.Add(key, value);
                    }
                }
                PropertyInfo[] properties = GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
                for (int i = 0; i < properties.Length; i++)
                {
                    PropertyInfo property = properties[i];
                    string       strval   = values[property.Name];
                    if (strval != null)
                    {
                        try
                        {
                            if (strval.Length >= 2 && strval[0] == '\"' && strval[strval.Length - 1] == '\"')
                            {
                                strval = strval.Substring(1, strval.Length - 2);
                            }
                            object value = StringUtility.Parse(property.PropertyType, strval, CultureInfo.InvariantCulture);
                            property.SetValue(this, value, new object[0]);
                        }
                        catch (Exception e)
                        {
                            throw new ApplicationException("Property " + property.Name + ": " + e.Message, e);
                        }
                    }
                }
            }
        }
        /// <summary> Creates the controls for the custom columns in the <paramref name="columns"/> array. </summary>
        private void CreateCustomColumnControls(BocColumnDefinition[] columns)
        {
            EnsureChildControls();

            Assertion.IsTrue(_customColumnControls.Count == 0);
            Assertion.IsTrue(_customColumnsPlaceHolder.Controls.Count == 0);

            var controlEnabledCustomColumns = columns
                                              .Select((column, index) => new { Column = column as BocCustomColumnDefinition, Index = index })
                                              .Where(d => d.Column != null)
                                              .Where(
                d => d.Column.Mode == BocCustomColumnDefinitionMode.ControlsInAllRows ||
                d.Column.Mode == BocCustomColumnDefinitionMode.ControlInEditedRow)
                                              .ToArray();

            foreach (var customColumnData in controlEnabledCustomColumns)
            {
                var customColumn = customColumnData.Column;
                var placeHolder  = new PlaceHolder();

                var customColumnTuples = new List <BocListCustomColumnTuple>();
                foreach (var row in EnsureBocListRowsForCurrentPageGot())
                {
                    bool isEditedRow = _editModeController.IsRowEditModeActive && _editModeController.GetEditableRow(row.ValueRow.Index) != null;
                    if (customColumn.Mode == BocCustomColumnDefinitionMode.ControlInEditedRow && !isEditedRow)
                    {
                        continue;
                    }

                    var     args    = new BocCustomCellArguments(this, customColumn);
                    Control control = customColumn.CustomCell.CreateControlInternal(args);
                    control.ID = ID + "_CustomColumnControl_" + customColumnData.Index + "_" + RowIDProvider.GetControlRowID(row.ValueRow);
                    placeHolder.Controls.Add(control);
                    customColumnTuples.Add(new BocListCustomColumnTuple(row.ValueRow.BusinessObject, row.ValueRow.Index, control));
                }
                _customColumnsPlaceHolder.Controls.Add(placeHolder);
                _customColumnControls[customColumn] = customColumnTuples.ToArray();
            }
        }
        protected virtual IComparer <BocListRow> CreateCellValueComparer(BocCustomCellArguments arguments)
        {
            ArgumentUtility.CheckNotNull("arguments", arguments);

            return(arguments.ColumnDefinition.GetPropertyPath().CreateComparer());
        }
 internal IComparer <BocListRow> CreateCellValueComparerInternal(BocCustomCellArguments arguments)
 {
     InitArguments(arguments);
     return(CreateCellValueComparer(arguments));
 }
 /// <summary> Override this method to initialize a custom column. </summary>
 /// <remarks> This method is called for each column if it contains at least one <see cref="T:Control"/>. </remarks>
 protected virtual void OnInit(BocCustomCellArguments arguments)
 {
 }
 internal void Init(BocCustomCellArguments arguments)
 {
     InitArguments(arguments);
     OnInit(arguments);
 }
 protected virtual void OnPreRender(BocCustomCellArguments arguments)
 {
     throw new NotSupportedException("Use OnPreRender (BocCustomCellPreRenderArguments) instead. (1.13.216)");
 }
        IComparer <BocListRow> IBocSortableColumnDefinition.CreateCellValueComparer()
        {
            var args = new BocCustomCellArguments((IBocList)OwnerControl, this);

            return(CustomCell.CreateCellValueComparerInternal(args));
        }