コード例 #1
0
        public static IDictionary <string, string> GetPackageVersions(CodeGenerationContext context)
        {
            IDictionary <string, string> versions;

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            string packageReferenceFileName = PackageVersions.GetPackageReferenceFileName(context);

            if (PackageVersions.PackageFileContents != null)
            {
                PackageVersions.PackageFileContents.TryGetValue(packageReferenceFileName, out versions);
                if (versions != null)
                {
                    return(versions);
                }
            }
            else
            {
                PackageVersions.PackageFileContents = new Dictionary <string, IDictionary <string, string> >(StringComparer.OrdinalIgnoreCase);
            }
            versions = VersionFileReader.GetVersions(packageReferenceFileName, "/Packages/Package");
            if (versions == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "The {0} file is missing from the installed template folder.", packageReferenceFileName));
            }
            PackageVersions.PackageFileContents[packageReferenceFileName] = versions;
            return(versions);
        }
コード例 #2
0
        public static Version GetLatestAssemblyVersion(string assemblyName)
        {
            string  str;
            Version version;

            if (assemblyName == null)
            {
                throw new ArgumentNullException("assemblyReferenceName");
            }
            if (AssemblyVersions.Versions == null)
            {
                AssemblyVersions.Versions = VersionFileReader.GetVersions("Templates\\AssemblyVersions.xml", "/Assemblies/Assembly");
                if (AssemblyVersions.Versions == null)
                {
                    throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "The {0} file is missing from the installed template folder.", "Templates\\AssemblyVersions.xml"));
                }
            }
            AssemblyVersions.Versions.TryGetValue(assemblyName, out str);
            if (!Version.TryParse(str, out version))
            {
                return(null);
            }
            return(version);
        }