Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / ParsedAttributeCollection.cs / 1305376 / ParsedAttributeCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections; using System.Collections.Specialized; using System.Globalization; using System.Web.Util; ////// Contains parsed attributes organized by filter. /// The IDictionary implementation uses the combination of all filters using filter:attrName as the attribute names /// internal sealed class ParsedAttributeCollection : IDictionary { private IDictionary _filterTable; private IDictionary _allFiltersDictionary; internal ParsedAttributeCollection() { _filterTable = new ListDictionary(StringComparer.OrdinalIgnoreCase); } ////// Returns the combination of all filters using filter:attrName as the attribute names /// private IDictionary AllFiltersDictionary { get { if (_allFiltersDictionary == null) { _allFiltersDictionary = new ListDictionary(StringComparer.OrdinalIgnoreCase); foreach (FilteredAttributeDictionary fac in _filterTable.Values) { foreach (DictionaryEntry entry in fac) { Debug.Assert(entry.Key != null); _allFiltersDictionary[Util.CreateFilteredName(fac.Filter, entry.Key.ToString())] = entry.Value; } } } return _allFiltersDictionary; } } ////// Adds a filtered attribute /// public void AddFilteredAttribute(string filter, string name, string value) { if (String.IsNullOrEmpty(name)) { throw ExceptionUtil.ParameterNullOrEmpty("name"); } if (value == null) { throw new ArgumentNullException("value"); } if (filter == null) { filter = String.Empty; } if (_allFiltersDictionary != null) { _allFiltersDictionary.Add(Util.CreateFilteredName(filter, name), value); } FilteredAttributeDictionary filteredAttributes = (FilteredAttributeDictionary)_filterTable[filter]; if (filteredAttributes == null) { filteredAttributes = new FilteredAttributeDictionary(this, filter); _filterTable[filter] = filteredAttributes; } filteredAttributes.Data.Add(name, value); } ////// Clears all attributes from the specified filter /// public void ClearFilter(string filter) { if (filter == null) { filter = String.Empty; } if (_allFiltersDictionary != null) { ArrayList removeList = new ArrayList(); foreach (string key in _allFiltersDictionary.Keys) { string attrName; string currentFilter = Util.ParsePropertyDeviceFilter(key, out attrName); if (StringUtil.EqualsIgnoreCase(currentFilter, filter)) { removeList.Add(key); } } foreach (string key in removeList) { _allFiltersDictionary.Remove(key); } } _filterTable.Remove(filter); } ////// Gets the collection of FilteredAttributeDictionaries used by this collection. /// public ICollection GetFilteredAttributeDictionaries() { return _filterTable.Values; } ////// Removes the specified attribute from the specified filter. /// public void RemoveFilteredAttribute(string filter, string name) { if (String.IsNullOrEmpty(name)) { throw ExceptionUtil.ParameterNullOrEmpty("name"); } if (filter == null) { filter = String.Empty; } if (_allFiltersDictionary != null) { _allFiltersDictionary.Remove(Util.CreateFilteredName(filter, name)); } FilteredAttributeDictionary filteredAttributes = (FilteredAttributeDictionary)_filterTable[filter]; if (filteredAttributes != null) { filteredAttributes.Data.Remove(name); } } ////// Replaces the specified attribute's value from the specified filter. /// public void ReplaceFilteredAttribute(string filter, string name, string value) { if (String.IsNullOrEmpty(name)) { throw ExceptionUtil.ParameterNullOrEmpty("name"); } if (filter == null) { filter = String.Empty; } if (_allFiltersDictionary != null) { _allFiltersDictionary[Util.CreateFilteredName(filter, name)] = value; } FilteredAttributeDictionary filteredAttributes = (FilteredAttributeDictionary)_filterTable[filter]; if (filteredAttributes == null) { filteredAttributes = new FilteredAttributeDictionary(this, filter); _filterTable[filter] = filteredAttributes; } filteredAttributes.Data[name] = value; } #region IDictionary implementation ///bool IDictionary.IsFixedSize { get { return false; } } /// bool IDictionary.IsReadOnly { get { return false; } } /// object IDictionary.this[object key] { get { return AllFiltersDictionary[key]; } set { if (key == null) { throw new ArgumentNullException("key"); } string attrName; string filter = Util.ParsePropertyDeviceFilter(key.ToString(), out attrName); ReplaceFilteredAttribute(filter, attrName, value.ToString()); } } /// ICollection IDictionary.Keys { get { return AllFiltersDictionary.Keys; } } /// ICollection IDictionary.Values { get { return AllFiltersDictionary.Values; } } /// void IDictionary.Add(object key, object value) { if (key == null) { throw new ArgumentNullException("key"); } if (value == null) { value = String.Empty; } string attrName; string filter = Util.ParsePropertyDeviceFilter(key.ToString(), out attrName); AddFilteredAttribute(filter, attrName, value.ToString()); } /// bool IDictionary.Contains(object key) { return AllFiltersDictionary.Contains(key); } /// void IDictionary.Clear() { AllFiltersDictionary.Clear(); _filterTable.Clear(); } /// IDictionaryEnumerator IDictionary.GetEnumerator() { return AllFiltersDictionary.GetEnumerator(); } /// void IDictionary.Remove(object key) { if (key == null) { throw new ArgumentNullException("key"); } string attrName; string filter = Util.ParsePropertyDeviceFilter(key.ToString(), out attrName); RemoveFilteredAttribute(filter, attrName); } #endregion IDictionary implementation #region ICollection implementation /// int ICollection.Count { get { return AllFiltersDictionary.Count; } } /// bool ICollection.IsSynchronized { get { return ((ICollection)AllFiltersDictionary).IsSynchronized; } } /// object ICollection.SyncRoot { get { return AllFiltersDictionary.SyncRoot; } } /// void ICollection.CopyTo(Array array, int index) { AllFiltersDictionary.CopyTo(array, index); } /// IEnumerator IEnumerable.GetEnumerator() { return AllFiltersDictionary.GetEnumerator(); } #endregion ICollection implementation } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections; using System.Collections.Specialized; using System.Globalization; using System.Web.Util; ////// Contains parsed attributes organized by filter. /// The IDictionary implementation uses the combination of all filters using filter:attrName as the attribute names /// internal sealed class ParsedAttributeCollection : IDictionary { private IDictionary _filterTable; private IDictionary _allFiltersDictionary; internal ParsedAttributeCollection() { _filterTable = new ListDictionary(StringComparer.OrdinalIgnoreCase); } ////// Returns the combination of all filters using filter:attrName as the attribute names /// private IDictionary AllFiltersDictionary { get { if (_allFiltersDictionary == null) { _allFiltersDictionary = new ListDictionary(StringComparer.OrdinalIgnoreCase); foreach (FilteredAttributeDictionary fac in _filterTable.Values) { foreach (DictionaryEntry entry in fac) { Debug.Assert(entry.Key != null); _allFiltersDictionary[Util.CreateFilteredName(fac.Filter, entry.Key.ToString())] = entry.Value; } } } return _allFiltersDictionary; } } ////// Adds a filtered attribute /// public void AddFilteredAttribute(string filter, string name, string value) { if (String.IsNullOrEmpty(name)) { throw ExceptionUtil.ParameterNullOrEmpty("name"); } if (value == null) { throw new ArgumentNullException("value"); } if (filter == null) { filter = String.Empty; } if (_allFiltersDictionary != null) { _allFiltersDictionary.Add(Util.CreateFilteredName(filter, name), value); } FilteredAttributeDictionary filteredAttributes = (FilteredAttributeDictionary)_filterTable[filter]; if (filteredAttributes == null) { filteredAttributes = new FilteredAttributeDictionary(this, filter); _filterTable[filter] = filteredAttributes; } filteredAttributes.Data.Add(name, value); } ////// Clears all attributes from the specified filter /// public void ClearFilter(string filter) { if (filter == null) { filter = String.Empty; } if (_allFiltersDictionary != null) { ArrayList removeList = new ArrayList(); foreach (string key in _allFiltersDictionary.Keys) { string attrName; string currentFilter = Util.ParsePropertyDeviceFilter(key, out attrName); if (StringUtil.EqualsIgnoreCase(currentFilter, filter)) { removeList.Add(key); } } foreach (string key in removeList) { _allFiltersDictionary.Remove(key); } } _filterTable.Remove(filter); } ////// Gets the collection of FilteredAttributeDictionaries used by this collection. /// public ICollection GetFilteredAttributeDictionaries() { return _filterTable.Values; } ////// Removes the specified attribute from the specified filter. /// public void RemoveFilteredAttribute(string filter, string name) { if (String.IsNullOrEmpty(name)) { throw ExceptionUtil.ParameterNullOrEmpty("name"); } if (filter == null) { filter = String.Empty; } if (_allFiltersDictionary != null) { _allFiltersDictionary.Remove(Util.CreateFilteredName(filter, name)); } FilteredAttributeDictionary filteredAttributes = (FilteredAttributeDictionary)_filterTable[filter]; if (filteredAttributes != null) { filteredAttributes.Data.Remove(name); } } ////// Replaces the specified attribute's value from the specified filter. /// public void ReplaceFilteredAttribute(string filter, string name, string value) { if (String.IsNullOrEmpty(name)) { throw ExceptionUtil.ParameterNullOrEmpty("name"); } if (filter == null) { filter = String.Empty; } if (_allFiltersDictionary != null) { _allFiltersDictionary[Util.CreateFilteredName(filter, name)] = value; } FilteredAttributeDictionary filteredAttributes = (FilteredAttributeDictionary)_filterTable[filter]; if (filteredAttributes == null) { filteredAttributes = new FilteredAttributeDictionary(this, filter); _filterTable[filter] = filteredAttributes; } filteredAttributes.Data[name] = value; } #region IDictionary implementation ///bool IDictionary.IsFixedSize { get { return false; } } /// bool IDictionary.IsReadOnly { get { return false; } } /// object IDictionary.this[object key] { get { return AllFiltersDictionary[key]; } set { if (key == null) { throw new ArgumentNullException("key"); } string attrName; string filter = Util.ParsePropertyDeviceFilter(key.ToString(), out attrName); ReplaceFilteredAttribute(filter, attrName, value.ToString()); } } /// ICollection IDictionary.Keys { get { return AllFiltersDictionary.Keys; } } /// ICollection IDictionary.Values { get { return AllFiltersDictionary.Values; } } /// void IDictionary.Add(object key, object value) { if (key == null) { throw new ArgumentNullException("key"); } if (value == null) { value = String.Empty; } string attrName; string filter = Util.ParsePropertyDeviceFilter(key.ToString(), out attrName); AddFilteredAttribute(filter, attrName, value.ToString()); } /// bool IDictionary.Contains(object key) { return AllFiltersDictionary.Contains(key); } /// void IDictionary.Clear() { AllFiltersDictionary.Clear(); _filterTable.Clear(); } /// IDictionaryEnumerator IDictionary.GetEnumerator() { return AllFiltersDictionary.GetEnumerator(); } /// void IDictionary.Remove(object key) { if (key == null) { throw new ArgumentNullException("key"); } string attrName; string filter = Util.ParsePropertyDeviceFilter(key.ToString(), out attrName); RemoveFilteredAttribute(filter, attrName); } #endregion IDictionary implementation #region ICollection implementation /// int ICollection.Count { get { return AllFiltersDictionary.Count; } } /// bool ICollection.IsSynchronized { get { return ((ICollection)AllFiltersDictionary).IsSynchronized; } } /// object ICollection.SyncRoot { get { return AllFiltersDictionary.SyncRoot; } } /// void ICollection.CopyTo(Array array, int index) { AllFiltersDictionary.CopyTo(array, index); } /// IEnumerator IEnumerable.GetEnumerator() { return AllFiltersDictionary.GetEnumerator(); } #endregion ICollection implementation } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DebugInfoGenerator.cs
- XmlNamespaceMapping.cs
- FileFormatException.cs
- UserControlFileEditor.cs
- SafeEventLogWriteHandle.cs
- _FixedSizeReader.cs
- BaseHashHelper.cs
- PassportAuthentication.cs
- ResourceReferenceExpression.cs
- SelectionBorderGlyph.cs
- AVElementHelper.cs
- TemplateField.cs
- XmlSerializer.cs
- Transform.cs
- StringResourceManager.cs
- NamespaceDisplayAutomationPeer.cs
- ToolBarButton.cs
- EndPoint.cs
- DataGridViewColumnEventArgs.cs
- EventLogPermission.cs
- ProtocolsSection.cs
- ObjectDataSourceMethodEventArgs.cs
- DocComment.cs
- DesignerObjectListAdapter.cs
- InheritanceRules.cs
- DateTimePicker.cs
- ThreadInterruptedException.cs
- OptimalTextSource.cs
- PartialTrustVisibleAssembly.cs
- ProgressBar.cs
- OrthographicCamera.cs
- EntityUtil.cs
- Polygon.cs
- IconEditor.cs
- UnaryNode.cs
- XmlSchemaComplexType.cs
- WebPartConnectVerb.cs
- DataRelationPropertyDescriptor.cs
- SqlDataSource.cs
- ExceptionUtil.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- keycontainerpermission.cs
- ErrorWebPart.cs
- RichTextBoxAutomationPeer.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- WorkflowMarkupSerializer.cs
- WorkflowItemsPresenter.cs
- MatrixConverter.cs
- ProcessProtocolHandler.cs
- ObjectListFieldsPage.cs
- DecimalAnimation.cs
- SqlParameterCollection.cs
- FocusManager.cs
- ResourceProperty.cs
- URLString.cs
- PropertyEmitterBase.cs
- WindowsGraphicsCacheManager.cs
- SafeBitVector32.cs
- ContextDataSourceView.cs
- StatusBarPanelClickEvent.cs
- TraceSwitch.cs
- DateTimeStorage.cs
- FreezableCollection.cs
- FileDialog_Vista.cs
- RecognitionEventArgs.cs
- NumberEdit.cs
- FrameworkContentElement.cs
- LinearQuaternionKeyFrame.cs
- ClientApiGenerator.cs
- DataServiceRequest.cs
- BooleanProjectedSlot.cs
- QuaternionRotation3D.cs
- XhtmlBasicSelectionListAdapter.cs
- PropertyTabChangedEvent.cs
- ControlPaint.cs
- ReadWriteObjectLock.cs
- WebPart.cs
- LocalBuilder.cs
- PeerObject.cs
- SmtpFailedRecipientException.cs
- DataTableMapping.cs
- TCPClient.cs
- TimelineGroup.cs
- HashHelper.cs
- TextServicesCompartmentContext.cs
- ParenthesizePropertyNameAttribute.cs
- HMACRIPEMD160.cs
- DataKeyCollection.cs
- GenericEnumerator.cs
- ECDsaCng.cs
- ProgressBarHighlightConverter.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- RoleManagerSection.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- TrackingConditionCollection.cs
- FileDialogCustomPlacesCollection.cs
- IsolatedStorageFilePermission.cs
- Shape.cs
- WebContext.cs
- ReferenceService.cs