Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Services / Monitoring / system / Diagnosticts / Design / CounterCreationDataConverter.cs / 1 / CounterCreationDataConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Diagnostics.Design { using System.Runtime.Serialization.Formatters; using System.Diagnostics; using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Globalization; using System.Reflection; internal class CounterCreationDataConverter : ExpandableObjectConverter { ////// /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ///Gets a value indicating whether this converter can /// convert an object to the given destination type using the context. ////// /// Converts the given object to another type. The most common types to convert /// are to and from a string object. The default implementation will make a call /// to ToString on the object if the object is valid and if the destination /// type is string. If this cannot convert to the desitnation type, this will /// throw a NotSupportedException. /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(InstanceDescriptor) && value is CounterCreationData) { CounterCreationData data = (CounterCreationData)value; ConstructorInfo ctor = typeof(CounterCreationData).GetConstructor(new Type[] { typeof(string), typeof(string), typeof(PerformanceCounterType)}); if (ctor != null) { return new InstanceDescriptor(ctor, new object[] { data.CounterName, data.CounterHelp, data.CounterType}); } } return base.ConvertTo(context, culture, value, destinationType); } } } // 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
- SaveFileDialog.cs
- DataTableClearEvent.cs
- StartFileNameEditor.cs
- ProxyElement.cs
- ToolCreatedEventArgs.cs
- ProcessProtocolHandler.cs
- ContainerSelectorBehavior.cs
- ConstructorExpr.cs
- WeakReadOnlyCollection.cs
- Link.cs
- SettingsPropertyValueCollection.cs
- RepeatBehaviorConverter.cs
- Brush.cs
- UIElementIsland.cs
- UDPClient.cs
- PerformanceCounterCategory.cs
- BaseTemplateParser.cs
- MultiTrigger.cs
- DefaultCommandExtensionCallback.cs
- DateTimeUtil.cs
- AccessViolationException.cs
- SecurityPermission.cs
- SiteMapNodeCollection.cs
- ButtonStandardAdapter.cs
- GridViewPageEventArgs.cs
- TaskHelper.cs
- SettingsSection.cs
- DbTransaction.cs
- BinaryObjectReader.cs
- MemoryMappedViewStream.cs
- IPAddressCollection.cs
- TransformerConfigurationWizardBase.cs
- MappingItemCollection.cs
- MemoryStream.cs
- Crc32Helper.cs
- DependencySource.cs
- TypeHelpers.cs
- XamlToRtfWriter.cs
- FontStretchConverter.cs
- PartialArray.cs
- AvtEvent.cs
- LinqToSqlWrapper.cs
- MobileErrorInfo.cs
- XPathBinder.cs
- AsyncOperation.cs
- localization.cs
- PropertyEntry.cs
- ExpressionVisitorHelpers.cs
- XmlSchemaInclude.cs
- XmlBinaryReader.cs
- ToolStripDropTargetManager.cs
- ImageMapEventArgs.cs
- ChtmlPhoneCallAdapter.cs
- ScalarConstant.cs
- ConsumerConnectionPointCollection.cs
- MsiStyleLogWriter.cs
- EventMappingSettings.cs
- webeventbuffer.cs
- TreeViewEvent.cs
- TableNameAttribute.cs
- FastEncoder.cs
- StackSpiller.Temps.cs
- HttpCachePolicyElement.cs
- HMACSHA256.cs
- FormsAuthenticationCredentials.cs
- DataGridViewCheckBoxCell.cs
- NonClientArea.cs
- ExtensionDataReader.cs
- TimeSpanMinutesConverter.cs
- IncrementalCompileAnalyzer.cs
- FileAuthorizationModule.cs
- DataTable.cs
- SecUtil.cs
- AuthenticatingEventArgs.cs
- ParenExpr.cs
- ByteStream.cs
- CompositeDataBoundControl.cs
- TreeNodeStyle.cs
- AllMembershipCondition.cs
- ListViewItemEventArgs.cs
- HostingEnvironmentException.cs
- PolyBezierSegmentFigureLogic.cs
- SqlUserDefinedAggregateAttribute.cs
- RotateTransform.cs
- UpdatePanel.cs
- XmlSchemaIdentityConstraint.cs
- AuthenticationService.cs
- SessionSwitchEventArgs.cs
- TextBlockAutomationPeer.cs
- XmlSiteMapProvider.cs
- QilExpression.cs
- MediaContext.cs
- UpdatePanelTriggerCollection.cs
- KeyInstance.cs
- WindowsListViewGroup.cs
- Point3DAnimationBase.cs
- AxHost.cs
- Point4DConverter.cs
- Light.cs
- HelpEvent.cs