当前位置: 首页>>代码示例>>C#>>正文


C# ValidationContext.GetService方法代码示例

本文整理汇总了C#中ValidationContext.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# ValidationContext.GetService方法的具体用法?C# ValidationContext.GetService怎么用?C# ValidationContext.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ValidationContext的用法示例。


在下文中一共展示了ValidationContext.GetService方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidationContext_Can_Remove_Service_From_Parent_Container_Implicitly

        public void ValidationContext_Can_Remove_Service_From_Parent_Container_Implicitly() {
            MyServiceContainer container = new MyServiceContainer();
            container.AddService(typeof(MyTestService), new MyTestService());

            ValidationContext context = new ValidationContext(this, container, null);
            Assert.IsInstanceOfType(context.GetService(typeof(MyTestService)), typeof(MyTestService));
            context.ServiceContainer.RemoveService(typeof(MyTestService)); // Implicit promotion
            Assert.IsNull(context.GetService(typeof(MyTestService)));
        }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:9,代码来源:ValidationContextTest.cs

示例2: ValidationContext_ServiceProvider_Null

 public void ValidationContext_ServiceProvider_Null() {
     ValidationContext context = new ValidationContext(new object(), null, null);
     object service = context.GetService(typeof(string));
     Assert.IsNull(service);
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:5,代码来源:ValidationContextTest.cs

示例3: ValidationContext_Can_Remove_Service_From_Container

 public void ValidationContext_Can_Remove_Service_From_Container() {
     ValidationContext context = new ValidationContext(this, null, null);
     context.ServiceContainer.AddService(typeof(MyTestService), new MyTestService());
     Assert.IsInstanceOfType(context.GetService(typeof(MyTestService)), typeof(MyTestService));
     context.ServiceContainer.RemoveService(typeof(MyTestService));
     Assert.IsNull(context.GetService(typeof(MyTestService)));
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:7,代码来源:ValidationContextTest.cs

示例4: ValidationContext_Remove_Service_Can_Not_Affect_Parent

        public void ValidationContext_Remove_Service_Can_Not_Affect_Parent() {
            MyServiceContainer container = new MyServiceContainer();
            container.AddService(typeof(MyTestService), new MyTestService());

            ValidationContext context = new ValidationContext(this, container, null);
            Assert.IsInstanceOfType(context.GetService(typeof(MyTestService)), typeof(MyTestService));
            context.ServiceContainer.RemoveService(typeof(MyTestService), false);
            Assert.IsInstanceOfType(context.GetService(typeof(MyTestService)), typeof(MyTestService));
        }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:9,代码来源:ValidationContextTest.cs

示例5: ValidationContext_GetService_Returns_Null_When_Service_Not_Found

 public void ValidationContext_GetService_Returns_Null_When_Service_Not_Found() {
     ValidationContext context = new ValidationContext(this, null, null);
     Assert.IsNull(context.GetService(typeof(MyTestService)));
     Assert.IsNull(context.ServiceContainer.GetService(typeof(MyTestService)));
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:5,代码来源:ValidationContextTest.cs

示例6: ValidationContext_Exposes_Services_Through_Callbacks_From_ServiceContainer

 public void ValidationContext_Exposes_Services_Through_Callbacks_From_ServiceContainer() {
     ValidationContext context = new ValidationContext(this, null, null);
     context.ServiceContainer.AddService(typeof(MyTestService), new System.ComponentModel.Design.ServiceCreatorCallback((c, t) => { return new MyTestService(); }));
     Assert.IsInstanceOfType(context.GetService(typeof(MyTestService)), typeof(MyTestService));
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:5,代码来源:ValidationContextTest.cs

示例7: ValidationContext_Can_Add_And_Get_Service

 public void ValidationContext_Can_Add_And_Get_Service() {
     ValidationContext context = new ValidationContext(this, null, null);
     MyTestService service = new MyTestService();
     context.ServiceContainer.AddService(service.GetType(), service);
     Assert.AreSame(service, context.GetService(service.GetType()));
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:6,代码来源:ValidationContextTest.cs

示例8: ValidationContext_Can_Accept_Container_And_Return_Service_From_GetService

        public void ValidationContext_Can_Accept_Container_And_Return_Service_From_GetService() {
            MyServiceContainer container = new MyServiceContainer();
            MyTestService service = new MyTestService();
            container.AddService(service.GetType(), service);

            ValidationContext context = new ValidationContext(this, container, null);
            Assert.AreSame(service, context.GetService(service.GetType()));
        }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:8,代码来源:ValidationContextTest.cs

示例9: ValidationContext_ServiceProvider

        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);
        }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:10,代码来源:ValidationContextTest.cs


注:本文中的ValidationContext.GetService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。