12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System;
- using System.Collections.Generic;
- using System.Reflection;
- using Xunit;
- namespace VCommon.Ioc.Tests
- {
- public class InterceptorTest
- {
- private class Interceptor : IInterceptor, ITransientIocClass
- {
- public void BeforeInvoke(Type svcClass, MethodBase svcMethod, IReadOnlyDictionary<string, object> paramDic)
- {
- }
- public void AfterInvoke(Type svcClass, MethodBase svcMethod, IReadOnlyDictionary<string, object> paramDic, object resultReturnValue, Exception resultException)
- {
- }
- }
- public interface ITestInterface
- {
- int TestMethod(int value);
- }
- private class TestClass : ITestInterface, ITransientIocClass<IInterceptor>
- {
- public int TestMethod(int value)
- {
- return value + 1;
- }
- }
- [Fact]
- public void Test()
- {
- var container = new IocManager();
- var child = container.CreateChildren();
- child.RegisterInstanceToContainer(child);
- var svc = container.Resolve<ITestInterface>();
- var ret = svc.TestMethod(1);
- }
- }
- }
|