private IOrderedDictionary GetDefault() { if (_defaultFields == null) { lock (PadLock) { if (_defaultFields == null) { _defaultFields = new OrderedDictionary(); if (UseOrdinal) { foreach (IndexMapping mapping in Mappings) { _defaultFields.Add(mapping.SourceIndex, null); } } else { foreach (Mapping mapping in Mappings) { _defaultFields.Add(mapping.Source, null); } } } } } return(Reset(_defaultFields)); }
private void AddValues(IOrderedDictionary values) { FileUpload logoFileUpload = GetControl <FileUpload>("FileUploadLogo", PageFormView); if (logoFileUpload.HasFile) { if (logoFileUpload.PostedFile.ContentType.ToLower() == "image/pjpeg") { BinaryReader reader = new BinaryReader(logoFileUpload.PostedFile.InputStream); byte[] image = reader.ReadBytes(logoFileUpload.PostedFile.ContentLength); values.Add("Logo", image); values.Add("LogoURI", logoFileUpload.PostedFile.FileName); } else { throw new Exception("Please choose a JPEG for the logo."); } } else { throw new Exception("File Upload failed."); } }
/// <summary> /// Create a unique id for each text value in the HTML being parsed and save in a dictionary. /// This method is designed to collect identified text in an HTML /// and track the number of occurences on the page. /// This is done to prevent a case where we will have the same text appearing multiple times, /// where however, we would like to have a different interpretation per appeareance. /// </summary> /// <param name="htmlOriginalValuesDict"></param> /// <param name="htmlTextDict"></param> /// <param name="text">The text used for generating the unique Id</param> /// <returns>Returns eithe the text as is or with the number of encounters that have been detected previously on the page</returns> private void AddUniqueIdToDictionary(IOrderedDictionary <string, string> htmlOriginalValuesDict, IOrderedDictionary <string, int> htmlTextDict, string text) { if (!htmlTextDict.ContainsKey(text)) { htmlOriginalValuesDict.Add(text, text); // Save the text to a OrderedDictionary that keeps the original values htmlTextDict.Add(text, 1); // Default to one enocunter return; } htmlTextDict[text] = htmlTextDict[text] + 1; // Increase encounters var textEncountersCount = htmlTextDict[text]; htmlOriginalValuesDict.Add($"{text}{textEncountersCount}", text); // Save the text to a OrderedDictionary that keeps the original values htmlTextDict.Add($"{text}{textEncountersCount}", 1); // Save new encounter to the OrderedDictionary with a default of 1 }
/// <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); } } }
/// <devdoc> /// Inheritable overridable implementation of LoadViewState /// </devdoc> protected virtual void LoadViewState(object state) { if (state != null) { if (_keyNames != null) { object[] myState = (object[])state; // if we have key names, then we only stored values. if (myState[0] != null) { for (int i = 0; i < myState.Length && i < _keyNames.Length; i++) { _keyTable.Add(_keyNames[i], myState[i]); } } } else { if (state != null) { ArrayList stateArrayList = state as ArrayList; if (stateArrayList == null) { throw new HttpException(SR.GetString(SR.ViewState_InvalidViewState)); } OrderedDictionaryStateHelper.LoadViewState(_keyTable, stateArrayList); } } } }
/// <summary> /// Retrieves a set of name/value pairs for values bound using /// two-way ASP.NET data-binding syntax within the templated content. /// </summary> /// <param name="container"> /// The System.Web.UI.Control from which to extract name/value pairs, which are /// passed by the data-bound control to an associated data source control in /// two-way data-binding scenarios. /// </param> /// <returns> /// An System.Collections.Specialized.IOrderedDictionary of name/value pairs. /// The name represents the name of a control within templated content, and the /// value is the current value of a property value bound using two-way ASP.NET /// data-binding syntax. /// </returns> public IOrderedDictionary ExtractValues(Control container) { IOrderedDictionary multi = null; IOrderedDictionary temp; if (HasTemplates) { multi = _templates[0].ExtractValues(container); // extract the values for each of the templates for (int i = 1; i < _templates.Length; i++) { temp = _templates[i].ExtractValues(container); // copy over to the first collection foreach (Object key in temp.Keys) { multi.Add(key, temp[key]); } } } // return the combined collection return(multi); }
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly) { if (this.UseCheckBox) { 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); } } } else { base.ExtractValuesFromCell(dictionary, cell, rowState, includeReadOnly); } }
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); } } }
/// <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); } } }
private void AddValues(IOrderedDictionary values) { //the settings property holds either MSMQ or FTP settings //and as it is a "special" property we need to help the databinding a little MultiView multiView = GetControl <MultiView>("MultiViewSettings", PageFormView); ConnectionSettings connectionSettings; if ( (Integration.Connection.ChannelTypeEnum)Enum.Parse(typeof(Integration.Connection.ChannelTypeEnum), GetControl <DropDownList>("DropDownListChannel", PageFormView).SelectedValue) == Integration.Connection.ChannelTypeEnum.MSMQ) { connectionSettings = new MSMQConnectionSettings(); ((MSMQConnectionSettings)connectionSettings).QueueName = GetControl <DropDownList>("DropDownListQueues", multiView).Text; } else { connectionSettings = new FTPConnectionSettings(); ((FTPConnectionSettings)connectionSettings).Port = Convert.ToInt32(GetControl <TextBox>("TextBoxPort", multiView).Text); ((FTPConnectionSettings)connectionSettings).IpAddress = GetControl <TextBox>("TextBoxIPAddress", multiView).Text; ((FTPConnectionSettings)connectionSettings).Password = GetControl <TextBox>("TextBoxPassword", multiView).Text; ((FTPConnectionSettings)connectionSettings).Username = GetControl <TextBox>("TextBoxUserName", multiView).Text; ((FTPConnectionSettings)connectionSettings).ErrorCount = Convert.ToInt32(GetControl <TextBox>("TextBoxErrorCount", multiView).Text); } values.Add("Settings", connectionSettings); }
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); } }
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); } }
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly) { var key = DataField; object value = null; if (cell.Controls.Count > 0) { var control = cell.Controls[0]; var list = control as DropDownList; if ((list != null) && list.Items.Count > 0 && (includeReadOnly || list.Enabled)) { value = list.SelectedValue; } } if (value != null) { if (dictionary.Contains(key)) { dictionary[key] = value; } else { dictionary.Add(key, value); } } }
/// <summary> /// 从单元格取出数值 /// </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) { Control control = null; string dataField = this.DataField; object obj2 = null; if (cell.Controls.Count > 0) { control = cell.Controls[0]; DropDownList box = control as DropDownList; if ((box != null) && (includeReadOnly || box.Enabled)) { obj2 = box.SelectedValue; } } if (obj2 != null) { if (dictionary.Contains(dataField)) { dictionary[dataField] = obj2; } else { dictionary.Add(dataField, obj2); } } }
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly) { string dataField = DataField; object obj2 = null; // object obj3 = null; if (cell.Controls.Count > 0) { // Get column editor of type DropDownList of current cell Control control = cell.Controls[0]; DropDownList dropDownList = control as DropDownList; if ((dropDownList != null) && (includeReadOnly || dropDownList.Enabled)) { obj2 = dropDownList.Text; } } if (obj2 != null) { if (dictionary.Contains(dataField)) { dictionary[dataField] = obj2; } else { //put both text and value into the dictionary dictionary.Add(dataField, obj2); } } }
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); }
/// <summary> /// Adds values before saving. /// </summary> /// <param name="values">The values.</param> private void AddValues(IOrderedDictionary values) { DropDownList dropDownListDestinationValue = GetControl <DropDownList>("DropDownListDestinationValue", PageFormView); if (dropDownListDestinationValue.Visible) { values.Add("DestinationValue", dropDownListDestinationValue.SelectedValue); } else { TextBox textBoxDestinationValue = GetControl <TextBox>("TextBoxDestinationValue", PageFormView); values.Add("DestinationValue", textBoxDestinationValue.Text); } values.Add("mappingPropertyAssociationId", GetDropDownListDestinationPropertyControl().SelectedValue); }
void AddDataKey(string key, object value, IOrderedDictionary dics) { foreach (string s in PanelContext.DataKeys) { if (s == key) { dics.Add(key, value); } } }
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); } } } }
/// <summary> /// Initialize a new <see cref="ParameterCollection"/> with the given collection /// of <see cref="IMethodParameter"/>s. /// </summary> /// <param name="parameters">The parameters to add to the collection.</param> public ParameterCollection(IEnumerable <IMethodParameter> parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } foreach (var parameter in parameters) { _parameters.Add(parameter.Name, parameter); } }
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); } }
private void Load(IParser parser, DocumentLoadingState state) { var mapping = parser.Consume <MappingStart>(); Load(mapping, state); Style = mapping.Style; bool hasUnresolvedAliases = false; while (!parser.TryConsume <MappingEnd>(out var _)) { var key = ParseNode(parser, state); var value = ParseNode(parser, state); try { children.Add(key, value); } catch (ArgumentException err) { throw new YamlException(key.Start, key.End, "Duplicate key", err); } hasUnresolvedAliases |= key is YamlAliasNode || value is YamlAliasNode; } if (hasUnresolvedAliases) { state.AddNodeWithUnresolvedAliases(this); } }
/// <summary> /// Read the value in the templates and add to dictionary /// </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) { if ((rowState & DataControlRowState.Edit) == DataControlRowState.Edit) { if (this.EditItemTemplate != null) { IBindableTemplate templ = (IBindableTemplate)this.EditItemTemplate; IOrderedDictionary dict = templ.ExtractValues(cell); foreach (var key in dict.Keys) { dictionary.Add(key, dict[key]); } } } else if ((rowState & DataControlRowState.Insert) == DataControlRowState.Insert) { IBindableTemplate templ = (IBindableTemplate)(this.InsertItemTemplate ?? this.EditItemTemplate); if (templ != null) { IOrderedDictionary dict = templ.ExtractValues(cell); foreach (var key in dict.Keys) { dictionary.Add(key, dict[key]); } } } else if (cell.HasControls()) { // We will not have controls during deleting GridViewRow row = (GridViewRow)cell.NamingContainer; Label lbl = (Label)cell.Controls[0]; _extractedValue = new Pair(); _extractedValue.First = row.RowIndex; _extractedValue.Second = lbl.Text; } base.ExtractValuesFromCell(dictionary, cell, rowState, includeReadOnly); }
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly) { Control control = null; string dataField = this.DataField; object obj2 = null; object obj3 = null; if (cell.Controls.Count > 0) { // Get column editor of type DropDownList of current cell control = cell.Controls[0]; DropDownList box = control as DropDownList; if ((box != null) && (includeReadOnly || box.Enabled)) { obj2 = box.Text; if (obj2 != null) { // extract value from DropDownList ListItem itm = box.Items.FindByValue(obj2.ToString()); obj3 = itm.Text; } } } if (obj2 != null) { if (dictionary.Contains(dataField)) { dictionary[dataField] = obj2; } else { //put both text and value into the dictionary dictionary.Add(dataField, obj3); dictionary.Add(this.IDDataField, obj2); } } }
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); } } }
public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly) { Control editor = null; String field = this.DataField; Boolean valueSet = false; Object currentValue = null; if (cell.Controls.Count > 0) { editor = cell.Controls[0]; CheckBox checkBoxEditor = editor as CheckBox; if ((checkBoxEditor != null) && (includeReadOnly || checkBoxEditor.Enabled)) { valueSet = true; currentValue = checkBoxEditor.Checked; } ListControl listEditor = editor as ListControl; if ((listEditor != null) && (includeReadOnly || listEditor.Enabled)) { valueSet = true; if (listEditor.SelectedValue == Boolean.TrueString) { currentValue = true; } else if (listEditor.SelectedValue == Boolean.FalseString) { currentValue = false; } else { currentValue = DBNull.Value; } } } if (valueSet) { if (dictionary.Contains(field)) { dictionary[field] = currentValue; } else { dictionary.Add(field, currentValue); } } }
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); } } } }
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); } } } }
/// <summary> /// Extracts the values. /// </summary> /// <param name="container">The container.</param> /// <returns>The values.</returns> public override IOrderedDictionary ExtractValues(Control container) { Assert.ArgumentNotNull(container, "container"); IOrderedDictionary result = base.ExtractValues(container); if (this.Field != null) { OrderStateList orderStateListControl = this.FindControlInContainer(container); if (orderStateListControl != null) { result.Add(this.Field.Name, this.StateUnlocalizer.UnlocalizeState(orderStateListControl.CurrentState)); } } return(result); }
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 pair = (Pair)state[i]; dictionary.Add(pair.First, pair.Second); } } }
/// <summary> /// Initializes a new instance of the <see cref="YamlMappingNode"/> class. /// </summary> /// <param name="events">The events.</param> /// <param name="state">The state.</param> internal YamlMappingNode(EventReader events, DocumentLoadingState state) { MappingStart mapping = events.Expect <MappingStart>(); Load(mapping, state); Style = mapping.Style; bool hasUnresolvedAliases = false; while (!events.Accept <MappingEnd>()) { YamlNode key = ParseNode(events, state); YamlNode value = ParseNode(events, state); try { children.Add(key, value); } catch (ArgumentException err) { throw new YamlException(key.Start, key.End, "Duplicate key", err); } hasUnresolvedAliases |= key is YamlAliasNode || value is YamlAliasNode; } if (hasUnresolvedAliases) { state.AddNodeWithUnresolvedAliases(this); } #if DEBUG else { foreach (var child in children) { if (child.Key is YamlAliasNode) { throw new InvalidOperationException("Error in alias resolution."); } if (child.Value is YamlAliasNode) { throw new InvalidOperationException("Error in alias resolution."); } } } #endif events.Expect <MappingEnd>(); }
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); } } }
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); } }
/// <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); } } }
/// <summary> /// Start call context /// </summary> /// <returns>id of the context node</returns> public Guid?StartCallContext() { RemoveEndedCallContexts(); Guid?nodeGuid = null; if (m_stackCount > 0) { LinkedListNode <ConcurrentDictionary <string, object> > dataNode = new LinkedListNode <ConcurrentDictionary <string, object> >(SharedData); m_dataStack.AddFirst(dataNode); m_data = null; nodeGuid = Guid.NewGuid(); lock (m_nodesDictionary) { m_nodesDictionary.Add(nodeGuid, dataNode); } } Interlocked.Increment(ref m_stackCount); return(nodeGuid); }
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); } }
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); }
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); } } } }
/// <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); } } }
/// <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)); } }
/// <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]); } }
/// <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); } } }