コード例 #1
0
        public void ValidationContext_ServiceProvider()
        {
            IServiceProvider  provider = new MyServiceProvider();
            ValidationContext context  = new ValidationContext(new object(), provider, null);
            object            service  = context.GetService(typeof(string));

            Assert.IsNotNull(service);
            Assert.AreEqual("hello", service);

            service = context.GetService(typeof(Guid));
            Assert.IsNull(service);
        }
コード例 #2
0
        public void ValidationContext_ServiceProvider() {
            IServiceProvider provider = new MyServiceProvider();
            ValidationContext context = new ValidationContext(new object(), provider, null);
            object service = context.GetService(typeof(string));
            Assert.IsNotNull(service);
            Assert.AreEqual("hello", service);

            service = context.GetService(typeof(Guid));
            Assert.IsNull(service);
        }