public NamedPipe(NameTypes pipeType) { _disposed = false; _started = false; _pipeName = pipeType.ToString(); _thread = new Thread(Main); _thread.SetApartmentState(ApartmentState.STA); _thread.Name = "NamePipe: " + pipeType.ToString() + " Thread"; _thread.IsBackground = true; }
private Ranks GetRanks(NameTypes tp) { var votes = Location.EnumerateFiles(string.Format("*.{0}.xml", tp.ToString().ToLowerInvariant())); var vetos = Location.EnumerateFiles(string.Format("*.{0}.vetos.txt", tp.ToString().ToLowerInvariant())); var ranks = new Ranks( Names.FromDirectory(Location, tp).Distinct(), votes.SelectMany(file => Votes.Load(file)), vetos.SelectMany(file => Vetos.Load(file))) { NameType = tp }; ranks.Recalculate(); return(ranks); }
public static T Receive(NameTypes pipeType) { using (var nps = new NamedPipeServerStream(pipeType.ToString(), PipeDirection.In)) { return(Receive(nps)); } }
public static void Send(NameTypes pipeType, T t) { using (var npc = new NamedPipeClientStream(".", pipeType.ToString(), PipeDirection.Out)) { var bf = new BinaryFormatter(); npc.Connect(); bf.Serialize(npc, t); } }
public NamedPipe(NameTypes pipeType) { disposed = false; started = false; pipeName = pipeType.ToString(); thread = new Thread(Main); thread.SetApartmentState(ApartmentState.STA); thread.Name = $"NamePipe: {pipeType} Thread"; thread.IsBackground = true; }
public static void Send(NameTypes pipeType, T t) { try { using (var npc = new NamedPipeClientStream(".", pipeType.ToString(), PipeDirection.Out)) { var bf = new BinaryFormatter(); npc.Connect(); bf.Serialize(npc, t); } } catch (UnauthorizedAccessException) { throw; } }
public static FileInfo GetFile(DirectoryInfo root, NameTypes tp, string id) { var fileName = string.Format("{0}.{1}.vetos.txt", id, tp.ToString().ToLowerInvariant()); return(new FileInfo(Path.Combine(root.FullName, fileName))); }