2 using System.Collections.Generic;
12 static void Main (string [] args) {
13 string file = args [0];
14 string mode = args [1];
15 XElement config = XElement.Load(file,LoadOptions.PreserveWhitespace);
17 XElement appSettings = config.Element("appSettings");
18 if (appSettings == null) {
19 appSettings = new XElement ("appSettings");
20 config.Add (appSettings);
22 var results = from el in appSettings.Elements ()
23 where el.Attribute ("key").Value == "onlyClients"
26 if (results.Count() == 1)
27 onlyClients = results.First ();
28 else if (results.Count() == 0) {
29 onlyClients = new XElement ("add");
30 onlyClients.SetAttributeValue ("key", "onlyClients");
31 appSettings.Add (onlyClients);
34 throw new Exception ("Too many onlyClients appSettings clauses");
36 onlyClients.SetAttributeValue("value","true");
37 else if (mode == "inproc")
38 onlyClients.SetAttributeValue ("value", "false");
40 throw new Exception ("Unrecognized mode: " + mode);
42 config.Save (file,SaveOptions.DisableFormatting);
43 Console.WriteLine ("Successfully switched to mode : " + mode);