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

            foo.SomeOtherProperty = 123;
        }
Beispiel #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");
            }
        }
Beispiel #4
0
            public void Run()
            {
                _foo.DoSomething();

                var result = _foo.GetTest();

                Assert.IsNull(result);
            }
        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();
        }
        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();
        }
Beispiel #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();
        }
 public void UsingDispatch()
 {
     dispatchProxy.DoSomething();
 }
 public void UsingLinFu()
 {
     linFuProxy.DoSomething();
 }
 public void UsingCastle()
 {
     castleProxy.DoSomething();
 }
 public void UsingLightInject()
 {
     lightInjectProxy.DoSomething();
 }
 public void UsingManualNoInliningProxy()
 {
     manualNoInliningProxy.DoSomething();
 }
Beispiel #13
0
 public bool DoSomething(string value)
 {
     return(_ifooObject.DoSomething(value));
 }
Beispiel #14
0
 public void Hello()
 {
     foo.DoSomething("ping");
     var name = foo.Name;
 }
 public void Bar(IFoo foo)
 {
     foo.DoSomething();
 }
        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);
 }
Beispiel #19
0
    public void HandleSomething()
    {
        IFoo foo = this.fooFactory.Create();

        foo.DoSomething();
    }
 public bool DoSomething(string value)
 {
     return(_foo.DoSomething(value));
 }