generator: Add a XmlElement.GetAttributeAsBoolean extension method

This will make it easier to correctly handle attributes that contain a
boolean value.
This commit is contained in:
Bertrand Lorentz 2012-10-21 14:33:29 +02:00
parent f1c737923f
commit d35ef48f86
3 changed files with 27 additions and 1 deletions

View File

@ -61,7 +61,8 @@ sources = \
StructGen.cs \
SymbolTable.cs \
VirtualMethod.cs \
VMSignature.cs
VMSignature.cs \
XmlElementExtensions.cs
build_sources = $(addprefix $(srcdir)/, $(sources))
dist_sources = $(sources)

View File

@ -0,0 +1,20 @@
using System;
using System.Xml;
namespace GtkSharp.Generation
{
public static class XmlElementExtensions
{
public static bool GetAttributeAsBoolean (this XmlElement elt, string name)
{
string value = elt.GetAttribute (name);
if (String.IsNullOrEmpty (value)) {
return false;
} else {
return XmlConvert.ToBoolean (value);
}
}
}
}

View File

@ -87,9 +87,14 @@
<Compile Include="SymbolTable.cs" />
<Compile Include="VMSignature.cs" />
<Compile Include="VirtualMethod.cs" />
<Compile Include="XmlElementExtensions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="DESIGN" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
</Project>