/// <summary> /// Constructor takes a file communicator object. If the file in question is already /// being watched, this is ignored. Otherwise, the file is watched by a system file watcher /// object. /// </summary> /// <param name="comms">File CommunicatorModel</param> public FlatFileHandler(FileCommunicator comms) { if (PathsBeingWatched.Contains(@comms.FilePath)) { DebugOutput.Print("Already watching for updates on file at ", comms.FilePath); } else if (comms.Inbound) { DebugOutput.Print("Attempting to create new connection to file at ", comms.FilePath); Communicator = comms; StartFileWatcher(); } }
/// <summary> /// Constructor takes a file communicator object. /// </summary> /// <param name="comms">File Communicator Model</param> public FlatFileHandler(FileCommunicator comms, Rule rule, Value val) { //Set the Communicator object. _communicator = comms; //Configure the local File Path variables. _filePath = comms.FilePath; //Give access to the value. _value = val; //Output the data required - any instance of [val] is replaced with the actual value StringBuilder builder = new StringBuilder(rule.Action.OutputValue); builder.Replace("[val]", _value.StringValue); //Output the string OutputValue(builder.ToString()); }