Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / Monitoring / System / Diagnostics / Design / LogConverter.cs / 1 / LogConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Diagnostics.Design { using System.Runtime.Serialization.Formatters; using System.ComponentModel; using System.Diagnostics; using System; using System.Collections; using System.Windows.Forms; using Microsoft.Win32; using System.ComponentModel.Design; using System.Globalization; ////// /// LogConverter is the TypeConverter for the Log property on EventLog. It returns /// a list of all event logs on the system. /// [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)] public class LogConverter : TypeConverter { ////// /// private StandardValuesCollection values; private string oldMachineName; ////// Provides a ///that specifies the /// possible values for the enumeration. /// /// /// public LogConverter() { } ////// Initializes a new instance of the LogConverter class for the given /// type. /// ///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); } /// /// /// /// public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { EventLog component = (context == null) ? null : context.Instance as EventLog; string machineName = "."; if (component != null) machineName = component.MachineName; if (values == null || machineName != oldMachineName) { try { EventLog[] eventLogs = EventLog.GetEventLogs(machineName); object[] names = new object[eventLogs.Length]; for (int i = 0; i < names.Length; i++) names[i] = eventLogs[i].Log; values = new StandardValuesCollection(names); oldMachineName = machineName; } catch(Exception) { //Do Nothing } } 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
- Overlapped.cs
- ProfileSettings.cs
- TableCell.cs
- SetterTriggerConditionValueConverter.cs
- GenerateTemporaryTargetAssembly.cs
- LinkConverter.cs
- DecimalConstantAttribute.cs
- XmlDataSourceNodeDescriptor.cs
- UnsafeNativeMethodsCLR.cs
- IntPtr.cs
- Roles.cs
- DownloadProgressEventArgs.cs
- ManifestBasedResourceGroveler.cs
- PublisherIdentityPermission.cs
- SafeCertificateStore.cs
- DataBoundControlAdapter.cs
- UriWriter.cs
- ThreadExceptionDialog.cs
- SchemaElementDecl.cs
- DesignSurfaceCollection.cs
- SecureStringHasher.cs
- RightNameExpirationInfoPair.cs
- HyperLinkStyle.cs
- MetricEntry.cs
- HwndStylusInputProvider.cs
- WebPartChrome.cs
- HeaderCollection.cs
- EntityCollection.cs
- NameTable.cs
- ListMarkerLine.cs
- MarkupProperty.cs
- InvalidProgramException.cs
- SqlUtils.cs
- SubMenuStyleCollection.cs
- XamlPoint3DCollectionSerializer.cs
- comcontractssection.cs
- Context.cs
- ShapeTypeface.cs
- SemanticResolver.cs
- RecordsAffectedEventArgs.cs
- StylusDevice.cs
- VScrollProperties.cs
- ExceptionTrace.cs
- HtmlGenericControl.cs
- OracleFactory.cs
- MissingMemberException.cs
- embossbitmapeffect.cs
- _ListenerAsyncResult.cs
- Process.cs
- SystemException.cs
- CheckBox.cs
- EntityConnection.cs
- TextServicesHost.cs
- PersonalizableTypeEntry.cs
- DiscoveryDocumentSerializer.cs
- TextViewSelectionProcessor.cs
- PersonalizationProviderCollection.cs
- MustUnderstandSoapException.cs
- GeometryDrawing.cs
- GetUserPreferenceRequest.cs
- ParserContext.cs
- MemberPathMap.cs
- ConfigurationManagerHelper.cs
- UpdateProgress.cs
- TypeSource.cs
- PerspectiveCamera.cs
- CharEnumerator.cs
- SqlDataSourceConnectionPanel.cs
- SqlDataSourceCache.cs
- EtwTrackingParticipant.cs
- XmlSchemaSequence.cs
- NavigationExpr.cs
- CrossSiteScriptingValidation.cs
- Effect.cs
- SerTrace.cs
- AtomPub10ServiceDocumentFormatter.cs
- ResourceAttributes.cs
- shaperfactoryquerycacheentry.cs
- ExternalException.cs
- SharedPersonalizationStateInfo.cs
- WindowsListViewItemStartMenu.cs
- InProcStateClientManager.cs
- TextContainerHelper.cs
- DataGridAutoFormatDialog.cs
- BehaviorEditorPart.cs
- UInt64Converter.cs
- PopupRootAutomationPeer.cs
- XmlSchemaElement.cs
- ConfigXmlReader.cs
- HeaderCollection.cs
- TextEffectResolver.cs
- PropertyState.cs
- WmpBitmapEncoder.cs
- SQLBytesStorage.cs
- Rules.cs
- HttpListenerElement.cs
- ComponentCollection.cs
- PropertyMapper.cs
- ConfigXmlWhitespace.cs
- ResourceCodeDomSerializer.cs