I saw examples of this where the interface is provided by the factory, and it generates objects that implement the interface. It is not so difficult for me, but I do not understand how it can be used to implement behavior.
Take ChannelFactory in WCF, for example ... when you create a channel from an interface, it provides methods (from the interface) that invoke remote procedures when called. It seems that I have a small gap in my knowledge of how this can be done. This is probably the general design pattern, but I decided that I would use SO again as an extension of the study.
. . System.Reflection.Emit.
, Type , , , , TypeBuilder, , ( / return default (T)), MethodBuilder .., .
Mocking frameworks, , , . () . , , .
:
Mock<IRepository> repMock = new Mock<IRepository>(); repMock.Setup(r => r.FindById(1)).Returns(new MyObject());
, IRepository FindByID, Setup "" . Reflection.Emit, IL .
IRepository
FindByID
Setup
Reflection.Emit
Source: https://habr.com/ru/post/1762949/More articles:.NET Async TcpListener / TcpClient Question - multithreadingNetbeans Platform application installer - netbeans-platformHow can I archive the proc file system? - linuxIs there a way to make the application always start working with Activity1 after using the "Home" button? - javaHow to force the application pool to recycle in classic ASP (without using the IIS management console)? - asp-classicHow to handle multiple accounts using OAuth? - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1762951/add-fields-to-user-register&usg=ALkJrhhuc4nrDqGNQOd9bFwjqp4RIArI0gIs there a Java equivalent for a pointer to a C ++ function? - javaПередача состояния между страницами при использовании geb & spock - grailsSourcecollection count - 0 newitemholderholder is not displayed - wpfAll Articles