//Client Code static void Main_11(string[] args) { ConcreteVehicleFactory factoryMethod = new ConcreteVehicleFactory(); IDrive vehicle = factoryMethod.GetVehicleKm(VehicleType.Car); vehicle.Drive(); }
/// <summary> /// 发送数据时,引发 SendingData 事件。 /// </summary> /// <param name="drive">发送数据的驱动对象</param> /// <param name="sendData">发送的数据</param> protected internal void OnSendingData(IDrive drive, byte[] sendData) { if (this.SendingData != null) { this.SendingData(drive, sendData); } }
public LiveStub(LiveVirtualFileSystem fileSystem) { _fileSystem = fileSystem; _actualDrive = fileSystem.Drive; _actualDirectory = fileSystem.Directory; _actualFile = fileSystem.File; }
/// <summary> /// 接收数据时,引发 ReceivingData 事件。 /// </summary> /// <param name="drive">收到数据的驱动对象</param> /// <param name="receiveData">收到的数据</param> protected internal void OnReceivingData(IDrive drive, byte[] receiveData) { if (this.ReceivingData != null) { this.ReceivingData(drive, receiveData); } }
///<summary> /// Sets up a directory structure as follows: /// C:\ /// |---FileInRoot1 ("an entry") /// |---FileInRoot2 ("a long entry in a file") /// |---subDir1 /// | |---File1InDir1 (empty) /// | |---File2InDir1 (empty) /// |---subdir2 /// </summary> public void CreateTestFileStructure() { drive = new Drive("C"); rootDir = drive.RootDirectory; fileInRoot1 = new File("FileInRoot1", "an entry"); rootDir.Add(fileInRoot1); fileInRoot2 = new File("FileInRoot2", "a long entry in a file"); rootDir.Add(fileInRoot2); subDir1 = new Directory("subDir1"); rootDir.Add(subDir1); file1InDir1 = new File("File1InDir1", ""); subDir1.Add(file1InDir1); file2InDir1 = new File("File2InDir1", ""); subDir1.Add(file2InDir1); subDir2 = new Directory("subDir2"); rootDir.Add(subDir2); commandInvoker = new CommandInvoker(); testOutput = new TestOutput(); numbersOfDirectoriesBeforeTest = drive.RootDirectory.GetNumberOfContainedDirectories(); numbersOfFilesBeforeTest = drive.RootDirectory.GetNumberOfContainedFiles(); }
void OnDriveChanged(object sender, object NewValue) { IDrive newDrive = driveList.Find(NewValue as string); schedule.DriveChanged(drive, newDrive, time, position); drive = newDrive; }
private void RefreshDriveEntries(IDrive drive, TreeNode node, DataGridView grid, bool forceRefresh) { var driveEntryKey = node.Name.Split('|')[0]; if (!_driveEntryCache.ContainsKey(driveEntryKey) || forceRefresh) { var driveEntries = drive.GetDriveEntries(driveEntryKey); if (driveEntries == null) { grid.DataSource = null; return; } _driveEntryCache[driveEntryKey] = driveEntries; } grid.DataSource = _driveEntryCache[driveEntryKey].ToList(); if (node.FirstNode == null || !String.IsNullOrEmpty(node.FirstNode.Name)) { return; } node.Nodes.Clear(); foreach (var newNode in _driveEntryCache[driveEntryKey] .Where(entry => entry.Type == DriveEntryType.Directory) .Select(directory => node.Nodes.Add(directory.Key, directory.Name))) { newNode.Nodes.Add(Resources.LoadingText); } }
public void Drive(IDrive c) { c.Accelerate(); c.Start(); c.ChangeGear(); c.Breake(); }
static void traverse_drive(IDrive d, int levels) { var folders = d.folders.ToList(); // level 1 dump_folders_and_files(folders, d.files, 0); for (int i = 1; i < levels; ++i) { var child_folders = new List <IFolder>(); var child_files = new List <IFile>(); foreach (var f in folders) { try { child_folders.AddRange(f.child_folders); } catch (Exception e) { // could be unauthorized access Console.WriteLine(new string(' ', i * 2) + f.full_path + " *** UNAUTHORIZED folders " + e); } try { child_files.AddRange(f.files); } catch { // could be unauthorized access Console.WriteLine(new string(' ', i * 2) + f.full_path + " *** UNAUTHORIZED files"); } } dump_folders_and_files(child_folders, child_files, i); folders = child_folders; } }
/// <summary> /// takes current state/pose, new sensors data, odometry and everything else - and evaluates new state and pose /// </summary> /// <param name="behaviorData"></param> public void EvaluatePoseAndState(IBehaviorData behaviorData, IDrive driveController) { // consider compass or AHRS reading for determining direction: if(behaviorData.sensorsData.CompassHeadingDegrees != null) { behaviorData.robotPose.direction.heading = behaviorData.sensorsData.CompassHeadingDegrees; } // use GPS data to update position: if (behaviorData.sensorsData.GpsFixType != GpsFixTypes.None) { behaviorData.robotPose.geoPosition.Lat = behaviorData.sensorsData.GpsLatitude; behaviorData.robotPose.geoPosition.Lng = behaviorData.sensorsData.GpsLongitude; } // utilize odometry data: if (driveController.hardwareBrickOdometry != null) { // already calculated odometry comes from the hardware brick (i.e. Arduino) IOdometry odom = driveController.hardwareBrickOdometry; behaviorData.robotPose.XMeters = odom.XMeters; behaviorData.robotPose.YMeters = odom.YMeters; behaviorData.robotPose.ThetaRadians = odom.ThetaRadians; } else { // we have wheels encoders data and must calculate odometry here: long[] encoderTicks = new long[] { behaviorData.sensorsData.WheelEncoderLeftTicks, behaviorData.sensorsData.WheelEncoderRightTicks }; driveController.OdometryCompute(behaviorData.robotPose, encoderTicks); } }
static void ShowDriverCredentials(IDrive driver) { Console.WriteLine($"My license is from {driver.StateLicense}"); Console.WriteLine($"i am at least {driver.MinAge}"); Console.WriteLine("==============================="); Console.WriteLine(); }
public string Drive(IDrive person) { // starting a car is the responsibility of // a Person, so that method is on the Person class person.StartCar(); return("i drove"); }
/// <summary> /// Parse the folder in the drive /// </summary> /// <param name="drive">Drive to parse</param> /// <param name="path">Path to parse</param> /// <returns></returns> public IFolder ParseFolder(IDrive drive, string path) { //string folder_or_file; //SplitIntoDriveAndFolderPath(path, out drive_str, out folder_or_file); return(drive.ParseFolder(path)); }
static void Main(string[] args) { GLib.GType.Init(); VolumeMonitor monitor = VolumeMonitor.Default; Console.WriteLine("Volumes:"); foreach (IVolume v in monitor.Volumes) { Console.WriteLine("\t{0}", v.Name); } Console.WriteLine("\nMounts:"); foreach (IMount m in monitor.Mounts) { Console.WriteLine("\tName:{0}, UUID:{1}, root:{2}, CanUnmount: {3}", m.Name, m.Uuid, m.Root, m.CanUnmount); IVolume v = m.Volume; if (v != null) { Console.WriteLine("\t\tVolume:{0}", v.Name); } IDrive d = m.Drive; if (d != null) { Console.WriteLine("\t\tDrive:{0}", d.Name); } } Console.WriteLine("\nConnectedDrives:"); foreach (IDrive d in monitor.ConnectedDrives) { Console.WriteLine("\t{0}, HasVolumes:{1}", d.Name, d.HasVolumes); } }
static void InterfaceExample() { Clown clown = new Clown(); Scary scary = new Scary(); IDrive driver = scary; DriveExample(scary); }
public TestCommand(string cmdName, IDrive drive) : base(cmdName, drive) { this.CheckNumberOfParametersReturnValue = true; this.CheckParameterValuesReturnValue = true; this.Executed = false; this.NumberOfPassedParameters = -1; }
public virtual void SetUpBase() { drive = new Drive("C"); rootDir = drive.RootDirectory; commandInvoker = new CommandInvoker(); testOutput = new TestOutput(); }
public Product(IProducer producer, string model, double price, string processor, float screenSize, IDrive drive) { Producer = producer; Model = model; Price = price; Processor = processor; ScreenSize = screenSize; Drive = drive; }
public static Directory GetDirectory(IDrive drive, string directoryPath, string directoryName) { FileSystemItem fileSystemItem = drive.GetItemFromPath(directoryPath); Assert.IsNotNull(fileSystemItem); Assert.AreEqual(directoryName, fileSystemItem.Name); Assert.IsTrue(fileSystemItem.IsDirectory()); return((Directory)fileSystemItem); }
public static File GetFile(IDrive drive, string filePath, string fileName) { FileSystemItem fileSystemItem = drive.GetItemFromPath(filePath + "\\" + fileName); Assert.IsNotNull(fileSystemItem); Assert.AreEqual(fileName, fileSystemItem.Name); Assert.IsFalse(fileSystemItem.IsDirectory()); return((File)fileSystemItem); }
private static void ChangeCurrentDirectory(Directory destinationDirectory, IDrive drive, IOutputter outputter) { bool success = drive.ChangeCurrentDirectory(destinationDirectory); if (!success) { outputter.PrintLine(SYSTEM_CANNOT_FIND_THE_PATH_SPECIFIED); } }
public PositionProperty(Schedule schedule, DriveList driveList, IDrive drive, double time, double position) { this.driveList = driveList; this.schedule = schedule; this.drive = drive; this.position = position; this.time = time; orgDrive = drive; orgTime = time; orgPosition = position; }
internal void PositionChanged(IDrive drive, double time, double oldPosition, double newPosition) { if (drive != null) { SortedList <double, double> toModify; if (steps.TryGetValue(drive, out toModify)) { toModify[time] = newPosition; } } }
internal void TimeChanged(IDrive drive, double oldTime, double newTime, double position) { if (drive != null) { SortedList <double, double> toModify; if (steps.TryGetValue(drive, out toModify)) { toModify.Remove(oldTime); } AddPosition(drive, newTime, position); } }
public FileTransferForm(IDrive sourceDrive, StringCollection sourcePaths, IDrive targetDrive, string targetPath, bool moveMode) { InitializeComponent(); _sourceDrive = sourceDrive; _sourcePaths = sourcePaths; _targetDrive = targetDrive; _targetPath = targetPath; _moveMode = moveMode; _fileTransferQueue = new Queue <FileTransferParameters>(); _sourcePathsToDelete = new Queue <string>(); }
public FileTransferForm(IDrive sourceDrive, StringCollection sourcePaths, IDrive targetDrive, string targetPath, bool moveMode) { InitializeComponent(); _sourceDrive = sourceDrive; _sourcePaths = sourcePaths; _targetDrive = targetDrive; _targetPath = targetPath; _moveMode = moveMode; _fileTransferQueue = new Queue<FileTransferParameters>(); _sourcePathsToDelete = new Queue<string>(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); // make a call to my DB to collect ALL drivers in my system IDrive[] drivers = new IDrive[4]; Person person = new Person() { Name = "Josie", MinAge = 16, StateLicense = "WA" }; Cat cat = new Cat() { StateLicense = "CA", MinAge = 18 }; Cat kitty = new Cat() { MinAge = 13, StateLicense = "ND" }; Person person1 = new Person() { Name = "Fred", MinAge = 25, StateLicense = "AK" }; drivers[0] = person; drivers[1] = kitty; drivers[2] = cat; drivers[3] = person1; for (int i = 0; i < drivers.Length; i++) { var driver = drivers[i]; if (driver is Person) { // casting var p = (Person)driver; p.Walk(); } else if (driver is Cat) { var kat = (Cat)driver; kat.Meow(); } ShowDriverCredentials(drivers[i]); } }
static IFile get_biggest_file(IDrive d) { IFile biggest = get_biggest_file(d.files.ToList()); foreach (var child in d.folders) { var child_biggest = get_biggest_file_recursive(child); if (file_size(biggest) < file_size(child_biggest)) { biggest = child_biggest; } } return(biggest); }
static IFile GetBiggestFile(IDrive d) { IFile biggest = GetBiggestFile(d.Files.ToList()); foreach (var child in d.Folders) { var child_biggest = GetBiggestFileRecursive(child); if (FileSize(biggest) < FileSize(child_biggest)) { biggest = child_biggest; } } return(biggest); }
static void DisplayLastFile() { Console.WriteLine("\r\n----------------------------------------"); if (CheckDrivers() == false) { return; } short index = InputDriveIndex(); IDrive drive = portable_drives[index]; Console.WriteLine("Please enter the name of the folder [" + imageFolder + "]:"); string str = Console.ReadLine(); if (str != "") { imageFolder = str; } IFolder dest = null; //迭代查找目录 foreach (IFolder folder in drive.Folders) { dest = FindFolder(folder, imageFolder); if (dest != null) { break; } } if (dest != null) { FindLastFileInFolder(dest); if (lastFile != null) { Console.WriteLine("The last file : " + lastFile.FullPath + "\t" + lastFile.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss:sss") + "\n"); } else { Console.WriteLine("#Maybe, no files in the folder."); } } else { Console.WriteLine("\n ## The folder [" + imageFolder + "] not found !"); } }
public CommandFactory(IDrive drive) { commands = new List <DosCommand> { new CmdDir("dir", drive), new CmdCd("cd", drive), new CmdCd("chdir", drive), new CmdMkDir("mkdir", drive), new CmdMkDir("md", drive), new CmdMkFile("mf", drive), new CmdMkFile("mkfile", drive) // Add your commands here }; }
internal void DriveChanged(IDrive oldDrive, IDrive newDrive, double time, double position) { if (oldDrive != null) { SortedList <double, double> toModify; if (steps.TryGetValue(oldDrive, out toModify)) { toModify.Remove(time); } } if (newDrive != null) { AddPosition(newDrive, time, position); } }
public CommanderViewModel() { LeftPanel = new GDriveDirectory(); RightPanel = new WPDirectory(); }
private void InitDrive() { IDifferentialMotorController dmc = hardwareBrick.produceDifferentialMotorController(); driveController = new DifferentialDrive(hardwareBrick) { wheelRadiusMeters = WHEEL_RADIUS_METERS, wheelBaseMeters = WHEEL_BASE_METERS, encoderTicksPerRevolution = ENCODER_TICKS_PER_REVOLUTION, speedToVelocityFactor = SPEED_TO_VELOCITY_FACTOR, turnToOmegaFactor = TURN_TO_OMEGA_FACTOR, differentialMotorController = dmc }; this.odometry = hardwareBrick.produceOdometry(ODOMETRY_SAMPLING_INTERVAL_MS); this.odometry.OdometryChanged += ((SensorsControllerPlucky)sensorsController).ArduinoBrickOdometryChanged; this.gps = hardwareBrick.produceGps(GPS_SAMPLING_INTERVAL_MS); this.gps.GpsPositionChanged += ((SensorsControllerPlucky)sensorsController).ArduinoBrickGpsChanged; this.gps.Enabled = true; driveController.hardwareBrickOdometry = odometry; driveGeometry = (IDifferentialDrive)driveController; driveController.Init(); driveController.Enabled = true; }
public GioDriveMetadataSource(IDrive drive) { Drive = drive; }
private async Task refreshListing(IDrive panelModel) { //try //{ panelModel.FileCollection.Clear(); var listing = await panelModel.GetListingAsync(); //it will still block current thead which is UI thread var sortedListing = from i in listing orderby i.IsDirectory descending, i.Title ascending select i; foreach (var item in sortedListing) panelModel.FileCollection.Add(item); //} //catch (Exception e) //{ // await ShowAlert(e); //} }
private void InitDrive() { IDifferentialMotorController dmc = produceDifferentialMotorController(); IDifferentialDrive ddc = new DifferentialDrive(hardwareBrick) { wheelRadiusMeters = WHEEL_RADIUS_METERS, wheelBaseMeters = WHEEL_BASE_METERS, encoderTicksPerRevolution = ENCODER_TICKS_PER_REVOLUTION, speedToVelocityFactor = SPEED_TO_VELOCITY_FACTOR, turnToOmegaFactor = TURN_TO_OMEGA_FACTOR, differentialMotorController = dmc }; driveController = ddc; driveGeometry = ddc; driveController.Init(); }
private void RefreshDriveEntries(IDrive drive, TreeNode node, DataGridView grid, bool forceRefresh) { var driveEntryKey = node.Name.Split('|')[0]; if (!_driveEntryCache.ContainsKey(driveEntryKey) || forceRefresh) { var driveEntries = drive.GetDriveEntries(driveEntryKey); if (driveEntries == null) { grid.DataSource = null; return; } _driveEntryCache[driveEntryKey] = driveEntries; } grid.DataSource = _driveEntryCache[driveEntryKey].ToList(); if (node.FirstNode == null || !String.IsNullOrEmpty(node.FirstNode.Name)) return; node.Nodes.Clear(); foreach (var newNode in _driveEntryCache[driveEntryKey] .Where(entry => entry.Type == DriveEntryType.Directory) .Select(directory => node.Nodes.Add(directory.Key, directory.Name))) { newNode.Nodes.Add(Resources.LoadingText); } }
private int PercentUsedOf(IDrive drive) { return (drive.Size <= 0 || drive.Used <= 0) ? 0 : (int)Math.Round((drive.Used / (float)drive.Size) * 100); }