コード例 #1
0
ファイル: CDSDependencyResolver.cs プロジェクト: phGama/CDSL
        public static T GetService <T>(RequestContext Request) where T : class
        {
            string Token       = string.Empty;
            var    SessionAuth = Request.HttpContext.Session[GlobalParams.UserSessionKey];
            var    TokenType   = SVC.DTO.TokenType.WebAuth;

            if (SessionAuth != null)
            {
                var AuthObject = (AuthResponse)SessionAuth;
                Token = AuthObject.Token;
            }

            if (typeof(T) == typeof(IAuthService))
            {
                return((T)ServiceFinder.GetAuthService());
            }
            else if (typeof(T) == typeof(IContentService))
            {
                return((T)ServiceFinder.GetContentService(Token, TokenType, Request.HttpContext.Server.MapPath("~/Uploads/")));
            }
            else if (typeof(T) == typeof(IUserService))
            {
                return((T)ServiceFinder.GetUserService(Token, TokenType));
            }
            else if (typeof(T) == typeof(IGroupService))
            {
                return((T)ServiceFinder.GetGroupService(Token, TokenType));
            }
            else if (typeof(T) == typeof(IGenreService))
            {
                return((T)ServiceFinder.GetGenreService(Token, TokenType));
            }

            return(null);
        }
コード例 #2
0
ファイル: ContentTest.cs プロジェクト: phGama/CDSL
        private IContentService GetAdminService()
        {
            string CodeAdmin = string.Empty;

            using (var TokenService = ServiceFinder.GetTokenService())
            {
                CodeAdmin = TokenService.CreateToken(TokenType.WebAuth, 1);
            }
            var ContentService = ServiceFinder.GetContentService(CodeAdmin, TokenType.WebAuth, BaseUploadPath);

            return(ContentService);
        }
コード例 #3
0
ファイル: ContentTest.cs プロジェクト: phGama/CDSL
        private IContentService GetCommonService()
        {
            int Id = 0;

            using (CDSEntities db = new CDSEntities()){
                Id = db.Users.First(x => x.IdType == 2).Id;
            }
            string CodeCommon = string.Empty;

            using (var TokenService = ServiceFinder.GetTokenService())
            {
                CodeCommon = TokenService.CreateToken(TokenType.WebAuth, Id);
            }
            var ContentService = ServiceFinder.GetContentService(CodeCommon, TokenType.WebAuth, BaseUploadPath);

            return(ContentService);
        }