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
- autovalidator.cs
- ApplicationFileCodeDomTreeGenerator.cs
- RankException.cs
- TreeNodeClickEventArgs.cs
- CodeSnippetExpression.cs
- OracleParameterCollection.cs
- GetPolicyDetailsRequest.cs
- ObjectQuery.cs
- XmlSchemaElement.cs
- ManipulationStartingEventArgs.cs
- GroupBox.cs
- FactoryMaker.cs
- Win32.cs
- XmlMembersMapping.cs
- DeclarativeCatalogPart.cs
- PreservationFileReader.cs
- CodeEntryPointMethod.cs
- XsltContext.cs
- ScaleTransform3D.cs
- FieldNameLookup.cs
- ObjectViewEntityCollectionData.cs
- XmlSchemaAll.cs
- WorkflowRuntimeServicesBehavior.cs
- ExtentCqlBlock.cs
- TransformValueSerializer.cs
- RectangleGeometry.cs
- InvokeGenerator.cs
- RC2.cs
- XpsImage.cs
- CodeMemberProperty.cs
- ToggleProviderWrapper.cs
- KeyManager.cs
- RequiredAttributeAttribute.cs
- ListView.cs
- EdmFunctions.cs
- TreeViewDataItemAutomationPeer.cs
- ContractValidationHelper.cs
- RequestQueue.cs
- PhonemeEventArgs.cs
- AsyncCallback.cs
- ThumbAutomationPeer.cs
- UniqueConstraint.cs
- CodeSnippetTypeMember.cs
- Int32.cs
- oledbmetadatacolumnnames.cs
- RelatedCurrencyManager.cs
- UserInitiatedNavigationPermission.cs
- MergePropertyDescriptor.cs
- XmlBinaryReader.cs
- ProfessionalColors.cs
- HttpResponseInternalWrapper.cs
- WebPartUserCapability.cs
- DataGridViewImageColumn.cs
- ModelItemDictionaryImpl.cs
- PanelStyle.cs
- AnimationClockResource.cs
- TreeNodeBindingCollection.cs
- Object.cs
- GlobalizationSection.cs
- RoutedEventConverter.cs
- TableSectionStyle.cs
- WebReferencesBuildProvider.cs
- DynamicDataExtensions.cs
- SessionState.cs
- BufferAllocator.cs
- RowTypePropertyElement.cs
- BehaviorService.cs
- QueryOptionExpression.cs
- ReferencedCollectionType.cs
- ProgressBarBrushConverter.cs
- GreenMethods.cs
- ContextMenu.cs
- AutomationPatternInfo.cs
- Validator.cs
- MenuItemStyleCollectionEditor.cs
- RtfToXamlLexer.cs
- FacetValues.cs
- ISAPIRuntime.cs
- ImageListImageEditor.cs
- WindowsScrollBar.cs
- DelegatedStream.cs
- ProvidePropertyAttribute.cs
- SHA384CryptoServiceProvider.cs
- ReflectionPermission.cs
- Accessible.cs
- SafeThreadHandle.cs
- DownloadProgressEventArgs.cs
- Binding.cs
- HttpModuleActionCollection.cs
- PageParserFilter.cs
- CheckBoxField.cs
- CompareValidator.cs
- MbpInfo.cs
- EventLogInformation.cs
- XamlWriterExtensions.cs
- SemanticAnalyzer.cs
- DetailsViewRowCollection.cs
- Currency.cs
- ClickablePoint.cs
- EmbeddedMailObject.cs