public static IThreadSafeProxyFactory CreateThreadSafeProxyFactory( IThreadSafeInterceptorFactory threadSafeInterceptorFactory, IProxyGenerator proxyGenerator) { return new ThreadSafeProxyFactory( threadSafeInterceptorFactory, proxyGenerator); }
public FakeObjectCreator(IProxyGenerator proxyGenerator, IExceptionThrower thrower, IFakeManagerAccessor fakeManagerAttacher, IFakeObjectConfigurator configurer) { this.proxyGenerator = proxyGenerator; this.thrower = thrower; this.fakeManagerAttacher = fakeManagerAttacher; this.configurer = configurer; }
public DynamicGenerator(Type type) { if (!typeof(IProxyGenerator).IsAssignableFrom(type)) { throw new Exception(); } this.generator = (IProxyGenerator)Activator.CreateInstance(type); }
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; }
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; }
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()); }
/// <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; }
public void GetStub_returns_object_instance([SingletonGenerator] IProxyGenerator generator) { var sut = new StubFactory(generator, () => new StubInterceptor()); Assert.That(() => sut.GetStub <IServiceInterface>(), Is.Not.Null); }
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); }
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); }
public virtual void SetUp() { _generator = CreateGenerator(); _outputAssemblyPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NHibernate.ProxyGenerators.Test.Proxies.dll"); }
public void Setup() { this.proxyGenerator = A.Fake<IProxyGenerator>(); this.interceptionAsserter = new DefaultInterceptionAsserter(this.proxyGenerator); }
public ReflectionRdActivator([NotNull] ReflectionSerializersFactory serializersFactory, [NotNull] IProxyGenerator proxyGenerator, [CanBeNull] ITypesCatalog typesCatalog) { mySerializersFactory = serializersFactory; myTypesCatalog = typesCatalog; myProxyGenerator = proxyGenerator; }
public HomeController(IProxyGenerator generator, IFibonacciEvaluator fibonacciEvaluator, IInterceptor interceptor) { this._fibonacciEvaluator = generator.CreateInterfaceProxyWithTarget(fibonacciEvaluator, interceptor); }
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)); }
public FlowEngine(IProxyGenerator proxyGenerator) { _proxyGenerator = proxyGenerator; }
public DataLoader() { _generator = new ProxyGenerator(); _repositories = new Dictionary <string, object>(); }
public ContractProxyGenerator(IProxyGenerator proxyGenerator, IMethodDispatcher methodDispatcher) { _proxyGenerator = proxyGenerator; _methodDispatcher = methodDispatcher; }
public DisposedProxyGenerator(IServiceResolver serviceResolver) { _serviceResolver = serviceResolver; _proxyGenerator = serviceResolver.ResolveRequired <IProxyGenerator>(); }
// ReSharper disable once MemberCanBePrivate.Global public PolicyBuilder(IProxyGenerator proxyGenerator) => this._proxyGenerator = proxyGenerator;
public ProxyWrapperFactory(IProxyGenerator generator) : this(generator, new MethodInfoEqualityComparer()) { }
public DynamicGenerator(IProxyGenerator generator) { this.generator = generator; }
private void readUI() { SelectedGenerator = ((GeneratorItem)cmbGenerator.SelectedItem).Generator; selectedTypeMap = ((TypeMapItem)cmbTypeMap.SelectedItem).TypeMap; SelectedGenerator.TypeMap = selectedTypeMap; }
public ConfigurationRouter(IProxyGenerator generator, IRoutingInterceptor interceptor) { _generator = generator; _interceptor = interceptor; }
public void Setup() { this.proxyGenerator = A.Fake <IProxyGenerator>(); this.interceptionAsserter = new DefaultInterceptionAsserter(this.proxyGenerator); }
public ProxyGeneratorSelector(DelegateProxyGenerator delegateProxyGenerator, IProxyGenerator defaultProxyGenerator) { this.delegateProxyGenerator = delegateProxyGenerator; this.defaultProxyGenerator = defaultProxyGenerator; }
public DefaultInterceptionAsserter(IProxyGenerator proxyGenerator) { this.proxyGenerator = proxyGenerator; }
public DynamicServiceActorLocator(IServiceProvider serviceProvider) : base(serviceProvider) { this._provider = serviceProvider; this._generator = serviceProvider.GetRequiredService <IProxyGenerator>(); }
public ProxyHttpHandler(IProxyGenerator generator) { if (generator == null) throw new ArgumentNullException("generator"); _generator = generator; }
public void Setup() { _proxyGenerator = CreateProxyGenerator(); _engine = new ScriptEngine(); _engine.Execute("var jQuery = {};"); _engine.Execute(_proxyGenerator.GenerateProxyScript()); }
/// <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)); }
public static Type CreateType <TInterface>([NotNull] this IProxyGenerator proxyGenerator) where TInterface : class { return(proxyGenerator.CreateType(typeof(TInterface))); }
public ProxyGeneratorSelectorTests() { this.delegateProxyGenerator = A.Fake <DelegateProxyGenerator>(); this.defaultProxyGenerator = A.Fake <IProxyGenerator>(); this.selector = new ProxyGeneratorSelector(this.delegateProxyGenerator, this.defaultProxyGenerator); }
public InterceptorFactory(IInterceptorChainBuilder chainBuilder, IProxyGenerator proxyGenerator, IInterceptBuilder interceptBuilder) { _chainBuilder = chainBuilder; _proxyGenerator = proxyGenerator; _interceptBuilder = interceptBuilder; }
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; }
/// <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; }
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); }
public FakeObjectCreator(IProxyGenerator proxyGenerator, IExceptionThrower thrower, FakeCallProcessorProvider.Factory fakeCallProcessorProviderFactory) { this.proxyGenerator = proxyGenerator; this.thrower = thrower; this.fakeCallProcessorProviderFactory = fakeCallProcessorProviderFactory; }
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>()); }
public ProxyWrapperFactory(IProxyGenerator generator, IEqualityComparer <MethodInfo> compareMethodInfo) : this(generator, MethodInfoCacheHelper.CreateCache(compareMethodInfo)) { }
public ChartProxy(IProxyGenerator generator, IInterceptor interceptor) { this.generator = generator; this.interceptor = interceptor; Chart = generator.CreateInterfaceProxyWithoutTarget <TChart>(interceptor); }