Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / ControlIdConverter.cs / 1 / 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. /// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] 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. //------------------------------------------------------------------------------ //// 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. /// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ReaderWriterLock.cs
- DataGridRow.cs
- Triplet.cs
- AutoResizedEvent.cs
- HwndMouseInputProvider.cs
- QueueProcessor.cs
- ClientFormsAuthenticationCredentials.cs
- XPathPatternBuilder.cs
- Decimal.cs
- Brushes.cs
- StreamInfo.cs
- HijriCalendar.cs
- AuthorizationRule.cs
- XmlFileEditor.cs
- XmlILModule.cs
- FlowDocumentFormatter.cs
- ComContractElementCollection.cs
- NCryptSafeHandles.cs
- ItemPager.cs
- BufferedWebEventProvider.cs
- SingleObjectCollection.cs
- XamlSerializerUtil.cs
- NetNamedPipeBindingCollectionElement.cs
- UpdatePanelTriggerCollection.cs
- SqlDataRecord.cs
- TextParagraphView.cs
- ObjectQueryProvider.cs
- TraceProvider.cs
- WindowsTokenRoleProvider.cs
- Errors.cs
- basecomparevalidator.cs
- DataGridPageChangedEventArgs.cs
- DeviceContext2.cs
- ToolStripStatusLabel.cs
- InfoCardTrace.cs
- SymbolUsageManager.cs
- XmlEventCache.cs
- CodeDomLoader.cs
- TransportReplyChannelAcceptor.cs
- SerializationInfoEnumerator.cs
- Int16Storage.cs
- Brushes.cs
- CompareValidator.cs
- IUnknownConstantAttribute.cs
- TimerEventSubscription.cs
- ComponentManagerBroker.cs
- DataGridDesigner.cs
- ReadOnlyCollectionBase.cs
- XmlCountingReader.cs
- AlignmentYValidation.cs
- PasswordTextNavigator.cs
- DurationConverter.cs
- ObjectRef.cs
- DoubleCollectionConverter.cs
- DataGridViewSelectedRowCollection.cs
- ImpersonationContext.cs
- ListSortDescription.cs
- FixedSchema.cs
- SizeConverter.cs
- XmlDocumentFragment.cs
- TextRangeEdit.cs
- BindStream.cs
- HtmlObjectListAdapter.cs
- NativeCompoundFileAPIs.cs
- StickyNoteAnnotations.cs
- PeerHopCountAttribute.cs
- EdmProviderManifest.cs
- ObjectSerializerFactory.cs
- SchemaName.cs
- CompilationPass2TaskInternal.cs
- UserMapPath.cs
- ContextMenuStrip.cs
- Hash.cs
- LambdaCompiler.Expressions.cs
- TaskExceptionHolder.cs
- FileClassifier.cs
- CanExpandCollapseAllConverter.cs
- Int64AnimationUsingKeyFrames.cs
- FunctionOverloadResolver.cs
- Html32TextWriter.cs
- DataObjectMethodAttribute.cs
- KeyPressEvent.cs
- SafeEventLogWriteHandle.cs
- DoWorkEventArgs.cs
- NoneExcludedImageIndexConverter.cs
- TabControlCancelEvent.cs
- AdapterUtil.cs
- ThreadStateException.cs
- RelationshipEnd.cs
- Shared.cs
- ApplicationInfo.cs
- InplaceBitmapMetadataWriter.cs
- BatchWriter.cs
- WorkflowInspectionServices.cs
- Int64KeyFrameCollection.cs
- DataObjectSettingDataEventArgs.cs
- Brush.cs
- ToolStripComboBox.cs
- ISFClipboardData.cs
- EncryptedKey.cs