/*
Kooboo is a content management system based on ASP.NET MVC framework. Copyright 2009 Yardi Technology Limited.
This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License version 3 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.kooboo.com/gpl3/.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
namespace Everest.Forms{
public interface IColumn : IColumnContainer
{
/// <summary>
/// Gets or sets a value indicating whether [primary key].
/// </summary>
/// <value><c>true</c> if [primary key]; otherwise, <c>false</c>.</value>
bool Queryable { get; set; }
string Name
{
get;
set;
}
string Label
{
get;
set;
}
int Length
{
get;
set;
}
bool AllowNull
{
get;
set;
}
string Description
{
get;
set;
}
/// <summary>
/// Gets or sets the default value.
/// multi defaultvalue split by "|" like "value1|value2"
/// </summary>
/// <value>The default value.</value>
string DefaultValue
{
get;
set;
}
/// <summary>
/// Gets or sets the items.
/// item compose by name:::value
/// multi item split by "|" like "name1:::value1|name2:::value2"
/// </summary>
/// <value>The items.</value>
string Items
{
get;
set;
}
/// <summary>
/// Gets or sets the control.
/// </summary>
/// <value>The control.</value>
IControlType Control
{
get;
set;
}
/// <summary>
/// Gets or sets the order.
/// </summary>
/// <value>The order.</value>
int Order { get; set; }
/// <summary>
/// Gets a value indicating whether [require entire row].
/// </summary>
/// <value><c>true</c> if [require entire row]; otherwise, <c>false</c>.</value>
bool EntireRow { get; set; }
/// <summary>
/// Gets or sets the data index in list.
/// </summary>
/// <value>The data index in list.</value>
string DataIndexInList { get; set; }
/// <summary>
/// Gets or sets the data index in detail.
/// </summary>
/// <value>The data index in detail.</value>
string DataIndexInDetail { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="IColumn"/> is modifiable.
/// </summary>
/// <value><c>true</c> if modifiable; otherwise, <c>false</c>.</value>
bool Modifiable { get; set; }
/// <summary>
/// Gets or sets the list attributes.
/// </summary>
/// <value>The list attributes.</value>
NameValueCollection ListAttributes { get; set; }
/// <summary>
/// Gets or sets the detail attributes.
/// </summary>
/// <value>The detail attributes.</value>
NameValueCollection DetailAttributes { get; set; }
/// <summary>
/// Gets or sets the events.
/// </summary>
/// <value>The events.</value>
NameValueCollection Events { get; set; }
}
public static class ColumnHelper
{
/// <summary>
/// Parses the column items.
/// </summary>
/// <param name="itemsString">The items string.</param>
/// <returns></returns>
public static NameValueCollection ParseColumnItems(string itemsString)
{
string[] items = itemsString.Split('|');
NameValueCollection nameValues = new NameValueCollection();
foreach (string item in items)
{
string[] nameValue = item.Split(new string[] { ":::" }, StringSplitOptions.RemoveEmptyEntries);
nameValues.Add(nameValue[0], nameValue.Length < 2 ? nameValue[0] : nameValue[1]);
}
return nameValues;
}
}
}
|