public ActionResult ProcessSelectShop(FormCollection collection)
        {
            var name = collection["name"];
            var shopid = collection["shopid"].TryTo(0);
            var ischeck = collection["ischeck"].TryTo(false);
            var all = collection["all"];

            var r = new Dictionary<int, string>();
            if (!all.IsEmpty())
            {
                r = all.Deserialize<Dictionary<int, string>>();
            }

            if (ischeck && !r.ContainsKey(shopid))
            {
                r.Add(shopid, name);
            }

            if (!ischeck)
            {
                r.Remove(shopid);
            }
            return Content(r.Serialize());
        }
Example #2
0
 public void SerializeTest()
 {
     Dictionary<string, string> dict = new Dictionary<string, string>();
     dict["asd"] = "dsa";
     string str = dict.Serialize();
     string str_inline = dict.SerializeInline();
     byte[] bytes = dict.SerializeAsBytes();
     str.Deserialize<Dictionary<string, string>>();
     bytes.Deserialize<Dictionary<string, string>>();
 }
 private TestProcess StartProcess(string executable, Dictionary<string, string> args, Action<int, string, Action<string>, Action> onMessage)
 {
     var process = new Process
     {
         StartInfo = new ProcessStartInfo(string.Format(@"{0}\{1}.{0}.exe", executable, TestGroup))
         {
             UseShellExecute = false,
             RedirectStandardOutput = true,
             CreateNoWindow = true,
             RedirectStandardInput = true,
             Arguments = args != null ? args.Serialize() : ""
         }
     };
     ManualResetEventSlim doneEvent = new ManualResetEventSlim(false);
     process.OutputDataReceived += (sender, eventArgs) =>
     {
         Trace.WriteLine(executable + ": " + eventArgs.Data);
         onMessage(process.Id, eventArgs.Data,
             response =>
             {
                 process.StandardInput.WriteLine(response);
                 process.StandardInput.Flush();
             },
             () => doneEvent.Set()
             );
     };
     process.Start();
     process.BeginOutputReadLine();
     return new TestProcess(process, doneEvent);
 }