コード例 #1
0
 public static IThreadSafeProxyFactory CreateThreadSafeProxyFactory(
     IThreadSafeInterceptorFactory threadSafeInterceptorFactory, IProxyGenerator proxyGenerator)
 {
     return new ThreadSafeProxyFactory(
         threadSafeInterceptorFactory,
         proxyGenerator);
 }
コード例 #2
0
 public FakeObjectCreator(IProxyGenerator proxyGenerator, IExceptionThrower thrower, IFakeManagerAccessor fakeManagerAttacher, IFakeObjectConfigurator configurer)
 {
     this.proxyGenerator = proxyGenerator;
     this.thrower = thrower;
     this.fakeManagerAttacher = fakeManagerAttacher;
     this.configurer = configurer;
 }
コード例 #3
0
ファイル: DynamicGenerator.cs プロジェクト: kumait/HXF.net
 public DynamicGenerator(Type type)
 {
     if (!typeof(IProxyGenerator).IsAssignableFrom(type))
     {
         throw new Exception();
     }
     this.generator = (IProxyGenerator)Activator.CreateInstance(type);
 }
コード例 #4
0
		public int Execute(TextWriter error, params string[] args )
		{
			var generatorOptions = new ProxyGeneratorOptions();
			if (Parser.ParseHelp(args))
			{
				Parser.ParseArguments(args, generatorOptions);
			}
			else if (Parser.ParseArguments(args, generatorOptions) == false)
			{
				error.WriteLine(Parser.ArgumentsUsage(generatorOptions.GetType()));
				return Error.InvalidArguments;
			}

			if (ProxyGenerator == null)
			{
				try
				{
					ProxyGenerator = CreateProxyGenerator(generatorOptions.Generator);
				}
				catch (Exception exc)
				{
					error.WriteLine(exc.Message);
					return Error.CreateProxyGenerator;
				}
			}

			generatorOptions = ProxyGenerator.GetOptions();
			if( generatorOptions == null )
			{
				error.WriteLine("{0}.GetOptions() returned null.  Please use a different Generator.", ProxyGenerator.GetType().FullName);
				return Error.InvalidGenerator;
			}

			if (Parser.ParseHelp(args))
			{
				error.WriteLine(Parser.ArgumentsUsage(generatorOptions.GetType()));
				return Error.None;
			}
			if (Parser.ParseArguments(args, generatorOptions) == false)
			{
				error.WriteLine(Parser.ArgumentsUsage(generatorOptions.GetType()));
				return Error.InvalidArguments;
			}

			try
			{
				ProxyGenerator.Generate(generatorOptions);
			}
			catch (Exception exc)
			{
				error.WriteLine(exc.Message);
				error.WriteLine(exc.StackTrace);
				return Error.Unknown;				
			}

			return Error.None;
		}
コード例 #5
0
        public void SetUp()
        {
            _error = new StringWriter();
            _mocks = new MockRepository();

            _generator = _mocks.DynamicMock<IProxyGenerator>();
            SetupResult.For(_generator.GetOptions())
                .Return(new ProxyGeneratorOptions());

            _program = new Program();
            _program.ProxyGenerator = _generator;
        }
コード例 #6
0
		public void Setup()
		{
			_proxyGenerator = CreateProxyGenerator();
			_engine			= new ScriptEngine();
			//create fake implementations of $.isFunction and $.extend
			_engine.Execute(@"var jQuery = { 
				isFunction: function() {}, 
				extend: function() {
					for(var i=1; i<arguments.length; i++)
						for(var key in arguments[i])
							if(arguments[i].hasOwnProperty(key))
								arguments[0][key] = arguments[i][key];
					return arguments[0]; 
				}
			};");
			_engine.Execute(_proxyGenerator.GenerateProxyScript());
		}
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MongoSessionFactory"/> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="mongo">The mongo.</param>
        public MongoSessionFactory(string databaseName, IMappingStore mappingStore, IMongoFactory mongoFactory, IProxyGenerator proxyGenerator)
        {
            if (string.IsNullOrEmpty(databaseName))
                throw new ArgumentException("Cannot be null or empty.", "databaseName");
            if (mappingStore == null)
                throw new ArgumentNullException("mappingStore");
            if (mongoFactory == null)
                throw new ArgumentNullException("mongoFactory");
            if (proxyGenerator == null)
                throw new ArgumentNullException("proxyGenerator");

            this.databaseName = databaseName;
            this.initialized = false;
            this.initializationObject = new object();
            this.mappingStore = mappingStore;
            this.mongoFactory = mongoFactory;
            this.proxyGenerator = proxyGenerator;
        }
コード例 #8
0
        public void GetStub_returns_object_instance([SingletonGenerator] IProxyGenerator generator)
        {
            var sut = new StubFactory(generator, () => new StubInterceptor());

            Assert.That(() => sut.GetStub <IServiceInterface>(), Is.Not.Null);
        }
コード例 #9
0
        public void GetStub_does_not_throw_when_executing_a_void_method([SingletonGenerator] IProxyGenerator generator)
        {
            var sut = new StubFactory(generator, () => new StubInterceptor());

            Assert.That(() => sut.GetStub <IServiceInterface>()?.DoTheThing(), Throws.Nothing);
        }
コード例 #10
0
        public ReflectionSerializersFacade([CanBeNull] ITypesCatalog typesCatalog = null, [CanBeNull] IScalarSerializers scalarSerializers = null, [CanBeNull] ReflectionSerializersFactory reflectionSerializers = null, [CanBeNull] IProxyGenerator proxyGenerator = null, [CanBeNull] ReflectionRdActivator activator = null, [CanBeNull] TypesRegistrar registrar = null, bool allowSave = false)
        {
            TypesCatalog       = typesCatalog ?? new SimpleTypesCatalog();
            ScalarSerializers  = scalarSerializers ?? new ScalarSerializer(TypesCatalog);
            SerializersFactory = reflectionSerializers ?? new ReflectionSerializersFactory(TypesCatalog, ScalarSerializers);

            ProxyGenerator = proxyGenerator ?? new ProxyGeneratorCache(new ProxyGenerator(ScalarSerializers, allowSave));
            Activator      = activator ?? new ReflectionRdActivator(SerializersFactory, ProxyGenerator, TypesCatalog);
            Registrar      = registrar ?? new TypesRegistrar(TypesCatalog, SerializersFactory);
        }
コード例 #11
0
 public virtual void SetUp()
 {
     _generator = CreateGenerator();
     _outputAssemblyPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NHibernate.ProxyGenerators.Test.Proxies.dll");
 }
コード例 #12
0
        public void Setup()
        {
            this.proxyGenerator = A.Fake<IProxyGenerator>();

            this.interceptionAsserter = new DefaultInterceptionAsserter(this.proxyGenerator);
        }
コード例 #13
0
 public ReflectionRdActivator([NotNull] ReflectionSerializersFactory serializersFactory, [NotNull] IProxyGenerator proxyGenerator, [CanBeNull] ITypesCatalog typesCatalog)
 {
     mySerializersFactory = serializersFactory;
     myTypesCatalog       = typesCatalog;
     myProxyGenerator     = proxyGenerator;
 }
コード例 #14
0
 public HomeController(IProxyGenerator generator, IFibonacciEvaluator fibonacciEvaluator, IInterceptor interceptor)
 {
     this._fibonacciEvaluator = generator.CreateInterfaceProxyWithTarget(fibonacciEvaluator, interceptor);
 }
コード例 #15
0
 public static TService CreateInterfaceProxy <TService, TImplementation>(this IProxyGenerator proxyGenerator, params object[] args)
     where TService : class
     where TImplementation : TService
 {
     return((TService)CreateInterfaceProxy(proxyGenerator, typeof(TService), typeof(TImplementation), args));
 }
コード例 #16
0
ファイル: FlowEngine.cs プロジェクト: zabavin/BlogCode
 public FlowEngine(IProxyGenerator proxyGenerator)
 {
     _proxyGenerator = proxyGenerator;
 }
コード例 #17
0
 public DataLoader()
 {
     _generator    = new ProxyGenerator();
     _repositories = new Dictionary <string, object>();
 }
コード例 #18
0
 public ContractProxyGenerator(IProxyGenerator proxyGenerator, IMethodDispatcher methodDispatcher)
 {
     _proxyGenerator   = proxyGenerator;
     _methodDispatcher = methodDispatcher;
 }
コード例 #19
0
 public DisposedProxyGenerator(IServiceResolver serviceResolver)
 {
     _serviceResolver = serviceResolver;
     _proxyGenerator  = serviceResolver.ResolveRequired <IProxyGenerator>();
 }
コード例 #20
0
 // ReSharper disable once MemberCanBePrivate.Global
 public PolicyBuilder(IProxyGenerator proxyGenerator) => this._proxyGenerator = proxyGenerator;
コード例 #21
0
 public ProxyWrapperFactory(IProxyGenerator generator)
     : this(generator, new MethodInfoEqualityComparer())
 {
 }
コード例 #22
0
ファイル: DynamicGenerator.cs プロジェクト: kumait/HXF.net
 public DynamicGenerator(IProxyGenerator generator)
 {
     this.generator = generator;
 }
コード例 #23
0
ファイル: GenOptionsDialog.cs プロジェクト: kumait/HXF.net
 private void readUI()
 {
     SelectedGenerator = ((GeneratorItem)cmbGenerator.SelectedItem).Generator;
     selectedTypeMap = ((TypeMapItem)cmbTypeMap.SelectedItem).TypeMap;
     SelectedGenerator.TypeMap = selectedTypeMap;
 }
コード例 #24
0
 public ConfigurationRouter(IProxyGenerator generator, IRoutingInterceptor interceptor)
 {
     _generator   = generator;
     _interceptor = interceptor;
 }
コード例 #25
0
        public void Setup()
        {
            this.proxyGenerator = A.Fake <IProxyGenerator>();

            this.interceptionAsserter = new DefaultInterceptionAsserter(this.proxyGenerator);
        }
コード例 #26
0
 public ProxyGeneratorSelector(DelegateProxyGenerator delegateProxyGenerator, IProxyGenerator defaultProxyGenerator)
 {
     this.delegateProxyGenerator = delegateProxyGenerator;
     this.defaultProxyGenerator  = defaultProxyGenerator;
 }
コード例 #27
0
 public DefaultInterceptionAsserter(IProxyGenerator proxyGenerator)
 {
     this.proxyGenerator = proxyGenerator;
 }
コード例 #28
0
 public DynamicServiceActorLocator(IServiceProvider serviceProvider) : base(serviceProvider)
 {
     this._provider  = serviceProvider;
     this._generator = serviceProvider.GetRequiredService <IProxyGenerator>();
 }
コード例 #29
0
        public ProxyHttpHandler(IProxyGenerator generator)
        {
            if (generator == null) throw new ArgumentNullException("generator");

            _generator = generator;
        }
コード例 #30
0
 public void Setup()
 {
     _proxyGenerator = CreateProxyGenerator();
     _engine			= new ScriptEngine();
     _engine.Execute("var jQuery = {};");
     _engine.Execute(_proxyGenerator.GenerateProxyScript());
 }
コード例 #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StubFactory"/> class.
 /// </summary>
 /// <param name="proxyGenerator">A DynamicProxy proxy generator.</param>
 /// <param name="interceptorFactory">A function which creates a DynamicProxy interceptor.</param>
 public StubFactory(IProxyGenerator proxyGenerator, Func <IInterceptor> interceptorFactory)
 {
     this.proxyGenerator     = proxyGenerator ?? throw new ArgumentNullException(nameof(proxyGenerator));
     this.interceptorFactory = interceptorFactory ?? throw new ArgumentNullException(nameof(interceptorFactory));
 }
コード例 #32
0
 public static Type CreateType <TInterface>([NotNull] this IProxyGenerator proxyGenerator) where TInterface : class
 {
     return(proxyGenerator.CreateType(typeof(TInterface)));
 }
コード例 #33
0
 public ProxyGeneratorSelectorTests()
 {
     this.delegateProxyGenerator = A.Fake <DelegateProxyGenerator>();
     this.defaultProxyGenerator  = A.Fake <IProxyGenerator>();
     this.selector = new ProxyGeneratorSelector(this.delegateProxyGenerator, this.defaultProxyGenerator);
 }
コード例 #34
0
 public InterceptorFactory(IInterceptorChainBuilder chainBuilder, IProxyGenerator proxyGenerator, IInterceptBuilder interceptBuilder)
 {
     _chainBuilder     = chainBuilder;
     _proxyGenerator   = proxyGenerator;
     _interceptBuilder = interceptBuilder;
 }
コード例 #35
0
 public ProxyGeneratorSelector(DelegateProxyGenerator delegateProxyGenerator, IProxyGenerator defaultProxyGenerator)
 {
     this.delegateProxyGenerator = delegateProxyGenerator;
     this.defaultProxyGenerator = defaultProxyGenerator;
 }
コード例 #36
0
 public virtual void SetUp()
 {
     _generator          = CreateGenerator();
     _outputAssemblyPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NHibernate.ProxyGenerators.Test.Proxies.dll");
 }
コード例 #37
0
 public DefaultInterceptionAsserter(IProxyGenerator proxyGenerator)
 {
     this.proxyGenerator = proxyGenerator;
 }
コード例 #38
0
        public DynamicClientProxy(IServiceProvider provider)
        {
            this._generator = provider.GetRequiredService <IProxyGenerator>();

            this._provider = provider;
        }
        /// <summary>
        /// Initialises a new instance of the MasterProxy that wraps an object
        /// </summary>
        /// <param name="serviceProvider">Services Collection</param>
        /// <param name="proxyGenerator">Proxy Generator instance</param>
        /// <param name="config">Proxy Configuration</param>

        public ProxyFactory(IServiceProvider serviceProvider, IProxyGenerator proxyGenerator, SimpleProxyConfiguration config)
        {
            this.proxyConfiguration = config;
            this.proxyGenerator     = proxyGenerator;
            this.serviceProvider    = serviceProvider;
        }
コード例 #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FakeObjectFactory"/> class.
 /// </summary>
 /// <param name="container">The container to use.</param>
 /// <param name="proxyGenerator">The proxy generator to use.</param>
 /// <param name="fakeObjectFactory">The fake object factory to use.</param>
 public FakeObjectFactory(IFakeObjectContainer container, IProxyGenerator proxyGenerator, FakeObject.Factory fakeObjectFactory)
 {
     this.container         = container;
     this.proxyGenerator    = proxyGenerator;
     this.fakeObjectFactory = fakeObjectFactory;
 }
コード例 #41
0
        public void GetStub_returns_which_returns_null_for_reference_type([SingletonGenerator] IProxyGenerator generator)
        {
            var sut = new StubFactory(generator, () => new StubInterceptor());

            Assert.That(() => sut.GetStub <IServiceInterface>()?.GetString(), Is.Null);
        }
コード例 #42
0
 public FakeObjectCreator(IProxyGenerator proxyGenerator, IExceptionThrower thrower, FakeCallProcessorProvider.Factory fakeCallProcessorProviderFactory)
 {
     this.proxyGenerator = proxyGenerator;
     this.thrower        = thrower;
     this.fakeCallProcessorProviderFactory = fakeCallProcessorProviderFactory;
 }
コード例 #43
0
        public void GetStub_throws_exception_for_invalid_abstract_class([SingletonGenerator] IProxyGenerator generator)
        {
            var sut = new StubFactory(generator, () => new StubInterceptor());

            Assert.That(() => sut.GetStub <AnAbstractClass>(), Throws.InstanceOf <AutoLazyException>());
        }
コード例 #44
0
 public FakeObjectCreator(IProxyGenerator proxyGenerator, IExceptionThrower thrower, FakeCallProcessorProvider.Factory fakeCallProcessorProviderFactory)
 {
     this.proxyGenerator = proxyGenerator;
     this.thrower = thrower;
     this.fakeCallProcessorProviderFactory = fakeCallProcessorProviderFactory;
 }
コード例 #45
0
 public ProxyWrapperFactory(IProxyGenerator generator,
                            IEqualityComparer <MethodInfo> compareMethodInfo)
     : this(generator, MethodInfoCacheHelper.CreateCache(compareMethodInfo))
 {
 }
コード例 #46
0
ファイル: ChartProxy.cs プロジェクト: water1st/Liquidity2
 public ChartProxy(IProxyGenerator generator, IInterceptor interceptor)
 {
     this.generator   = generator;
     this.interceptor = interceptor;
     Chart            = generator.CreateInterfaceProxyWithoutTarget <TChart>(interceptor);
 }