Open Tschaul opened 8 years ago
Hi @Tschaul, unfortunately it's only possible to access public instance members at the moment. However, Typewriter 2.0 will have a richer code model including access to static properties.
Cool, thank you!
It is indeed a must have functionality
@Tschaul here a quick and dirty work around that I use to generate static access to resources:
string Resources(Class classe){
//return classe.FullName;
var assembly = System.Reflection.Assembly.LoadFile(@"MyPathResources.dll");
if(assembly==null){
return "ERROR assembly";
}
List<string> result = new List<string>();
foreach(var type in assembly.GetTypes().Where(t=>t.Name==classe.Name))
{
var properties = type.GetProperties();
result.Add(string.Join(Environment.NewLine+"\t",properties.Where(p=>p.CanRead && p.GetGetMethod().IsStatic && p.PropertyType==typeof(string))
.Select(p=> string.Format("static {0} : string = \"{1}\";", p.Name, p.GetValue(null,null), classe.name, classe.Name))));
}
return string.Join(Environment.NewLine,result);
}
I would be keen on adding some angular 2 extensions when your version 2.0 is ready.
Any update for v2, which would have .resx support? Thanks!
Hi,
Thanks a lot for your efforts at typewriter. So far it worked flawlessly for me. But now i ran into a problem. I want to generate typings for my server-side resources (resx-files). But the "Properties" of the generated classes (in the .designer.cs fiels) are empty. The only reason i see why this should be is that these are all static properties.
Is there a way to get a list of the static properties programatically inside typewriter?
Greetings
PS: I only need the names not the values!