本文整理汇总了C#中System.Version.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Version.Clone方法的具体用法?C# Version.Clone怎么用?C# Version.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Version
的用法示例。
在下文中一共展示了Version.Clone方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCloneCompare
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)");
}
示例2: Clone_EqualsOriginal
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);
}
示例3: OperatingSystem
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;
}
示例4: OperatingSystem
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;
}
示例5: OperatingSystem
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"));
}
}
示例6: runTest
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;
}
}
示例7: Init
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;
}
示例8: OperatingSystem
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;
}
示例9: TestClone
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");
}
示例10: TestClone
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));
}