本文整理汇总了C#中Version类的典型用法代码示例。如果您正苦于以下问题:C# Version类的具体用法?C# Version怎么用?C# Version使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Version类属于命名空间,在下文中一共展示了Version类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItem
protected override Item GetItem(ID itemId, Language language, Version version, Database database)
{
Assert.ArgumentNotNull(itemId, "itemId");
Assert.ArgumentNotNull(language, "language");
Assert.ArgumentNotNull(version, "version");
Assert.ArgumentNotNull(database, "database");
if (Switcher<bool, IntegrationDisabler>.CurrentValue) return base.GetItem(itemId, language, version, database);
if (Context.Site == null || !Context.Site.Name.Equals("shell") || Config.ContentDatabase == null)
return base.GetItem(itemId, language, version, database);
// checking for the database validity. we don't want to run this for core db for ex.
if (!Config.SupportedDatabases.Any(d => d.Equals(database.Name)))
return base.GetItem(itemId, language, version, database);
var item = base.GetItem(itemId, language, version, database);
// checking if the item implements IRepository
bool isRepository = item.IsRepository();
if (item == null || !isRepository || item.Name.Equals(Constants.StandardValuesItemName))
{
//if we are not a repository, then leave
return item;
}
var args = new GenericItemProviderArgs(item);
CorePipeline.Run("genericItemProvider", args);
return args.RootItem;
}
开发者ID:JasonBunting,项目名称:SitecoreSuperchargers.GenericItemProvider,代码行数:32,代码来源:GenericItemProvider.cs
示例2: ParseRustcOutput
public static Version ParseRustcOutput(String output)
{
var outputParts = output.Split(' ');
if (outputParts.Length != 4)
return null;
var releaseParts = outputParts[1].Split('.', '-');
if (releaseParts.Length != 4)
return null;
var result = new Version();
try
{
result.VersionMajor = Convert.ToUInt32(releaseParts[0]);
result.VersionMinor = Convert.ToUInt32(releaseParts[1]);
result.VersionPatch = Convert.ToUInt32(releaseParts[2]);
result.VersionVariant = releaseParts[3].Trim().ToLowerInvariant();
}
catch (Exception ex)
{
return null;
}
return result;
}
示例3: Update
internal void Update(Stream stream)
{
using (var binReader = new BinaryReader(stream))
{
binReader.ReadByte();
Version = binReader.ReadByte();
Model = binReader.ReadByte();
Id = Encoding.UTF8.GetString(binReader.ReadBytes(2), 0, 2);
BootloaderVersion = new Version(
binReader.ReadByte(),
binReader.ReadByte(),
binReader.ReadByte(),
binReader.ReadByte()
);
FirmwareVersion = new Version(
binReader.ReadByte(),
binReader.ReadByte(),
binReader.ReadByte(),
default(byte)
);
var macBuilder = new StringBuilder();
macBuilder.Append(Convert.ToString(binReader.ReadByte(), 16));
for (var i = 0; i < 5; i++)
macBuilder.Append("-").Append(Convert.ToString(binReader.ReadByte(), 16));
MacAddress = macBuilder.ToString();
var ssidLength = binReader.ReadByte();
Ssid = Encoding.UTF8.GetString(binReader.ReadBytes(ssidLength), 0, ssidLength);
}
}
示例4: VersionLabel
/// <summary>
/// Constructor for the <c>VersionLabel</c> object. This is
/// used to create a label that can convert from a double to an
/// XML attribute and vice versa. This requires the annotation and
/// contact extracted from the XML schema class.
/// </summary>
/// <param name="contact">
/// this is the field from the XML schema class
/// </param>
/// <param name="label">
/// represents the annotation for the field
/// </param>
public VersionLabel(Contact contact, Version label) {
this.detail = new Signature(contact, this);
this.decorator = new Qualifier(contact);
this.type = contact.Type;
this.name = label.name();
this.label = label;
}
示例5: Update
public void Update(Version message)
{
ServerOS = message.os;
ServerOSVersion = message.os;
ServerRelease = message.release;
ServerVersion = message.version;
}
示例6: GetUpdateInformation
public static string GetUpdateInformation(string UserAgent, Version version)
{
if (UserAgent.Contains("Mac"))
{
return "It looks like you're running a Mac. There's no .NET Framework download from Microsoft for the Mac, but you might check out either <a href=\"http://www.microsoft.com/silverlight/resources/install.aspx\">Silverlight</a> which is a browser plugin that includes a small version of the .NET Framework. You could also check out <a href=\"http://www.go-mono.com/mono-downloads/download.html\">Mono</a>, which is an Open Source platform that can run .NET code on a Mac.";
}
if (UserAgent.Contains("nix"))
{
return "It looks like you're running a Unix machine. There's no .NET Framework download from Microsoft for Unix, but you might check out <a href=\"http://www.go-mono.com/mono-downloads/download.html\">Mono</a>, which is an Open Source platform that can run .NET code on Unix.";
}
if (UserAgent.Contains("fox"))
{
return MessageForBrowser("Firefox");
}
else if (UserAgent.Contains("Chrome"))
{
return MessageForBrowser("Chrome");
}
else if (UserAgent.Contains("Safari")) // Chrome also uses safari in the user agent so this check must come after
{
return MessageForBrowser("Safari");
}
else if(!UserAgent.Contains("MSIE"))
{
return UnknownBrowserMessage();
}
var windowsFactory = new WindowsVersionFactory();
var latest = windowsFactory.GetLatestWindows();
return latest.CheckOs(UserAgent);
}
示例7: TupleSpace
public TupleSpace(String host, int port, String userName, String password, String[] spaces)
{
try
{
server = new TcpClient(host, port);
writer = new StreamWriter(server.GetStream());
writer.AutoFlush = true;
responseThread = new ResponseThread(new StreamReader(server.GetStream()));
Thread rThread = new Thread(new ThreadStart(responseThread.run));
rThread.IsBackground = true;
rThread.Start();
ConnectCommand cc = new ConnectCommand(userName, password, spaces);
TSResponse response = SendReceive(cc);
Tuple[] tuples = response.Tuples;
this.spaces = new Space[tuples.Length];
for (int i = 0; i < tuples.Length; i++)
{
Field[] f = tuples[i].Fields;
Version v = new Version((int) f[2].Value, (int) f[3].Value,
(int) f[4].Value, (int) f[5].Value, (string) f[6].Value,
(int) f[7].Value);
int spaceId = (int) f[1].Value;
string spaceName = f[0].Value.ToString();
this.spaces[i] = new Space(spaceName, spaceId, v);
}
}
catch (Exception e)
{
throw new TupleSpaceException(e.Message);
}
}
示例8: IsUpdateAvailable2
public UpdatePresentResult2 IsUpdateAvailable2(
UpdateCheckInfo2 info )
{
try
{
CheckThrowApiKey(info.ApiKey);
var v1 = new Version(info.VersionNumber);
var v2 = availableVersion;
var url = v1 >= v2 ? string.Empty : ConfigurationManager.AppSettings[@"updateChecker.downloadUrl"];
var web = v1 >= v2 ? string.Empty : ConfigurationManager.AppSettings[@"updateChecker.websiteUrl"];
var result =
new UpdatePresentResult2
{
IsPresent = v1 < v2,
DownloadWebsiteUrl = web
};
LogCentral.Current.LogInfo(string.Format(@"Returning download URL '{0}'.", url));
return result;
}
catch (Exception x)
{
LogCentral.Current.LogError(@"Error checking whether an update is available.", x);
throw;
}
}
示例9: PosTest2
public bool PosTest2()
{
bool retVal = true;
// Add your scenario description here
TestLibrary.TestFramework.BeginScenario("PosTest2: Verify property Build with args ctor.");
try
{
int intMajor = TestLibrary.Generator.GetInt32(-55);
int intMinor = TestLibrary.Generator.GetInt32(-55);
int intBuild = TestLibrary.Generator.GetInt32(-55);
int intRevision = TestLibrary.Generator.GetInt32(-55);
Version version = new Version(intMajor, intMinor, intBuild, intRevision);
if (version.Build != intBuild)
{
Console.WriteLine("excepted value is :" + version.Build);
Console.WriteLine("actual value is :" + intBuild);
TestLibrary.TestFramework.LogError("002.1", "Property Build Err !");
retVal = false;
return retVal;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e);
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例10: Parse
public Version Parse(string version)
{
if (string.IsNullOrEmpty(version))
new System.ArgumentNullException("version", "Version was null or empty.");
Version v = new Version();
version = version.Trim();
string[] parts = version.Split(' ');
string versionInfo = parts[0];
for (int i = 1; i < parts.Length; i++)
{
v.Description += parts[i] + " ";
}
if (v.Description != null) v.Description = v.Description.Trim();
string[] vParts = versionInfo.Split('.');
if (vParts.Length > 0) v.Major = ParsingTools.ParseIndex(vParts, 0);
if (vParts.Length > 1) v.Minor = ParsingTools.ParseIndex(vParts, 1);
if (vParts.Length > 2) v.Build = ParsingTools.ParseIndex(vParts, 2);
int year = 0;
if (vParts.Length > 3) year = ParsingTools.ParseIndex(vParts, 3);
int month = 0;
if (vParts.Length > 4) month = ParsingTools.ParseIndex(vParts, 4);
int day = 0;
if (vParts.Length > 5) day = ParsingTools.ParseIndex(vParts, 5);
if (year > 0 && month > 0 && day > 0 && month < 13 && day < 32) v.DateTime = new DateTime(year, month, day);
return v;
}
示例11: GetFrameworkVersion
void GetFrameworkVersion(XDocument xDocument)
{
FrameworkVersionAsString = xDocument.Descendants("TargetFrameworkVersion")
.Select(c => c.Value)
.First();
FrameworkVersionAsNumber = Version.Parse(FrameworkVersionAsString.Remove(0, 1));
}
示例12: PosTest2
public bool PosTest2()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest2: Ensure Equals(System.Object) return false when the current Version object and obj are both Version objects but not every component of the current Version object matches the corresponding component of obj.");
try
{
Version TestVersion1 = new Version("2.3.4.5");
Object TestObject1 = (Object)TestVersion1;
Version TestVersion2 = new Version("1.2.3.4");
if (TestVersion2.Equals(TestObject1))
{
TestLibrary.TestFramework.LogError("P02.1", "Equals(System.Object) failed when the current Version object and obj are both Version objects but not every component of the current Version object matches the corresponding component of obj!");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("P02.2", "Unexpected exception: " + e);
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例13: CommitVersion
public static void CommitVersion(Version version)
{
Log.Info(string.Format("Committing version #{0}", version.version));
RunCommand("add", version.date, "--all", ".");
List<string> commit_args = new List<string>();
if (!string.IsNullOrWhiteSpace(version.comment))
{
commit_args.Add("-m");
commit_args.Add("\"" + version.comment.Replace("\\", "\\\\") + "\"");
}
commit_args.Add("-m");
commit_args.Add(string.Format(
"\"Original Vault Commit: version {0} on {1:yyyy-MM-dd HH:mm:ss} by {2}\"",
version.version,
version.date,
version.user));
commit_args.Add(string.Format("--date=\"{0:yyyy-MM-ddTHH:mm:ss}\"", version.date));
if (version.GitAuthor != null)
{
commit_args.Add(string.Format("--author=\"{0}\"", version.GitAuthor));
}
commit_args.Add("-a");
RunCommand("commit", version.date, commit_args.ToArray());
commit_count++;
if (commit_count % 50 == 0)
{
RunCommand("gc", null);
}
}
示例14: StartCore
// Adds Parameter for unit tests
internal static bool StartCore(Version testVersion = null) {
var version = testVersion ?? WebPagesDeployment.GetVersion(HttpRuntime.AppDomainAppPath, WebConfigurationManager.AppSettings);
bool loaded = false;
if (version == AssemblyUtils.ThisAssemblyName.Version) {
Debug.WriteLine("WebPages Bootstrapper v{0}: loading WebPages", AssemblyUtils.ThisAssemblyName.Version);
loaded = true;
if (testVersion == null) {
LoadWebPages();
}
}
else if (version == null) {
Debug.WriteLine("WebPages Bootstrapper v{0}: WebPages not enabled, registering for change notifications", AssemblyUtils.ThisAssemblyName.Version);
// Register for change notifications under the application root
// but do not register if webPages:Enabled has been explicitly set to false (Dev10 bug 913600)
if (testVersion == null && !WebPagesDeployment.IsExplicitlyDisabled(WebConfigurationManager.AppSettings)) {
RegisterForChangeNotifications();
}
}
else {
Debug.WriteLine("WebPages Bootstrapper v{0}: site version is {1}, not loading WebPages", AssemblyUtils.ThisAssemblyName.Version, version);
}
return loaded;
}
示例15: NegTest1
public bool NegTest1()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("NegTest1: ArgumentException is not thrown.");
try
{
Version version = new Version(1, 3, 5);
string str = version.ToString(4);
TestLibrary.TestFramework.LogError("101.1", " ArgumentException is not thrown.");
retVal = false;
}
catch (ArgumentException)
{ }
catch (Exception e)
{
TestLibrary.TestFramework.LogError("101.2", "Unexpected exception: " + e);
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}