http://bugzilla.novell.com/show_bug.cgi?id=520397

User j...@jammm.eu.org added comment
http://bugzilla.novell.com/show_bug.cgi?id=520397#c4


My Name <j...@jammm.eu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |j...@jammm.eu.org
           Platform|x86-64                      |All
         Resolution|FIXED                       |




--- Comment #4 from My Name <j...@jammm.eu.org>  2009-09-22 12:06:16 MDT ---
hi,
it seams the bug is not fixed yet (in the mono-2-4 branch, revision 142326).

The System.Web.Compilation.TemplateControlCompiler in the Method
AssignPropertyFromResources(ControlBuilder, MemberInfo, string) returns after
invokation of ResourceProviderHasObject(string). This method returns false
because the DefaultResouceProvider which is used by the
HttpContext.GetResourceProvider method does not implement the ResourceReader
Property (returns null).
So the TemplateControlCompiler does not generate Code for accessing the local
resource

possible solution:

dont call the ResourceProviderHasObject method or implement the ResourceReader
property

we have chosen the first approach:

1.
removed line 897-898 of TemplateControlCompiler.cs (ResourceProviderHasObject)

2.
removed lines 920-925 of TemplateControlCompiler.cs (code generation)

3.
added the following code:

Type memberType = null;

if (isProperty)    
    memberType = ((PropertyInfo)mi).PropertyType;  
else if (isField)
    memberType = ((FieldInfo)mi).FieldType;

CodeVariableDeclarationStatement declaration = new
CodeVariableDeclarationStatement();
declaration.Name = "localizedText";
declaration.Type = new CodeTypeReference(typeof(object)); /* Could it be
something else than a string? */
declaration.InitExpression =
ResourceExpressionBuilder.CreateGetLocalResourceObject(mi, resname);

CodeBinaryOperatorExpression expression = new CodeBinaryOperatorExpression();
expression.Operator = CodeBinaryOperatorType.IdentityInequality;
expression.Left = new CodeVariableReferenceExpression("localizedText");
expression.Right = new CodePrimitiveExpression(null);

CodeAssignStatement assign = new CodeAssignStatement();
assign.Left = new CodePropertyReferenceExpression(null, "ctrlVar.memberName");
assign.Left = new CodePropertyReferenceExpression(ctrlVar, memberName);
assign.Right = new CodeCastExpression(memberType, new
CodeVariableReferenceExpression("localizedText"));

CodeConditionStatement condition = new CodeConditionStatement(
    expression,
    assign
);   

builder.Method.Statements.Add (AddLinePragma (declaration, builder));
builder.Method.Statements.Add (AddLinePragma (condition, builder));

this generates code like:

object localizedText =
System.Convert.ToString(this.GetLocalResourceObject("resname.Property"),
System.Globalization.CultureInfo.CurrentCulture);
if ((localizedText != null)) {
    __ctrl.Text = ((string)(localizedText));
}

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
_______________________________________________
mono-bugs maillist  -  mono-bugs@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to