• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Framework.ProxyFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Main

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        public static void Main(string[] args)
        {
            try
            {
                // Create AOP proxy programmatically.
                ProxyFactory factory = new ProxyFactory(new ServiceCommand());
                factory.AddAdvice(new ConsoleLoggingBeforeAdvice());
                factory.AddAdvice(new ConsoleLoggingAfterAdvice());
                factory.AddAdvice(new ConsoleLoggingThrowsAdvice());
                ICommand command = (ICommand)factory.GetProxy();

                command.Execute();
                if (command.IsUndoCapable)
                {
                    command.UnExecute();
                }
            }
            catch (Exception ex)
            {
				Console.Out.WriteLine();
                Console.Out.WriteLine(ex);
            }
            finally
            {
				Console.Out.WriteLine();
                Console.Out.WriteLine("--- hit <return> to quit ---");
                Console.ReadLine();
            }
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:32,代码来源:Program.cs


示例2: Main

 private static void Main(string[] args)
 {
     ProxyFactory factory = new ProxyFactory(new ServiceCommand());
     factory.AddAdvice(new ConsoleLoggingAroundAdvice());
     ICommand command = (ICommand)factory.GetProxy();
     command.Execute("This is the argument");
 }
开发者ID:laball,项目名称:demo,代码行数:7,代码来源:Program.cs


示例3: GetEntity

 public static IXMLMailUtil GetEntity()
 {
     if (entity == null)
     {
         ProxyFactory factory = new ProxyFactory(new XMLMailUtil());
         factory.AddAdvice(new AroundAdvice());
         entity = (IXMLMailUtil)factory.GetProxy();
     }
     return entity;
 }
开发者ID:jcbarrueta,项目名称:ISEN.MSH,代码行数:10,代码来源:XMLMailUtil.cs


示例4: AddPersistenceExceptionTranslation

        protected override void AddPersistenceExceptionTranslation(ProxyFactory pf, IPersistenceExceptionTranslator pet)
        {
            if (AttributeUtils.FindAttribute(pf.TargetType, typeof(RepositoryAttribute)) != null)
            {
                DefaultListableObjectFactory of = new DefaultListableObjectFactory();
                of.RegisterObjectDefinition("peti", new RootObjectDefinition(typeof(PersistenceExceptionTranslationInterceptor)));
                of.RegisterSingleton("pet", pet);
                pf.AddAdvice((PersistenceExceptionTranslationInterceptor) of.GetObject("peti"));

            }
        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:11,代码来源:PersistenceExceptionTranslationInterceptorTests.cs


示例5: Advised

 protected override object Advised(object target, IPlatformTransactionManager ptm,
                                   ITransactionAttributeSource tas)
 {
     TransactionInterceptor ti = new TransactionInterceptor();
     ti.TransactionManager = ptm;
     Assert.AreEqual(ptm, ti.TransactionManager);
     ti.TransactionAttributeSource = tas;
     Assert.AreEqual(tas, ti.TransactionAttributeSource);
     ProxyFactory pf = new ProxyFactory(target);
     pf.AddAdvice(0, ti);
     return pf.GetProxy();
 }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:12,代码来源:TransactionInterceptorTests.cs


示例6: CreateInventorStore

        protected override IInventorRepository CreateInventorStore()
        {
            Region region = CreateRegion();
            cache = new GemFireCache(region);

            context.ObjectFactory.RegisterSingleton("inventors", cache);

            ProxyFactory pf = new ProxyFactory(new InventorRepository());
            pf.AddAdvisors(cacheAspect);

            Repository = (IInventorRepository)pf.GetProxy();
            return Repository;
        }
开发者ID:spring-projects,项目名称:spring-gemfire-net,代码行数:13,代码来源:GemfireCacheTests.cs


示例7: Main

 static void Main(string[] args)
 {
     ProxyFactory factory = new ProxyFactory(new ServiceCommand());
     factory.AddAdvice(new ExceptionAdvice());
     ICommand cc = (ICommand)factory.GetProxy();
     cc.Execute();
     //cc.DoExecute();
     //var ctx = ContextRegistry.GetContext();
     //ICommand command = (ICommand)ctx.GetObject("myAfterAdvice");
     //command.Execute();
     //command.DoExecute();
     Console.ReadLine();
 }
开发者ID:likesea,项目名称:spring.net,代码行数:13,代码来源:Program.cs


示例8: GetProxy

        private static Contact GetProxy()
        {
            Contact target = new Contact();
            target.FirstName = "Aleksandar";
            target.LastName = "Seovic";

            ProxyFactory pf = new ProxyFactory(target);
            pf.AddAdvisor(new ModificationAdvisor(target.GetType()));
            pf.AddIntroduction(new IsModifiedAdvisor());
            pf.ProxyTargetType = true;

            return (Contact)pf.GetProxy();
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:13,代码来源:Program.cs


示例9: Main

        static void Main(string[] args)
        {
            //Person p=new Person();
              //  p.Pen=new Pen();
              //  p.Write();

            ProxyFactory proxy = new ProxyFactory(new Pen());
            //proxy.AddAdvice(new BeforeAdvice());
            proxy.AddAdvice(new AroundAdvice());
            IWrite p = proxy.GetProxy() as IWrite;
            p.Write();

            Console.ReadKey();
        }
开发者ID:15751064254,项目名称:NewRepo,代码行数:14,代码来源:Program.cs


示例10: TestIntroductionInterceptorWithDelegation

		public void TestIntroductionInterceptorWithDelegation()
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ITimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);
	
			ITimeStampedIntroduction ts = MockRepository.GenerateMock<ITimeStampedIntroduction>();
			ts.Stub(x => x.TimeStamp).Return(EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			factory.AddIntroduction(advisor);

			ITimeStamped tsp = (ITimeStamped) factory.GetProxy();
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
		}
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:15,代码来源:DelegatingIntroductionInterceptorTests.cs


示例11: GetServiceProxy

        public object GetServiceProxy(Assembly webServiceAssembly, string serviceName)
        {
            object proxy = webServiceAssembly.CreateInstance(serviceName);
            if (proxy == null)
                throw new Exception("Cannot create proxy instance");

            if (_modifier == null)
                return proxy;

            var factory = new ProxyFactory(proxy) { ProxyTargetType = true };
            factory.AddAdvice(new WebRequestModifyInterceptor(_modifier));
            var result = factory.GetProxy();

            SetUpMissingValues(proxy, result);
            return result;
        }
开发者ID:sadowskik,项目名称:WebServiceInvoker,代码行数:16,代码来源:SpringProxyCreator.cs


示例12: TestIntroductionInterceptorWithInterfaceHierarchy

		public void TestIntroductionInterceptorWithInterfaceHierarchy() 
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ISubTimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);

            ISubTimeStampedIntroduction ts = MockRepository.GenerateMock<ISubTimeStampedIntroduction>();
			ts.Stub(x => x.TimeStamp).Return(EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			// we must add introduction, not an advisor
			factory.AddIntroduction(advisor);

			object proxy = factory.GetProxy();
			ISubTimeStamped tsp = (ISubTimeStamped) proxy;
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
		}
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:17,代码来源:DelegatingIntroductionInterceptorTests.cs


示例13: testIntroductionInterceptorWithDelegation

		public void testIntroductionInterceptorWithDelegation()
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ITimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);
	
			IDynamicMock tsControl = new DynamicMock(typeof(ITimeStampedIntroduction));
			ITimeStampedIntroduction ts = (ITimeStampedIntroduction) tsControl.Object;
			tsControl.ExpectAndReturn("TimeStamp", EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			factory.AddIntroduction(advisor);

			ITimeStamped tsp = (ITimeStamped) factory.GetProxy();
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
	
			tsControl.Verify();
		}
开发者ID:fuadm,项目名称:spring-net,代码行数:18,代码来源:DelegatingIntroductionInterceptorTests.cs


示例14: IntegrationTest

        public void IntegrationTest()
        {
            ProxyFactory pf = new ProxyFactory(new TestTarget());

            ILog log = (ILog)mocks.CreateMock(typeof(ILog));
            SimpleLoggingAdvice loggingAdvice = new SimpleLoggingAdvice(log);
            pf.AddAdvice(loggingAdvice);

            Expect.Call(log.IsTraceEnabled).Return(true).Repeat.Any();
            log.Trace("Entering DoSomething");
            log.Trace("Exiting DoSomething");

            mocks.ReplayAll();

            object proxy = pf.GetProxy();
            ITestTarget ptt = (ITestTarget)proxy;
            ptt.DoSomething();

            mocks.VerifyAll();
        }
开发者ID:spring-projects,项目名称:spring-net,代码行数:20,代码来源:SimpleLoggingAdviceTests.cs


示例15: Matches

		public void Matches()
		{
			SerializablePerson target = new SerializablePerson();
			target.SetAge(27);
			ControlFlowPointcut cflow = new ControlFlowPointcut(typeof(One), "GetAge");
			ProxyFactory factory = new ProxyFactory(target);
			NopInterceptor nop = new NopInterceptor();
			IPerson proxied = (IPerson) factory.GetProxy();
			factory.AddAdvisor(new DefaultPointcutAdvisor(cflow, nop));

			// not advised, not under One...
			Assert.AreEqual(target.GetAge(), proxied.GetAge());
			Assert.AreEqual(0, nop.Count, "Whoops, appear to be advising when not under One's cflow.");

			// will be advised...
			One one = new One();
			Assert.AreEqual(27, one.GetAge(proxied));
			Assert.AreEqual(1, nop.Count, "Not advising when under One's cflow (must be).");

			// won't be advised...
			Assert.AreEqual(target.GetAge(), new One().NoMatch(proxied));
			Assert.AreEqual(1, nop.Count, "Whoops, appear to be advising when under One's cflow scope, BUT NOT under a target method's cflow scope.");
			Assert.AreEqual(3, cflow.EvaluationCount, "Pointcut not invoked the correct number of times.");
		}
开发者ID:fgq841103,项目名称:spring-net,代码行数:24,代码来源:ControlFlowPointcutTests.cs


示例16: GetsAllInterfaces

        public void GetsAllInterfaces()
        {
            // Extend to get new interface
            TestObjectSubclass raw = new TestObjectSubclass();
            ProxyFactory factory = new ProxyFactory(raw);
            Assert.AreEqual(8, factory.Interfaces.Length, "Found correct number of interfaces");
            //System.out.println("Proxied interfaces are " + StringUtils.arrayToDelimitedString(factory.getProxiedInterfaces(), ","));
            ITestObject tb = (ITestObject)factory.GetProxy();
            Assert.IsTrue(tb is IOther, "Picked up secondary interface");

            raw.Age = 25;
            Assert.IsTrue(tb.Age == raw.Age);

            DateTime t = new DateTime(2004, 8, 1);
            TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor(t);

            Console.WriteLine(StringUtils.ArrayToDelimitedString(factory.Interfaces, "/"));

            //factory.addAdvisor(0, new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped)));
            factory.AddIntroduction(
                new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped))
                );

            Console.WriteLine(StringUtils.ArrayToDelimitedString(factory.Interfaces, "/"));

            ITimeStamped ts = (ITimeStamped)factory.GetProxy();
            Assert.IsTrue(ts.TimeStamp == t);
            // Shouldn't fail;
            ((IOther)ts).Absquatulate();
        }
开发者ID:smnbss,项目名称:spring-net,代码行数:30,代码来源:ProxyFactoryTests.cs


示例17: TestAutomaticInterfaceRecognitionInDelegate

		public void TestAutomaticInterfaceRecognitionInDelegate() 
		{
			IIntroductionAdvisor ia = new DefaultIntroductionAdvisor(new Test(EXPECTED_TIMESTAMP));
		
			TestObject target = new TestObject();
			ProxyFactory pf = new ProxyFactory(target);
			pf.AddIntroduction(0, ia);

			ITimeStamped ts = (ITimeStamped) pf.GetProxy();
		
			Assert.IsTrue(ts.TimeStamp == EXPECTED_TIMESTAMP);
			((ITest) ts).Foo();
		
			int age = ((ITestObject) ts).Age;
		}
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:15,代码来源:DelegatingIntroductionInterceptorTests.cs


示例18: TryRemoveNonProxiedInterface

 public void TryRemoveNonProxiedInterface()
 {
     ProxyFactory factory = new ProxyFactory(new TestObject());
     Assert.IsFalse(factory.RemoveInterface(typeof(IServiceProvider)));
 }
开发者ID:smnbss,项目名称:spring-net,代码行数:5,代码来源:ProxyFactoryTests.cs


示例19: ReplaceAdvisor

 public void ReplaceAdvisor()
 {
     TestObject target = new TestObject();
     ProxyFactory pf = new ProxyFactory(target);
     NopInterceptor nop = new NopInterceptor();
     CountingBeforeAdvice cba1 = new CountingBeforeAdvice();
     CountingBeforeAdvice cba2 = new CountingBeforeAdvice();
     IAdvisor advisor1 = new DefaultPointcutAdvisor(cba1);
     IAdvisor advisor2 = new DefaultPointcutAdvisor(cba2);
     pf.AddAdvisor(advisor1);
     pf.AddAdvice(nop);
     ITestObject proxied = (ITestObject)pf.GetProxy();
     // Use the type cast feature
     // Replace etc methods on advised should be same as on ProxyFactory
     IAdvised advised = (IAdvised)proxied;
     proxied.Age = 5;
     Assert.AreEqual(1, cba1.GetCalls());
     Assert.AreEqual(0, cba2.GetCalls());
     Assert.AreEqual(1, nop.Count);
     Assert.IsFalse(advised.ReplaceAdvisor(null, null));
     Assert.IsFalse(advised.ReplaceAdvisor(null, advisor2));
     Assert.IsFalse(advised.ReplaceAdvisor(advisor1, null));
     Assert.IsTrue(advised.ReplaceAdvisor(advisor1, advisor2));
     Assert.AreEqual(advisor2, pf.Advisors[0]);
     Assert.AreEqual(5, proxied.Age);
     Assert.AreEqual(1, cba1.GetCalls());
     Assert.AreEqual(2, nop.Count);
     Assert.AreEqual(1, cba2.GetCalls());
     Assert.IsFalse(pf.ReplaceAdvisor(new DefaultPointcutAdvisor(null), advisor1));
 }
开发者ID:smnbss,项目名称:spring-net,代码行数:30,代码来源:ProxyFactoryTests.cs


示例20: RemoveProxiedInterface

 public void RemoveProxiedInterface()
 {
     ProxyFactory factory = new ProxyFactory(new TestObject());
     Assert.IsTrue(factory.RemoveInterface(typeof(ITestObject)));
 }
开发者ID:smnbss,项目名称:spring-net,代码行数:5,代码来源:ProxyFactoryTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Support.XmlApplicationContext类代码示例发布时间:2022-05-26
下一篇:
C# SpreadsheetUtilities.Formula类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap