当前位置: 首页>>代码示例>>C#>>正文


C# ModuleInfo.GetPackageName方法代码示例

本文整理汇总了C#中ModuleInfo.GetPackageName方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleInfo.GetPackageName方法的具体用法?C# ModuleInfo.GetPackageName怎么用?C# ModuleInfo.GetPackageName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModuleInfo的用法示例。


在下文中一共展示了ModuleInfo.GetPackageName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetModuleAssemblyRef

        /// <summary>
        /// Gets the module assembly ref.
        /// </summary>
        /// <param name="moduleInfo">The module info</param>
        /// <returns>The module assembly ref</returns>
        /// <exception cref="System.ArgumentNullException">The <paramref name="moduleInfo" /> is <c>null</c>.</exception>
        private string GetModuleAssemblyRef(ModuleInfo moduleInfo)
        {
            // ReSharper disable once ImplicitlyCapturedClosure
            Argument.IsNotNull(() => moduleInfo);

            return _assemblyRefCacheStorage.GetFromCacheOrFetch(moduleInfo, () =>
                {
                    PackageName packageName = moduleInfo.GetPackageName();
                    string directoryName = packageName.ToString().Replace(' ', '.');
                    return string.Format(CultureInfo.InvariantCulture, RelativeUrlPattern, BaseUrl, directoryName, _frameworkNameIdentifier, moduleInfo.GetAssemblyName());
                });
        }
开发者ID:paytonli2013,项目名称:Catel,代码行数:18,代码来源:NuGetBasedModuleCatalog.cs

示例2: TryCreateInstallPackageRequest

        /// <summary>
        /// Tries to create and install package request from the <paramref name="moduleInfo"/>.
        /// </summary>
        /// <param name="moduleInfo">
        /// The module info.
        /// </param>
        /// <param name="installPackageRequest">
        /// The install package request.
        /// </param>
        /// <returns>
        /// <c>true</c> whether the install package request is created, otherwise <c>false</c>
        /// </returns>
        public bool TryCreateInstallPackageRequest(ModuleInfo moduleInfo, out InstallPackageRequest installPackageRequest)
        {
            installPackageRequest = null;
            PackageName packageName = moduleInfo.GetPackageName();
            if (packageName.Version != null && IsModuleAssemblyInstalled(moduleInfo))
            {
                Log.Debug("Creating local install package request for '{0}'.", packageName.Name);

                installPackageRequest = new InstallPackageRequest(GetModuleAssemblyRef(moduleInfo));
            }
            else
            {
                IPackageRepository repository = GetPackageRepository();
                if (repository != null)
                {
                    Log.Debug("Looking for package '{0}' with version '{1}' on the repository '{2}'", packageName.Id, packageName.Version, PackageSource);

                    IPackage package;
                    if (repository.TryFindPackage(packageName.Id, packageName.Version, out package))
                    {
                        /*
                        IEnumerable<FrameworkName> supportedFrameworks = package.GetSupportedFrameworks();
                        if (supportedFrameworks != null && supportedFrameworks.Any(name => FrameworkIdentifierConversionMap.ContainsKey(name.FullName) && FrameworkIdentifierConversionMap[name.FullName].Equals(_frameworkNameIdentifier)))
                        {
                            Log.Debug("Creating remote install package request for '{0}' from '{1}'", package.GetFullName(), PackageSource);
                        }
                        */

                        installPackageRequest = new RemoteInstallPackageRequest(this, package, GetModuleAssemblyRef(moduleInfo, package.Version));
                    }
                }
            }

            return installPackageRequest != null;
        }
开发者ID:paytonli2013,项目名称:Catel,代码行数:47,代码来源:NuGetBasedModuleCatalog.cs

示例3: GetModuleAssemblyRef

        /// <summary>
        /// Gets the module assembly ref overriden the version number.
        /// </summary>
        /// <param name="moduleInfo">The module info</param>
        /// <param name="version">The version</param>
        /// <returns>The module assembly ref</returns>
        /// <exception cref="System.ArgumentNullException">The <paramref name="moduleInfo" /> is <c>null</c>.</exception>
        private ModuleAssemblyRef GetModuleAssemblyRef(ModuleInfo moduleInfo, SemanticVersion version)
        {
            Argument.IsNotNull(() => moduleInfo);

            var moduleInfoKey = string.Format(CultureInfo.InvariantCulture, "ModuleName:{0}; ModuleType:{1}; Ref:{2}; Version:{3}", moduleInfo.ModuleName, moduleInfo.ModuleType, moduleInfo.Ref, version);
            ModuleInfo moduleInfoFromCache = _moduleInfoCacheStoreCacheStorage.GetFromCacheOrFetch(moduleInfoKey, () => new ModuleInfo(moduleInfo.ModuleName, moduleInfo.ModuleType) { Ref = string.Format("{0}, {1}", moduleInfo.GetPackageName().Id, version), DependsOn = moduleInfo.DependsOn });

            return moduleInfoFromCache.GetModuleAssemblyRef(OutputDirectoryAbsoluteUri);
        }
开发者ID:rishabh8,项目名称:Catel,代码行数:16,代码来源:NuGetBasedModuleCatalog.cs

示例4: TryCreateInstallPackageRequest

        /// <summary>
        /// Tries to create and install package request from the <paramref name="moduleInfo" />.
        /// </summary>
        /// <param name="moduleInfo">The module info.</param>
        /// <param name="installPackageRequest">The install package request.</param>
        /// <returns><c>true</c> whether the install package request is created, otherwise <c>false</c></returns>
        public bool TryCreateInstallPackageRequest(ModuleInfo moduleInfo, out InstallPackageRequest installPackageRequest)
        {
            installPackageRequest = null;
            var packageName = moduleInfo.GetPackageName();

            ModuleAssemblyRef moduleAssemblyRef = moduleInfo.GetModuleAssemblyRef(OutputDirectoryAbsoluteUri);
            if (packageName.Version != null && moduleAssemblyRef.IsInstalled)
            {
                Log.Debug("Creating local install package request for '{0}'.", packageName.Name);

                installPackageRequest = new InstallPackageRequest(moduleAssemblyRef);
            }
            else
            {
                var repositories = GetPackageRepositories().ToList();

                int i = 0;
                while (installPackageRequest == null && i < repositories.Count)
                {
                    var repository = repositories[i++];
                    if (repository != null)
                    {
                        Log.Debug("Looking for package '{0}' with version '{1}' on the repository '{2}'", packageName.Id, packageName.Version, PackageSource);

                        try
                        {
                            var package = repository.FindPackage(packageName.Id, packageName.Version);
                            if (package != null)
                            {
                                /*
                                IEnumerable<FrameworkName> supportedFrameworks = package.GetSupportedFrameworks();
                                if (supportedFrameworks != null && supportedFrameworks.Any(name => FrameworkIdentifierConversionMap.ContainsKey(name.FullName) && FrameworkIdentifierConversionMap[name.FullName].Equals(Platforms.CurrentPlatform)))
                                {
                                    Log.Debug("Creating remote install package request for '{0}' from '{1}'", package.GetFullName(), PackageSource);
                                }
                                */

                                installPackageRequest = new RemoteInstallPackageRequest(this, package, GetModuleAssemblyRef(moduleInfo, package.Version));
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex, "Failed to create install package request for package '{0}'", packageName.Id);
                        }
                    }
                }
            }

            return installPackageRequest != null;
        }
开发者ID:rishabh8,项目名称:Catel,代码行数:56,代码来源:NuGetBasedModuleCatalog.cs

示例5: LoadModuleType

        /// <summary>
        /// Load the module type.
        /// </summary>
        /// <param name="moduleInfo">The module Info.</param>
        /// <exception cref="System.ArgumentNullException">The <paramref name="moduleInfo" /> is <c>null</c>.</exception>
        public void LoadModuleType(ModuleInfo moduleInfo)
        {
            // ReSharper disable once ImplicitlyCapturedClosure
            Argument.IsNotNull(() => moduleInfo);

            var currentDispatcher = DispatcherHelper.CurrentDispatcher;

            Log.Debug("Loading module type '{0}' from package '{1}'", moduleInfo.ModuleType, moduleInfo.Ref);

            var thread = new Thread(() =>
            {
                InstallPackageRequest installPackageRequest;
                var packageName = moduleInfo.GetPackageName();
                if (packageName != null && TryCreateInstallPackageRequest(moduleInfo, out installPackageRequest))
                {
                    currentDispatcher.BeginInvoke(() => OnModuleDownloadProgressChanged(new ModuleDownloadProgressChangedEventArgs(moduleInfo, 0, 1)));

                    var installed = false;

                    try
                    {
                        installPackageRequest.Execute();
                        installed = true;
                    }
                    catch (Exception ex)
                    {
                        currentDispatcher.BeginInvoke(() => OnLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, ex)));
                    }

                    if (installed)
                    {
                        var fileModuleTypeLoader = new FileModuleTypeLoader();
                        var fileModuleInfo = new ModuleInfo(moduleInfo.ModuleName, moduleInfo.ModuleType)
                        {
                            Ref = installPackageRequest.ModuleAssemblyRef.Ref,
                            InitializationMode = moduleInfo.InitializationMode,
                            DependsOn = moduleInfo.DependsOn
                        };

                        fileModuleTypeLoader.ModuleDownloadProgressChanged += (sender, args) =>
                        {
                            moduleInfo.State = args.ModuleInfo.State;
                            currentDispatcher.BeginInvoke(() => OnModuleDownloadProgressChanged(new ModuleDownloadProgressChangedEventArgs(moduleInfo, args.BytesReceived, args.TotalBytesToReceive)));
                        };

                        fileModuleTypeLoader.LoadModuleCompleted += (sender, args) =>
                        {
                            moduleInfo.State = args.ModuleInfo.State;
                            currentDispatcher.BeginInvoke(() => OnLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, args.Error)));
                        };

                        fileModuleTypeLoader.LoadModuleType(fileModuleInfo);

                        Log.Info("Module '{0}' is installed and loaded", moduleInfo.ModuleName);
                    }
                }
                else
                {
                    currentDispatcher.BeginInvoke(() => OnLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, new ModuleNotFoundException(moduleInfo.ModuleName, string.Format(CultureInfo.InvariantCulture, "The package '{0}' for module '{1}' was not found", moduleInfo.Ref, moduleInfo.ModuleName)))));
                }
            });

            thread.Start();
        }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:69,代码来源:NuGetModuleTypeLoader.cs

示例6: CanLoadModuleType

        /// <summary>
        /// Can load module type.
        /// </summary>
        /// <param name="moduleInfo">The module Info.</param>
        /// <returns>The <see cref="bool" />.</returns>
        /// <exception cref="System.ArgumentNullException">The <paramref name="moduleInfo" /> is <c>null</c>.</exception>
        /// <exception cref="System.InvalidOperationException">The <see cref="ModuleInfo.ModuleType" /> property of <paramref name="moduleInfo" /> parameter doesn't speciefied usign qualified name pattern.</exception>
        public bool CanLoadModuleType(ModuleInfo moduleInfo)
        {
            Argument.IsNotNull(() => moduleInfo);

            return moduleInfo.GetPackageName() != null;
        }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:13,代码来源:NuGetModuleTypeLoader.cs


注:本文中的ModuleInfo.GetPackageName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。