Code:
/ 4.0 / 4.0 / 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; ////// /// public abstract class FeatureSupport : IFeatureSupport { ///Provides ///methods for retrieving feature information from the /// current system. /// /// public static bool IsPresent(string featureClassName, string featureConstName) { return IsPresent(featureClassName, featureConstName, new Version(0, 0, 0, 0)); } ///Determines whether any 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; } ///Determines whether the specified or newer version of the specified feature is /// installed in the system. This method is ///. /// /// 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; } ///Gets the version of the specified feature that is available on the system. ////// /// public virtual bool IsPresent(object feature) { return IsPresent(feature, new Version(0, 0, 0, 0)); } ///Determines whether any 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; } ///Determines whether the specified or newer version of the /// specified feature is installed in the system. ////// /// public abstract Version GetVersionPresent(object feature); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //When overridden in a derived class, gets the version of the specified /// feature that is available on the system. ///// 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; ////// /// public abstract class FeatureSupport : IFeatureSupport { ///Provides ///methods for retrieving feature information from the /// current system. /// /// public static bool IsPresent(string featureClassName, string featureConstName) { return IsPresent(featureClassName, featureConstName, new Version(0, 0, 0, 0)); } ///Determines whether any 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; } ///Determines whether the specified or newer version of the specified feature is /// installed in the system. This method is ///. /// /// 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; } ///Gets the version of the specified feature that is available on the system. ////// /// public virtual bool IsPresent(object feature) { return IsPresent(feature, new Version(0, 0, 0, 0)); } ///Determines whether any 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; } ///Determines whether the specified or newer version of the /// specified feature is installed in the system. ////// /// public abstract Version GetVersionPresent(object feature); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.When overridden in a derived class, gets the version of the specified /// feature that is available on the system. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ButtonChrome.cs
- DesignTimeXamlWriter.cs
- ComboBoxRenderer.cs
- WebPartVerbCollection.cs
- TargetPerspective.cs
- Latin1Encoding.cs
- AdornerDecorator.cs
- ApplicationCommands.cs
- RawStylusInputCustomDataList.cs
- UniqueSet.cs
- XMLUtil.cs
- _ConnectStream.cs
- PrintDialog.cs
- KnownTypesHelper.cs
- KeySpline.cs
- Roles.cs
- GrammarBuilderDictation.cs
- TrackingProvider.cs
- WindowsSlider.cs
- TextEditorDragDrop.cs
- XmlFormatReaderGenerator.cs
- XmlReaderSettings.cs
- CollectionChangeEventArgs.cs
- Icon.cs
- WorkflowQueue.cs
- TagMapCollection.cs
- TimeSpanValidatorAttribute.cs
- MenuItemCollection.cs
- QueryOpeningEnumerator.cs
- GridPattern.cs
- DetailsView.cs
- WorkflowApplicationUnloadedException.cs
- QilInvokeEarlyBound.cs
- Byte.cs
- UndoEngine.cs
- MsmqQueue.cs
- XmlCharacterData.cs
- LinkButton.cs
- SettingsAttributeDictionary.cs
- LifetimeServices.cs
- OleDbReferenceCollection.cs
- PropertyDescriptors.cs
- ActiveXSite.cs
- ILGen.cs
- TemplatedMailWebEventProvider.cs
- MediaContextNotificationWindow.cs
- ProcessInfo.cs
- TcpClientSocketManager.cs
- QilReference.cs
- DataRecordObjectView.cs
- _HelperAsyncResults.cs
- RadioButtonPopupAdapter.cs
- SelfIssuedAuthRSAPKCS1SignatureDeformatter.cs
- InvokeProviderWrapper.cs
- BoolExpressionVisitors.cs
- GroupBox.cs
- LinqExpressionNormalizer.cs
- WindowPattern.cs
- DetailsViewRow.cs
- XMLUtil.cs
- FixedBufferAttribute.cs
- DataTemplateSelector.cs
- HttpServerVarsCollection.cs
- WorkflowItemPresenter.cs
- ValidationSummary.cs
- ErrorReporting.cs
- KeyManager.cs
- BlurBitmapEffect.cs
- AddDataControlFieldDialog.cs
- WebPartRestoreVerb.cs
- SchemaElementDecl.cs
- DisplayInformation.cs
- DbTypeMap.cs
- PageVisual.cs
- ClientSettingsStore.cs
- CheckBox.cs
- MissingFieldException.cs
- TargetControlTypeCache.cs
- HtmlForm.cs
- PermissionSet.cs
- TableParaClient.cs
- TableItemPattern.cs
- HelloOperation11AsyncResult.cs
- MasterPageBuildProvider.cs
- CallSite.cs
- DataView.cs
- WebScriptEndpointElement.cs
- ParsedAttributeCollection.cs
- ApplicationException.cs
- FixedDocumentSequencePaginator.cs
- ResourceKey.cs
- PaginationProgressEventArgs.cs
- CommandField.cs
- SystemIcmpV6Statistics.cs
- Parameter.cs
- DeviceContexts.cs
- MenuBindingsEditorForm.cs
- OutOfProcStateClientManager.cs
- BinHexDecoder.cs
- NameValueConfigurationCollection.cs