提交 6eb0ebd5 编写于 作者: L Lluis Sanchez

Fix flags enum deserialization

Flag enums values can be a composition of several
values separated by spaces. The deserializer now
properly handles this case.
上级 3dc10b0f
......@@ -983,9 +983,23 @@ namespace System.Runtime.Serialization
HandleId (id, deserializer, value);
if (value != String.Empty) {
foreach (EnumMemberInfo emi in enum_members)
if (emi.XmlName == value)
return emi.Value;
if (flag_attr && value.IndexOf (' ') != -1) {
long flags = 0l;
foreach (string flag in value.Split (' ')) {
foreach (EnumMemberInfo emi in enum_members) {
if (emi.XmlName == flag) {
flags |= Convert.ToInt64 (emi.Value);
break;
}
}
}
return Enum.ToObject (RuntimeType, flags);
}
else {
foreach (EnumMemberInfo emi in enum_members)
if (emi.XmlName == value)
return emi.Value;
}
}
if (!flag_attr)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册