private void checkField(Type type, MemberInfo member) { var field = member as FieldInfo; if (field != null) { if (field.IsPublic || field.IsAssembly || field.IsFamilyOrAssembly) { throw new InvalidOperationException("Type " + type + "'s field " + member.Name + " is public. Proxy factory " + _proxyFactory.GetType().FullName + " does not allow this."); } } }
private static void UseProxyFactory(IProxyFactory<ITrialsService> proxyFactory) { Console.WriteLine("\n\nUsing {0} as IProxyFactory.", proxyFactory.GetType().GetGenericTypeDefinition().Name); Console.Write("Enter a number: "); int parameter; while (!int.TryParse(Console.ReadLine(), out parameter)) { Console.Write("Please enter a valid integer: "); } var proxy = proxyFactory.GetProxy(); var parameters = new SomeParameters() { Parameter = parameter }; var operationStatus = proxy.Execute(ch => ch.DoSomething(parameters)); Console.WriteLine("Proxy operation result: {0}", operationStatus.Result); Console.Write("Press any key to continue..."); Console.ReadKey(); }
/// <summary> /// Verifies that there are no proxy factories attached as kernel components. /// </summary> protected virtual void VerifyNoBoundProxyFactoriesExist() { IProxyFactory existingProxyFactory = Kernel.Components.Get <IProxyFactory>(); if (existingProxyFactory != null) { StringBuilder builder = new StringBuilder(); builder.AppendFormat("The Ninject Kernel already has an implementation of IProxyFactory bound to {0}. ", existingProxyFactory.GetType().Name); builder.AppendLine(); builder.AppendLine( " Please verify that if you are using automatic extension loading that you only have one interception module."); builder.AppendLine( " If you have more than one interception module, please disable automatic extension loading by passing an INinjectSettings object into your Kernel's .ctor with"); throw new InvalidOperationException(); } }
private static void UseProxyFactory(IProxyFactory <ITrialsService> proxyFactory) { Console.WriteLine("\n\nUsing {0} as IProxyFactory.", proxyFactory.GetType().GetGenericTypeDefinition().Name); Console.Write("Enter a number: "); int parameter; while (!int.TryParse(Console.ReadLine(), out parameter)) { Console.Write("Please enter a valid integer: "); } var proxy = proxyFactory.GetProxy(); var parameters = new SomeParameters() { Parameter = parameter }; var operationStatus = proxy.Execute(ch => ch.DoSomething(parameters)); Console.WriteLine("Proxy operation result: {0}", operationStatus.Result); Console.Write("Press any key to continue..."); Console.ReadKey(); }