Code:
/ DotNET / DotNET / 8.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
- StrongNameUtility.cs
- FrameAutomationPeer.cs
- ClassGenerator.cs
- Normalization.cs
- ObjectDataProvider.cs
- IteratorFilter.cs
- ScopelessEnumAttribute.cs
- BaseConfigurationRecord.cs
- EnumMember.cs
- EntityCollection.cs
- ClientEndpointLoader.cs
- DataServiceKeyAttribute.cs
- DataGridViewRowCollection.cs
- CqlQuery.cs
- ColumnClickEvent.cs
- KnownBoxes.cs
- ToolboxCategoryItems.cs
- CollectionViewProxy.cs
- DbTransaction.cs
- SymbolDocumentInfo.cs
- SchemaMapping.cs
- EntityDataSourceColumn.cs
- FrameworkRichTextComposition.cs
- Geometry3D.cs
- Brush.cs
- EventLogPermissionEntryCollection.cs
- complextypematerializer.cs
- PipelineModuleStepContainer.cs
- smtpconnection.cs
- AmbiguousMatchException.cs
- CompilerCollection.cs
- ReachVisualSerializerAsync.cs
- StringToken.cs
- MsmqIntegrationProcessProtocolHandler.cs
- ValueHandle.cs
- Peer.cs
- InstanceHandleReference.cs
- Comparer.cs
- ForeignKeyConstraint.cs
- ErasingStroke.cs
- ToolStripProgressBar.cs
- Geometry3D.cs
- MethodSignatureGenerator.cs
- WebPartDescription.cs
- TableCellAutomationPeer.cs
- PipeSecurity.cs
- xsdvalidator.cs
- CustomLineCap.cs
- XmlSchemaImporter.cs
- DataControlLinkButton.cs
- ScopelessEnumAttribute.cs
- StdValidatorsAndConverters.cs
- HtmlElement.cs
- RectAnimationClockResource.cs
- FormsAuthenticationUser.cs
- SingleConverter.cs
- RunClient.cs
- LayoutEvent.cs
- PartialTrustVisibleAssembly.cs
- Events.cs
- Message.cs
- ComboBox.cs
- ContractsBCL.cs
- Util.cs
- FormatSettings.cs
- TCPClient.cs
- IconConverter.cs
- EncoderBestFitFallback.cs
- ActivityTrace.cs
- SpecialFolderEnumConverter.cs
- HtmlGenericControl.cs
- TextEditorSelection.cs
- WithStatement.cs
- FlowDocumentPageViewerAutomationPeer.cs
- TimerElapsedEvenArgs.cs
- RequiredFieldValidator.cs
- CommandTreeTypeHelper.cs
- ButtonBaseAutomationPeer.cs
- _BufferOffsetSize.cs
- StylusPoint.cs
- PerfCounterSection.cs
- RoleManagerSection.cs
- XmlnsCache.cs
- ECDiffieHellmanCng.cs
- NativeMethodsCLR.cs
- WebPartConnectionsEventArgs.cs
- Stroke2.cs
- ObjectStorage.cs
- LoadWorkflowByInstanceKeyCommand.cs
- StrokeNodeOperations.cs
- InheritanceAttribute.cs
- ViewgenContext.cs
- Normalization.cs
- ProfileSettingsCollection.cs
- SingleKeyFrameCollection.cs
- StoreItemCollection.Loader.cs
- OletxCommittableTransaction.cs
- BufferedReadStream.cs
- ToolStripScrollButton.cs
- StringCollection.cs