Exemple #1
0
        private string PublishDirectory(string token)
        {
            var gh           = new GitHub(token);
            var snippetFiles = new SnippetFiles(Directory);

            return(Id.IsNullOrWhiteSpace() ?
                   gh.CreateGist(Description, snippetFiles, isPublic: !Secret).Result :
                   gh.UpdateGist(Id, Description, snippetFiles).Result);
        }
        public void Execute(object parameter)
        {
            var viewModel   = _ViewModel;
            var codeToShare = viewModel.Code;

            viewModel.SharedLocation = "Saving...";

            ThreadPool.QueueUserWorkItem(x => {
                var location = GitHub.CreateGist(codeToShare);
                _UiDispatcher.Invoke((Action)(() => viewModel.SharedLocation = location));
            });
        }
Exemple #3
0
        private string PublishSnippet(string token)
        {
            var gh        = new GitHub(token);
            var directory = Path.Combine(Options.SnippetPath, Snippet.Directory);

            var snippetFiles = new SnippetFiles(directory);

            if (Uri.IsWellFormedUriString(snippetFiles.Meta.GistUrl, UriKind.Absolute))
            {
                var id          = new Uri(snippetFiles.Meta.GistUrl).Segments.Last();
                var description = Description.IsNullOrWhiteSpace() ? snippetFiles.Meta.Description : Description;
                return(gh.UpdateGist(id, description, snippetFiles).Result);
            }

            return(gh.CreateGist(Description, snippetFiles, isPublic: true).Result);
        }