Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / clr / src / BCL / System / OperatingSystem.cs / 1 / OperatingSystem.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: OperatingSystem ** ** ** Purpose: ** ** ===========================================================*/ namespace System { using System.Runtime.Serialization; using System.Globalization; using System.Security.Permissions; using System.Runtime.InteropServices; [ComVisible(true)] [Serializable()] public sealed class OperatingSystem : ICloneable , ISerializable { private Version _version; private PlatformID _platform; private string _servicePack; private string _versionString; private OperatingSystem() { } public OperatingSystem(PlatformID platform, Version version) : this(platform, version, null) { } internal OperatingSystem(PlatformID platform, Version version, string servicePack) { if( platform < PlatformID.Win32S || platform > PlatformID.Unix) { throw new ArgumentException( String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Arg_EnumIllegalVal"), (int)platform), "platform"); } if ((Object) version == null) throw new ArgumentNullException("version"); _platform = platform; _version = (Version) version.Clone(); _servicePack = servicePack; } private OperatingSystem(SerializationInfo info, StreamingContext context) { SerializationInfoEnumerator enumerator = info.GetEnumerator(); while( enumerator.MoveNext()) { switch( enumerator.Name) { case "_version": _version = (Version) info.GetValue("_version", typeof(Version)); break; case "_platform": _platform = (PlatformID) info.GetValue("_platform", typeof(PlatformID)); break; case "_servicePack": _servicePack = info.GetString("_servicePack"); break; } } if (_version == null ) { throw new SerializationException(Environment.GetResourceString("Serialization_MissField", "_version")); } } [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)] public void GetObjectData(SerializationInfo info, StreamingContext context) { if( info == null ) { throw new ArgumentNullException("info"); } info.AddValue("_version", _version); info.AddValue("_platform", _platform); info.AddValue("_servicePack", _servicePack); } public PlatformID Platform { get { return _platform; } } public string ServicePack { get { if( _servicePack == null) { return string.Empty; } return _servicePack; } } public Version Version { get { return _version; } } public Object Clone() { return new OperatingSystem(_platform, _version, _servicePack ); } public override String ToString() { return VersionString; } public String VersionString { get { if(_versionString != null) { return _versionString; } String os; if (_platform == PlatformID.Win32NT) os = "Microsoft Windows NT "; else if (_platform == PlatformID.Win32Windows) { if ((_version.Major > 4) || ((_version.Major == 4) && (_version.Minor > 0))) os = "Microsoft Windows 98 "; else os = "Microsoft Windows 95 "; } else if (_platform == PlatformID.Win32S) os = "Microsoft Win32S "; else if (_platform == PlatformID.WinCE) os = "Microsoft Windows CE "; else os = ""; if( String.IsNullOrEmpty(_servicePack)) { _versionString = os + _version.ToString(); } else { _versionString = os + _version.ToString(3) + " " + _servicePack; } return _versionString; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: OperatingSystem ** ** ** Purpose: ** ** ===========================================================*/ namespace System { using System.Runtime.Serialization; using System.Globalization; using System.Security.Permissions; using System.Runtime.InteropServices; [ComVisible(true)] [Serializable()] public sealed class OperatingSystem : ICloneable , ISerializable { private Version _version; private PlatformID _platform; private string _servicePack; private string _versionString; private OperatingSystem() { } public OperatingSystem(PlatformID platform, Version version) : this(platform, version, null) { } internal OperatingSystem(PlatformID platform, Version version, string servicePack) { if( platform < PlatformID.Win32S || platform > PlatformID.Unix) { throw new ArgumentException( String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Arg_EnumIllegalVal"), (int)platform), "platform"); } if ((Object) version == null) throw new ArgumentNullException("version"); _platform = platform; _version = (Version) version.Clone(); _servicePack = servicePack; } private OperatingSystem(SerializationInfo info, StreamingContext context) { SerializationInfoEnumerator enumerator = info.GetEnumerator(); while( enumerator.MoveNext()) { switch( enumerator.Name) { case "_version": _version = (Version) info.GetValue("_version", typeof(Version)); break; case "_platform": _platform = (PlatformID) info.GetValue("_platform", typeof(PlatformID)); break; case "_servicePack": _servicePack = info.GetString("_servicePack"); break; } } if (_version == null ) { throw new SerializationException(Environment.GetResourceString("Serialization_MissField", "_version")); } } [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)] public void GetObjectData(SerializationInfo info, StreamingContext context) { if( info == null ) { throw new ArgumentNullException("info"); } info.AddValue("_version", _version); info.AddValue("_platform", _platform); info.AddValue("_servicePack", _servicePack); } public PlatformID Platform { get { return _platform; } } public string ServicePack { get { if( _servicePack == null) { return string.Empty; } return _servicePack; } } public Version Version { get { return _version; } } public Object Clone() { return new OperatingSystem(_platform, _version, _servicePack ); } public override String ToString() { return VersionString; } public String VersionString { get { if(_versionString != null) { return _versionString; } String os; if (_platform == PlatformID.Win32NT) os = "Microsoft Windows NT "; else if (_platform == PlatformID.Win32Windows) { if ((_version.Major > 4) || ((_version.Major == 4) && (_version.Minor > 0))) os = "Microsoft Windows 98 "; else os = "Microsoft Windows 95 "; } else if (_platform == PlatformID.Win32S) os = "Microsoft Win32S "; else if (_platform == PlatformID.WinCE) os = "Microsoft Windows CE "; else os = " "; if( String.IsNullOrEmpty(_servicePack)) { _versionString = os + _version.ToString(); } else { _versionString = os + _version.ToString(3) + " " + _servicePack; } return _versionString; } } } } // 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
- BuildProviderAppliesToAttribute.cs
- SoapElementAttribute.cs
- OleDbDataAdapter.cs
- FreezableDefaultValueFactory.cs
- SiteMapDataSource.cs
- X509Utils.cs
- ResourcePropertyMemberCodeDomSerializer.cs
- StylusPointPropertyInfo.cs
- ThreadExceptionDialog.cs
- LineBreak.cs
- ExternalFile.cs
- DefaultSerializationProviderAttribute.cs
- SqlFunctionAttribute.cs
- IisTraceListener.cs
- OracleFactory.cs
- DataGridViewImageCell.cs
- DataGridViewRowStateChangedEventArgs.cs
- SQLChars.cs
- FileRecordSequenceHelper.cs
- RadioButtonPopupAdapter.cs
- WebServiceErrorEvent.cs
- ScrollItemPattern.cs
- CompletedAsyncResult.cs
- ResourceDefaultValueAttribute.cs
- DiscoveryClientRequestChannel.cs
- HttpApplication.cs
- PropertyMetadata.cs
- MethodImplAttribute.cs
- Vector3DValueSerializer.cs
- DbParameterCollection.cs
- AssemblyCollection.cs
- webeventbuffer.cs
- LinkClickEvent.cs
- ProcessHostConfigUtils.cs
- ProjectionCamera.cs
- MethodExpression.cs
- GatewayIPAddressInformationCollection.cs
- ServiceParser.cs
- EntityDataSourceWizardForm.cs
- SignatureDescription.cs
- ProfileSettings.cs
- StructuralType.cs
- OperatingSystem.cs
- FormConverter.cs
- WhiteSpaceTrimStringConverter.cs
- GradientStop.cs
- FieldNameLookup.cs
- GridViewEditEventArgs.cs
- NativeMethods.cs
- XmlDocumentFragment.cs
- CommonBehaviorsSection.cs
- PeerNodeTraceRecord.cs
- _AutoWebProxyScriptWrapper.cs
- StylesEditorDialog.cs
- ViewKeyConstraint.cs
- SqlInfoMessageEvent.cs
- XmlNodeChangedEventManager.cs
- DataViewManagerListItemTypeDescriptor.cs
- MetaData.cs
- DetailsViewAutoFormat.cs
- DataTableReaderListener.cs
- SR.Designer.cs
- LeftCellWrapper.cs
- TextEncodedRawTextWriter.cs
- CodeExporter.cs
- ExpressionBinding.cs
- AutomationPeer.cs
- FlatButtonAppearance.cs
- FontSourceCollection.cs
- DirectoryNotFoundException.cs
- ContentOperations.cs
- XmlDataLoader.cs
- Rectangle.cs
- HostingEnvironmentSection.cs
- TextElementCollectionHelper.cs
- ValidationResult.cs
- AspNetSynchronizationContext.cs
- TablePattern.cs
- GB18030Encoding.cs
- lengthconverter.cs
- mda.cs
- DirtyTextRange.cs
- SkinBuilder.cs
- StringStorage.cs
- UnmanagedMarshal.cs
- DataGridColumnCollection.cs
- FamilyTypeface.cs
- OutOfProcStateClientManager.cs
- KeyTimeConverter.cs
- ActiveDocumentEvent.cs
- SqlCommand.cs
- JoinCqlBlock.cs
- SHA512Managed.cs
- DoubleAnimationUsingPath.cs
- VirtualDirectoryMapping.cs
- References.cs
- CryptoProvider.cs
- ImageResources.Designer.cs
- ThreadPoolTaskScheduler.cs
- oledbmetadatacolumnnames.cs