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


C# EmptyClass类代码示例

本文整理汇总了C#中EmptyClass的典型用法代码示例。如果您正苦于以下问题:C# EmptyClass类的具体用法?C# EmptyClass怎么用?C# EmptyClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: InterfaceReRegisteredFromInstanceToInstance_Success

        public void InterfaceReRegisteredFromInstanceToInstance_Success()
        {
            var c = new Container();
            IEmptyClass emptyClass = new EmptyClass();
            c.RegisterInstance(emptyClass).AsPerHttpContext();

            var controller = new DefaultController();
            HttpContext.Current = new HttpContext(new HttpRequest("", "http://tempuri.org", ""), new HttpResponse(new StringWriter()));
            var result1 = controller.ResolveObject<IEmptyClass>(c, ResolveKind.PartialEmitFunction);
            var emptyClass1 = (IEmptyClass)((ViewResult)result1).Model;
            var result2 = controller.ResolveObject<IEmptyClass>(c, ResolveKind.PartialEmitFunction);
            var emptyClass2 = (IEmptyClass)((ViewResult)result2).Model;

            IEmptyClass emptyClass3 = new EmptyClass();
            c.RegisterInstance(emptyClass3).AsPerHttpContext();
            var result4 = controller.ResolveObject<IEmptyClass>(c, ResolveKind.PartialEmitFunction);
            var emptyClass4 = (IEmptyClass)((ViewResult)result4).Model;
            var result5 = controller.ResolveObject<IEmptyClass>(c, ResolveKind.PartialEmitFunction);
            var emptyClass5 = (IEmptyClass)((ViewResult)result5).Model;

            Assert.AreEqual(emptyClass, emptyClass1);
            Assert.AreEqual(emptyClass1, emptyClass2);
            Assert.AreEqual(emptyClass3, emptyClass4);
            Assert.AreEqual(emptyClass4, emptyClass5);
            Assert.AreNotEqual(emptyClass, emptyClass3);
        }
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:26,代码来源:ReRegistereInterfaceTests.cs

示例2: InterfaceReRegisteredFromInstanceToInstance_Success

        public void InterfaceReRegisteredFromInstanceToInstance_Success()
        {
            var c = new Container();
            IEmptyClass emptyClass = new EmptyClass();
            IEmptyClass emptyClass3 = new EmptyClass();
            c.RegisterInstance(emptyClass).AsPerThread();
            IEmptyClass emptyClass1 = null;
            IEmptyClass emptyClass2 = null;
            IEmptyClass emptyClass4 = null;
            IEmptyClass emptyClass5 = null;

            var thread = new Thread(() =>
            {
                emptyClass1 = c.Resolve<IEmptyClass>(ResolveKind.FullEmitFunction);
                emptyClass2 = c.Resolve<IEmptyClass>(ResolveKind.FullEmitFunction);

                c.RegisterInstance(emptyClass3).AsPerThread();
                emptyClass4 = c.Resolve<IEmptyClass>(ResolveKind.FullEmitFunction);
                emptyClass5 = c.Resolve<IEmptyClass>(ResolveKind.FullEmitFunction);
            });
            thread.Start();
            thread.Join();

            Assert.AreEqual(emptyClass, emptyClass1);
            Assert.AreEqual(emptyClass1, emptyClass2);
            Assert.AreEqual(emptyClass3, emptyClass4);
            Assert.AreEqual(emptyClass4, emptyClass5);
            Assert.AreNotEqual(emptyClass, emptyClass3);
        }
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:29,代码来源:ReRegistereInterfaceTests.cs

示例3: ClassReRegisteredFromClassToInstance_Success

        public void ClassReRegisteredFromClassToInstance_Success()
        {
            var c = new Container();
            c.RegisterType<EmptyClass>().AsPerThread();
            var emptyClass = new EmptyClass();
            EmptyClass emptyClass1 = null;
            EmptyClass emptyClass2 = null;
            EmptyClass emptyClass3 = null;
            EmptyClass emptyClass4 = null;

            var thread = new Thread(() =>
            {
                emptyClass1 = c.Resolve<EmptyClass>(ResolveKind.PartialEmitFunction);
                emptyClass2 = c.Resolve<EmptyClass>(ResolveKind.PartialEmitFunction);

                c.RegisterInstance(emptyClass).AsPerThread();
                emptyClass3 = c.Resolve<EmptyClass>(ResolveKind.PartialEmitFunction);
                emptyClass4 = c.Resolve<EmptyClass>(ResolveKind.PartialEmitFunction);
            });
            thread.Start();
            thread.Join();

            Assert.AreEqual(emptyClass1, emptyClass2);
            Assert.AreEqual(emptyClass, emptyClass3);
            Assert.AreEqual(emptyClass3, emptyClass4);
            Assert.AreNotEqual(emptyClass1, emptyClass);
        }
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:27,代码来源:ReRegistereClassTests.cs

示例4: TestRequestWithResponse

        public void TestRequestWithResponse(int httpMethod)
        {
            var parameters = new Dictionary<string, object> { { "p1", "2" } };
            var method = (HttpMethod)httpMethod;
            var bytes = new byte[] { 1, 2, 3, 4 };
            var scAccessToken = new SCAccessToken
            {
                AccessToken = "aToken"
            };

            var expected = new EmptyClass();

            using (mocks.Record())
            {
                var uriBuilder = NewMock<IUriBuilder>();
                uriBuilder.Expect(f => f.AddCredentials(scCredentials, scAccessToken)).Return(uriBuilder);
                uriBuilderFactory.Expect(f => f.Create(Domain.Api.GetParameterName() + "prefix/command.json")).Return(uriBuilder);

                webGateway.Expect(f => f.Request(uriBuilder, method, parameters, bytes, scAccessToken.AccessToken)).Return("response");

                serializer.Expect(f => f.Deserialize<EmptyClass>("response")).Return(expected);
            }
            
            var soundCloudRawClient = new SoundCloudRawClient(scCredentials, uriBuilderFactory, webGateway, serializer)
            {
                AccessToken = scAccessToken
            };
            var actual = soundCloudRawClient.Request<EmptyClass>("prefix", "command", method, parameters, bytes, "json", Domain.Api);

            Assert.AreEqual(expected, actual);
        }
开发者ID:opcon,项目名称:SoundCloud.API.Client,代码行数:31,代码来源:SoundCloudRawClientTest.cs

示例5: DoubleAddException

        public void DoubleAddException()
        {
            var manager = new ServiceManager();
            var empty = new EmptyClass();

            manager.SetProvider(empty);
            manager.SetProvider(empty);
        }
开发者ID:devast8a,项目名称:FlyingTuna,代码行数:8,代码来源:ServiceManagerTest.cs

示例6: InterfaceWithTwoMembers_InSubClass

        public void InterfaceWithTwoMembers_InSubClass()
        {
            dynamic d = new EmptyClass();
            Assert.Throws<RuntimeBinderException>(() => d.Foo());

            Assert.Throws<InvalidCastException>(() => Helpers.Cast<BaseInterfaceWithTwoMembers>(d));
            Assert.Throws<InvalidCastException>(() => ((BaseInterfaceWithTwoMembers)d).Foo());
        }
开发者ID:Corillian,项目名称:corefx,代码行数:8,代码来源:Conformance.dynamic.context.ExplicitImple.Inheritance.cs

示例7: GetProvider

        public void GetProvider()
        {
            var manager = new ServiceManager();
            var empty = new EmptyClass();

            manager.SetProvider(empty);

            Assert.AreSame(manager.GetProvider<EmptyClass>(), empty);
        }
开发者ID:devast8a,项目名称:FlyingTuna,代码行数:9,代码来源:ServiceManagerTest.cs

示例8: RegisterInstanceOfEmptyClass_Success

        public void RegisterInstanceOfEmptyClass_Success()
        {
            var c = new Container();
            var emptyClass1 = new EmptyClass();
            c.RegisterInstance(emptyClass1);

            var emptyClass2 = c.Resolve<EmptyClass>(ResolveKind.FullEmitFunction);

            Assert.AreEqual(emptyClass1, emptyClass2);
        }
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:10,代码来源:RegisterClassInstanceTests.cs

示例9: Delete

        public void Delete()
        {
            var testClass = new EmptyClass();
            Assert.Throws<NotFoundException>(() => testClass.Delete());

            testClass.Save();
            Assert.False(testClass.IsDeleted());
            testClass.Delete();
            Assert.True(testClass.IsDeleted());
            Assert.Throws<NotFoundException>(() => testClass.Delete());
        }
开发者ID:bazer,项目名称:Modl,代码行数:11,代码来源:EmptyClassTest.cs

示例10: RegisterInstanceOfClassNeededByOtherClass_Success

        public void RegisterInstanceOfClassNeededByOtherClass_Success()
        {
            var c = new Container();
            var emptyClass = new EmptyClass();
            c.RegisterType<SampleClass>();
            c.RegisterInstance(emptyClass);

            var sampleClass = c.Resolve<SampleClass>(ResolveKind.FullEmitFunction);

            Assert.IsNotNull(sampleClass);
            Assert.AreEqual(emptyClass, sampleClass.EmptyClass);
        }
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:12,代码来源:RegisterClassInstanceTests.cs

示例11: RegisterInstanceOfInterfaceNeededByInterface_Success

        public void RegisterInstanceOfInterfaceNeededByInterface_Success()
        {
            var c = new Container();
            IEmptyClass emptyClass = new EmptyClass();
            c.RegisterType<ISampleClassWithInterfaceAsParameter, SampleClassWithInterfaceAsParameter>();
            c.RegisterInstance(emptyClass);

            var sampleClass = c.Resolve<ISampleClassWithInterfaceAsParameter>(ResolveKind.PartialEmitFunction);

            Assert.IsNotNull(sampleClass);
            Assert.AreEqual(emptyClass, sampleClass.EmptyClass);
        }
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:12,代码来源:RegisterInterfaceInstanceTests.cs

示例12: FactoryObjectReturnNewObject_Success

        public void FactoryObjectReturnNewObject_Success()
        {
            var c = new Container();
            IEmptyClass emptyClass = new EmptyClass();
            c.RegisterType<SampleClassWithInterfaceAsParameter>(() => new SampleClassWithInterfaceAsParameter(emptyClass)).AsSingleton();

            var sampleClass1 = c.Resolve<SampleClassWithInterfaceAsParameter>(ResolveKind.PartialEmitFunction);
            var sampleClass2 = c.Resolve<SampleClassWithInterfaceAsParameter>(ResolveKind.PartialEmitFunction);

            Assert.AreEqual(sampleClass1, sampleClass2);
            Assert.AreEqual(emptyClass, sampleClass1.EmptyClass);
            Assert.AreEqual(emptyClass, sampleClass2.EmptyClass);
        }
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:13,代码来源:RegisterTypeByFactoryObjectForClassWithInterfaceTests.cs

示例13: FactoryObjectReturnNewObject_Success

        public void FactoryObjectReturnNewObject_Success()
        {
            var c = new Container();
            var emptyClass = new EmptyClass();
            c.RegisterType<ISampleClass>(() => new SampleClass(emptyClass));

            var sampleClass1 = c.Resolve<ISampleClass>(ResolveKind.FullEmitFunction);
            var sampleClass2 = c.Resolve<ISampleClass>(ResolveKind.FullEmitFunction);

            Assert.AreNotEqual(sampleClass1, sampleClass2);
            Assert.AreEqual(emptyClass, sampleClass1.EmptyClass);
            Assert.AreEqual(emptyClass, sampleClass2.EmptyClass);
        }
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:13,代码来源:RegisterTypeByFactoryObjectForInterfaceWithClassTests.cs

示例14: NestedFactoryObjectReturnTheSameObject_Success

        public void NestedFactoryObjectReturnTheSameObject_Success()
        {
            var c = new Container();
            IEmptyClass emptyClass = new EmptyClass();
            c.RegisterType<IEmptyClass>(() => emptyClass);
            c.RegisterType<ISampleClassWithInterfaceAsParameter, SampleClassWithInterfaceAsParameter>();

            var sampleClass1 = c.Resolve<ISampleClassWithInterfaceAsParameter>(ResolveKind.FullEmitFunction);
            var sampleClass2 = c.Resolve<ISampleClassWithInterfaceAsParameter>(ResolveKind.FullEmitFunction);

            Assert.AreNotEqual(sampleClass1, sampleClass2);
            Assert.AreEqual(sampleClass1.EmptyClass, sampleClass2.EmptyClass);
        }
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:13,代码来源:RegisterTypeByFactoryObjectForInterfaceTests.cs

示例15: NestedFactoryObjectReturnTheSameObject_Success

        public void NestedFactoryObjectReturnTheSameObject_Success()
        {
            var c = new Container();
            var emptyClass = new EmptyClass();
            c.RegisterType<EmptyClass>(() => emptyClass).AsSingleton();
            c.RegisterType<SampleClass>().AsSingleton();

            var sampleClass1 = c.Resolve<SampleClass>(ResolveKind.FullEmitFunction);
            var sampleClass2 = c.Resolve<SampleClass>(ResolveKind.FullEmitFunction);

            Assert.AreEqual(sampleClass1, sampleClass2);
            Assert.AreEqual(sampleClass1.EmptyClass, sampleClass2.EmptyClass);
        }
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:13,代码来源:RegisterTypeByFactoryObjectForClassTests.cs


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