Esempio n. 1
0
        public Story(string name, IRuleset <IStory, IStoryHandler> handlerProvider)
        {
            try
            {
                Ensure.ArgumentNotEmpty(name, "name");
                Ensure.ArgumentNotNull(handlerProvider, "handlerProvider");

                this.HandlerProvider = handlerProvider;
                this.stopWatch       = new Stopwatch();
                this.log             = new StoryLog(this);
                this.data            = new StoryData(this);

                if (this.Parent == null)
                {
                    this.Name = name;
                }
                else
                {
                    this.Name = this.Parent.Name + "/" + name;
                }
            }
            catch
            {
                base.Detach();
                throw;
            }
        }
Esempio n. 2
0
        public async Task <IReadOnlyCollection <ContentInfo> > GetAllContentsAsync(string owner, string repoName, string path)
        {
            Ensure.ArgumentNotEmpty(owner, nameof(owner));
            Ensure.ArgumentNotEmpty(repoName, nameof(repoName));

            var url = GITHUB_CONTENT_URL
                      .Replace(UriParts.OWNER, owner)
                      .Replace(UriParts.REPO, repoName)
                      .Replace(UriParts.PATH, path);

            return((await HttpClient.GetJsonAsync <List <ContentInfo> >(url)).AsReadOnly());
        }
Esempio n. 3
0
        public Story(string name, IRuleset <IStory, IStoryHandler> handlerProvider, bool notInContext = false)
        {
            Ensure.ArgumentNotEmpty(name, "name");
            Ensure.ArgumentNotNull(handlerProvider, "handlerProvider");

            this.HandlerProvider = handlerProvider;
            this.notInContext    = notInContext;
            this.stopWatch       = new Stopwatch();
            this.log             = new StoryLog(this);
            this.data            = new StoryData(this);

            this.Name = name;
        }
Esempio n. 4
0
        private async Task <(string Owner, string RepoName, string FilePath)> ResolveParamsAsync(GithubUri githubUri)
        {
            if (!string.IsNullOrWhiteSpace(githubUri.FilePath))
            {
                Ensure.ArgumentNotEmpty(githubUri.RepoName, nameof(githubUri.RepoName));
            }

            Ensure.ArgumentNotEmpty(githubUri.Owner, nameof(githubUri.Owner));

            var repoName = await GetRepoNameOrDefaultAsync(githubUri);

            var filePath = await GetFilePathOrDefaultAsync(githubUri);

            return(githubUri.Owner, repoName, filePath);
        }
Esempio n. 5
0
        public async Task <File> GetFileContentAsync(string owner, string repoName, string path)
        {
            Ensure.ArgumentNotEmpty(owner, nameof(owner));
            Ensure.ArgumentNotEmpty(repoName, nameof(repoName));
            Ensure.ArgumentNotEmpty(path, nameof(path));

            var url = GITHUB_CONTENT_URL
                      .Replace(UriParts.OWNER, owner)
                      .Replace(UriParts.REPO, repoName)
                      .Replace(UriParts.PATH, path);

            var repoFileContent = await HttpClient.GetJsonAsync <File>(url);

            repoFileContent.Content = FromBase64String(repoFileContent.Content);
            return(repoFileContent);
        }
Esempio n. 6
0
        public virtual object this[string key]
        {
            get
            {
                Ensure.ArgumentNotEmpty(key, "key");

                object result;
                return(this.entries.TryGetValue(key, out result) ? result : null);
            }

            set
            {
                Ensure.ArgumentNotEmpty(key, "key");

                this.entries[key] = value;
                this.Story.Log.Debug("Added key '{0}' to data.", key);
            }
        }
Esempio n. 7
0
        public virtual object this[string key]
        {
            get
            {
                Ensure.ArgumentNotEmpty(key, "key");

                object result;
                return(this.entries.TryGetValue(key, out result) ? result : null);
            }

            set
            {
                Ensure.ArgumentNotEmpty(key, "key");

                if (!IgnoreDuplicates && this.entries.ContainsKey(key))
                {
                    throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, "Data already has key [{0}] with value", key));
                }

                this.entries[key] = value;
                this.Story.Log.Debug("Added key '{0}' to data.", key);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Finalizez the files of a project.
        /// </summary>
        /// <remarks>
        /// This method requires authentication.
        /// See the <a href="http://gs2017dev.sdl.com:41234/documentation/api/index#/">API documentation</a> for more information.
        /// </remarks>
        /// <exception cref="AuthorizationException">
        /// Thrown when the current user does not have permission to make the request.
        /// </exception>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>A list of byte[] wich represents downloaded files.</returns>
        public async Task <byte[]> Finalize(string projectId, List <string> languageFileIds)
        {
            Ensure.ArgumentNotEmpty(languageFileIds, "languageFileIds");

            return(await ApiConnection.Post <byte[]>(ApiUrls.Finalize(projectId, LanguageIdQuery(languageFileIds))));
        }
Esempio n. 9
0
        /// <summary>
        ///Downloads the files with the specific language ids.
        /// </summary>
        /// <remarks>
        /// This method requires authentication.
        /// See the <a href="http://gs2017dev.sdl.com:41234/documentation/api/index#/">API documentation</a> for more information.
        /// </remarks>
        /// <exception cref="AuthorizationException">
        /// Thrown when the current user does not have permission to make the request.
        /// </exception>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>A list of byte[] wich represents downloaded files.</returns>
        public async Task <byte[]> DownloadFiles(string projectId, List <string> languageFileIds)
        {
            Ensure.ArgumentNotEmpty(languageFileIds, "languageFileIds");

            return(await ApiConnection.Get <byte[]>(ApiUrls.DownloadFiles(projectId, LanguageIdQuery(languageFileIds)), null));
        }