public CollectionTypeMap( Type type, Type elementType, QName qname, KnownTypeCollection knownTypes) : base(type, qname, knownTypes) { element_type = elementType; element_qname = KnownTypes.GetQName(element_type); var icoll = GetGenericCollectionInterface(RuntimeType); if (icoll != null) { if (RuntimeType.IsInterface) { add_method = RuntimeType.GetMethod("Add", icoll.GetGenericArguments()); } else { var imap = RuntimeType.GetInterfaceMap(icoll); for (int i = 0; i < imap.InterfaceMethods.Length; i++) { if (imap.InterfaceMethods [i].Name == "Add") { add_method = imap.TargetMethods [i]; break; } } if (add_method == null) { add_method = type.GetMethod("Add", icoll.GetGenericArguments()); } } } }
internal virtual QName GetItemQName() { string name = a != null ? a.ItemName : null; string ns = a != null ? a.Namespace : null; name = name ?? "KeyValueOf" + KnownTypes.GetQName(key_type).Name + KnownTypes.GetQName(value_type).Name; ns = ns ?? (a != null ? ContractNamespace : KnownTypeCollection.MSArraysNamespace); return(new QName(name, ns)); }
public XmlQualifiedName GetSchemaTypeName(Type type) { QName qname = KnownTypes.GetQName(type); if (qname.Namespace == KnownTypeCollection.MSSimpleNamespace) { //primitive type, mapping to XmlSchema ns return(new QName(qname.Name, XmlSchema.Namespace)); } return(qname); }
internal void Initialize() { Type type = RuntimeType; List <DataMemberInfo> members = new List <DataMemberInfo> (); object [] atts = type.GetCustomAttributes( typeof(DataContractAttribute), false); IsReference = atts.Length > 0 ? (((DataContractAttribute)atts [0]).IsReference) : false; while (type != null) { QName qname = KnownTypes.GetQName(type); members = GetMembers(type, qname, true); members.Sort(DataMemberInfo.DataMemberInfoComparer.Instance); Members.InsertRange(0, members); members.Clear(); type = type.BaseType; } }
public bool CanExport(Type type) { return(!KnownTypes.GetQName(type).IsEmpty); }