[asp.net] Ignore JavaScript blocks enclosed in HTML comments
[mono.git] / mcs / class / System.Web / System.Web.Compilation / ConnectionStringsExpressionBuilder.cs
index 2b8b6daa264ec337f0d3d050a897cd2cc5a7f3e6..20169411de189580e3aad9ad0a12584e4a326627 100644 (file)
@@ -28,7 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
 
 using System;
 using System.CodeDom;
@@ -54,7 +53,7 @@ namespace System.Web.Compilation {
                        Pair connString = parsedData as Pair;
                        return new CodeMethodInvokeExpression (
                                new CodeTypeReferenceExpression (typeof (ConnectionStringsExpressionBuilder)),
-                               "GetConnectionString",
+                               (bool)connString.Second ? "GetConnectionStringProviderName" : "GetConnectionString",
                                new CodeExpression [] {new CodePrimitiveExpression (connString.First)}
                        );
                }
@@ -63,7 +62,7 @@ namespace System.Web.Compilation {
                {
                        ConnectionStringSettings conn = WebConfigurationManager.ConnectionStrings [connectionStringName];
                        if (conn == null)
-                               return "";
+                               return String.Empty;
                        else
                                return conn.ConnectionString;
                }
@@ -72,14 +71,29 @@ namespace System.Web.Compilation {
                {
                        ConnectionStringSettings conn = WebConfigurationManager.ConnectionStrings [connectionStringName];
                        if (conn == null)
-                               return "";
+                               return String.Empty;
                        else
                                return conn.ProviderName;
                }
 
                public override object ParseExpression (string expression, Type propertyType, ExpressionBuilderContext context)
                {
-                       return new Pair (expression, GetConnectionString (expression));
+                       bool wantsProviderName = false;
+                       string connStringName = String.Empty;
+
+                       if (!String.IsNullOrEmpty (expression)) {
+                               int subidx = expression.Length;
+                               
+                               if (expression.EndsWith (".providername", StringComparison.InvariantCultureIgnoreCase)) {
+                                       wantsProviderName = true;
+                                       subidx -= 13;
+                               } else if (expression.EndsWith (".connectionstring", StringComparison.InvariantCultureIgnoreCase))
+                                       subidx -= 17;
+
+                               connStringName = expression.Substring (0, subidx);
+                       }
+                       
+                       return new Pair (connStringName, wantsProviderName);
                }
 
                public override bool SupportsEvaluate {
@@ -89,6 +103,6 @@ namespace System.Web.Compilation {
 
 }
 
-#endif
+