Esempio n. 1
0
        /// <summary>
        /// Try parse a package reference from the provided string
        /// </summary>
        public static bool TryParse(string value, out PackageReference result)
        {
            try
            {
                result = Parse(value);
                return(true);
            }
            catch (ArgumentException)
            {
            }

            result = null;
            return(false);
        }
        /// <summary>
        /// Read json
        /// </summary>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType != JsonToken.String)
            {
                return(null);
            }

            var result = existingValue as PackageReference ?? new PackageReference();
            var value  = reader.Value as string;

            if (PackageReference.TryParse(value, out PackageReference newValue))
            {
                result = newValue;
            }

            return(result);
        }
Esempio n. 3
0
 /// <summary>
 /// Build the kitchen include path
 /// </summary>
 public static string BuildKitchenIncludePath(LocalUserConfig config, PackageReference reference)
 {
     return(BuildKitchenIncludePath(config, reference.Name, reference.Version));
 }