public void show(InterfaceA interfaceA) { Console.WriteLine("我要调用属性注入"); ProperA.showA(); Console.WriteLine("我是函数注入"); interfaceA.showA(); }
/// <summary> /// 通过autofac 注入,自定扩展的实例 /// </summary> /// <param name="interface1"></param> /// <param name="interface2"></param> /// <param name="interface3"></param> public AutofacController(Interface1 interface1, Interface2 interface2, Interface3 interface3, InterfaceA interfaceA) { interface1.Show();//通过配置文件注入的实例 this._Interface1 = interface1; this._Interface2 = interface2; this._Interface3 = interface3; this._interfaceA = interfaceA; }
public ThirdController(ILogger <ThirdController> logger, IConfiguration configuration, InterfaceA interfaceA, InterfaceB interfaceB, InterfaceC interfaceC) { _logger = logger; _configuration = configuration; _interfaceA = interfaceA; _interfaceB = interfaceB; _interfaceC = interfaceC; }
public void M3(InterfaceA b) { bool t = true; bool f = false; // should not exhibit flow b.CallSinkIfTrue(new object(), f); b.CallSinkIfFalse(new object(), t); b.LocalCallSensitivity(new object(), f); // should exhibit flow b.CallSinkIfTrue(new object(), t); b.CallSinkIfFalse(new object(), f); b.LocalCallSensitivity(new object(), t); }
public void Start() { Context context = Context.Create() .RegisterTypeAsMultiple <MultipleInterfaceDependency>(typeof(InterfaceA), typeof(InterfaceB)) .RegisterType <Recipient>() .CreateAll(); context.EventManager.DispatchEvent(new Event()); InterfaceA dependency = context.Resolve <InterfaceA>(); Assert.True(dependency.AlreadyNotified, "multi-interface dependency received event"); context.Destroy(); }
// 7.运行期使用“合并”方式修改对象行为 Mixin public static void Main27(string[] args) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); ProxyGenerator generator = new ProxyGenerator(); var options = new ProxyGenerationOptions(); options.AddMixinInstance(new ClassA()); ClassB objB = generator.CreateClassProxy <ClassB>(options, new CallingLogInterceptor()); objB.ActionB(); InterfaceA objA = objB as InterfaceA; objA.ActionA(); Console.Read(); }
public static void Main() { MyClass myClass = new MyClass(); Console.WriteLine("Calling myClass.MethodA()"); myClass.MethodA(); InterfaceB mySteerable = myClass as InterfaceB; Console.WriteLine("Calling mySteerable.MethodA()"); mySteerable.MethodA(); ((InterfaceB)myClass).MethodA(); InterfaceA myDrivable = myClass as InterfaceA; Console.WriteLine("Calling myDrivable.MethodA()"); myDrivable.MethodA(); ((InterfaceA)myClass).MethodA(); }
public Recipient(InterfaceA a, InterfaceB b) { Assert.Equals(a, b, "multiple type dependency"); }
public ClassB(InterfaceA a) { this.A = a; }
//Dependencies Inject,using constructor. public MyClass(InterfaceA a) { ComponentA = a; }
public ClassC(InterfaceA a, ClassB b) { }
public ClassB(InterfaceA a) { Argument.IsNotNull(() => a); }
public ClassB(InterfaceA instance_a) { class_a = instance_a; Time = DateTime.Now.ToString(); }
public static void PrintCounterA(InterfaceA a) { System.Console.Out.WriteLine(a.Counter); }
public ClassB(InterfaceA interfaceA) { interfaceA.showA(); }
public ServiceB(InterfaceA interfaceA) { @interface = interfaceA; }
public ClassC(InterfaceA a, ClassB b) { }
public ClassB(InterfaceA a) { this.A = a; }
//public ImpB(InterfaceA interfaceA, InterfaceC interfaceC) //{ // _interfaceA = interfaceA; // _interfaceC = interfaceC; //} public ImpB(InterfaceA interfaceA) { _interfaceA = interfaceA; }
static public void DoSomething(InterfaceA <BaseClass> nterfaceA) { }
public DerivedB(InterfaceA original) { var1 = original.var1; var2 = original.var2; }