本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例5: DoubleAddException
public void DoubleAddException()
{
var manager = new ServiceManager();
var empty = new EmptyClass();
manager.SetProvider(empty);
manager.SetProvider(empty);
}
示例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());
}
示例7: GetProvider
public void GetProvider()
{
var manager = new ServiceManager();
var empty = new EmptyClass();
manager.SetProvider(empty);
Assert.AreSame(manager.GetProvider<EmptyClass>(), empty);
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}