public static void TestCloneCompare(Assert assert) { assert.Expect(13); var v1 = new Version(1, 2, 3, (4 << 16) + 5); var o = v1.Clone(); assert.Ok(o != null, "v1 Cloned"); var v2 = o as Version; assert.Ok(v2 != null, "v1 Cloned as Version"); assert.Equal(v2.Major, 1, "v2.Major 1"); assert.Equal(v2.Minor, 2, "v2.Minor 2"); assert.Equal(v2.Build, 3, "v2.Build 3"); assert.Equal(v2.Revision, 262149, "v2.Revision (4 << 16) + 5 = 262149"); assert.Equal(v2.MajorRevision, 4, "v2.MajorRevision 4"); assert.Equal(v2.MinorRevision, 5, "v2.MinorRevision 5"); var v3 = new Version(1, 2, 2, (4 << 16) + 5); assert.Equal(v1.CompareTo(v3), 1, "v1.CompareTo(v3)"); var v4 = new Version(1, 3, 3, (4 << 16) + 5); assert.Equal(v1.CompareTo(v4), -1, "v1.CompareTo(v4)"); assert.Equal(v1.CompareTo(o), 0, "v1.CompareTo(o)"); assert.Equal(v1.CompareTo(v2), 0, "v1.CompareTo(v2)"); assert.NotEqual(v1.CompareTo(null), 0, "v1.CompareTo(null)"); }
public static void Clone_EqualsOriginal(string input, Version expected) { var actual = new Version(input); Assert.Equal(expected, actual); var clone = (Version)actual.Clone(); Assert.Equal(expected, clone); }
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; }
internal OperatingSystem(PlatformID platform, Version version, string servicePack) { if( platform < PlatformID.Win32S || platform > PlatformID.MacOSX) { throw new ArgumentException( Environment.GetResourceString("Arg_EnumIllegalVal", (int)platform), nameof(platform)); } if ((Object) version == null) throw new ArgumentNullException(nameof(version)); Contract.EndContractBlock(); _platform = platform; _version = (Version) version.Clone(); _servicePack = servicePack; }
public FrameworkName(string identifier, System.Version version, string profile) { if (identifier == null) { throw new ArgumentNullException("identifier"); } if (identifier.Trim().Length == 0) { throw new ArgumentException(SR.GetString("net_emptystringcall", new object[] { "identifier" }), "identifier"); } if (version == null) { throw new ArgumentNullException("version"); } this.m_identifier = identifier.Trim(); this.m_version = (System.Version)version.Clone(); this.m_profile = (profile == null) ? string.Empty : profile.Trim(); }
internal OperatingSystem(PlatformID platform, Version version, string servicePack) { #if !FEATURE_LEGACYNETCF if( platform < PlatformID.Win32S || platform > PlatformID.MacOSX) { #else // FEATURE_LEGACYNETCF if( platform < PlatformID.Win32S || platform > PlatformID.NokiaS60) { #endif // FEATURE_LEGACYNETCF throw new ArgumentException( Environment.GetResourceString("Arg_EnumIllegalVal", (int)platform), "platform"); } if ((Object) version == null) throw new ArgumentNullException("version"); Contract.EndContractBlock(); _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")); } }
internal void Init(string name, byte[] publicKey, byte[] publicKeyToken, System.Version version, System.Globalization.CultureInfo cultureInfo, AssemblyHashAlgorithm hashAlgorithm, AssemblyVersionCompatibility versionCompatibility, string codeBase, AssemblyNameFlags flags, StrongNameKeyPair keyPair) { this._Name = name; if (publicKey != null) { this._PublicKey = new byte[publicKey.Length]; Array.Copy(publicKey, this._PublicKey, publicKey.Length); } if (publicKeyToken != null) { this._PublicKeyToken = new byte[publicKeyToken.Length]; Array.Copy(publicKeyToken, this._PublicKeyToken, publicKeyToken.Length); } if (version != null) { this._Version = (System.Version)version.Clone(); } this._CultureInfo = cultureInfo; this._HashAlgorithm = hashAlgorithm; this._VersionCompatibility = versionCompatibility; this._CodeBase = codeBase; this._Flags = flags; this._StrongNameKeyPair = keyPair; }
public bool runTest() { Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; String strValue = String.Empty; try { strLoc = "Loc_4988s"; Version ver2 = new Version(3, 33, Int32.MaxValue, 5); iCountTestcases++; if(ver2.Build != Int32.MaxValue) { iCountErrors++; printerr ( "Error_49xy7! Incorrect build value set"); } iCountTestcases++; if(ver2.Major != 3) { iCountErrors++; printerr( "Error_49x8a! Incorrect major value set"); } iCountTestcases++; if(ver2.Minor != 33) { iCountErrors++; printerr( "Error_498x8! Incorrect minor value set"); } iCountTestcases++; if(ver2.Revision != 5) { iCountErrors++; printerr( "Error_498vy! Incorrect Revision set"); } Version ver3 = (Version)ver2.Clone(); if(ver3.Build != Int32.MaxValue) { iCountErrors++; printerr ( "Error_49xy7! Incorrect build value set"); } iCountTestcases++; if(ver3.Major != 3) { iCountErrors++; printerr( "Error_49x8a! Incorrect major value set"); } iCountTestcases++; if(ver3.Minor != 33) { iCountErrors++; printerr( "Error_498x8! Incorrect minor value set"); } iCountTestcases++; if(ver3.Revision != 5) { iCountErrors++; printerr( "Error_498vy! Incorrect Revision set"); } } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general.ToString()); } if ( iCountErrors == 0 ) { Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString()); return true; } else { Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums ); return false; } }
internal void Init(String name, byte[] publicKey, byte[] publicKeyToken, Version version, CultureInfo cultureInfo, AssemblyHashAlgorithm hashAlgorithm, AssemblyVersionCompatibility versionCompatibility, String codeBase, AssemblyNameFlags flags, StrongNameKeyPair keyPair) // Null if ref, matching Assembly if def { _Name = name; if (publicKey != null) { _PublicKey = new byte[publicKey.Length]; Array.Copy(publicKey, _PublicKey, publicKey.Length); } if (publicKeyToken != null) { _PublicKeyToken = new byte[publicKeyToken.Length]; Array.Copy(publicKeyToken, _PublicKeyToken, publicKeyToken.Length); } if (version != null) _Version = (Version) version.Clone(); _CultureInfo = cultureInfo; _HashAlgorithm = hashAlgorithm; _VersionCompatibility = versionCompatibility; _CodeBase = codeBase; _Flags = flags; _StrongNameKeyPair = keyPair; }
internal OperatingSystem(PlatformID platform, Version version, string servicePack) { if (platform < PlatformID.Win32S || platform > PlatformID.MacOSX) { throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", new object[] { (int)platform }), "platform"); } if (version == null) { throw new ArgumentNullException("version"); } this._platform = platform; this._version = (Version)version.Clone(); this._servicePack = servicePack; }
public void TestClone () { Version v1 = new Version (1, 2, 3, 4); Version v2 = (Version) v1.Clone (); Assert.IsTrue (v1.Equals (v2), "#A1"); Assert.IsFalse (object.ReferenceEquals (v1, v2), "#A2"); Version v3 = new Version (); // 0.0 v2 = (Version) v3.Clone (); Assert.IsTrue (v3.Equals (v2), "#B1"); Assert.IsFalse (object.ReferenceEquals (v3, v2), "#B2"); }
/// <summary> /// use this method to get the current version of the KGFCore. /// </summary> /// <returns>returns the current version of the KGFCore.</returns> static public System.Version GetCurrentVersion() { return((System.Version)itsVersion.Clone()); }
protected AbstractVersion(System.Version version) { this.version = (System.Version)version?.Clone(); }
public void TestClone () { Version v1 = new Version (1, 2, 3, 4); Version v2 = (Version) v1.Clone (); Assert ("A1", v1.Equals (v2)); Assert ("A2", !ReferenceEquals (v1, v2)); Version v3 = new Version (); // 0.0 v2 = (Version) v3.Clone (); Assert ("A3", v3.Equals (v2)); Assert ("A4", !ReferenceEquals (v3, v2)); }