コード例 #1
0
        public static Package Load(ITaskManager taskManager, IGitEnvironment environment, UriString packageFeed)
        {
            Package package = null;

            var filename = packageFeed.Filename.ToSPath();

            if (!filename.IsInitialized || filename.IsRoot)
            {
                return(package);
            }

            var key  = filename.FileNameWithoutExtension + "_updatelastCheckTime";
            var now  = DateTimeOffset.Now;
            var feed = environment.UserCachePath.Combine(packageFeed.Filename);

            if (!feed.FileExists() || now.Date > environment.UserSettings.Get <DateTimeOffset>(key).Date)
            {
                feed = new DownloadTask(taskManager, packageFeed, environment.UserCachePath)
                       .Catch(ex =>
                {
                    Logger.Warning(@"Error downloading package feed:{0} ""{1}"" Message:""{2}""", packageFeed, ex.GetType().ToString(), ex.GetExceptionMessageShort());
                    return(true);
                })
                       .RunSynchronously().ToSPath();

                if (feed.IsInitialized)
                {
                    environment.UserSettings.Set <DateTimeOffset>(key, now);
                }
            }

            if (!feed.IsInitialized)
            {
                // try from assembly resources
                feed = AssemblyResources.ToFile(ResourceType.Platform, packageFeed.Filename, environment.UserCachePath, environment);
            }

            if (feed.IsInitialized)
            {
                try
                {
                    package = feed.ReadAllText().FromJson <Package>(true, false);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            }
            return(package);
        }
コード例 #2
0
 private void GoToProfile(object obj)
 {
     var connection = (Connection) obj;
     var uriString = new UriString(connection.Host).Combine(connection.Username);
     Application.OpenURL(uriString);
 }