Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / ControlIdConverter.cs / 1305376 / ControlIdConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Globalization; using System.Reflection; using System.Web.Util; using System.Security.Permissions; ////// TypeConverter for ControlParameter's ControlID property. /// public class ControlIDConverter : StringConverter { ////// protected virtual bool FilterControl(Control control) { return true; } ///Determines whether a given control should have its id added to the StandardValuesCollection. ////// Returns a list of all control IDs in the container. /// private string[] GetControls(IDesignerHost host, object instance) { IContainer container = host.Container; // Locate nearest container IComponent component = instance as IComponent; if (component != null && component.Site != null) { container = component.Site.Container; } if (container == null) { return null; } ComponentCollection allComponents = container.Components; ArrayList array = new ArrayList(); // For each control in the container foreach (IComponent comp in (IEnumerable)allComponents) { Control control = comp as Control; // Ignore DesignerHost.RootComponent (Page or UserControl), controls that don't have ID's, // and the Control itself if (control != null && control != instance && control != host.RootComponent && control.ID != null && control.ID.Length > 0 && FilterControl(control)) { array.Add(control.ID); } } array.Sort(Comparer.Default); return (string[])array.ToArray(typeof(string)); } ////// Returns a collection of standard values retrieved from the context specified /// by the specified type descriptor. /// public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (context == null) { return null; } IDesignerHost host = (IDesignerHost)context.GetService(typeof(IDesignerHost)); Debug.Assert(host != null, "Unable to get IDesignerHost in ControlIDConverter"); if (host != null) { string[] controlIDs = GetControls(host, context.Instance); if (controlIDs == null) { return null; } return new StandardValuesCollection(controlIDs); } return null; } ////// Gets whether or not the context specified contains exclusive standard values. /// public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return false; } ////// Gets whether or not the specified context contains supported standard values. /// public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return (context != null); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Globalization; using System.Reflection; using System.Web.Util; using System.Security.Permissions; ////// TypeConverter for ControlParameter's ControlID property. /// public class ControlIDConverter : StringConverter { ////// protected virtual bool FilterControl(Control control) { return true; } ///Determines whether a given control should have its id added to the StandardValuesCollection. ////// Returns a list of all control IDs in the container. /// private string[] GetControls(IDesignerHost host, object instance) { IContainer container = host.Container; // Locate nearest container IComponent component = instance as IComponent; if (component != null && component.Site != null) { container = component.Site.Container; } if (container == null) { return null; } ComponentCollection allComponents = container.Components; ArrayList array = new ArrayList(); // For each control in the container foreach (IComponent comp in (IEnumerable)allComponents) { Control control = comp as Control; // Ignore DesignerHost.RootComponent (Page or UserControl), controls that don't have ID's, // and the Control itself if (control != null && control != instance && control != host.RootComponent && control.ID != null && control.ID.Length > 0 && FilterControl(control)) { array.Add(control.ID); } } array.Sort(Comparer.Default); return (string[])array.ToArray(typeof(string)); } ////// Returns a collection of standard values retrieved from the context specified /// by the specified type descriptor. /// public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (context == null) { return null; } IDesignerHost host = (IDesignerHost)context.GetService(typeof(IDesignerHost)); Debug.Assert(host != null, "Unable to get IDesignerHost in ControlIDConverter"); if (host != null) { string[] controlIDs = GetControls(host, context.Instance); if (controlIDs == null) { return null; } return new StandardValuesCollection(controlIDs); } return null; } ////// Gets whether or not the context specified contains exclusive standard values. /// public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return false; } ////// Gets whether or not the specified context contains supported standard values. /// public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return (context != null); } } } // 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
- CalendarButtonAutomationPeer.cs
- AddToCollection.cs
- UnauthorizedAccessException.cs
- PersistenceMetadataNamespace.cs
- TrayIconDesigner.cs
- TypeDescriptionProviderAttribute.cs
- Activator.cs
- ChildTable.cs
- PowerStatus.cs
- TableAutomationPeer.cs
- IdnElement.cs
- PropertyBuilder.cs
- ReferenceTypeElement.cs
- PagePropertiesChangingEventArgs.cs
- TextRangeProviderWrapper.cs
- WindowsAltTab.cs
- FormsAuthenticationModule.cs
- PlainXmlSerializer.cs
- _TLSstream.cs
- EncryptedType.cs
- TagMapInfo.cs
- XmlSchemaSimpleTypeUnion.cs
- RegexWorker.cs
- ExecutionScope.cs
- _IPv4Address.cs
- PathGeometry.cs
- TreeNodeCollection.cs
- ToolStripDropDown.cs
- designeractionbehavior.cs
- XamlLoadErrorInfo.cs
- ContentValidator.cs
- CharConverter.cs
- SharedDp.cs
- Set.cs
- ReturnEventArgs.cs
- MultiSelectRootGridEntry.cs
- ErrorFormatter.cs
- DataGridViewRowEventArgs.cs
- DispatcherFrame.cs
- TimestampInformation.cs
- XmlDocumentSerializer.cs
- Keyboard.cs
- TextBlockAutomationPeer.cs
- Viewport2DVisual3D.cs
- InProcStateClientManager.cs
- ValueChangedEventManager.cs
- VisualTreeHelper.cs
- FormattedTextSymbols.cs
- ThreadAbortException.cs
- TraceFilter.cs
- DesignTimeVisibleAttribute.cs
- ResourceCategoryAttribute.cs
- WindowsEditBox.cs
- PackagingUtilities.cs
- EntitySqlException.cs
- NavigationWindow.cs
- BufferCache.cs
- LinkConverter.cs
- _IPv6Address.cs
- DataGridViewDataErrorEventArgs.cs
- StylusTip.cs
- DefaultBinder.cs
- HttpConfigurationContext.cs
- JoinTreeNode.cs
- OdbcReferenceCollection.cs
- WSHttpBindingCollectionElement.cs
- DateTimeValueSerializerContext.cs
- HttpTransportManager.cs
- Menu.cs
- DataGridViewCellValueEventArgs.cs
- PersonalizationProvider.cs
- PerformanceCounter.cs
- SelectionGlyph.cs
- SocketSettings.cs
- OleServicesContext.cs
- SourceChangedEventArgs.cs
- FormViewCommandEventArgs.cs
- InheritanceAttribute.cs
- TextElement.cs
- AuthenticationConfig.cs
- Vector3D.cs
- ClickablePoint.cs
- SharedConnectionWorkflowTransactionService.cs
- BypassElementCollection.cs
- CacheSection.cs
- OciEnlistContext.cs
- unitconverter.cs
- AsymmetricAlgorithm.cs
- MULTI_QI.cs
- TagPrefixAttribute.cs
- TemplateBindingExtension.cs
- HttpRequestTraceRecord.cs
- DataRow.cs
- TwoPhaseCommitProxy.cs
- ForEachAction.cs
- MethodSet.cs
- UserPreferenceChangedEventArgs.cs
- SystemResourceHost.cs
- SystemWebCachingSectionGroup.cs
- DataGridViewEditingControlShowingEventArgs.cs