Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / FeatureSupport.cs / 1305376 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RuleSettingsCollection.cs
- TypeContext.cs
- OdbcHandle.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- GatewayDefinition.cs
- ViewgenGatekeeper.cs
- ZipIORawDataFileBlock.cs
- DesignTable.cs
- SrgsElementFactory.cs
- RowsCopiedEventArgs.cs
- HostedElements.cs
- TextBoxAutomationPeer.cs
- Base64Decoder.cs
- EntryPointNotFoundException.cs
- AtomicFile.cs
- SoapAttributes.cs
- CqlLexerHelpers.cs
- VirtualDirectoryMapping.cs
- ListBindableAttribute.cs
- PropertyStore.cs
- QilUnary.cs
- StreamResourceInfo.cs
- FrameworkTemplate.cs
- DataSourceXmlAttributeAttribute.cs
- Statements.cs
- BitVector32.cs
- BlurEffect.cs
- RadioButton.cs
- NoneExcludedImageIndexConverter.cs
- TypeBuilderInstantiation.cs
- AuthenticatedStream.cs
- BmpBitmapDecoder.cs
- AssociationType.cs
- PeerNameResolver.cs
- ScaleTransform3D.cs
- RawStylusInput.cs
- TextTreePropertyUndoUnit.cs
- AstTree.cs
- MinMaxParagraphWidth.cs
- ProxyElement.cs
- UrlMappingsModule.cs
- MetafileHeader.cs
- TdsParserSessionPool.cs
- SkipQueryOptionExpression.cs
- Transform.cs
- XmlObjectSerializerWriteContext.cs
- DocumentPageTextView.cs
- ProcessHostFactoryHelper.cs
- CurrentChangingEventManager.cs
- EncryptedKeyIdentifierClause.cs
- UIElementPropertyUndoUnit.cs
- CollectionAdapters.cs
- UrlMappingsSection.cs
- WebPartPersonalization.cs
- DataServiceQueryOfT.cs
- TypeForwardedToAttribute.cs
- WebScriptMetadataFormatter.cs
- UIElementParaClient.cs
- WSSecurityPolicy.cs
- _Rfc2616CacheValidators.cs
- ComboBoxItem.cs
- PreviewPrintController.cs
- ContainerVisual.cs
- DataListItem.cs
- ExpressionBuilder.cs
- listitem.cs
- SpotLight.cs
- OleDbException.cs
- PageBuildProvider.cs
- QueryExpr.cs
- CfgParser.cs
- ViewBase.cs
- followingsibling.cs
- DefaultMemberAttribute.cs
- TakeQueryOptionExpression.cs
- SchemaCollectionPreprocessor.cs
- COM2EnumConverter.cs
- XslNumber.cs
- FlagsAttribute.cs
- InstanceOwner.cs
- UTF7Encoding.cs
- TableItemProviderWrapper.cs
- NameValueFileSectionHandler.cs
- DataGridViewCellFormattingEventArgs.cs
- SuppressIldasmAttribute.cs
- LineBreakRecord.cs
- DataBinding.cs
- TransformProviderWrapper.cs
- DirectionalLight.cs
- OletxEnlistment.cs
- RoutedUICommand.cs
- ServiceBusyException.cs
- invalidudtexception.cs
- CmsUtils.cs
- DrawingState.cs
- FontFamilyValueSerializer.cs
- XmlJsonReader.cs
- _NegotiateClient.cs
- AutomationPeer.cs
- Point3DAnimationUsingKeyFrames.cs