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
- UserControlParser.cs
- NativeRightsManagementAPIsStructures.cs
- TcpConnectionPoolSettings.cs
- StylusPointPropertyInfoDefaults.cs
- AsmxEndpointPickerExtension.cs
- SaveFileDialog.cs
- SafeLocalMemHandle.cs
- ValueChangedEventManager.cs
- OLEDB_Util.cs
- FixedSchema.cs
- GrowingArray.cs
- EntityDataSourceDataSelection.cs
- MobilePage.cs
- AtlasWeb.Designer.cs
- XamlReader.cs
- EntityFrameworkVersions.cs
- TextSchema.cs
- Baml2006KnownTypes.cs
- DebugView.cs
- RegistryDataKey.cs
- StreamUpdate.cs
- HttpModuleActionCollection.cs
- GeneralTransform.cs
- OrderByBuilder.cs
- DeadLetterQueue.cs
- LineBreak.cs
- ExtentJoinTreeNode.cs
- XmlDataImplementation.cs
- Label.cs
- ScriptManager.cs
- BrowsableAttribute.cs
- MbpInfo.cs
- Route.cs
- WebPartDisplayModeCancelEventArgs.cs
- TextSerializer.cs
- QilXmlReader.cs
- Atom10FormatterFactory.cs
- ManagementQuery.cs
- TrackingValidationObjectDictionary.cs
- UserPreferenceChangingEventArgs.cs
- AttributeEmitter.cs
- XmlIgnoreAttribute.cs
- EmptyStringExpandableObjectConverter.cs
- Compilation.cs
- BindingsCollection.cs
- CssClassPropertyAttribute.cs
- _NestedMultipleAsyncResult.cs
- UpdateCommandGenerator.cs
- Asn1Utilities.cs
- HttpApplicationFactory.cs
- Pair.cs
- InstanceDescriptor.cs
- WindowProviderWrapper.cs
- HttpRequestCacheValidator.cs
- thaishape.cs
- RemoteCryptoSignHashRequest.cs
- TextEndOfSegment.cs
- Viewport3DVisual.cs
- ExpressionConverter.cs
- UnSafeCharBuffer.cs
- StructuredTypeEmitter.cs
- GlyphRun.cs
- HitTestParameters3D.cs
- PropertySourceInfo.cs
- AuthenticationManager.cs
- CanonicalFontFamilyReference.cs
- BuildDependencySet.cs
- Section.cs
- WorkflowWebHostingModule.cs
- CanonicalXml.cs
- RelatedView.cs
- _SafeNetHandles.cs
- StylusEventArgs.cs
- HttpHandlersSection.cs
- MachineKeyConverter.cs
- Metadata.cs
- ElementNotAvailableException.cs
- SaveFileDialog.cs
- MetadataArtifactLoaderResource.cs
- TcpClientCredentialType.cs
- ISFTagAndGuidCache.cs
- XamlLoadErrorInfo.cs
- DoubleStorage.cs
- TextElementCollection.cs
- LayoutTable.cs
- FilteredDataSetHelper.cs
- SelectionPattern.cs
- ToolStripSplitStackLayout.cs
- TreeView.cs
- RelatedEnd.cs
- StringArrayConverter.cs
- WebBrowserHelper.cs
- PipelineDeploymentState.cs
- DataGridViewToolTip.cs
- SmtpReplyReader.cs
- ArraySet.cs
- PartialCachingAttribute.cs
- LinqDataSourceView.cs
- HostProtectionPermission.cs
- SoapParser.cs