Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Util / versioninfo.cs / 1305376 / versioninfo.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
* Support for getting file versions
*
* Copyright (c) 1999 Microsoft Corporation
*/
namespace System.Web.Util {
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Runtime.Serialization.Formatters;
using System.Configuration.Assemblies;
using System.Security.Permissions;
//
// Support for getting file version of relevant files
//
internal class VersionInfo {
static private string _engineVersion;
static private string _mscoreeVersion;
static private string _exeName;
static private object _lock = new object();
private VersionInfo() {
}
[FileIOPermission(SecurityAction.Assert, Unrestricted = true)]
internal static string GetFileVersion(String filename) {
#if !FEATURE_PAL // FEATURE_PAL does not fully support FileVersionInfo
try {
FileVersionInfo ver = FileVersionInfo.GetVersionInfo(filename);
return string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}.{3}",
ver.FileMajorPart, ver.FileMinorPart, ver.FileBuildPart, ver.FilePrivatePart);
}
catch {
return String.Empty;
}
#else // !FEATURE_PAL
// ROTORTODO
return String.Empty;
#endif // !FEATURE_PAL
}
internal static string GetLoadedModuleFileName(string module) {
#if !FEATURE_PAL // FEATURE_PAL does not fully support FileVersionInfo
IntPtr h = UnsafeNativeMethods.GetModuleHandle(module);
if (h == IntPtr.Zero)
return null;
StringBuilder buf = new StringBuilder(256);
if (UnsafeNativeMethods.GetModuleFileName(h, buf, 256) == 0)
return null;
String fileName = buf.ToString();
if (StringUtil.StringStartsWith(fileName, "\\\\?\\")) // on Whistler GetModuleFileName migth return this
fileName = fileName.Substring(4);
return fileName;
#else // !FEATURE_PAL
// ROTORTODO
return String.Empty;
#endif // !FEATURE_PAL
}
internal static string GetLoadedModuleVersion(string module) {
String filename = GetLoadedModuleFileName(module);
if (filename == null)
return null;
return GetFileVersion(filename);
}
internal static string SystemWebVersion {
get {
return ThisAssembly.InformationalVersion;
}
}
internal static string EngineVersion {
#if !FEATURE_PAL // FEATURE_PAL does not enable IIS-based hosting features
get {
if (_engineVersion == null) {
lock(_lock) {
if (_engineVersion == null)
_engineVersion = GetLoadedModuleVersion(ModName.ENGINE_FULL_NAME);
}
}
return _engineVersion;
#else // !FEATURE_PAL
// ROTORTODO
return "1.2.0.0";
#endif // !FEATURE_PAL
}
}
internal static string ClrVersion {
get {
if (_mscoreeVersion == null) {
lock(_lock) {
if (_mscoreeVersion == null) {
//@
// Substring(1) removes the 'v' character.
_mscoreeVersion =
System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion().Substring(1);
}
}
}
return _mscoreeVersion;
}
}
internal static string ExeName {
get {
if (_exeName == null) {
lock(_lock) {
if (_exeName == null) {
String s = GetLoadedModuleFileName(null);
if (s == null)
s = String.Empty;
// strip path
int i = s.LastIndexOf('\\');
if (i >= 0)
s = s.Substring(i+1);
// strip extension
i = s.LastIndexOf('.');
if (i >= 0)
s = s.Substring(0, i);
_exeName = s.ToLower(CultureInfo.InvariantCulture);
}
}
}
return _exeName;
}
}
}
//
// Support for getting OS Flavor
//
internal enum OsFlavor {
Undetermined,
Other,
WebBlade,
StdServer,
AdvServer,
DataCenter,
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
* Support for getting file versions
*
* Copyright (c) 1999 Microsoft Corporation
*/
namespace System.Web.Util {
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Runtime.Serialization.Formatters;
using System.Configuration.Assemblies;
using System.Security.Permissions;
//
// Support for getting file version of relevant files
//
internal class VersionInfo {
static private string _engineVersion;
static private string _mscoreeVersion;
static private string _exeName;
static private object _lock = new object();
private VersionInfo() {
}
[FileIOPermission(SecurityAction.Assert, Unrestricted = true)]
internal static string GetFileVersion(String filename) {
#if !FEATURE_PAL // FEATURE_PAL does not fully support FileVersionInfo
try {
FileVersionInfo ver = FileVersionInfo.GetVersionInfo(filename);
return string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}.{3}",
ver.FileMajorPart, ver.FileMinorPart, ver.FileBuildPart, ver.FilePrivatePart);
}
catch {
return String.Empty;
}
#else // !FEATURE_PAL
// ROTORTODO
return String.Empty;
#endif // !FEATURE_PAL
}
internal static string GetLoadedModuleFileName(string module) {
#if !FEATURE_PAL // FEATURE_PAL does not fully support FileVersionInfo
IntPtr h = UnsafeNativeMethods.GetModuleHandle(module);
if (h == IntPtr.Zero)
return null;
StringBuilder buf = new StringBuilder(256);
if (UnsafeNativeMethods.GetModuleFileName(h, buf, 256) == 0)
return null;
String fileName = buf.ToString();
if (StringUtil.StringStartsWith(fileName, "\\\\?\\")) // on Whistler GetModuleFileName migth return this
fileName = fileName.Substring(4);
return fileName;
#else // !FEATURE_PAL
// ROTORTODO
return String.Empty;
#endif // !FEATURE_PAL
}
internal static string GetLoadedModuleVersion(string module) {
String filename = GetLoadedModuleFileName(module);
if (filename == null)
return null;
return GetFileVersion(filename);
}
internal static string SystemWebVersion {
get {
return ThisAssembly.InformationalVersion;
}
}
internal static string EngineVersion {
#if !FEATURE_PAL // FEATURE_PAL does not enable IIS-based hosting features
get {
if (_engineVersion == null) {
lock(_lock) {
if (_engineVersion == null)
_engineVersion = GetLoadedModuleVersion(ModName.ENGINE_FULL_NAME);
}
}
return _engineVersion;
#else // !FEATURE_PAL
// ROTORTODO
return "1.2.0.0";
#endif // !FEATURE_PAL
}
}
internal static string ClrVersion {
get {
if (_mscoreeVersion == null) {
lock(_lock) {
if (_mscoreeVersion == null) {
//@
// Substring(1) removes the 'v' character.
_mscoreeVersion =
System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion().Substring(1);
}
}
}
return _mscoreeVersion;
}
}
internal static string ExeName {
get {
if (_exeName == null) {
lock(_lock) {
if (_exeName == null) {
String s = GetLoadedModuleFileName(null);
if (s == null)
s = String.Empty;
// strip path
int i = s.LastIndexOf('\\');
if (i >= 0)
s = s.Substring(i+1);
// strip extension
i = s.LastIndexOf('.');
if (i >= 0)
s = s.Substring(0, i);
_exeName = s.ToLower(CultureInfo.InvariantCulture);
}
}
}
return _exeName;
}
}
}
//
// Support for getting OS Flavor
//
internal enum OsFlavor {
Undetermined,
Other,
WebBlade,
StdServer,
AdvServer,
DataCenter,
}
}
// 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
- UriScheme.cs
- UpdateExpressionVisitor.cs
- ScriptBehaviorDescriptor.cs
- WebPartManagerInternals.cs
- ExpiredSecurityTokenException.cs
- Vector3DCollection.cs
- SupportsEventValidationAttribute.cs
- LazyInitializer.cs
- ReadOnlyMetadataCollection.cs
- RenderData.cs
- TiffBitmapEncoder.cs
- HeaderedItemsControl.cs
- RowTypeElement.cs
- StyleCollection.cs
- ControlBuilderAttribute.cs
- AssemblyAssociatedContentFileAttribute.cs
- XamlInt32CollectionSerializer.cs
- ItemsPresenter.cs
- PostBackOptions.cs
- BrowserInteropHelper.cs
- Stackframe.cs
- unsafeIndexingFilterStream.cs
- D3DImage.cs
- Stack.cs
- RemoveStoryboard.cs
- UnsupportedPolicyOptionsException.cs
- CorePropertiesFilter.cs
- PageThemeBuildProvider.cs
- TimeStampChecker.cs
- CryptoKeySecurity.cs
- WeakReference.cs
- RegistrationContext.cs
- WriteStateInfoBase.cs
- CustomExpression.cs
- HeaderUtility.cs
- ProviderManager.cs
- HighlightOverlayGlyph.cs
- HtmlElementErrorEventArgs.cs
- Solver.cs
- OleDbSchemaGuid.cs
- WebMessageEncoderFactory.cs
- InlineObject.cs
- TrackingProfile.cs
- DataBindEngine.cs
- DiscoveryUtility.cs
- ServerValidateEventArgs.cs
- CodeTypeDeclaration.cs
- FormatException.cs
- MsmqTransportBindingElement.cs
- DependencyPropertyKind.cs
- ConnectorDragDropGlyph.cs
- SpecularMaterial.cs
- ColorInterpolationModeValidation.cs
- TextRangeProviderWrapper.cs
- _NetworkingPerfCounters.cs
- PenLineJoinValidation.cs
- WindowsFormsSectionHandler.cs
- NamespaceDecl.cs
- ellipse.cs
- ToolStripItem.cs
- ParameterCollection.cs
- DynamicResourceExtension.cs
- AddingNewEventArgs.cs
- ResourceSetExpression.cs
- RealizationContext.cs
- RepeaterItem.cs
- TextTreeTextBlock.cs
- SafeEventLogWriteHandle.cs
- IIS7UserPrincipal.cs
- AttachedPropertyInfo.cs
- WindowsUpDown.cs
- SetStoryboardSpeedRatio.cs
- DataMember.cs
- UriParserTemplates.cs
- InputBindingCollection.cs
- HttpResponseWrapper.cs
- HttpCacheParams.cs
- UriParserTemplates.cs
- DataGridLength.cs
- EncryptedKeyIdentifierClause.cs
- ObjectDataSource.cs
- QilPatternVisitor.cs
- ColumnWidthChangedEvent.cs
- Mouse.cs
- AuditLevel.cs
- AtomicFile.cs
- SqlBuilder.cs
- ScriptingJsonSerializationSection.cs
- XmlConvert.cs
- Rfc2898DeriveBytes.cs
- XmlTextEncoder.cs
- EncryptedKeyIdentifierClause.cs
- Pkcs7Signer.cs
- WorkerRequest.cs
- AmbientLight.cs
- CodeDOMUtility.cs
- PanelDesigner.cs
- TextControlDesigner.cs
- SchemaConstraints.cs
- MdImport.cs