You've already forked linux-packaging-mono
Imported Upstream version 6.6.0.97
Former-commit-id: 36b6262d38adef7275aee46c9258ae34f9e3fb39
This commit is contained in:
parent
95fdb59ea6
commit
15bdb7a527
@ -12,8 +12,6 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -1207,157 +1205,54 @@ namespace MonoTests.System.Xml.TestClasses
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region PR_11194
|
||||
|
||||
#region PR_11194_GenerateOverrides
|
||||
public static class PR11194
|
||||
[Serializable]
|
||||
public class PropertiesWithSameNameAsTheirType
|
||||
{
|
||||
public static XmlAttributeOverrides GenerateLayoutOverrides<T>()
|
||||
public PropertiesWithSameNameAsTheirType ()
|
||||
{
|
||||
Type tType = typeof(T);
|
||||
|
||||
TypeInfo tTypeInfo = tType.GetTypeInfo();
|
||||
|
||||
IEnumerable<PropertyInfo> props = tType.GetRuntimeProperties();
|
||||
|
||||
XmlAttributeOverrides overrides = new XmlAttributeOverrides();
|
||||
|
||||
foreach (PropertyInfo prop in props) {
|
||||
XmlDerrivedAttribute attr = prop.GetCustomAttribute<XmlDerrivedAttribute>();
|
||||
|
||||
if (attr == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Type dType = prop.DeclaringType;
|
||||
|
||||
Type pType = prop.PropertyType;
|
||||
TypeInfo pTypeInfo = pType.GetTypeInfo();
|
||||
|
||||
Type enumType = typeof(IEnumerable<>);
|
||||
|
||||
if (pTypeInfo.IsGenericType
|
||||
&& pTypeInfo.ImplementedInterfaces.Any(t =>
|
||||
(t.GetTypeInfo().IsGenericType && t.GetGenericTypeDefinition() == enumType))) {
|
||||
pType = pType.GenericTypeArguments[0];
|
||||
}
|
||||
|
||||
XmlAttributes overrideAttributes = GenerateOverrideAttributes(dType, pType, attr);
|
||||
|
||||
overrides.Add(dType, prop.Name, overrideAttributes);
|
||||
}
|
||||
|
||||
return overrides;
|
||||
}
|
||||
|
||||
private static XmlAttributes GenerateOverrideAttributes (Type declaringType, Type propertyType, XmlDerrivedAttribute attr)
|
||||
{
|
||||
XmlAttributes xAttrs = new XmlAttributes();
|
||||
public object obj1 { get; set; }
|
||||
public object obj2 { get; set; }
|
||||
public object obj3 { get; set; }
|
||||
public object obj4 { get; set; }
|
||||
public object obj5 { get; set; }
|
||||
|
||||
Assembly a = declaringType.GetTypeInfo().Assembly;
|
||||
TypeInfo interfaceType = propertyType.GetTypeInfo();
|
||||
IEnumerable<Type> types = a.ExportedTypes.Where(t => interfaceType.IsAssignableFrom(t.GetTypeInfo()) && !t.GetTypeInfo().IsAbstract);
|
||||
|
||||
foreach (Type t in types) {
|
||||
string name = NameBySourceType(t, attr.SrcType);// t.GetTypeInfo().GetCustomAttribute<XmlTypeAttribute>().TypeName;
|
||||
XmlElementAttribute xAttr = new XmlElementAttribute();
|
||||
xAttr.ElementName = name;
|
||||
xAttr.Type = t;
|
||||
xAttrs.XmlElements.Add(xAttr);
|
||||
}
|
||||
|
||||
return xAttrs;
|
||||
}
|
||||
|
||||
private static string NameBySourceType (Type derrivedType, XmlDerrivedSourceType srcType)
|
||||
{
|
||||
string name = null;
|
||||
switch (srcType)
|
||||
{
|
||||
case XmlDerrivedSourceType.ByXmlType:
|
||||
name = derrivedType.GetTypeInfo().GetCustomAttribute<XmlTypeAttribute>().TypeName;
|
||||
break;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
public E1 E1 { get; set; }
|
||||
public E2 E2 { get; set; }
|
||||
public E3 E3 { get; set; }
|
||||
public E4 E4 { get; set; }
|
||||
public E5 E5 { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region helperAttribute
|
||||
public enum XmlDerrivedSourceType
|
||||
public enum E1
|
||||
{
|
||||
ByXmlType
|
||||
One,
|
||||
Two,
|
||||
}
|
||||
|
||||
public class XmlDerrivedAttribute : Attribute
|
||||
public enum E2
|
||||
{
|
||||
public XmlDerrivedSourceType SrcType { get; set; }
|
||||
|
||||
public XmlDerrivedAttribute(XmlDerrivedSourceType srcType)
|
||||
{
|
||||
SrcType = srcType;
|
||||
}
|
||||
One,
|
||||
Two,
|
||||
}
|
||||
#endregion
|
||||
|
||||
public abstract class PR11194Parent
|
||||
public enum E5
|
||||
{
|
||||
[XmlIgnore]
|
||||
public PR11194Parent Parent { get; set; }
|
||||
One,
|
||||
Two,
|
||||
}
|
||||
|
||||
public abstract class PR11194Parent2 : PR11194Parent
|
||||
public enum E3
|
||||
{
|
||||
[XmlAttribute]
|
||||
public float width { get; set; }
|
||||
[XmlAttribute]
|
||||
public float height { get; set; }
|
||||
[XmlAttribute]
|
||||
public float x { get; set; }
|
||||
[XmlAttribute]
|
||||
public float y { get; set; }
|
||||
[XmlAttribute]
|
||||
public string id { get; set; }
|
||||
[XmlElement]
|
||||
[XmlDerrived(XmlDerrivedSourceType.ByXmlType)]
|
||||
public List<PR11194Parent> children { get; set; }
|
||||
One,
|
||||
Two,
|
||||
}
|
||||
|
||||
[XmlType("background")]
|
||||
public class PR11194ChildB : PR11194Parent2
|
||||
public enum E4
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string image { get; set; }
|
||||
One,
|
||||
Two,
|
||||
}
|
||||
|
||||
[XmlType("br")]
|
||||
public class PR11194ChildBr : PR11194Parent
|
||||
{
|
||||
[XmlAttribute("brSize")]
|
||||
public int breaks { get; set; }
|
||||
}
|
||||
|
||||
[XmlType("div")]
|
||||
public class PR11194ChildD : PR11194ChildLo
|
||||
{
|
||||
}
|
||||
|
||||
[XmlType("label")]
|
||||
public class PR11194ChildL : PR11194Parent2
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string font { get; set; }
|
||||
[XmlAttribute]
|
||||
public int fontSize { get; set; }
|
||||
[XmlText]
|
||||
public string Text { get; set; }
|
||||
}
|
||||
|
||||
[XmlType("layout")]
|
||||
public class PR11194ChildLo : PR11194Parent2
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user