public GithubRef(RemoteRef remoteRef, bool usePrelease = false) : base(remoteRef) { var match = Pattern.Match(remoteRef.Id); if (match.Success) { Account = match.Groups["account"].Value; Project = match.Groups["project"].Value; Repository = string.Format("{0}/{1}", Account, Project); Filter = match.Groups["filter"].Success ? new Regex(match.Groups["filter"].Value, RegexOptions.Compiled) : Constants.DefaultAssetMatchPattern; UsePrelease = usePrelease; } else { throw new Kraken(string.Format(@"Could not parse reference: ""{0}""", remoteRef)); } }
public Metadata(JObject json) { if (json == null) { throw new ArgumentNullException("json"); } _json = json; JToken krefToken; if (json.TryGetValue(KrefPropertyName, out krefToken)) { if (krefToken.Type == JTokenType.String) { Kref = new RemoteRef((string)krefToken); } else { throw new Kraken(string.Format("{0} must be a string.", KrefPropertyName)); } } JToken vrefToken; if (json.TryGetValue(VrefPropertyName, out vrefToken)) { if (vrefToken.Type == JTokenType.String) { Vref = new RemoteRef((string)vrefToken); } else { throw new Kraken(string.Format("{0} must be a string.", VrefPropertyName)); } } JToken specVersionToken; if (json.TryGetValue(SpecVersionPropertyName, out specVersionToken)) { if (specVersionToken.Type == JTokenType.Integer && (int)specVersionToken == 1) { SpecVersion = new ModuleVersion("v1.0"); } else if (specVersionToken.Type == JTokenType.String) { SpecVersion = new ModuleVersion((string)specVersionToken); } else { throw new Kraken(string.Format(@"Could not parse {0}: ""{1}""", SpecVersionPropertyName, specVersionToken )); } } else { throw new Kraken(string.Format("{0} must be specified.", SpecVersionPropertyName)); } JToken versionToken; if (json.TryGetValue(VersionPropertyName, out versionToken)) { Version = new ModuleVersion((string)versionToken); } JToken downloadToken; if (json.TryGetValue(DownloadPropertyName, out downloadToken)) { Download = new Uri((string)downloadToken); } JToken stagedToken; if (json.TryGetValue(StagedPropertyName, out stagedToken)) { Staged = (bool)stagedToken; } JToken stagingReasonToken; if (json.TryGetValue(StagingReasonPropertyName, out stagingReasonToken)) { StagingReason = (string)stagingReasonToken; } JToken updatedToken; DateTime t; if (json.TryGetValue(UpdatedPropertyName, out updatedToken) && DateTime.TryParse(updatedToken.ToString(), out t)) { RemoteTimestamp = t; } }
public Metadata(JObject json) { if (json == null) { throw new ArgumentNullException("json"); } _json = json; JToken krefToken; if (json.TryGetValue(KrefPropertyName, out krefToken)) { if (krefToken.Type == JTokenType.String) { Kref = new RemoteRef((string)krefToken); } else { throw new Kraken(string.Format("{0} must be a string.", KrefPropertyName)); } } JToken vrefToken; if (json.TryGetValue(VrefPropertyName, out vrefToken)) { if (vrefToken.Type == JTokenType.String) { Vref = new RemoteRef((string)vrefToken); } else { throw new Kraken(string.Format("{0} must be a string.", VrefPropertyName)); } } JToken specVersionToken; if (json.TryGetValue(SpecVersionPropertyName, out specVersionToken)) { if (specVersionToken.Type == JTokenType.Integer && (int)specVersionToken == 1) { SpecVersion = new Version("v1.0"); } else if (specVersionToken.Type == JTokenType.String) { SpecVersion = new Version((string)specVersionToken); } else { throw new Kraken(string.Format(@"Could not parse {0}: ""{1}""", SpecVersionPropertyName, specVersionToken )); } } else { throw new Kraken(string.Format("{0} must be specified.", SpecVersionPropertyName)); } JToken versionToken; if (json.TryGetValue(VersionPropertyName, out versionToken)) { Version = new Version((string)versionToken); } JToken downloadToken; if (json.TryGetValue(DownloadPropertyName, out downloadToken)) { Download = new Uri((string)downloadToken); } }
public RemoteRef(RemoteRef remoteRef) : this(new Arguments(remoteRef.Source, remoteRef.Id)) { }
public Metadata(JObject json) { if (json == null) throw new ArgumentNullException("json"); _json = json; JToken krefToken; if (json.TryGetValue(KrefPropertyName, out krefToken)) { if (krefToken.Type == JTokenType.String) { Kref = new RemoteRef((string)krefToken); } else { throw new Kraken(string.Format("{0} must be a string.", KrefPropertyName)); } } JToken vrefToken; if (json.TryGetValue(VrefPropertyName, out vrefToken)) { if (vrefToken.Type == JTokenType.String) { Vref = new RemoteRef((string)vrefToken); } else { throw new Kraken(string.Format("{0} must be a string.", VrefPropertyName)); } } JToken specVersionToken; if (json.TryGetValue(SpecVersionPropertyName, out specVersionToken)) { if (specVersionToken.Type == JTokenType.Integer && (int)specVersionToken == 1) { SpecVersion = new Version("v1.0"); } else if (specVersionToken.Type == JTokenType.String) { SpecVersion = new Version((string)specVersionToken); } else { throw new Kraken(string.Format(@"Could not parse {0}: ""{1}""", SpecVersionPropertyName, specVersionToken )); } } else { throw new Kraken(string.Format("{0} must be specified.", SpecVersionPropertyName)); } JToken versionToken; if (json.TryGetValue(VersionPropertyName, out versionToken)) { Version = new Version((string)versionToken); } JToken downloadToken; if (json.TryGetValue(DownloadPropertyName, out downloadToken)) { Download = new Uri((string)downloadToken); } }