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:
parent
f1c737923f
commit
d35ef48f86
3 changed files with 27 additions and 1 deletions
|
@ -61,7 +61,8 @@ sources = \
|
||||||
StructGen.cs \
|
StructGen.cs \
|
||||||
SymbolTable.cs \
|
SymbolTable.cs \
|
||||||
VirtualMethod.cs \
|
VirtualMethod.cs \
|
||||||
VMSignature.cs
|
VMSignature.cs \
|
||||||
|
XmlElementExtensions.cs
|
||||||
|
|
||||||
build_sources = $(addprefix $(srcdir)/, $(sources))
|
build_sources = $(addprefix $(srcdir)/, $(sources))
|
||||||
dist_sources = $(sources)
|
dist_sources = $(sources)
|
||||||
|
|
20
generator/XmlElementExtensions.cs
Normal file
20
generator/XmlElementExtensions.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -87,9 +87,14 @@
|
||||||
<Compile Include="SymbolTable.cs" />
|
<Compile Include="SymbolTable.cs" />
|
||||||
<Compile Include="VMSignature.cs" />
|
<Compile Include="VMSignature.cs" />
|
||||||
<Compile Include="VirtualMethod.cs" />
|
<Compile Include="VirtualMethod.cs" />
|
||||||
|
<Compile Include="XmlElementExtensions.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="DESIGN" />
|
<None Include="DESIGN" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Add table
Reference in a new issue