Author: mhutch
Date: 2007-09-05 07:43:45 -0400 (Wed, 05 Sep 2007)
New Revision: 85350

Modified:
   trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs
Log:
* MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs:
  Add support for displaying the CodeDom autogeneration notice
  (useful for designer-maintained partial classes).

Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog        2007-09-05 
11:42:20 UTC (rev 85349)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog        2007-09-05 
11:43:45 UTC (rev 85350)
@@ -1,3 +1,9 @@
+2007-09-05  Michael Hutchinson <[EMAIL PROTECTED]> 
+
+       * MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs: 
Add
+         support for displaying the CodeDom autogeneration notice (useful for
+         designer-maintained partial classes).
+
 2007-09-04  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
 
        * MonoDevelop.Ide.Gui.Pads/NodeState.cs: Option values must be loaded as

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs
      2007-09-05 11:42:20 UTC (rev 85349)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs
      2007-09-05 11:43:45 UTC (rev 85350)
@@ -50,6 +50,7 @@
                string content;
                CodeDomProvider parserProvider;
                string tempSubstitutedContent;
+               bool showAutogenerationNotice = false;
                
                public override void Load (XmlElement filenode)
                {
@@ -60,6 +61,15 @@
                        if ((sourceLang == null) || (sourceLang.Length == 0))
                                sourceLang = "C#";
                        
+                       string showAutogen = filenode.GetAttribute 
("ShowAutogenerationNotice");
+                       if ((showAutogen != null) && (showAutogen.Length > 0)) {
+                               try {
+                                       showAutogenerationNotice = bool.Parse 
(showAutogen.ToLower());
+                               } catch (FormatException) {
+                                       throw new InvalidOperationException 
("Invalid value for ShowAutogenerationNotice in template.");
+                               }
+                       }
+                       
                        parserProvider = getProvider (sourceLang);
                }
                
@@ -94,11 +104,14 @@
                        options.IndentString = "\t";
                        options.BracingStyle = "C";
                        
-                       StringWriter sw = new StringWriter ();
-                       provider.GenerateCodeFromCompileUnit (ccu, sw, options);
-                       string txt = sw.ToString ();
-                       sw.Close ();
+                       string txt = string.Empty;
+                       using (StringWriter sw = new StringWriter ()) {
+                               provider.GenerateCodeFromCompileUnit (ccu, sw, 
options);
+                               txt = sw.ToString ();
+                       }
                        
+                       if (showAutogenerationNotice) return txt;
+                       
                        //remove auto-generation notice
                        int i = txt.IndexOf ("</autogenerated>");
                        if (i == -1) return txt;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to