Exemplo n.º 1
0
        public FrameworkApi3x(AssemblyName assemblyName)
        {
            var assembly = assemblyName.GetAssembly();

            // NuGetFramework
            _nuGetFrameworkType = assembly.GetType("NuGet.Frameworks.NuGetFramework");

            _getDotNetFrameworkName = _nuGetFrameworkType
                                      .GetProperty("DotNetFrameworkName")
                                      .GetGetMethod();

            _getShortFolderName = _nuGetFrameworkType
                                  .GetMethod("GetShortFolderName", new Type[0]);

            _parse = _nuGetFrameworkType
                     .GetMethod("Parse", new[] { typeof(string) });

            _getIdentifier = _nuGetFrameworkType
                             .GetProperty("Framework")
                             .GetGetMethod();

            _getVersion = _nuGetFrameworkType
                          .GetProperty("Version")
                          .GetGetMethod();

            _getProfile = _nuGetFrameworkType
                          .GetProperty("Profile")
                          .GetGetMethod();

            // List<NuGetFramework>
            var listType = typeof(List <>);

            _nuGetFrameworkListType = listType.MakeGenericType(_nuGetFrameworkType);

            _listAdd = _nuGetFrameworkListType
                       .GetMethod("Add");

            // FrameworkReducer
            _frameworkReducerType = assembly.GetType("NuGet.Frameworks.FrameworkReducer");

            _getNearest = _frameworkReducerType
                          .GetMethod("GetNearest");

            // DefaultCompatibilityProvider
            var defaultCompatibilityProviderType = assembly.GetType("NuGet.Frameworks.DefaultCompatibilityProvider");

            _getCompatibilityProviderInstance = defaultCompatibilityProviderType
                                                .GetProperty("Instance")
                                                .GetGetMethod();

            // CompatiblityProvider
            var compatibilityProviderType = assembly.GetType("NuGet.Frameworks.CompatibilityProvider");

            _isCompatible = compatibilityProviderType
                            .GetMethod("IsCompatible");
        }
Exemplo n.º 2
0
        public FrameworkApi2x(AssemblyName assemblyName)
        {
            var assembly = assemblyName.GetAssembly();

            // PackageReferenceSet
            _packageReferenceSetType = assembly.GetType("NuGet.PackageReferenceSet");

            // List<PackageReferenceSet>
            var listType = typeof(List <>);

            _packageReferenceSetListType = listType
                                           .MakeGenericType(_packageReferenceSetType);

            _listAdd = _packageReferenceSetListType
                       .GetMethod("Add");

            // IEnumerable<PackageReferenceSet>
            var ienumerableType = typeof(IEnumerable <>);

            _packageReferenceSetEnumerableType = ienumerableType
                                                 .MakeGenericType(_packageReferenceSetType);

            // Enumerable
            var enumerableType = typeof(Enumerable);

            _getFirst = enumerableType
                        .GetMethods()
                        .First(x => x.Name == "First" && x.GetParameters().Length == 1)
                        .MakeGenericMethod(_packageReferenceSetType);

            // VersionUtility
            var versionUtilityType = assembly.GetType("NuGet.VersionUtility");

            _getShortFolderName = versionUtilityType
                                  .GetMethod("GetShortFrameworkName");

            _parse = versionUtilityType
                     .GetMethod("ParseFrameworkName");

            _isCompatible = versionUtilityType
                            .GetMethod("IsCompatible");

            _tryGetCompatibleItems = versionUtilityType
                                     .GetMethod("TryGetCompatibleItems")
                                     .MakeGenericMethod(_packageReferenceSetType);
        }
Exemplo n.º 3
0
        public VersionRangeApi2x(AssemblyName assemblyName)
        {
            var assembly = assemblyName.GetAssembly();

            // VersionUtility
            var versionUtilityType = assembly.GetType("NuGet.VersionUtility");

            _parse = versionUtilityType
                     .GetMethod("ParseVersionSpec");

            _prettyPrint = versionUtilityType
                           .GetMethod("PrettyPrint");

            // VersionExtensions
            var versionExtensionsType = assembly.GetType("NuGet.VersionExtensions");

            _satisfies = versionExtensionsType
                         .GetMethod("Satisfies");

            // VersionSpec
            var versionSpecType = assembly.GetType("NuGet.VersionSpec");

            _getMinVersion = versionSpecType
                             .GetProperty("MinVersion")
                             .GetGetMethod();

            _isMinInclusive = versionSpecType
                              .GetProperty("IsMinInclusive")
                              .GetGetMethod();

            _getMaxVersion = versionSpecType
                             .GetProperty("MaxVersion")
                             .GetGetMethod();

            _isMaxInclusive = versionSpecType
                              .GetProperty("IsMaxInclusive")
                              .GetGetMethod();

            _getNormalizedString = versionSpecType
                                   .GetMethod("ToString");
        }
Exemplo n.º 4
0
        public VersionApi3x(AssemblyName assemblyName)
        {
            var assembly = assemblyName.GetAssembly();

            // SemanticVersion
            var semanticVersionType = assembly.GetType("NuGet.Versioning.SemanticVersion");

            _isPrerelease = semanticVersionType
                            .GetProperty("IsPrerelease")
                            .GetGetMethod();

            _getNormalizedString = semanticVersionType
                                   .GetMethod("ToNormalizedString");

            _compare = semanticVersionType
                       .GetMethod("CompareTo", new[] { semanticVersionType });

            // NuGetVersion
            var nuGetVersionType = assembly.GetType("NuGet.Versioning.NuGetVersion");

            _getRevision = nuGetVersionType
                           .GetProperty("Revision")
                           .GetGetMethod();

            _parse = nuGetVersionType
                     .GetMethod("Parse", new[] { typeof(string) });

            _getToString = nuGetVersionType
                           .GetMethod("ToString", new Type[0]);

            // NuGetVersion (3.4.3+)
            _isSemVer2 = nuGetVersionType
                         .GetProperty("IsSemVer2")?
                         .GetGetMethod();
            _isSemVer2Available = _isSemVer2 != null;

            // SemanticVersion (3.5.0-beta-final+)
            _getFullString = semanticVersionType
                             .GetMethod("ToFullString");
            _getFullStringAvailable = _getFullString != null;
        }
Exemplo n.º 5
0
        public VersionApi2x(AssemblyName assemblyName)
        {
            var assembly = assemblyName.GetAssembly();

            // SemanticVersion
            var semanticVersionType = assembly.GetType("NuGet.SemanticVersion");

            _getSpecialVersion = semanticVersionType
                                 .GetProperty("SpecialVersion")
                                 .GetGetMethod();

            _getNormalizedString = semanticVersionType
                                   .GetMethod("ToNormalizedString");
            _getNormalizedStringAvailable = _getNormalizedString != null;

            _compare = semanticVersionType
                       .GetMethod("CompareTo", new[] { semanticVersionType });

            _getVersion = semanticVersionType
                          .GetProperty("Version")
                          .GetGetMethod();

            _parse = semanticVersionType
                     .GetMethod("Parse");

            _isSemVer2 = semanticVersionType
                         .GetMethod("IsSemVer2");
            _isSemVer2Available = _isSemVer2 != null;

            _getFullString = semanticVersionType
                             .GetMethod("ToFullString");
            _getFullStringAvailable = _getFullString != null;

            _getToString = semanticVersionType
                           .GetMethod("ToString", new Type[0]);
        }
Exemplo n.º 6
0
        public VersionRangeApi3x(AssemblyName assemblyName)
        {
            var assembly = assemblyName.GetAssembly();

            // NuGetVersion
            var nuGetVersionType = assembly.GetType("NuGet.Versioning.NuGetVersion");

            // VersionRangeBase
            var versionRangeBaseType = assembly.GetType("NuGet.Versioning.VersionRangeBase");

            _hasLowerBound = versionRangeBaseType
                             .GetProperty("HasLowerBound")
                             .GetGetMethod();

            _hasUpperBound = versionRangeBaseType
                             .GetProperty("HasUpperBound")
                             .GetGetMethod();

            _isMinInclusive = versionRangeBaseType
                              .GetProperty("IsMinInclusive")
                              .GetGetMethod();

            _isMaxInclusive = versionRangeBaseType
                              .GetProperty("IsMaxInclusive")
                              .GetGetMethod();

            _getMinVersion = versionRangeBaseType
                             .GetProperty("MinVersion")
                             .GetGetMethod();

            _getMaxVersion = versionRangeBaseType
                             .GetProperty("MaxVersion")
                             .GetGetMethod();

            _satisfies = versionRangeBaseType
                         .GetMethod("Satisfies", new[] { nuGetVersionType });

            // VersionRange
            var nuGetVersionRangeType = assembly.GetType("NuGet.Versioning.VersionRange");

            _getNormalizedString = nuGetVersionRangeType
                                   .GetMethod("ToNormalizedString");

            _isFloating = nuGetVersionRangeType
                          .GetProperty("IsFloating")
                          .GetGetMethod();

            _prettyPrint = nuGetVersionRangeType
                           .GetMethod("PrettyPrint");

            _parse = nuGetVersionRangeType
                     .GetMethod("Parse", new[] { typeof(string) });

            _findBestMatch = nuGetVersionRangeType
                             .GetMethod("FindBestMatch");

            _getLegacyShortString = nuGetVersionRangeType
                                    .GetMethod("ToLegacyShortString");
            _getLegacyShortStringAvailable = _getLegacyShortString != null;

            _getLegacyString = nuGetVersionRangeType
                               .GetMethod("ToLegacyString");

            _getOriginalString = nuGetVersionRangeType
                                 .GetProperty("OriginalString")
                                 .GetGetMethod();

            // List<NuGetVersion>
            var listType = typeof(List <>);

            _nuGetVersionListType = listType.MakeGenericType(nuGetVersionType);

            _listAdd = _nuGetVersionListType
                       .GetMethod("Add");
        }