Example #1
0
        /// <summary>
        ///     This method is responsible for retrieving a project by uri.
        /// </summary>
        /// <param name="sourceUri">The uri which is used for searching an individual project.</param>
        /// <returns>This method returns a project from the specified uri.</returns>
        public async Task <Project> GetProjectByUri(Uri sourceUri)
        {
            IPublicDataSourceAdaptee publicDataSource = adaptee as IPublicDataSourceAdaptee;

            if (publicDataSource == null)
            {
                throw new NotSupportedException("Can not cast specified adaptee to authorized adaptee.");
            }
            return(await publicDataSource.GetPublicProjectFromUri(sourceUri));
        }
Example #2
0
        private async Task <IEnumerable <Project> > GetAllProjectsWithoutAccessToken(string username)
        {
            IPublicDataSourceAdaptee publicDataSourceAdaptee = adaptee as IPublicDataSourceAdaptee;

            if (publicDataSourceAdaptee == null)
            {
                throw new NotSupportedException("Can not cast specified adaptee to authorized adaptee.");
            }
            IEnumerable <Project> projects = await publicDataSourceAdaptee.GetAllPublicProjects(username);

            return(projects);
        }
Example #3
0
        /// <summary>
        ///     This method is responsible for retrieving a project by guid.
        /// </summary>
        /// <param name="token">The token parameters is used for finding all projects. This can be Oauth tokens, or the username.</param>
        /// <param name="id">The identifier which is used for searching an individual project.</param>
        /// <param name="needsAuth">The needsAuth parameter specifies which flow should get used.</param>
        /// <returns>This method returns a project with the specified identifier.</returns>
        public async Task <Project> GetProjectByGuid(string token, string id, bool needsAuth)
        {
            if (!needsAuth)
            {
                IPublicDataSourceAdaptee publicDataSource = adaptee as IPublicDataSourceAdaptee;
                if (publicDataSource == null)
                {
                    throw new NotSupportedException("Can not cast specified adaptee to authorized adaptee.");
                }
                return(await publicDataSource.GetPublicProjectById(id));
            }
            IAuthorizedDataSourceAdaptee authorizedDataSource = adaptee as IAuthorizedDataSourceAdaptee;

            if (authorizedDataSource == null)
            {
                throw new NotSupportedException("Can not cast specified adaptee to authorized adaptee.");
            }
            return(await authorizedDataSource.GetProjectById(token, id));
        }