/// <summary> /// <para>Метод класса и Интерфейсный метод имеют разные записи в таблице методов</para> /// <para>И указывают на РАЗНЫЕ реализации</para> /// </summary> private static void Example2() { var m2 = new MyClass2(); m2.MyMethod(); // output: MyClass2 implementation of IMyInterface IMyInterface i2 = m2; i2.MyMethod(); // output: MyClass2 EXPLICIT implementation of IMyInterface }
/// <summary> /// Метод класса и Интерфейсный метод имеют разные записи в таблице методов, но указывают на одну реализацию /// </summary> private static void Example1() { var m1 = new MyClass1(); m1.MyMethod(); // output: MyClass1 implementation of IMyInterface IMyInterface i1 = m1; i1.MyMethod(); // output: MyClass1 implementation of IMyInterface }
static void Main(string[] args) { ITypeConfig typeConfig = Core.FindOrCreateTypeConfig <IMyInterface, WrapperInterface>("MyGeneratedClass"); typeConfig.SetMemberMap(nameof(WrapperInterface.TheClass), nameof(MyClass.MyInt), nameof(IMyInterface.TheInt)); typeConfig.SetMemberMap(nameof(WrapperInterface.TheClass), nameof(MyClass.MyStr), nameof(IMyInterface.TheStr)); typeConfig.ConfigurationCompleted(); IMyInterface myInterfaceObj = Core.GetInstanceOfGeneratedType <IMyInterface>(typeConfig.ClassName); myInterfaceObj.TheInt = 1234; myInterfaceObj.TheStr = "Hello"; myInterfaceObj.MyMethod("blabla", 123); }
public IActionResult GetMyMethodValue() { ServiceEventSource.Current.ServiceMessage(cxt, "Retrieving MyMethod's value"); return(Ok(myField.MyMethod())); }
static int DoWork <T>(IMyInterface <T> a) => a.MyMethod();