本文整理汇总了C#中IOrderedDictionary.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IOrderedDictionary.Add方法的具体用法?C# IOrderedDictionary.Add怎么用?C# IOrderedDictionary.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrderedDictionary
的用法示例。
在下文中一共展示了IOrderedDictionary.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractValuesFromCell
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
{
Control control = null;
string dataField = this.DataField;
object obj2 = null;
if (cell.Controls.Count > 0)
{
control = cell.Controls[0];
CheckBox box = control as CheckBox;
if ((box != null) && (includeReadOnly || box.Enabled))
{
obj2 = box.Checked;
}
}
if (obj2 != null)
{
if (dictionary.Contains(dataField))
{
dictionary[dataField] = obj2;
}
else
{
dictionary.Add(dataField, obj2);
}
}
}
示例2: CopyTo
public static void CopyTo (this IOrderedDictionary from, IOrderedDictionary to)
{
if (to == null || from.Count == 0)
return;
foreach (DictionaryEntry de in from)
to.Add (de.Key, de.Value);
}
示例3: LoadViewState
public static void LoadViewState(IOrderedDictionary dictionary, ArrayList state) {
if (dictionary == null) {
throw new ArgumentNullException("dictionary");
}
if (state == null) {
throw new ArgumentNullException("state");
}
if (state != null) {
for (int i = 0; i < state.Count; i++) {
Pair pairEntry = (Pair)state[i];
dictionary.Add(pairEntry.First, pairEntry.Second);
}
}
}
示例4: ExtractValuesFromCell
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
{
Control control = null;
string dataImageUrlField = this.DataImageUrlField;
object imageUrl = null;
bool flag = false;
if ((((rowState & DataControlRowState.Insert) == DataControlRowState.Normal) || this.InsertVisible) && (cell.Controls.Count != 0))
{
control = cell.Controls[0];
Image image = control as Image;
if (image != null)
{
if (includeReadOnly)
{
flag = true;
if (image.Visible)
{
imageUrl = image.ImageUrl;
}
}
}
else
{
TextBox box = control as TextBox;
if (box != null)
{
imageUrl = box.Text;
flag = true;
}
}
if ((imageUrl != null) || flag)
{
if ((this.ConvertEmptyStringToNull && (imageUrl is string)) && (((string) imageUrl).Length == 0))
{
imageUrl = null;
}
if (dictionary.Contains(dataImageUrlField))
{
dictionary[dataImageUrlField] = imageUrl;
}
else
{
dictionary.Add(dataImageUrlField, imageUrl);
}
}
}
}
示例5: ExtractValuesFromCell
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
{
if (cell.Controls.Count > 0)
{
DropDownList ddl = cell.Controls[0] as DropDownList;
if (null == ddl)
{
throw new InvalidOperationException("DropDownField could not extract control.");
}
object selectedValue = ddl.SelectedValue;
if (dictionary.Contains(this.DataField))
{
dictionary[this.DataField] = selectedValue;
}
else
{
dictionary.Add(this.DataField, selectedValue);
}
}
}
示例6: ExtractValuesFromCell
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
{
string format = this.DataFormatString;
object val = null;
try
{
Decimal d = Decimal.Parse(cell.Text, CultureInfo.CurrentCulture);
val = d;
}
catch (Exception ex)
{ }
string dataField = this.DataField;
if (dictionary.Contains(dataField))
dictionary[dataField] = val;
else
{
dictionary.Add(dataField, val);
}
}
示例7: ExtractValuesFromCell
/// <summary>
/// This method is called by the ExtractRowValues methods of
/// GridView and DetailsView. Retrieve the current value of the
/// cell from the Checked state of the Radio button.
/// </summary>
/// <param name="dictionary"></param>
/// <param name="cell"></param>
/// <param name="rowState"></param>
/// <param name="includeReadOnly"></param>
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
{
// Determine whether the cell contains a RadioButtonList
// in its Controls collection.
if (cell.Controls.Count > 0)
{
object radio = cell.Controls[0];
object checkedValue = null;
if (radio is RadioButton || radio is RadioButtonList)
{
if (radio is RadioButton)
{
checkedValue = ((RadioButton)radio).Checked;
}
else if (radio is RadioButtonList)
{
checkedValue = ((RadioButtonList)radio).SelectedValue;
}
}
else
{
// A RadioButton is expected, but a null is encountered.
throw new InvalidOperationException("BoundRadioButtonField could not extract control.");
}
// Add the value of the Checked attribute of the
// RadioButton to the dictionary.
if (dictionary.Contains(DataField))
{
dictionary[DataField] = checkedValue;
}
else
{
dictionary.Add(DataField, checkedValue);
}
}
}
示例8: ExtractValuesFromCell
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
{
string format = this.DataFormatString;
if (string.IsNullOrEmpty(format))
format = DateTimeFormatInfo.CurrentInfo.ShortDatePattern;
object val = null;
try
{
DateTime dt = DateTime.ParseExact(cell.Text, format, CultureInfo.CurrentCulture);
val = dt;
}
catch (Exception ex)
{ }
string dataField = this.DataField;
if (dictionary.Contains(dataField))
dictionary[dataField] = val;
else
{
dictionary.Add(dataField, val);
}
}
示例9: SetValues
/// <summary>
/// Adds elements to the collection having the specified names and values.
/// </summary>
/// <param name="list">A collection of name/value pairs.</param>
/// <param name="names">The property names.</param>
/// <param name="values">The property values.</param>
public static void SetValues(IOrderedDictionary list, String[] names, Object[] values)
{
for ( int i = 0; i < names.Length; i++ )
{
if ( list.Contains(names[i]) )
{
list.Remove(names[i]);
}
list.Add(names[i], values[i]);
}
}
示例10: BindControl
/// <summary>
/// Binds a controls value to a property of an entity.
/// </summary>
/// <param name="control">The control to get the value from.</param>
/// <param name="list">The <see cref="IOrderedDictionary"/> containing the values.</param>
/// <param name="propertyName">The name of the property to bind the value to.</param>
public static void BindControl(Control control, IOrderedDictionary list, String propertyName)
{
if (control != null)
{
if (list.Contains(propertyName))
{
list.Remove(propertyName);
}
list.Add(propertyName, GetValue(control));
}
}
示例11: ExtractValuesFromCell
/// <devdoc>
/// Extracts the value(s) from the given cell and puts the value(s) into a dictionary. Indicate includeReadOnly
/// to have readonly fields' values inserted into the dictionary.
/// </devdoc>
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly) {
Control childControl = null;
string dataField = DataField;
object value = null;
string nullDisplayText = NullDisplayText;
if (((rowState & DataControlRowState.Insert) != 0) && !InsertVisible) {
return;
}
if (cell.Controls.Count > 0) {
childControl = cell.Controls[0];
TextBox editBox = childControl as TextBox;
if (editBox != null) {
value = editBox.Text;
}
}
else {
if (includeReadOnly == true) {
string cellText = cell.Text;
if (cellText == " ") { // nothing HtmlEncodes to , so we know that this means it was empty.
value = String.Empty;
}
else {
if (SupportsHtmlEncode && HtmlEncode) {
value = HttpUtility.HtmlDecode(cellText);
}
else {
value = cellText;
}
}
}
}
if (value != null) {
if ((value is string) && (((string)value).Length == 0) && ConvertEmptyStringToNull) {
value = null;
}
if (value is string && (string)value == nullDisplayText && nullDisplayText.Length > 0) {
value = null;
}
if (dictionary.Contains(dataField)) {
dictionary[dataField] = value;
}
else {
dictionary.Add(dataField, value);
}
}
}
示例12: SetFormViewParameters
public static void SetFormViewParameters(IOrderedDictionary parameters, object instance)
{
Type ObjType = instance.GetType();
foreach (DictionaryEntry parameter in parameters)
{
PropertyInfo property = ObjType.GetProperty(parameter.Key.ToString());
if (property != null)
{
Type t = property.PropertyType;
object value = null;
switch (t.Name)
{
case "Decimal":
if (!string.IsNullOrEmpty(parameter.Value.ToString()))
value = Convert.ToDecimal(parameter.Value);
else
value = Convert.ToDecimal(0.0);
break;
case "Boolean":
value = Convert.ToBoolean(parameter.Value);
break;
case "DateTime":
String DateTimeFormat = "dd/MM/yyyy";
DateTimeFormatInfo info = new DateTimeFormatInfo();
info.ShortDatePattern = DateTimeFormat;
String date = Convert.ToString(parameter.Value);
if (!String.IsNullOrEmpty(date) || date == "null")
value = Convert.ToDateTime(date,info);
break;
case "Double":
if (!string.IsNullOrEmpty(parameter.Value.ToString()))
value = Convert.ToDouble(parameter.Value);
else
value = 0.0;
break;
case "Int32":
value = Convert.ToInt32(parameter.Value);
break;
case "Single":
value = Convert.ToSingle(parameter.Value);
break;
case "String":
value = Convert.ToString(parameter.Value);
break;
case "Guid":
if (!string.IsNullOrEmpty(parameter.Value.ToString()))
value = new Guid("11111111111111111111111111111111");
break;
default:
break;
}
property.SetValue(instance, value, null);
}
}
parameters.Clear();
parameters.Add("Values", instance);
}
示例13: ExtractValuesFromCell
/// <devdoc>
/// Extracts the value(s) from the given cell and puts the value(s) into a dictionary. Indicate includeReadOnly
/// to have readonly fields' values inserted into the dictionary.
/// </devdoc>
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly) {
Control childControl = null;
string dataField = DataField;
object value = null;
if (cell.Controls.Count > 0) {
childControl = cell.Controls[0];
CheckBox checkBox = childControl as CheckBox;
if (checkBox != null) {
if (includeReadOnly || checkBox.Enabled) {
value = checkBox.Checked;
}
}
}
if (value != null) {
if (dictionary.Contains(dataField)) {
dictionary[dataField] = value;
}
else {
dictionary.Add(dataField, value);
}
}
}
示例14: ExtractValuesFromCell
/// <devdoc>
/// Extracts the value(s) from the given cell and puts the value(s) into a dictionary. Indicate includeReadOnly
/// to have readonly fields' values inserted into the dictionary.
/// </devdoc>
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly) {
Control childControl = null;
string dataField = DataImageUrlField;
object value = null;
bool includeNullValue = false;
if (((rowState & DataControlRowState.Insert) != 0) && !InsertVisible) {
return;
}
if (cell.Controls.Count == 0) { // this should happen only in design mode
Debug.Assert(DesignMode, "Unless you're in designmode, there should be a control in the cell.");
return;
}
childControl = cell.Controls[0];
Image image = childControl as Image;
if (image != null) {
if (includeReadOnly) {
includeNullValue = true;
if (image.Visible) {
value = image.ImageUrl;
}
}
}
else {
TextBox editBox = childControl as TextBox;
if (editBox != null) {
value = editBox.Text;
includeNullValue = true; // just in case someone wrote a derived textbox that returns null for Text.
}
}
if (value != null || includeNullValue) {
if (ConvertEmptyStringToNull && value is string && ((string)value).Length == 0) {
value = null;
}
if (dictionary.Contains(dataField)) {
dictionary[dataField] = value;
}
else {
dictionary.Add(dataField, value);
}
}
}
示例15: ExtractValuesFromCell
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
{
Control control = null;
string dataField = this.DataField;
object text = null;
string nullDisplayText = this.NullDisplayText;
if (((rowState & DataControlRowState.Insert) == DataControlRowState.Normal) || this.InsertVisible)
{
if (cell.Controls.Count > 0)
{
control = cell.Controls[0];
TextBox box = control as TextBox;
if (box != null)
{
text = box.Text;
}
}
else if (includeReadOnly)
{
string s = cell.Text;
if (s == " ")
{
text = string.Empty;
}
else if (this.SupportsHtmlEncode && this.HtmlEncode)
{
text = HttpUtility.HtmlDecode(s);
}
else
{
text = s;
}
}
if (text != null)
{
if (((text is string) && (((string) text).Length == 0)) && this.ConvertEmptyStringToNull)
{
text = null;
}
if (((text is string) && (((string) text) == nullDisplayText)) && (nullDisplayText.Length > 0))
{
text = null;
}
if (dictionary.Contains(dataField))
{
dictionary[dataField] = text;
}
else
{
dictionary.Add(dataField, text);
}
}
}
}