本文整理汇总了C#中Watcher类的典型用法代码示例。如果您正苦于以下问题:C# Watcher类的具体用法?C# Watcher怎么用?C# Watcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Watcher类属于命名空间,在下文中一共展示了Watcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStart
protected override void OnStart(string[] args)
{
try
{
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
var configuration = Settings.LoadSettings();
watcher = new Watcher(configuration);
watcher.Start();
log.Info("FileSystemWatcher started");
poster = new AutoPoster(configuration);
poster.Start();
log.Info("Autoposter started");
notifier = new IndexerNotifier(configuration);
notifier.Start();
log.Info("Notifier started");
verifier = new IndexerVerifier(configuration);
verifier.Start();
log.Info("Verifier started");
}
catch (Exception ex)
{
log.Fatal("Fatal exception when starting the autoposter.", ex);
throw;
}
}
示例2: Main
static void Main(string[] args)
{
var watcher = new Watcher(@"d:\Учеба\3 сем. Assembler, AutoCad, C#, MatLab\C#\Lab_3.Shabanski\",
@"d:\Учеба\3 сем. Assembler, AutoCad, C#, MatLab\C#\Lab_3.Shabanski\out_file.txt");
watcher.Start();
var faculty = TestCreateFaculty("Faculty of Computer Systems and Networks");
foreach (var group in faculty)
Console.WriteLine(group.ToString());
using (var file = new FileStream(@"d:\Учеба\3 сем. Assembler, AutoCad, C#, MatLab\C#\Lab_3.Shabanski\data.bin", FileMode.OpenOrCreate))
{
using(var file_deflate = new DeflateStream(file, CompressionMode.Compress))
{
faculty.SaveBinaryToStream(file_deflate);
}
}
Console.ReadKey();
Faculty f1;
using (var file = new FileStream(@"d:\Учеба\3 сем. Assembler, AutoCad, C#, MatLab\C#\Lab_3.Shabanski\data.bin", FileMode.OpenOrCreate))
{
using (var file_deflate = new DeflateStream(file, CompressionMode.Decompress))
{
f1 = Faculty.LoadBinaryFromStream(file_deflate);
}
}
foreach (var group in faculty)
Console.WriteLine(group.ToString());
Console.ReadKey();
watcher.Stop();
}
示例3: Create
public static int Create(ManagedDirectory info)
{
var gen = new Watcher(info);
gen.Index = __watchers.Count;
__watchers.Add(gen);
return gen.Index;
}
示例4: OnMouseUp
public void OnMouseUp()
{
GUI_TextureFactory.PaintPercentBar( tex, rand * 100 );
Process p;
p = PDelay( .5f );
p.Enqueue( PDelay( .5f ) )
.Enqueue( PDelay( .1f ) )
.Enqueue( PDelay( .1f ) )
.Enqueue( PDelay( .1f ) )
.Enqueue( PDelay( .1f ) )
.Enqueue( PDelay( .1f ) )
.Enqueue( PDelay( .1f ) )
.Enqueue( PDelay( .1f ) )
.Enqueue( PDelay( .1f ) ).Enqueue( PDelay( 50 ) ).Attach( PDelay( .25f ) );
pm.Add( p );
Watcher<ProcessBook.Wait> w = new Watcher<ProcessBook.Wait>();
w.eventWillStart += delegate( Process p1 ) {
Process p2 = PDelay( 50 );
p2.Attach( PDelay( 50 ) ).Attach( PDelay( 50 ) ).Attach( PDelay( 50 ) );
p2.Enqueue( PDelay( 50 ) ).Enqueue( PDelay( 50 ) ).Enqueue( PDelay( 50 ) );
pm.OvertakeAdd( p2, p1 );
Debug.LogWarning( "BAZINGA! >> " + p1 );
};
pm.Add( w );
}
示例5: ShouldWriteInitialTail
public void ShouldWriteInitialTail()
{
const int LogFileLineCount = 9;
var filePath = logFile9;
using (var watcher = new Watcher())
{
string[] writtenLines;
using (var stringWriter = new StringWriter())
{
var writer = new LineTextWriter(stringWriter);
watcher.LineWriter = writer;
watcher.DirectoryPath = Path.GetDirectoryName(filePath);
watcher.Filter = Path.GetFileName(filePath);
watcher.LineCount = 4;
watcher.Start();
writer.Flush();
Thread.Sleep(200);
writtenLines = stringWriter.ToString().ToLines();
}
writtenLines.ForEach(i => Debug.WriteLine(i));
var expectedLines = CreateLineListWithFileMarker(
TestData.LoadLines(logFile9,
LogFileLineCount - watcher.LineCount,
watcher.LineCount));
CompareLines(expectedLines.ToArray(), writtenLines);
}
}
示例6: FileSystemWatcherService
public FileSystemWatcherService(string path)
{
// This call is required by the Windows.Forms Component Designer.
InitializeComponent();
_builder = new StringBuilder();
_writer = new StringWriter(_builder);
_fileSystemWatcher = new Watcher(path, "", _writer);
}
示例7: Game
public Game() {
manager = new Manager();
watcher = new Watcher(manager);
instance = new Instance();
save = new Save();
env = new Environments();
env.GUID = Guid.NewGuid();
}
示例8: BaseZkTest
protected BaseZkTest(string zkConnectionString,
int sessionTimeout,
Watcher watcher,
bool readOnly)
{
ZkConnectionString = zkConnectionString;
Zookeeper = new ZooKeeper(zkConnectionString, sessionTimeout, watcher, readOnly);
}
示例9: Main
public static void Main(string[] args)
{
var arguments = new List<string>();
arguments.AddRange(args);
var configuration = GetConfigurationFromArguments(arguments);
if(configuration.Help)
return;
if (arguments.Count == 0)
{
WriteHelp();
return;
}
var inputFile = new FileInfo(arguments[0]);
if (!inputFile.Exists && inputFile.Extension != ".less" && !inputFile.FullName.EndsWith(".less.css"))
inputFile = new FileInfo(inputFile.FullName + ".less");
string outputFilePath;
if (arguments.Count > 1)
{
outputFilePath = arguments[1] + (Path.HasExtension(arguments[1]) ? "" : ".css");
outputFilePath = Path.GetFullPath(outputFilePath);
}
else if (inputFile.FullName.EndsWith(".less.css"))
outputFilePath = inputFile.Name.Substring(0, inputFile.Name.Length - 9) + ".css";
else
outputFilePath = Path.ChangeExtension(inputFile.Name, ".css");
var currentDir = Directory.GetCurrentDirectory();
if (inputFile.Directory != null)
Directory.SetCurrentDirectory(inputFile.Directory.FullName);
var engine = new EngineFactory(configuration).GetEngine();
Func<IEnumerable<string>> compilationDelegate = () => Compile(engine, inputFile.Name, outputFilePath);
var files = compilationDelegate();
if (configuration.Watch)
{
WriteAbortInstructions();
var watcher = new Watcher(files, compilationDelegate);
while (Console.ReadLine() != "")
{
WriteAbortInstructions();
}
watcher.RemoveWatchers();
}
Directory.SetCurrentDirectory(currentDir);
}
示例10: HandleHolder
internal HandleHolder(ZookeeperFactory zookeeperFactory, Watcher watcher, EnsembleProvider ensembleProvider,
int sessionTimeout, bool canBeReadOnly)
{
this.zookeeperFactory = zookeeperFactory;
this.watcher = watcher;
this.ensembleProvider = ensembleProvider;
this.sessionTimeout = sessionTimeout;
this.canBeReadOnly = canBeReadOnly;
}
示例11: Main
static void Main(string[] args)
{
try
{
var configuration = Settings.LoadSettings();
Watcher watcher = new Watcher(configuration);
watcher.Start();
log.Info("FileSystemWatcher started");
Console.WriteLine("FileSystemWatcher started");
AutoPoster poster = new AutoPoster(configuration);
poster.Start();
log.Info("Autoposter started");
Console.WriteLine("Autoposter started");
IndexerNotifier notifier = new IndexerNotifier(configuration);
notifier.Start();
log.Info("Notifier started");
Console.WriteLine("Notifier started");
IndexerVerifier verifier = new IndexerVerifier(configuration);
verifier.Start();
log.Info("Verifier started");
Console.WriteLine("Verifier started");
Console.WriteLine("Press the \"s\" key to stop after the current operations have finished.");
Boolean stop = false;
while (!stop)
{
var keyInfo = Console.ReadKey();
stop = keyInfo.KeyChar == 's' || keyInfo.KeyChar == 'S';
}
watcher.Stop();
log.Info("FileSystemWatcher stopped");
Console.WriteLine("FileSystemWatcher stopped");
verifier.Stop();
log.Info("Verifier stopped");
Console.WriteLine("Verifier stopped");
notifier.Stop();
log.Info("Notifier stopped");
Console.WriteLine("Notifier stopped");
poster.Stop();
log.Info("Autoposter stopped");
Console.WriteLine("Autoposter stopped");
}
catch(Exception ex)
{
log.Fatal("Fatal exception when starting the autoposter.", ex);
throw;
}
}
示例12: WatcherApplicationContext
public WatcherApplicationContext()
{
InitializeContext();
_watcher = new Watcher()
{
EventTriggered = WatcherTriggered
};
_watcher.Start();
}
示例13: CreateWatcherWithOptions
private static Watcher CreateWatcherWithOptions(Options options)
{
var watcher = new Watcher();
watcher.DirectoryPath = options.DirectoryPath ?? Environment.CurrentDirectory;
watcher.Filter = options.Filter ?? "*.log";
watcher.LineWriter = CreateWriter(options);
return watcher;
}
示例14: BootStrapper
public BootStrapper( DaemonConfiguration configuration, IBus bus, Watcher minionWatcher )
{
Configuration = configuration.BootStrapConfiguration;
Bus = bus;
MinionWatcher = minionWatcher;
bus.AddLocalChannel( x => x
.CorrelateBy<NewApplication>( m => m.DirectoryPath )
.CorrelateBy<ApplicationChanged>( m => m.DirectoryPath )
.CorrelateBy<ApplicationDeleted>( m => m.DirectoryPath ) );
}
示例15: start
private void start()
{
_watcher = new Watcher(
_watchPath,
(dir) => WatcherChangeHandler(ChangeType.DirectoryCreated, dir),
(dir) => WatcherChangeHandler(ChangeType.DirectoryDeleted, dir),
(file) => WatcherChangeHandler(ChangeType.FileCreated, file),
(file) => WatcherChangeHandler(ChangeType.FileChanged, file),
(file) => WatcherChangeHandler(ChangeType.FileDeleted, file));
_watcher.Watch();
}