I am producing some HTML content for the share charm in WinRT. So I need to precompile the cshtml to .cs in my WinRT project. I'm not entirely clear over the entire process that needs to be used here, but as I understand it I need to install
the RazorGenerator visual studio extension. Unfortunately I can only install that into visual studio 2010?
How do I get it installed into visual studio 2011, so that I can select a custom tool of RazorGenerator?
Secondly RazorGenerator.Templating isn't able to be installed in a WinRT project. So I decompiled the class and I can build that class, but there are some changes required in the write function. It should look like this:
public void Write(object value)
{
if (value == null)
return;
#if NETFX_CORE
MethodInfo method = null;
var methods = value.GetType().GetTypeInfo().GetDeclaredMethods("ToString");
if (methods != null)
{
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.GetParameters().Count() == 1 && methodInfo.GetParameters()[0].ParameterType == typeof (IFormatProvider))
{
method = methodInfo;
}
}
}
#else
MethodInfo method = value.GetType().GetMethod("ToString", new Type[1]
{
typeof (IFormatProvider)
});
#endif
string textToAppend;
if (method == (MethodInfo)null)
textToAppend = value.ToString();
else
textToAppend = (string)method.Invoke(value, new object[1]
{
(object) CultureInfo.InvariantCulture
});
this.WriteLiteral(textToAppend);
}
And then it works fine. Hopefully a WinRT specific version of the nuget project can be built at some point, but in the meantime if I include that class myself, I will be fine. Is just a matter of getting the razor generator functioning. Hope
someone is able to help with that.
Thanks,
Stefan
Comments: Do you think you could send this as a patch file or a pull request?
the RazorGenerator visual studio extension. Unfortunately I can only install that into visual studio 2010?
How do I get it installed into visual studio 2011, so that I can select a custom tool of RazorGenerator?
Secondly RazorGenerator.Templating isn't able to be installed in a WinRT project. So I decompiled the class and I can build that class, but there are some changes required in the write function. It should look like this:
public void Write(object value)
{
if (value == null)
return;
#if NETFX_CORE
MethodInfo method = null;
var methods = value.GetType().GetTypeInfo().GetDeclaredMethods("ToString");
if (methods != null)
{
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.GetParameters().Count() == 1 && methodInfo.GetParameters()[0].ParameterType == typeof (IFormatProvider))
{
method = methodInfo;
}
}
}
#else
MethodInfo method = value.GetType().GetMethod("ToString", new Type[1]
{
typeof (IFormatProvider)
});
#endif
string textToAppend;
if (method == (MethodInfo)null)
textToAppend = value.ToString();
else
textToAppend = (string)method.Invoke(value, new object[1]
{
(object) CultureInfo.InvariantCulture
});
this.WriteLiteral(textToAppend);
}
And then it works fine. Hopefully a WinRT specific version of the nuget project can be built at some point, but in the meantime if I include that class myself, I will be fine. Is just a matter of getting the razor generator functioning. Hope
someone is able to help with that.
Thanks,
Stefan
Comments: Do you think you could send this as a patch file or a pull request?