コード例 #1
0
 public string TestMethod(IFoo foo)
 {
     if (foo.DoSomething("ping"))
     {
         return("ping");
     }
     else if (foo.DoSomething("pong"))
     {
         return("pong");
     }
     return("blah");
 }
コード例 #2
0
        public void Hello()
        {
            foo.DoSomething("ping");
            var name = foo.Name;

            foo.SomeOtherProperty = 123;
        }
コード例 #3
0
        public void InterceptorCorrectlyRethrowsException()
        {
            IUnityContainer container = new UnityContainer()
                                        .AddNewExtension <Interception>()
                                        .RegisterType(typeof(IFoo), typeof(Foo))
                                        .Configure <Interception>()
                                        .SetInterceptorFor(typeof(Foo), new VirtualMethodInterceptor())
                                        .AddPolicy("AlwaysMatches")
                                        .AddMatchingRule <AlwaysMatchingRule>()
                                        .AddCallHandler <CallCountHandler>("callCount", new ContainerControlledLifetimeManager())
                                        .Interception
                                        .Container;

            IFoo myFoo = container.Resolve <IFoo>();

            try
            {
                myFoo.DoSomething();
                Assert.Fail("Should have thrown");
            }
            catch (Exception ex)
            {
                CallCountHandler handler = (CallCountHandler)(container.Resolve <ICallHandler>("callCount"));
                Assert.AreEqual(1, handler.CallCount);
                Assert.IsInstanceOfType(ex, typeof(FooCrashedException));

                var stackTrace = ex.StackTrace.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                Assert.IsTrue(stackTrace[0].Contains("DoSomethingLocal"), "stack trace is not full");
            }
        }
コード例 #4
0
            public void Run()
            {
                _foo.DoSomething();

                var result = _foo.GetTest();

                Assert.IsNull(result);
            }
コード例 #5
0
        static void Main(string[] args)
        {
            AppDomain appDomain = AppDomain.CreateDomain("foo");

            IFoo foo = (IFoo)appDomain.CreateInstanceFromAndUnwrap(Assembly.GetEntryAssembly().Location, typeof(Foo).FullName);

            foo.SetSource("Foo Host");

            foo.DoSomething();
        }
コード例 #6
0
        static void Main(string[] args)
        {
            AppDomain appDomain = AppDomain.CreateDomain("foo");

            appDomain.SetData(FooUtility.SourceKey, FooUtility.SourceValue);

            IFoo foo = (IFoo)appDomain.CreateInstanceFromAndUnwrap(Assembly.GetEntryAssembly().Location, typeof(Foo).FullName);

            foo.DoSomething();
        }
コード例 #7
0
        static void Main(string[] args)
        {
            MyProxy <IFoo> proxy = new MyProxy <IFoo>(new Foo());

            IFoo proxiedFoo = (IFoo)proxy.GetTransparentProxy();

            // make a proxied call...
            proxiedFoo.DoSomething();

            // cast proxiedFoo to IDisposable and dispose of it...
            IDisposable disposableFoo = proxiedFoo as IDisposable;

            // disposableFoo is null at this point.

            disposableFoo.Dispose();
        }
コード例 #8
0
 public void UsingDispatch()
 {
     dispatchProxy.DoSomething();
 }
コード例 #9
0
 public void UsingLinFu()
 {
     linFuProxy.DoSomething();
 }
コード例 #10
0
 public void UsingCastle()
 {
     castleProxy.DoSomething();
 }
コード例 #11
0
 public void UsingLightInject()
 {
     lightInjectProxy.DoSomething();
 }
コード例 #12
0
 public void UsingManualNoInliningProxy()
 {
     manualNoInliningProxy.DoSomething();
 }
コード例 #13
0
ファイル: Foo.cs プロジェクト: SY81517/Quiita
 public bool DoSomething(string value)
 {
     return(_ifooObject.DoSomething(value));
 }
コード例 #14
0
 public void Hello()
 {
     foo.DoSomething("ping");
     var name = foo.Name;
 }
コード例 #15
0
 public void Bar(IFoo foo)
 {
     foo.DoSomething();
 }
コード例 #16
0
        public static void Run()
        {
            s_instance.DoSomething();

            ThrowIfPresent(typeof(TestUnusedDefaultInterfaceMethod), nameof(NeverReferenced));
        }
 public void DoSomething() => _foo.DoSomething();
 public int CalculateBecauseOfSomething(int x, int y, string input)
 {
     return(_foo.DoSomething(input) ? x - y : y - x);
 }
コード例 #19
0
    public void HandleSomething()
    {
        IFoo foo = this.fooFactory.Create();

        foo.DoSomething();
    }
コード例 #20
0
 public bool DoSomething(string value)
 {
     return(_foo.DoSomething(value));
 }