Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / FeatureSupport.cs / 1 / FeatureSupport.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms {
using System.Configuration.Assemblies;
using System.Diagnostics;
using System;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
///
///
/// Provides methods for retrieving feature information from the
/// current system.
///
public abstract class FeatureSupport : IFeatureSupport {
///
///
/// Determines whether any version of the specified feature
/// is installed in the system. This method is .
///
public static bool IsPresent(string featureClassName, string featureConstName) {
return IsPresent(featureClassName, featureConstName, new Version(0, 0, 0, 0));
}
///
///
/// Determines whether the specified or newer version of the specified feature is
/// installed in the system. This method is .
///
public static bool IsPresent(string featureClassName, string featureConstName, Version minimumVersion)
{
object featureId = null;
IFeatureSupport featureSupport = null;
//APPCOMPAT: If Type.GetType() throws, we want to return
//null to preserve Everett behavior.
Type c = null;
try {
c = Type.GetType(featureClassName);
}
catch (ArgumentException) {}
if (c != null) {
FieldInfo fi = c.GetField(featureConstName);
if (fi != null) {
featureId = fi.GetValue(null);
}
}
if (featureId != null && typeof(IFeatureSupport).IsAssignableFrom(c)) {
featureSupport = (IFeatureSupport) SecurityUtils.SecureCreateInstance(c);
if (featureSupport != null) {
return featureSupport.IsPresent(featureId, minimumVersion);
}
}
return false;
}
///
///
/// Gets the version of the specified feature that is available on the system.
///
public static Version GetVersionPresent(string featureClassName, string featureConstName) {
object featureId = null;
IFeatureSupport featureSupport = null;
//APPCOMPAT: If Type.GetType() throws, we want to return
//null to preserve Everett behavior.
Type c = null;
try {
c = Type.GetType(featureClassName);
}
catch (ArgumentException) {}
if (c != null) {
FieldInfo fi = c.GetField(featureConstName);
if (fi != null) {
featureId = fi.GetValue(null);
}
}
if (featureId != null)
{
featureSupport = (IFeatureSupport) SecurityUtils.SecureCreateInstance(c);
if (featureSupport != null) {
return featureSupport.GetVersionPresent(featureId);
}
}
return null;
}
///
///
/// Determines whether any version of the specified feature
/// is installed in the system.
///
public virtual bool IsPresent(object feature) {
return IsPresent(feature, new Version(0, 0, 0, 0));
}
///
///
/// Determines whether the specified or newer version of the
/// specified feature is installed in the system.
///
public virtual bool IsPresent(object feature, Version minimumVersion) {
Version ver = GetVersionPresent(feature);
if (ver != null) {
return ver.CompareTo(minimumVersion) >= 0;
}
return false;
}
///
///
/// When overridden in a derived class, gets the version of the specified
/// feature that is available on the system.
///
public abstract Version GetVersionPresent(object feature);
}
}
// 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
- AsyncResult.cs
- VScrollBar.cs
- RSAPKCS1SignatureFormatter.cs
- DrawingAttributeSerializer.cs
- RbTree.cs
- IArgumentProvider.cs
- ScrollChrome.cs
- DataGridViewColumnStateChangedEventArgs.cs
- OdbcDataAdapter.cs
- xsdvalidator.cs
- EntityKey.cs
- ShapingWorkspace.cs
- ObjectSecurity.cs
- StringDictionary.cs
- EventToken.cs
- LinkedList.cs
- AliasGenerator.cs
- BasicCellRelation.cs
- HWStack.cs
- SafeNativeMethods.cs
- ResourcePart.cs
- GridViewCellAutomationPeer.cs
- GiveFeedbackEvent.cs
- SystemIPGlobalProperties.cs
- IncrementalReadDecoders.cs
- AssemblyAttributes.cs
- BrowserCapabilitiesCodeGenerator.cs
- MethodAccessException.cs
- PopupEventArgs.cs
- HtmlAnchor.cs
- MemoryRecordBuffer.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- MarkupProperty.cs
- ConfigurationSettings.cs
- Type.cs
- InvalidDocumentContentsException.cs
- CodeIterationStatement.cs
- BamlLocalizableResource.cs
- SHA1Managed.cs
- SchemaObjectWriter.cs
- PresentationAppDomainManager.cs
- ItemCheckedEvent.cs
- AutomationElementCollection.cs
- IndicCharClassifier.cs
- ObjectStorage.cs
- StringResourceManager.cs
- Utility.cs
- MatchingStyle.cs
- BrowserCapabilitiesFactoryBase.cs
- AdapterDictionary.cs
- SystemPens.cs
- HashSetEqualityComparer.cs
- DataControlButton.cs
- FormCollection.cs
- TdsParserStateObject.cs
- OrthographicCamera.cs
- InlinedLocationReference.cs
- ClientApiGenerator.cs
- ModelItemCollection.cs
- ConfigXmlComment.cs
- ReadOnlyDictionary.cs
- XmlDataSource.cs
- WebSysDescriptionAttribute.cs
- metadatamappinghashervisitor.cs
- MessagePropertyAttribute.cs
- TracePayload.cs
- ColumnWidthChangedEvent.cs
- SafeUserTokenHandle.cs
- ReflectionHelper.cs
- ItemContainerGenerator.cs
- Italic.cs
- CodeVariableReferenceExpression.cs
- StateManagedCollection.cs
- DataPagerFieldItem.cs
- CodeTypeReference.cs
- EditorServiceContext.cs
- CacheEntry.cs
- UITypeEditor.cs
- ValidatedControlConverter.cs
- MimeParameter.cs
- WinInetCache.cs
- DefaultDiscoveryService.cs
- CodeIdentifiers.cs
- StylusPointDescription.cs
- VisualState.cs
- mactripleDES.cs
- XPathDocumentNavigator.cs
- ValueTypeFixupInfo.cs
- ListenerTraceUtility.cs
- Bitmap.cs
- Schema.cs
- Color.cs
- AttachedPropertyMethodSelector.cs
- SimpleApplicationHost.cs
- WindowsPen.cs
- UrlAuthFailedErrorFormatter.cs
- NopReturnReader.cs
- ReadOnlyActivityGlyph.cs
- SrgsElementFactoryCompiler.cs
- XmlCollation.cs