Beispiel #1
0
 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);
        }
Beispiel #3
0
 public static T Receive(NameTypes pipeType)
 {
     using (var nps = new NamedPipeServerStream(pipeType.ToString(), PipeDirection.In))
     {
         return(Receive(nps));
     }
 }
Beispiel #4
0
 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);
     }
 }
Beispiel #5
0
 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;
 }
Beispiel #6
0
 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;
     }
 }
Beispiel #7
0
        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)));
        }