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


C# IPackage.DetectFrameworkVersion方法代码示例

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


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

示例1: executeInstall

        Task<List<string>> executeInstall(
            string currentAssemblyDir,
            IPackage bundledPackageMetadata,
            bool ignoreDeltaUpdates = false,
            IObserver<int> progress = null)
        {
            var fxVersion = bundledPackageMetadata.DetectFrameworkVersion();

            var eigenCheckProgress = new Subject<int>();
            var eigenCopyFileProgress = new Subject<int>();
            var eigenApplyProgress = new Subject<int>();

            var realCheckProgress = new Subject<int>();
            var realCopyFileProgress = new Subject<int>();
            var realApplyProgress = new Subject<int>();

            var eigenUpdateObs = Observable.Using(() => new UpdateManager(currentAssemblyDir, bundledPackageMetadata.Id, fxVersion, TargetRootDirectory), eigenUpdater => {
                // The real update takes longer than the eigenupdate because we're
                // downloading from the Internet instead of doing everything 
                // locally, so give it more weight
                Observable.Concat(
                    Observable.Concat(eigenCheckProgress, eigenCopyFileProgress, eigenCopyFileProgress)
                        .Select(x => (x/3.0)*0.33),
                    Observable.Concat(realCheckProgress, realCopyFileProgress, realApplyProgress)
                        .Select(x => (x/3.0)*0.67))
                    .Select(x => (int) x)
                    .Subscribe(progress);

                var updateInfoObs = eigenUpdater.CheckForUpdate(ignoreDeltaUpdates, eigenCheckProgress);

                return updateInfoObs.SelectMany(updateInfo => {
                    log.Info("The checking of releases completed - and there was much rejoicing");

                    if (!updateInfo.ReleasesToApply.Any()) {

                        var rootDirectory = TargetRootDirectory ?? Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

                        var version = updateInfo.CurrentlyInstalledVersion;
                        var releaseFolder = String.Format("app-{0}", version.Version);
                        var absoluteFolder = Path.Combine(rootDirectory, version.PackageName, releaseFolder);

                        if (!Directory.Exists(absoluteFolder)) {
                            log.Warn("executeInstall: the directory {0} doesn't exist - cannot find the current app?!!?");
                        } else {
                            return Observable.Return(
                                Directory.GetFiles(absoluteFolder, "*.exe", SearchOption.TopDirectoryOnly).ToList());
                        }
                    }

                    foreach (var u in updateInfo.ReleasesToApply) {
                        log.Info("HEY! We should be applying update {0}", u.Filename);
                    }

                    return eigenUpdater.DownloadReleases(updateInfo.ReleasesToApply, eigenCopyFileProgress)
                        .Do(_ => log.Info("The downloading of releases completed - and there was much rejoicing"))
                        .SelectMany(_ => eigenUpdater.ApplyReleases(updateInfo, eigenApplyProgress))
                        .Do(_ => log.Info("The applying of releases completed - and there was much rejoicing"));
                });
            });

            return eigenUpdateObs.SelectMany(ret => {
                var updateUrl = bundledPackageMetadata.ProjectUrl != null ? bundledPackageMetadata.ProjectUrl.ToString() : null;
                updateUrl = null; //XXX REMOVE ME
                if (updateUrl == null) {
                    realCheckProgress.OnNext(100); realCheckProgress.OnCompleted();
                    realCopyFileProgress.OnNext(100); realCopyFileProgress.OnCompleted();
                    realApplyProgress.OnNext(100); realApplyProgress.OnCompleted();

                    return Observable.Return(ret);
                }

                return Observable.Using(() => new UpdateManager(updateUrl, bundledPackageMetadata.Id, fxVersion, TargetRootDirectory), realUpdater => {
                    return realUpdater.CheckForUpdate(progress: realCheckProgress)
                        .SelectMany(x => realUpdater.DownloadReleases(x.ReleasesToApply, realCopyFileProgress).Select(_ => x))
                        .SelectMany(x => realUpdater.ApplyReleases(x, realApplyProgress))
                        .Select(_ => ret)
                        .LoggedCatch(this, Observable.Return(new List<string>()), "Failed to update to latest remote version");
                });
            }).ToTask();
        }
开发者ID:rzhw,项目名称:Squirrel.Windows,代码行数:80,代码来源:InstallManager.cs


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