Example #1
0
        /// <summary>
        /// 此测试用例的目的在于测试消息头的发送是否成功
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //初始化容器
            InitContainer();

            //伪造一个登录信息
            IAuthenticationContract authenticationContract = ResolveMediator.Resolve <IAuthenticationContract>();
            LoginInfo fakeLoginInfo = authenticationContract.Login(CommonConstants.AdminLoginId, CommonConstants.InitialPassword);

            //将登录信息存入约定位置
            base.Session.Add(SessionKey.CurrentUser, fakeLoginInfo);

            //实例化WCF服务端服务接口
            IServerContract serverContract = ResolveMediator.Resolve <IServerContract>();

            //调用服务获取消息头
            string header = serverContract.GetHeader();

            //如果消息头内容即是上述伪造的公钥,即说明整个认证过程没问题
            if (fakeLoginInfo.PublicKey.ToString() == header)
            {
                base.Response.Write("认证通过!");
            }

            ResolveMediator.Dispose();
        }
Example #2
0
        /// <summary>
        /// 此测试用例的目的在于测试消息头的发送是否成功
        /// </summary>
        static void Main()
        {
            //初始化容器
            InitContainer();

            //伪造一个登录信息
            IAuthenticationContract authenticationContract = ResolveMediator.Resolve <IAuthenticationContract>();
            LoginInfo fakeLoginInfo = authenticationContract.Login(CommonConstants.AdminLoginId, CommonConstants.InitialPassword);

            //将登录信息存入约定位置
            AppDomain.CurrentDomain.SetData(SessionKey.CurrentUser, fakeLoginInfo);

            //实例化WCF客户端服务接口
            IClientContract clientContract = ResolveMediator.Resolve <IClientContract>();

            //调用服务获取消息头,
            string header = clientContract.GetHeader();

            //如果消息头内容即是上述伪造的公钥,即说明整个认证过程没问题
            if (fakeLoginInfo.PublicKey.ToString() == header)
            {
                Console.WriteLine("认证通过!");
            }

            ResolveMediator.Dispose();
            Console.ReadKey();
        }
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public virtual void Dispose()
        {
            if (WebApiDependencyResolver.OnReleaseInstance != null)
            {
                WebApiDependencyResolver.OnReleaseInstance.Invoke();
            }

            ResolveMediator.Dispose();
        }
        public void Cleanup()
        {
            if (ResolveMediator.ContainerBuilt)
            {
                ResolveMediator.Dispose();
            }

            ScheduleMediator.Clear();
        }
Example #5
0
        /// <summary>
        /// 执行中间件
        /// </summary>
        public async Task Invoke(HttpContext context)
        {
            try
            {
                //初始化SessionId
                Initializer.InitSessionId();

                await this._next.Invoke(context);
            }
            finally
            {
                //清理依赖注入范围容器
                ResolveMediator.Dispose();
            }
        }
        /// <summary>
        /// 执行中间件
        /// </summary>
        public override async Task Invoke(IOwinContext context)
        {
            try
            {
                //初始化SessionId
                Initializer.InitSessionId();

                await base.Next.Invoke(context);
            }
            finally
            {
                //清理依赖注入范围容器
                ResolveMediator.Dispose();
            }
        }
Example #7
0
 /// <summary>
 /// 应用程序退出事件
 /// </summary>
 protected override void OnExit(object sender, EventArgs eventArgs)
 {
     ResolveMediator.Dispose();
 }
 /// <summary>
 /// 清理服务
 /// </summary>
 public void ReleaseService()
 {
     ResolveMediator.Dispose();
 }
Example #9
0
 public void Cleanup()
 {
     GlobalSetting.FreeCurrentSessionId();
     ResolveMediator.Dispose();
 }
Example #10
0
        /// <summary>
        /// 清理服务契约实例
        /// </summary>
        /// <param name="instanceContext">WCF上下文对象</param>
        /// <param name="instance">服务契约实例</param>
        public void ReleaseInstance(InstanceContext instanceContext, object instance)
        {
            OnReleaseInstance?.Invoke(instanceContext, instance);

            ResolveMediator.Dispose();
        }
Example #11
0
 public void Cleanup()
 {
     ResolveMediator.Dispose();
 }