コード例 #1
0
ファイル: XsdIdentityState.cs プロジェクト: pmq20/mono_forked
        // In this method, attributes are ignored.
        // It might throw Exception.
        public void ProcessMatch(bool isAttribute, ArrayList qnameStack, object sender, XmlNameTable nameTable, string sourceUri, object schemaType, NSResolver nsResolver, IXmlLineInfo li, int depth, string attrName, string attrNS, object attrValue, bool isXsiNil, ArrayList currentKeyFieldConsumers)
        {
            for (int i = 0; i < KeyFields.Count; i++)
            {
                XsdKeyEntryField keyField = KeyFields [i];
                XsdIdentityPath  path     = keyField.Matches(isAttribute, sender, nameTable, qnameStack, sourceUri, schemaType, nsResolver, li, depth, attrName, attrNS, attrValue);
                if (path == null)
                {
                    continue;
                }

                if (keyField.FieldFound)
                {
                    // HACK: This is not logical by nature. Attributes never be cosuming,
                    // so I used it as a temporary mark to sign it is *just* validated now.
                    if (!keyField.Consuming)
                    {
                        throw new ValException("Two or more matching field was found.",
                                               sender, sourceUri, this.OwnerSequence.SourceSchemaIdentity, null);
                    }
                    else
                    {
                        keyField.Consuming = false;
                    }
                }
                if (keyField.Consumed)
                {
                    continue;
                }

                if (isXsiNil && !keyField.SetIdentityField(Guid.Empty, true, XsdAnySimpleType.Instance, depth, li))
                {
                    throw new ValException("Two or more identical field was found.", sender, sourceUri, OwnerSequence.SourceSchemaIdentity, null);
                }
                XmlSchemaComplexType ct = schemaType as XmlSchemaComplexType;
                if (ct != null &&
                    (ct.ContentType == XmlSchemaContentType.Empty || ct.ContentType == XmlSchemaContentType.ElementOnly) &&
                    schemaType != XmlSchemaComplexType.AnyType)
                {
                    throw new ValException("Specified schema type is complex type, which is not allowed for identity constraints.", sender, sourceUri, OwnerSequence.SourceSchemaIdentity, null);
                }
                keyField.FieldFound      = true;
                keyField.FieldFoundPath  = path;
                keyField.FieldFoundDepth = depth;
                keyField.Consuming       = true;
                if (li != null && li.HasLineInfo())
                {
                    keyField.FieldHasLineInfo  = true;
                    keyField.FieldLineNumber   = li.LineNumber;
                    keyField.FieldLinePosition = li.LinePosition;
                }
                currentKeyFieldConsumers.Add(keyField);
            }
        }
コード例 #2
0
 public bool CompareIdentity(XsdKeyEntry other)
 {
     for (int i = 0; i < this.KeyFields.Count; i++)
     {
         XsdKeyEntryField xsdKeyEntryField  = this.KeyFields[i];
         XsdKeyEntryField xsdKeyEntryField2 = other.KeyFields[i];
         if ((xsdKeyEntryField.IsXsiNil && !xsdKeyEntryField2.IsXsiNil) || (!xsdKeyEntryField.IsXsiNil && xsdKeyEntryField2.IsXsiNil))
         {
             return(false);
         }
         if (!XmlSchemaUtil.AreSchemaDatatypeEqual(xsdKeyEntryField2.FieldType, xsdKeyEntryField2.Identity, xsdKeyEntryField.FieldType, xsdKeyEntryField.Identity))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #3
0
ファイル: XsdIdentityState.cs プロジェクト: pmq20/mono_forked
 public bool CompareIdentity(XsdKeyEntry other)
 {
     for (int i = 0; i < KeyFields.Count; i++)
     {
         XsdKeyEntryField f  = this.KeyFields [i];
         XsdKeyEntryField of = other.KeyFields [i];
         if (f.IsXsiNil && !of.IsXsiNil || !f.IsXsiNil && of.IsXsiNil)
         {
             return(false);
         }
         if (!XmlSchemaUtil.AreSchemaDatatypeEqual(
                 of.FieldType, of.Identity, f.FieldType, f.Identity))
         {
             return(false);                      // does not match
         }
     }
     return(true);               // matches
 }
コード例 #4
0
 public void ProcessMatch(bool isAttribute, ArrayList qnameStack, object sender, XmlNameTable nameTable, string sourceUri, object schemaType, IXmlNamespaceResolver nsResolver, IXmlLineInfo li, int depth, string attrName, string attrNS, object attrValue, bool isXsiNil, ArrayList currentKeyFieldConsumers)
 {
     for (int i = 0; i < this.KeyFields.Count; i++)
     {
         XsdKeyEntryField xsdKeyEntryField = this.KeyFields[i];
         XsdIdentityPath  xsdIdentityPath  = xsdKeyEntryField.Matches(isAttribute, sender, nameTable, qnameStack, sourceUri, schemaType, nsResolver, li, depth, attrName, attrNS, attrValue);
         if (xsdIdentityPath != null)
         {
             if (xsdKeyEntryField.FieldFound)
             {
                 if (!xsdKeyEntryField.Consuming)
                 {
                     throw new XmlSchemaValidationException("Two or more matching field was found.", sender, sourceUri, this.OwnerSequence.SourceSchemaIdentity, null);
                 }
                 xsdKeyEntryField.Consuming = false;
             }
             if (!xsdKeyEntryField.Consumed)
             {
                 if (isXsiNil && !xsdKeyEntryField.SetIdentityField(Guid.Empty, true, XsdAnySimpleType.Instance, depth, li))
                 {
                     throw new XmlSchemaValidationException("Two or more identical field was found.", sender, sourceUri, this.OwnerSequence.SourceSchemaIdentity, null);
                 }
                 XmlSchemaComplexType xmlSchemaComplexType = schemaType as XmlSchemaComplexType;
                 if (xmlSchemaComplexType != null && (xmlSchemaComplexType.ContentType == XmlSchemaContentType.Empty || xmlSchemaComplexType.ContentType == XmlSchemaContentType.ElementOnly) && schemaType != XmlSchemaComplexType.AnyType)
                 {
                     throw new XmlSchemaValidationException("Specified schema type is complex type, which is not allowed for identity constraints.", sender, sourceUri, this.OwnerSequence.SourceSchemaIdentity, null);
                 }
                 xsdKeyEntryField.FieldFound      = true;
                 xsdKeyEntryField.FieldFoundPath  = xsdIdentityPath;
                 xsdKeyEntryField.FieldFoundDepth = depth;
                 xsdKeyEntryField.Consuming       = true;
                 if (li != null && li.HasLineInfo())
                 {
                     xsdKeyEntryField.FieldHasLineInfo  = true;
                     xsdKeyEntryField.FieldLineNumber   = li.LineNumber;
                     xsdKeyEntryField.FieldLinePosition = li.LinePosition;
                 }
                 currentKeyFieldConsumers.Add(xsdKeyEntryField);
             }
         }
     }
 }
コード例 #5
0
ファイル: XsdIdentityState.cs プロジェクト: nobled/mono
		public int Add (XsdKeyEntryField value)
		{
			return List.Add (value);
		}
コード例 #6
0
 public int Add(XsdKeyEntryField value)
 {
     return(base.List.Add(value));
 }