usingSystem;namespaceconsoleapplication4{classProgram {/// <summary> ///situations where the appearance mode is not used///at this point the client and three subsystems are sent a coupling, so that the client program depends on the subsystem///to solve this problem, we can use the appearance pattern to design a unified interface for all subsystems .///The client only needs to invoke the method in the skin class, which simplifies the operation of the client///So that tight coupling between the customer and the subsystem is avoided/// </summary> /// <param name= "args" ></param> Static voidMain (string[] args) {Subsystema a=NewSubsystema (); Subsystemb b=NewSubsystemb (); SUBSYSTEMC C=NewSUBSYSTEMC (); A.methoda (); B.methodb (); C.METHODC (); Console.read (); } } //subsystem a Public classSubsystema { Public voidMethodA () {Console.WriteLine ("method A in the execution subsystem a"); } } //Subsystem B Public classSubsystemb { Public voidMethodB () {Console.WriteLine ("Execute method B in subsystem b"); } } //Subsystem C Public classSUBSYSTEMC { Public voidmethodc () {Console.WriteLine ("method C in the execution subsystem C"); } }}
usingSystem;namespaceconsoleapplication4{classProgram {Private StaticRegistrationfacade facade =NewRegistrationfacade (); /// <summary> ///situations where the appearance mode is not used///at this point the client and three subsystems are sent a coupling, so that the client program depends on the subsystem///to solve this problem, we can use the appearance pattern to design a unified interface for all subsystems .///The client only needs to invoke the method in the skin class, which simplifies the operation of the client///So that tight coupling between the customer and the subsystem is avoided/// </summary> /// <param name= "args" ></param> Static voidMain (string[] args) {facade. Registersystem (1); Façade. Registersystem (2); Façade. Registersystem (3); Console.read (); } } Public classRegistrationfacade {PrivateSubsystema Registrationa; PrivateSubsystemb registrationb; PrivateSUBSYSTEMC Registrationc; PublicRegistrationfacade () {Registrationa=NewSubsystema (); REGISTRATIONB=NewSubsystemb (); Registrationc=NewSUBSYSTEMC (); } Public voidRegistersystem (inttype) { if(Type = =1) {Registrationa.methoda (); } Else if(Type = =2) {Registrationb.methodb (); } Else if(Type = =3) {registrationc.methodc (); } } } //subsystem a Public classSubsystema { Public voidMethodA () {Console.WriteLine ("method A in the execution subsystem a"); } } //Subsystem B Public classSubsystemb { Public voidMethodB () {Console.WriteLine ("Execute method B in subsystem b"); } } //Subsystem C Public classSUBSYSTEMC { Public voidmethodc () {Console.WriteLine ("method C in the execution subsystem C"); } }}
11. Appearance mode (facade pattern)