Skip to content

Add method in XmlElement presumes args that are ValueTypes should be attributes #1

@robvon

Description

@robvon

The test is only for string. This prevents adding int and decimal et al directly without using "ToString()".
If you change your add method to test for type.IsValueType this can be facilitated:
(From line 29)

foreach (var arg in args)
{
if (arg is string)
value = arg as string;
else
{
var t = arg.GetType();
if (t.IsValueType)
{
value = arg.ToString();
}
else
{
foreach (var prop in arg.GetType().GetProperties())
{
attributes.Add(prop.Name, prop.GetValue(arg, null) as string);
}
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions