WebForm demo, simulating mobile phone Usb interface charging, webformdemo
MATERIALS: Mobile, MiniCharger, IUsb ),
Design Concept:
1. Declare the interaction mode between IUsb objects, including an event;
2. Mobile implements the IUsb interface, which is the key point. It is the interface implemented by the caller and needs to be delegated to the charging device through the event;
3. Mobile reflection charging device, injecting IUsb through constructor;
Code List:
1 public interface IUsb {2 decimal Voltage {get; set;} 3 event System. EventHandler Connecting; 4}IUsb. cs 1 <% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Mobile. aspx. cs" Inherits = "Mobile" %> 2 3 <! DOCTYPE html> 4 5 I just wrote a skeleton. If you are interested, you can implement several different types of Usb devices,
In addition, you can try to extend the functions of the Usb interface, such as adding the data copy function to the mobile phone,
See the different effects of connecting a laptop to a charger