// Updates and returns the version of the specified attribute. private string UpdateVersion(string attributeName, string format, OutArgument<Version> maxVersion) { var oldValue = this.file[attributeName]; if (oldValue == null || string.IsNullOrWhiteSpace(format)) { // do nothing return oldValue; } // parse old version (handle * character) bool containsWildcard = oldValue.Contains('*'); string versionPattern = "{0}.{1}.{2}.{3}"; if (containsWildcard) { if (oldValue.Split('.').Length == 3) { oldValue = oldValue.Replace("*", "0.0"); versionPattern = "{0}.{1}.*"; } else { oldValue = oldValue.Replace("*", "0"); versionPattern = "{0}.{1}.{2}.*"; } } if (!VersionParser.IsMatch(oldValue)) { throw new FormatException("Current value for attribute '" + attributeName + "' is not in a correct version format."); } var version = new Version(oldValue); // update version var tokens = format.Split('.'); if (tokens.Length != 4) { throw new FormatException("Specified value for attribute '" + attributeName + "' is not a correct version format."); } version = new Version( Convert.ToInt32(this.ReplaceTokens(tokens[0], version.Major)), Convert.ToInt32(this.ReplaceTokens(tokens[1], version.Minor)), Convert.ToInt32(this.ReplaceTokens(tokens[2], version.Build)), Convert.ToInt32(this.ReplaceTokens(tokens[3], version.Revision))); this.file[attributeName] = string.Format(versionPattern, version.Major, version.Minor, version.Build, version.Revision); if (version > maxVersion.Get(this.ActivityContext)) { maxVersion.Set(this.ActivityContext, version); } return version.ToString(); }
// Copies the specified attribute boolean value to the specified argument if present. private void ReadBoolAttribute(string attributeName, OutArgument argument) { var value = this.file[attributeName]; if (value == null) { argument.Set(this.ActivityContext, null); return; } argument.Set(this.ActivityContext, Convert.ToBoolean(value)); }
// Copies the specified attribute GUID value to the specified argument if present. private void ReadGuidAttribute(string attributeName, OutArgument argument) { var value = this.file[attributeName]; if (value == null) { argument.Set(this.ActivityContext, null); return; } argument.Set(this.ActivityContext, new System.Guid(value)); }
// Copies the specified attribute string value to the specified argument if present. private void ReadStringAttribute(string attributeName, OutArgument argument) { var value = this.file[attributeName]; if (value == null) { // do nothing return; } argument.Set(this.ActivityContext, value); }