Ejemplo n.º 1
0
        public void AddXsiTypeDefaults()
        {
            // If there is only one xsi:type possible for a known local name and namespace URI,
            // add another XmlType to recognize nodes that don't provide the xsi:type.

            var bits = new Dictionary <IXmlKnownType, bool>(
                itemsByXmlIdentity.Count,
                XmlKnownTypeNameComparer.Instance
                );

            foreach (var knownType in itemsByXmlIdentity.Values)
            {
                bool bit;
                bits[knownType] = bits.TryGetValue(knownType, out bit)
                  ? false                               // another by same name; can't add a default
                  : knownType.XsiType != XmlName.Empty; // first   by this name; can   add a default, if not already in default form
            }

            foreach (var pair in bits)
            {
                if (pair.Value)
                {
                    var template  = pair.Key;
                    var knownType = new XmlKnownType(
                        template.Name,
                        XmlName.Empty,
                        template.ClrType
                        );
                    Add(knownType, true);
                }
            }
        }
Ejemplo n.º 2
0
			protected IXmlCursor SelectChild(IXmlNode node, string name, Type type)
			{
				var knownTypes = new XmlKnownTypeSet(type);
				var knownType  = new XmlKnownType(name, null, null, null, type);
				knownTypes.Add(knownType, true);

				var cursor = node.SelectChildren(knownTypes, Namespaces, CursorFlags.Elements);
				Assert.True(cursor.MoveNext());

				return cursor;
			}