Equals() публичный Метод

public Equals ( object other ) : bool
other object
Результат bool
 public static XmlSchemaComplexType GetBuiltInComplexType(XmlQualifiedName qualifiedName)
 {
     if (qualifiedName == null)
     {
         throw new ArgumentNullException("qualifiedName");
     }
     if (qualifiedName.Equals(XmlSchemaComplexType.AnyType.QualifiedName))
     {
         return XmlSchemaComplexType.AnyType;
     }
     if (qualifiedName.Equals(XmlSchemaComplexType.UntypedAnyType.QualifiedName))
     {
         return XmlSchemaComplexType.UntypedAnyType;
     }
     return null;
 }
 private bool MatchEnumeration(XmlQualifiedName value, ArrayList enumeration)
 {
     for (int i = 0; i < enumeration.Count; i++)
     {
         if (value.Equals((XmlQualifiedName) enumeration[i]))
         {
             return true;
         }
     }
     return false;
 }
Пример #3
0
		bool CheckChoiceType (XmlQualifiedName typeQName, XmlSchemaParticle particle, ArrayList types, ref bool multiValue)
		{
			XmlQualifiedName type = null;

			multiValue = multiValue || particle.MaxOccurs > 1;

			if (particle is XmlSchemaGroupRef)
				return CheckChoiceType (typeQName, GetRefGroupParticle ((XmlSchemaGroupRef)particle), types, ref multiValue);

			if (particle is XmlSchemaElement) {
				string ns;
				XmlSchemaElement elem = (XmlSchemaElement)particle;
				XmlSchemaElement refElem = GetRefElement (typeQName, elem, out ns);
				if (refElem.SchemaType != null) return true;
				type = refElem.SchemaTypeName;
			}
			else if (particle is XmlSchemaAny) {
				type = anyType;
			}
			else if (particle is XmlSchemaSequence)
			{
				XmlSchemaSequence seq = particle as XmlSchemaSequence;
				foreach (XmlSchemaParticle par in seq.Items)
					if (!CheckChoiceType (typeQName, par, types, ref multiValue)) return false;
				return true;
			}
			else if (particle is XmlSchemaChoice)
			{
				foreach (XmlSchemaParticle choice in ((XmlSchemaChoice)particle).Items)
					if (!CheckChoiceType (typeQName, choice, types, ref multiValue)) return false;
				return true;
			}

			if (typeQName.Equals (type)) return false;

			// For primitive types, compare using CLR types, since several
			// xml types can be mapped to a single CLR type

			string t;
			if (IsPrimitiveTypeNamespace (type.Namespace))
				t = TypeTranslator.GetPrimitiveTypeData (type.Name).FullTypeName + ":" + type.Namespace;

			else
				t = type.Name + ":" + type.Namespace;

			if (types.Contains (t)) return false;
			types.Add (t);
			return true;
		}
Пример #4
0
		bool CanBeArray (XmlQualifiedName typeQName, XmlSchemaParticle particle, bool multiValue)
		{
			// To be an array, there can't be a direct child of type typeQName

			if (particle == null) return false;

			multiValue = multiValue || particle.MaxOccurs > 1;

			if (particle is XmlSchemaGroupRef)
				return CanBeArray (typeQName, GetRefGroupParticle ((XmlSchemaGroupRef)particle), multiValue);

			if (particle is XmlSchemaElement)
			{
				XmlSchemaElement elem = (XmlSchemaElement)particle;
				if (!elem.RefName.IsEmpty)
					return CanBeArray (typeQName, FindRefElement (elem), multiValue);
				else
					return multiValue && !typeQName.Equals (((XmlSchemaElement)particle).SchemaTypeName);
			}

			if (particle is XmlSchemaAny)
				return multiValue;

			if (particle is XmlSchemaSequence)
			{
				XmlSchemaSequence seq = particle as XmlSchemaSequence;
				if (seq.Items.Count != 1) return false;
				return CanBeArray (typeQName, (XmlSchemaParticle)seq.Items[0], multiValue);
			}

			if (particle is XmlSchemaChoice)
			{
				// Can be array if all choices have different types
				ArrayList types = new ArrayList ();
				if(!CheckChoiceType (typeQName, particle, types, ref multiValue)) return false;
				return multiValue;
			}

			return false;
		}
 private SchemaElementDecl FastGetElementDecl(XmlQualifiedName elementName, object particle)
 {
     SchemaElementDecl elementDecl = null;
     if (particle != null)
     {
         XmlSchemaElement element = particle as XmlSchemaElement;
         if (element != null)
         {
             elementDecl = element.ElementDecl;
         }
         else
         {
             XmlSchemaAny any = (XmlSchemaAny) particle;
             this.processContents = any.ProcessContentsCorrect;
         }
     }
     if ((elementDecl != null) || (this.processContents == XmlSchemaContentProcessing.Skip))
     {
         return elementDecl;
     }
     if (this.isRoot && (this.partialValidationType != null))
     {
         if (this.partialValidationType is XmlSchemaElement)
         {
             XmlSchemaElement partialValidationType = (XmlSchemaElement) this.partialValidationType;
             if (elementName.Equals(partialValidationType.QualifiedName))
             {
                 return partialValidationType.ElementDecl;
             }
             this.SendValidationEvent("Sch_SchemaElementNameMismatch", elementName.ToString(), partialValidationType.QualifiedName.ToString());
             return elementDecl;
         }
         if (this.partialValidationType is XmlSchemaType)
         {
             XmlSchemaType type = (XmlSchemaType) this.partialValidationType;
             return type.ElementDecl;
         }
         this.SendValidationEvent("Sch_ValidateElementInvalidCall", string.Empty);
         return elementDecl;
     }
     return this.compiledSchemaInfo.GetElementDecl(elementName);
 }
Пример #6
0
 private bool MatchEnumeration(XmlQualifiedName value, ArrayList enumeration, XmlSchemaDatatype datatype)
 {
     foreach (XmlQualifiedName correctValue in enumeration)
     {
         if (value.Equals(correctValue))
         {
             return true;
         }
     }
     return false;
 }
Пример #7
0
        public virtual void WriteValue(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (value is string)
            {
                WriteString((string)value);
            }
            else if (value is bool)
            {
                WriteValue((bool)value);
            }
            else if (value is byte)
            {
                WriteValue((int)value);
            }
            else if (value is byte [])
            {
                WriteBase64((byte [])value, 0, ((byte [])value).Length);
            }
            else if (value is char [])
            {
                WriteChars((char [])value, 0, ((char [])value).Length);
            }
            else if (value is DateTime)
            {
                WriteValue((DateTime)value);
            }
            else if (value is decimal)
            {
                WriteValue((decimal)value);
            }
            else if (value is double)
            {
                WriteValue((double)value);
            }
            else if (value is short)
            {
                WriteValue((int)value);
            }
            else if (value is int)
            {
                WriteValue((int)value);
            }
            else if (value is long)
            {
                WriteValue((long)value);
            }
            else if (value is float)
            {
                WriteValue((float)value);
            }
            else if (value is TimeSpan)             // undocumented
            {
                WriteString(XmlConvert.ToString((TimeSpan)value));
            }
            else if (value is Uri)
            {
                WriteString(((Uri)value).ToString());
            }
            else if (value is XmlQualifiedName)
            {
                XmlQualifiedName qname = (XmlQualifiedName)value;
                if (!qname.Equals(XmlQualifiedName.Empty))
                {
                    if (qname.Namespace.Length > 0 && LookupPrefix(qname.Namespace) == null)
                    {
                        throw new InvalidCastException(String.Format("The QName '{0}' cannot be written. No corresponding prefix is declared", qname));
                    }
                    WriteQualifiedName(qname.Name, qname.Namespace);
                }
                else
                {
                    WriteString(String.Empty);
                }
            }
            else if (value is IEnumerable)
            {
                bool follow = false;
                foreach (object obj in (IEnumerable)value)
                {
                    if (follow)
                    {
                        WriteString(" ");
                    }
                    else
                    {
                        follow = true;
                    }
                    WriteValue(obj);
                }
            }
            else
            {
                throw new InvalidCastException(String.Format("Type '{0}' cannot be cast to string", value.GetType()));
            }
        }
Пример #8
0
		/// <summary>
		/// Finds an element in the schema.
		/// </summary>
		/// <remarks>
		/// Only looks at the elements that are defined in the
		/// root of the schema so it will not find any elements
		/// that are defined inside any complex types.
		/// </remarks>
		XmlSchemaElement FindElement(XmlQualifiedName name)
		{
			foreach (XmlSchemaElement element in schema.Elements.Values) {
				if (name.Equals(element.QualifiedName)) {
					return element;
				}
			}
			return null;
		}
 private SchemaElementDecl FastGetElementDecl(XmlQualifiedName elementName, object particle) {
     SchemaElementDecl elementDecl = null;
     if (particle != null) {
         XmlSchemaElement element = particle as XmlSchemaElement;
         if (element != null) {
             elementDecl = element.ElementDecl;
         }
         else {
             XmlSchemaAny any = (XmlSchemaAny)particle;
             processContents = any.ProcessContentsCorrect;
         }
     }
     if (elementDecl == null && processContents != XmlSchemaContentProcessing.Skip) {
         if (isRoot && partialValidationType != null) {
             if (partialValidationType is XmlSchemaElement) {
                 XmlSchemaElement element = (XmlSchemaElement)partialValidationType;
                 if (elementName.Equals(element.QualifiedName)) {
                     elementDecl = element.ElementDecl;
                 }
                 else {
                     SendValidationEvent(Res.Sch_SchemaElementNameMismatch, elementName.ToString(), element.QualifiedName.ToString());
                 }
             }
             else if (partialValidationType is XmlSchemaType) { //Element name is wildcard
                 XmlSchemaType type = (XmlSchemaType)partialValidationType;
                 elementDecl = type.ElementDecl;
             }
             else { //its XmlSchemaAttribute
                 Debug.Assert(partialValidationType is XmlSchemaAttribute);
                 SendValidationEvent(Res.Sch_ValidateElementInvalidCall, string.Empty);
             }
         }
         else {
             elementDecl = compiledSchemaInfo.GetElementDecl(elementName);
         }
     }
     return elementDecl;
 }
Пример #10
0
 internal SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, XmlSchemaObject partialValidationType, out AttributeMatchState attributeMatchState) {
     SchemaAttDef attdef = null;
     attributeMatchState = AttributeMatchState.UndeclaredAttribute;
     if (ed != null) {
         attdef = ed.GetAttDef(qname);
         if (attdef != null) {
             attributeMatchState = AttributeMatchState.AttributeFound;
             return attdef;
         }
         XmlSchemaAnyAttribute any = ed.AnyAttribute;
         if (any != null) {
             if (!any.NamespaceList.Allows(qname)) {
                 attributeMatchState = AttributeMatchState.ProhibitedAnyAttribute;
             }
             else if (any.ProcessContentsCorrect != XmlSchemaContentProcessing.Skip) {
                 if (attributeDecls.TryGetValue(qname, out attdef)) {
                     if (attdef.Datatype.TypeCode == XmlTypeCode.Id) { //anyAttribute match whose type is ID
                         attributeMatchState = AttributeMatchState.AnyIdAttributeFound;
                     }
                     else {
                         attributeMatchState = AttributeMatchState.AttributeFound;
                     }
                 }
                 else if (any.ProcessContentsCorrect == XmlSchemaContentProcessing.Lax) {
                     attributeMatchState = AttributeMatchState.AnyAttributeLax;
                 }
             }
             else {
                 attributeMatchState = AttributeMatchState.AnyAttributeSkip;
             }
         }
         else if (ed.ProhibitedAttributes.ContainsKey(qname)) {
             attributeMatchState = AttributeMatchState.ProhibitedAttribute;
         }
     }
     else if (partialValidationType != null) {
         XmlSchemaAttribute attr = partialValidationType as XmlSchemaAttribute;
         if (attr != null) {
             if (qname.Equals(attr.QualifiedName)) {
                 attdef = attr.AttDef;
                 attributeMatchState = AttributeMatchState.AttributeFound;
             }
             else {
                 attributeMatchState = AttributeMatchState.AttributeNameMismatch;
             }
         }
         else {
             attributeMatchState = AttributeMatchState.ValidateAttributeInvalidCall;
         }
     }
     else {
         if (attributeDecls.TryGetValue(qname, out attdef)) {
             attributeMatchState = AttributeMatchState.AttributeFound;
         }
         else {
             attributeMatchState = AttributeMatchState.UndeclaredElementAndAttribute;
         }
     }
     return attdef;
 }
Пример #11
0
		/// <summary>
		/// Finds an element in the schema.
		/// </summary>
		/// <remarks>
		/// Only looks at the elements that are defined in the 
		/// root of the schema so it will not find any elements
		/// that are defined inside any complex types.
		/// </remarks>
		XmlSchemaElement FindElement (XmlQualifiedName name)
		{
			XmlSchemaElement matchedElement = null;
			foreach (XmlSchemaElement element in schema.Elements.Values) {
				if (name.Equals(element.QualifiedName)) {
					matchedElement = element;
					break;
				}
			}
			
			return matchedElement;
		}		
Пример #12
0
        /// <summary> 
        /// Finds and removes all annotations of the specified type that have part or the entire
        /// anchor covered by the start-end range. If the delete range is adjacent to the anchor it 
        /// it will not be deleted 
        /// </summary>
        /// <param name="service">service to use for this operation</param> 
        /// <param name="annotationType">type of the annotations to be removed</param>
        private static void DeleteSpannedAnnotations(AnnotationService service, XmlQualifiedName annotationType)
        {
            CheckInputs(service); 

            // Limited set of annotation types supported in V1 
            Invariant.Assert(annotationType != null && 
                (annotationType == HighlightComponent.TypeName ||
                annotationType == StickyNoteControl.TextSchemaName || 
                annotationType == StickyNoteControl.InkSchemaName), "Invalid Annotation Type");

            // Get the selection from the viewer
            ITextSelection selection = GetTextSelection((FrameworkElement)service.Root); 
            Invariant.Assert(selection != null, "TextSelection is null");
 
            // Get annotations spanned by current selection 
            IList<IAttachedAnnotation> attachedAnnotations = GetSpannedAnnotations(service);
 
            // Find the annotations that overlap with the selection
            foreach (IAttachedAnnotation attachedAnnot in attachedAnnotations)
            {
                if (annotationType.Equals(attachedAnnot.Annotation.AnnotationType)) 
                {
                    // Only annotations with TextRange anchors can be compared to 
                    // the text selection, we ignore others 

                    TextAnchor anchor = attachedAnnot.AttachedAnchor as TextAnchor; 
                    if (anchor == null)
                        continue;

                    // Remove any annotations that overlap in anyway 
                    if (((selection.Start.CompareTo(anchor.Start) > 0) && (selection.Start.CompareTo(anchor.End) < 0)) ||
                        ((selection.End.CompareTo(anchor.Start) > 0) && (selection.End.CompareTo(anchor.End) < 0)) || 
                        ((selection.Start.CompareTo(anchor.Start) <= 0) && (selection.End.CompareTo(anchor.End) >= 0)) || 
                        CheckCaret(selection, anchor, annotationType))
                    { 
                        service.Store.DeleteAnnotation(attachedAnnot.Annotation.Id);
                    }
                }
            } 
        }