Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Services / Monitoring / system / Diagnosticts / Design / InstanceNameConverter.cs / 1 / InstanceNameConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Diagnostics.Design { using System.Runtime.Serialization.Formatters; using System.Globalization; using System.Diagnostics; using System; using System.Windows.Forms.ComponentModel; using System.ComponentModel; using System.ComponentModel.Design; using System.Collections; internal class InstanceNameConverter : TypeConverter { ////// /// public InstanceNameConverter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { string text = ((string)value).Trim(); return text; } return base.ConvertFrom(context, culture, value); } ////// Initializes a new instance of the 'InstanceNameConverter' class for the given type. /// ////// /// /// public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { PerformanceCounter counter = (context == null) ? null : context.Instance as PerformanceCounter; string machineName = "."; string categoryName = String.Empty; if (counter != null) { machineName = counter.MachineName; categoryName = counter.CategoryName; } try { PerformanceCounterCategory cat = new PerformanceCounterCategory(categoryName, machineName); string[] retVal =cat.GetInstanceNames(); Array.Sort(retVal, Comparer.Default); return new StandardValuesCollection(retVal); } catch(Exception) { ; // do nothing } return null; } ///Gets a collection of standard values for the data type this validator is /// designed for. ////// /// /// public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.Gets a value indicating /// whether this object /// supports a standard set of values that can be picked /// from a list using the specified context. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ToolboxComponentsCreatedEventArgs.cs
- TrackingStringDictionary.cs
- HtmlShim.cs
- DbDataSourceEnumerator.cs
- PackWebResponse.cs
- MarkupCompilePass1.cs
- HtmlTableRowCollection.cs
- DrawingContextWalker.cs
- SafeNativeMethods.cs
- mda.cs
- ConfigXmlCDataSection.cs
- TextTreeText.cs
- SrgsElement.cs
- HierarchicalDataSourceConverter.cs
- DbSetClause.cs
- TimelineGroup.cs
- SchemaDeclBase.cs
- XmlSchemaDatatype.cs
- XmlQueryType.cs
- ProcessHostMapPath.cs
- PropertyTabChangedEvent.cs
- ResXResourceWriter.cs
- PointIndependentAnimationStorage.cs
- Window.cs
- TraceContextRecord.cs
- OdbcEnvironmentHandle.cs
- WebControl.cs
- ThemeDictionaryExtension.cs
- XmlSchemaCompilationSettings.cs
- ToolboxItemAttribute.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- PackWebRequest.cs
- DesignTimeParseData.cs
- DownloadProgressEventArgs.cs
- BrowserCapabilitiesFactory.cs
- DoubleSumAggregationOperator.cs
- HybridWebProxyFinder.cs
- GrammarBuilderBase.cs
- ModuleBuilder.cs
- WeakReferenceEnumerator.cs
- TransformGroup.cs
- DataObjectFieldAttribute.cs
- IndicFontClient.cs
- RubberbandSelector.cs
- AccessedThroughPropertyAttribute.cs
- TemplateApplicationHelper.cs
- NumberFormatInfo.cs
- InstanceDataCollectionCollection.cs
- CodeConstructor.cs
- ObjectListFieldsPage.cs
- Psha1DerivedKeyGeneratorHelper.cs
- CheckPair.cs
- DescendentsWalkerBase.cs
- __Filters.cs
- TableRow.cs
- ThreadSafeList.cs
- DataGridPageChangedEventArgs.cs
- WorkflowInstance.cs
- WorkflowInstanceSuspendedRecord.cs
- NamespaceQuery.cs
- SymbolEqualComparer.cs
- SQLByte.cs
- VisualBrush.cs
- ZipArchive.cs
- VolatileResourceManager.cs
- XmlSchemaType.cs
- LogicalCallContext.cs
- PersonalizationStateInfo.cs
- BindToObject.cs
- DocumentPageView.cs
- CompilerCollection.cs
- ReadOnlyPropertyMetadata.cs
- Number.cs
- SqlCommandBuilder.cs
- StreamGeometry.cs
- UnsafeNativeMethodsTablet.cs
- UserControlCodeDomTreeGenerator.cs
- PEFileReader.cs
- SimpleFieldTemplateUserControl.cs
- BaseValidator.cs
- ObjectHandle.cs
- FontNameEditor.cs
- CheckBoxBaseAdapter.cs
- CacheOutputQuery.cs
- FixedSOMPageElement.cs
- MultiPageTextView.cs
- DynamicResourceExtensionConverter.cs
- WindowsMenu.cs
- ThreadNeutralSemaphore.cs
- CoreSwitches.cs
- ReferenceEqualityComparer.cs
- ObfuscateAssemblyAttribute.cs
- ObjectDataSourceChooseTypePanel.cs
- SwitchElementsCollection.cs
- TimerElapsedEvenArgs.cs
- TypeBuilderInstantiation.cs
- SiteOfOriginContainer.cs
- FixedSchema.cs
- RadioButton.cs
- XhtmlBasicImageAdapter.cs