Exemplo n.º 1
0
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 {
     if (reader.Value == null)
     {
         return(null);
     }
     if (reader.ValueType != typeof(string))
     {
         throw new FormatException("BranchTimeVersion values must be a string");
     }
     return(BranchTimeVersion.TryParse(reader.Value.ToString()));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationVersionPair"/> class.
 /// </summary>
 /// <param name="friendly">The friendly version.</param>
 /// <param name="internal">The internal version.</param>
 public ApplicationVersionPair(BranchTimeVersion friendly, Version @internal)
 {
     if (friendly == null)
     {
         throw new ArgumentNullException("friendly");
     }
     if (@internal == null)
     {
         throw new ArgumentNullException("internal");
     }
     Friendly = friendly;
     Internal = @internal;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Attempts to parse friendly and internal version strings into a <see cref="ApplicationVersionPair"/>.
        /// </summary>
        /// <param name="friendlyStr">The friendly version string.</param>
        /// <param name="internalStr">The internal version string.</param>
        /// <returns>The <see cref="ApplicationVersionPair"/> if successful, or <c>null</c> otherwise.</returns>
        public static ApplicationVersionPair TryParse(string friendlyStr, string internalStr)
        {
            Version internalVersion;

            if (!Version.TryParse(internalStr, out internalVersion))
            {
                return(null);
            }
            var friendlyVersion = BranchTimeVersion.TryParse(friendlyStr);

            if (friendlyVersion == null)
            {
                return(null);
            }
            return(new ApplicationVersionPair(friendlyVersion, internalVersion));
        }