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
- DrawTreeNodeEventArgs.cs
- DesignerDataRelationship.cs
- OpenTypeCommon.cs
- XPathDocumentIterator.cs
- InternalConfigRoot.cs
- DataGridViewRowPostPaintEventArgs.cs
- Cell.cs
- HtmlShim.cs
- EditingScopeUndoUnit.cs
- FreeFormDesigner.cs
- GroupQuery.cs
- LocalFileSettingsProvider.cs
- ComponentResourceKeyConverter.cs
- ResourceExpressionBuilder.cs
- TypeSource.cs
- ReadWriteSpinLock.cs
- SystemMulticastIPAddressInformation.cs
- ResXDataNode.cs
- ClientOperationFormatterProvider.cs
- RawStylusInputCustomData.cs
- FileSystemWatcher.cs
- PointUtil.cs
- AssertFilter.cs
- ExpiredSecurityTokenException.cs
- BasicCommandTreeVisitor.cs
- ListViewItem.cs
- IxmlLineInfo.cs
- SystemPens.cs
- WebGetAttribute.cs
- EntityContainerRelationshipSetEnd.cs
- RootBuilder.cs
- DataGridViewCellStateChangedEventArgs.cs
- AccessKeyManager.cs
- CodePageEncoding.cs
- HttpRuntimeSection.cs
- UpWmlPageAdapter.cs
- WithParamAction.cs
- GetUserPreferenceRequest.cs
- OleAutBinder.cs
- ListView.cs
- UIElementIsland.cs
- ImageBrush.cs
- XpsS0ValidatingLoader.cs
- MD5.cs
- SizeValueSerializer.cs
- TextModifierScope.cs
- TreeView.cs
- ItemAutomationPeer.cs
- DataSourceProvider.cs
- TextRangeSerialization.cs
- WorkItem.cs
- SiteMapDataSourceView.cs
- RubberbandSelector.cs
- ModuleElement.cs
- TypeUsageBuilder.cs
- _BaseOverlappedAsyncResult.cs
- VBIdentifierNameEditor.cs
- RoleService.cs
- Error.cs
- TextEditorDragDrop.cs
- ProcessInfo.cs
- OutputCacheSettingsSection.cs
- DPTypeDescriptorContext.cs
- ImageIndexConverter.cs
- DataGridViewComboBoxEditingControl.cs
- SqlHelper.cs
- AdornerLayer.cs
- RegexParser.cs
- DataGridViewRowHeaderCell.cs
- HierarchicalDataSourceControl.cs
- ScaleTransform.cs
- ResizeBehavior.cs
- TraceListener.cs
- ServiceDescription.cs
- InvokePattern.cs
- DateTime.cs
- StsCommunicationException.cs
- DataGridTableCollection.cs
- IntSecurity.cs
- VisualBrush.cs
- ConfigurationValidatorAttribute.cs
- SymbolMethod.cs
- MimeFormReflector.cs
- SqlDataAdapter.cs
- IPCCacheManager.cs
- ObjectListCommandEventArgs.cs
- OleStrCAMarshaler.cs
- FieldAccessException.cs
- BaseDataBoundControl.cs
- ExpressionList.cs
- DefaultPrintController.cs
- TextEndOfParagraph.cs
- ReadWriteControlDesigner.cs
- IndicCharClassifier.cs
- ProcessInfo.cs
- InternalSafeNativeMethods.cs
- ScrollProperties.cs
- ToolboxItem.cs
- SystemInfo.cs
- PieceDirectory.cs