static void Main(string[] args) { Car myCar = new Car(); ICreateCar iCrCar = (ICreateCar)myCar; Console.WriteLine("Напишите имя: "); iCrCar.SetPetName(Console.ReadLine()); }
// GET: Home public HomeController(IUpdateCar updateCar, IGetCarByPlateNumber getCarByPlateNumber, IGetCarById getCarByIdCommand, ICreateCar createCarCommand, IBrandService brandService, IModelService modelService, IEngineService engineService, IOwnerService ownerService, IGetAllCars getAllCarsQuery) { _context = new CarHistoryContext(); _getCarByPlateNumber = getCarByPlateNumber; _createCarCommand = createCarCommand; _brandService = brandService; _modelService = modelService; _engineService = engineService; _ownerService = ownerService; _getCarByIdCommand = getCarByIdCommand; _getAllCarsQuery = getAllCarsQuery; _updateCar = updateCar; }
static void Main() { Car myCar = new Car(); ICreateCar iCreateCar = (ICreateCar)myCar; IStats iStats = (IStats)myCar; // Set car name Console.WriteLine("Напишите имя: "); iCreateCar.SetCarName(Console.ReadLine()); // Get car name string carName = string.Empty; iStats.GetCarName(carName); Console.WriteLine(carName); }
static void Main(string[] args) { object Res = 1; int a = 0; Car myCar = new Car(); //Type type = typeof(Car); ICreateCar iCrCar = (ICreateCar)myCar; IStats iStCar = (IStats)myCar; //Console.WriteLine("Напишите имя: "); //iCrCar.SetPetName(Console.ReadLine()); //IStats iStCar = (IStats)myCar; //string st = ""; //iStCar.GetPetName(ref st); //Console.WriteLine(st); iCrCar.SetPetName("Lolipop"); iCrCar.SetMaxSpeed(67); IDispatch disp = (IDispatch)myCar; iStCar.DisplayStats(); disp.GetTypeInfoCount(out a); Console.WriteLine(a.ToString()); int[] t = new int[1]; Guid guid = new Guid(); disp.GetIDsOfNames(ref guid, new string[] { "GetMaxSpeed" }, 1, 1, t); Console.WriteLine("Max speed " + t[0].ToString()); var arg = 51; var pVariant = Marshal.AllocCoTaskMem(16); Marshal.GetNativeVariantForObject(arg, pVariant); System.Runtime.InteropServices.ComTypes.DISPPARAMS par = new System.Runtime.InteropServices.ComTypes.DISPPARAMS() { cArgs = 1, cNamedArgs = 0, rgdispidNamedArgs = IntPtr.Zero, rgvarg = pVariant }; System.Runtime.InteropServices.ComTypes.INVOKEKIND flags = new System.Runtime.InteropServices.ComTypes.INVOKEKIND(); IntPtr info = new IntPtr(); IntPtr puArgErr = new IntPtr(); disp.Invoke(4, guid, 1, flags, par, out Res, info, puArgErr); disp.Invoke(1, guid, 1, flags, par, out Res, info, puArgErr); Console.WriteLine("Res = " + Res.ToString()); var arg_6 = ""; Marshal.GetNativeVariantForObject(arg_6, pVariant); System.Runtime.InteropServices.ComTypes.DISPPARAMS par_6 = new System.Runtime.InteropServices.ComTypes.DISPPARAMS() { cArgs = 1, cNamedArgs = 0, rgdispidNamedArgs = IntPtr.Zero, rgvarg = pVariant }; System.Runtime.InteropServices.ComTypes.INVOKEKIND flags_6 = new System.Runtime.InteropServices.ComTypes.INVOKEKIND(); disp.Invoke(6, guid, 1, flags_6, par_6, out Res, info, puArgErr); Console.WriteLine("Res = " + Res.ToString()); Console.ReadKey(); }