Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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.
//
//-----------------------------------------------------------------------------
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LinearGradientBrush.cs
- EventArgs.cs
- TextSerializer.cs
- DataTransferEventArgs.cs
- WebBrowserNavigatingEventHandler.cs
- TextTrailingWordEllipsis.cs
- Int64.cs
- WebPartMenuStyle.cs
- XmlElementAttributes.cs
- FileSystemInfo.cs
- ExitEventArgs.cs
- xmlglyphRunInfo.cs
- GlyphRun.cs
- ReadWriteSpinLock.cs
- TagPrefixAttribute.cs
- XPathNodeList.cs
- PageHandlerFactory.cs
- SqlNodeTypeOperators.cs
- followingquery.cs
- BitmapEffectInput.cs
- WindowsNonControl.cs
- TextProperties.cs
- WebPartTracker.cs
- Rotation3D.cs
- NullRuntimeConfig.cs
- CatalogPartCollection.cs
- ToolboxItemImageConverter.cs
- ColumnCollection.cs
- AlphabeticalEnumConverter.cs
- hresults.cs
- SyntaxCheck.cs
- PageTheme.cs
- MethodBuilderInstantiation.cs
- LeaseManager.cs
- StreamAsIStream.cs
- DiagnosticsConfiguration.cs
- RC2.cs
- FrameworkContextData.cs
- DictionaryEntry.cs
- ApplicationActivator.cs
- ReceiveSecurityHeaderEntry.cs
- TextEffectCollection.cs
- BitSet.cs
- MexTcpBindingElement.cs
- WinEventHandler.cs
- TrackingProfileCache.cs
- PrivateFontCollection.cs
- Reference.cs
- _KerberosClient.cs
- Token.cs
- SqlDataReader.cs
- FontDialog.cs
- ThreadAbortException.cs
- SponsorHelper.cs
- GetPageNumberCompletedEventArgs.cs
- DockProviderWrapper.cs
- UniqueIdentifierService.cs
- LongTypeConverter.cs
- PersonalizationProviderHelper.cs
- IriParsingElement.cs
- RecognizedPhrase.cs
- Hash.cs
- LinqMaximalSubtreeNominator.cs
- SurrogateSelector.cs
- BufferAllocator.cs
- BitmapEffectDrawingContent.cs
- XmlArrayItemAttributes.cs
- OutputCacheProfileCollection.cs
- NetworkInterface.cs
- QueueProcessor.cs
- DataControlFieldHeaderCell.cs
- Util.cs
- ContentOperations.cs
- TreeViewImageIndexConverter.cs
- CellCreator.cs
- MetadataArtifactLoaderCompositeFile.cs
- WebReferencesBuildProvider.cs
- ListBase.cs
- PropertyDescriptorCollection.cs
- Currency.cs
- DbSetClause.cs
- AdobeCFFWrapper.cs
- ReflectionPermission.cs
- StreamingContext.cs
- EdmPropertyAttribute.cs
- XmlEncoding.cs
- CodeIndexerExpression.cs
- ThicknessAnimationUsingKeyFrames.cs
- ConfigXmlCDataSection.cs
- ScriptManagerProxy.cs
- PlatformCulture.cs
- HttpWebRequest.cs
- MouseEvent.cs
- uribuilder.cs
- FrameworkElement.cs
- NotCondition.cs
- DeploymentExceptionMapper.cs
- IndexerNameAttribute.cs
- FastPropertyAccessor.cs
- UnsafeNativeMethods.cs