Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Services / Monitoring / system / Diagnosticts / Design / CategoryValueConverter.cs / 1 / CategoryValueConverter.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 CategoryValueConverter : TypeConverter { ////// /// private StandardValuesCollection values; private string previousMachineName; ////// Provides a ///that specifies the /// possible values for the enumeration. /// /// /// public CategoryValueConverter() { } 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 'CategoryValueConverter' class for the given type. /// ////// /// /// public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { PerformanceCounter counter = (context == null) ? null : context.Instance as PerformanceCounter; string machineName = "."; if (counter != null) { machineName = counter.MachineName; } if (machineName == previousMachineName) return values; else previousMachineName = machineName; try { PerformanceCounter.CloseSharedResources(); PerformanceCounterCategory[] cats = PerformanceCounterCategory.GetCategories(machineName); string[] retVal = new string[cats.Length]; for (int i = 0; i < cats.Length; i++) { retVal[i] = cats[i].CategoryName; } Array.Sort(retVal, Comparer.Default); values = new StandardValuesCollection(retVal); } catch (Exception) { values = null; } return values; } ///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
- ProfilePropertySettings.cs
- InkCollectionBehavior.cs
- ZoneButton.cs
- BinaryConverter.cs
- BindingBase.cs
- MessageRpc.cs
- WebPartsPersonalization.cs
- ParserStreamGeometryContext.cs
- OleDbPropertySetGuid.cs
- Point3DCollectionConverter.cs
- CssClassPropertyAttribute.cs
- LambdaCompiler.ControlFlow.cs
- ActivityCodeDomSerializer.cs
- SymLanguageType.cs
- WindowsListBox.cs
- DataSourceControlBuilder.cs
- FilterElement.cs
- UIElementAutomationPeer.cs
- MetadataHelper.cs
- ReturnEventArgs.cs
- EditorZoneBase.cs
- CodeCastExpression.cs
- EncoderFallback.cs
- ControlTemplate.cs
- FontFamily.cs
- EmbeddedMailObject.cs
- datacache.cs
- BasicAsyncResult.cs
- DbParameterCollectionHelper.cs
- SymLanguageType.cs
- DocumentPageView.cs
- XmlDeclaration.cs
- TextParagraph.cs
- FlowDocument.cs
- HttpChannelHelpers.cs
- NativeCppClassAttribute.cs
- DataGridViewColumnStateChangedEventArgs.cs
- WebPermission.cs
- Rotation3D.cs
- COSERVERINFO.cs
- UIntPtr.cs
- HTTPRemotingHandler.cs
- TemplatedMailWebEventProvider.cs
- ConnectionProviderAttribute.cs
- DefaultPropertyAttribute.cs
- ReaderContextStackData.cs
- RowBinding.cs
- XPathQilFactory.cs
- TreeNodeStyleCollection.cs
- SqlUserDefinedTypeAttribute.cs
- SoapMessage.cs
- PersistChildrenAttribute.cs
- RepeatEnumerable.cs
- ComplexObject.cs
- FileRecordSequenceHelper.cs
- DetailsViewRowCollection.cs
- TextSimpleMarkerProperties.cs
- GridProviderWrapper.cs
- ModelTreeEnumerator.cs
- VBIdentifierName.cs
- ReferenceEqualityComparer.cs
- GZipStream.cs
- ProviderConnectionPointCollection.cs
- LOSFormatter.cs
- DocumentPage.cs
- COAUTHIDENTITY.cs
- NegotiateStream.cs
- IdleTimeoutMonitor.cs
- CollectionDataContract.cs
- JpegBitmapEncoder.cs
- CollectionBase.cs
- EndPoint.cs
- TextBoxBase.cs
- SingleQueryOperator.cs
- MaskedTextProvider.cs
- ContainerUIElement3D.cs
- SecurityException.cs
- XmlSerializableReader.cs
- MenuCommands.cs
- WindowsTreeView.cs
- FixedTextContainer.cs
- ConstructorNeedsTagAttribute.cs
- CryptoStream.cs
- XPathNavigatorKeyComparer.cs
- FormViewUpdatedEventArgs.cs
- TextChange.cs
- StringCollectionMarkupSerializer.cs
- DependencyPropertyAttribute.cs
- ViewManager.cs
- DataColumnChangeEvent.cs
- AccessText.cs
- PenThread.cs
- HttpListenerPrefixCollection.cs
- SpeechRecognitionEngine.cs
- rsa.cs
- Path.cs
- MailBnfHelper.cs
- TemplateXamlParser.cs
- ComponentResourceKey.cs
- DefaultProxySection.cs