ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/xmlTools/trunk/posUpdate/ParametersParser.cs
(Generate patch)

Comparing xmlTools/trunk/posUpdate/ParametersParser.cs (file contents):
Revision 714 by s10k, Thu Mar 21 10:43:10 2013 UTC vs.
Revision 742 by s10k, Tue Mar 26 02:30:48 2013 UTC

# Line 14 | Line 14 | namespace xmlTools
14          private static string globalFileName="";
15          private static string globalElement="";
16          private static string globalParentElement="";
17 +        private static bool globalNoBackups = false;
18  
19          [Verb]
20          public static void addValue(
# Line 21 | Line 22 | namespace xmlTools
22              )
23          {
24              initialChecks();
25 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
25 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
26              List<string> filesToProcess = getFilesToProcess(globalFileName);
27              foreach (string currentFile in filesToProcess)
28              {
# Line 36 | Line 37 | namespace xmlTools
37              )
38          {
39              initialChecks();
40 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
40 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
41              List<string> filesToProcess = getFilesToProcess(globalFileName);
42              foreach (string currentFile in filesToProcess)
43              {
# Line 57 | Line 58 | namespace xmlTools
58              )
59          {
60              initialChecks();
61 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
61 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
62              List<string> filesToProcess = getFilesToProcess(globalFileName);
63              foreach (string currentFile in filesToProcess)
64              {
# Line 70 | Line 71 | namespace xmlTools
71          public static void Invert()
72          {
73              initialChecks();
74 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
74 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
75              List<string> filesToProcess = getFilesToProcess(globalFileName);
76              foreach (string currentFile in filesToProcess)
77              {
# Line 85 | Line 86 | namespace xmlTools
86              [Parameter(Required = true, Description = "New value to replace in Element.")] string newValue
87              )
88          {
89 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
89 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
90              List<string> filesToProcess = getFilesToProcess(globalFileName);
91              foreach (string currentFile in filesToProcess)
92              {
# Line 101 | Line 102 | namespace xmlTools
102              )
103          {
104              initialChecks();
105 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
105 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
106              List<string> filesToProcess = getFilesToProcess(globalFileName);
107              foreach (string currentFile in filesToProcess)
108              {
# Line 130 | Line 131 | namespace xmlTools
131  
132              if (forceInFiles != "")
133              {
134 <                myPatch = new XmlPatch(globalFileName, forceInFiles);
134 >                myPatch = new XmlPatch(globalFileName, forceInFiles, globalNoBackups);
135              }
136              else
137              {
138 <                myPatch = new XmlPatch(globalFileName);
138 >                myPatch = new XmlPatch(globalFileName, globalNoBackups);
139              }
140  
141              myPatch.startPatch();
# Line 148 | Line 149 | namespace xmlTools
149          }
150  
151          // Global Parameters
152 <        [Global]
152 >        [Global(Description = "Filename to apply the operations (with patchFile specifies the patch filename). Wildcards accepted for multiple files. No filename = search all .xml files in current path.")]
153          public static void fileName(
154 <             [Parameter(Required = true, Description = "Filename to apply the operations (with patchFile specifies the patch filename). Wildcards accepted for multiple files. No filename = search all .xml files in current path.")] string filename // xml filename. Wildcards accepted.
154 >             [Parameter(Required = true)] string filename // xml filename. Wildcards accepted.
155              )
156          {
157              globalFileName = filename;
158          }
159  
160 <        [Global]
160 >        [Global(Description = "Element to apply the operation.")]
161          public static void element(
162 <             [Parameter(Required = true, Description = "Element to apply the operation.")] string element
162 >             [Parameter(Required = true)] string element
163              )
164          {
165              globalElement = element;
166          }
167  
168 <        [Global]
168 >        [Global(Description = "Parent of the Element to apply the operation.")]
169          public static void parElement(
170 <             [Parameter(Required = true, Description = "Parent of the Element to apply the operation.")] string parentElement
170 >             [Parameter(Required = true)] string parentElement
171              )
172          {
173              globalParentElement = parentElement;
174          }
175  
176 <        //[PreVerbExecution]
177 <        //private static void InitialChecks(PreVerbExecutionContext context)
178 <        //{
179 <        //    bool elementFound = false;
180 <        //    foreach(ParameterAndValue param in context.Parameters){
180 <        //        if (param.Parameter.Names[0] == "element")
181 <        //        {
182 <        //            if(!String.IsNullOrEmpty(param.Value.ToString().Trim())){
183 <        //                elementFound = true;
184 <        //            }
185 <        //            break;
186 <        //        }
187 <        //    }
188 <        //    if (!elementFound)
189 <        //    {
190 <        //        Console.Error.WriteLine("You must specify the element parameter where the operations will be processed.");
191 <        //        Console.ReadLine();
192 <        //        System.Environment.Exit(1);
193 <        //    }
194 <        //}
176 >        [Global(Description = "Don't make backup of the files modified. Improves the overall program processing performance.")]
177 >        public static void noBackups()
178 >        {
179 >            globalNoBackups = true;
180 >        }
181  
182          // Private functions
183          private static List<String> getFilesToProcess(String filename)

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)