private static MruItem ParseMruItem(string[] parts)
        {
            // v1.1 onwards
            PackageType type;

            if (!Enum.TryParse(parts[3], out type))
            {
                return(null);
            }

            TemplatebleSemanticVersion version;

            if (!TemplatebleSemanticVersion.TryParse(parts[1], out version))
            {
                return(null);
            }

            return(new MruItem
            {
                Id = parts[0],
                Version = version,
                Path = parts[2],
                PackageType = type
            });
        }
Beispiel #2
0
        private PluginInfo ConvertFromDirectoryToPluginInfo(DirectoryInfo directory)
        {
            string       name  = directory.Name;
            const string regex = @"^(.+)\[(.+?)\]$";
            Match        match = Regex.Match(name, regex);

            if (match.Success)
            {
                string id            = match.Groups[1].Value;
                string versionString = match.Groups[2].Value;
                TemplatebleSemanticVersion version;
                if (TemplatebleSemanticVersion.TryParse(versionString, out version))
                {
                    return(new PluginInfo(id, version));
                }
            }

            return(null);
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var stringValue = (string)value;

            if (String.IsNullOrWhiteSpace(stringValue))
            {
                return(null);
            }
            else
            {
                TemplatebleSemanticVersion version;
                if (TemplatebleSemanticVersion.TryParse(stringValue, out version))
                {
                    return(version);
                }
                else
                {
                    return(DependencyProperty.UnsetValue);
                }
            }
        }