check MarkupTagElement attributes for comparison as well - hey, should we implement IComparable instead?

This commit is contained in:
Michael Becker 2019-12-29 16:35:02 -05:00
parent 3d1c95aca3
commit 1877c20645
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7
2 changed files with 14 additions and 2 deletions

View File

@ -132,7 +132,7 @@ namespace UniversalEditor.ObjectModels.Markup
if (attID != null) id = attID.Value;
}
if (Elements.Contains(el1.FullName, id))
if (Elements.Contains(el1.FullName, id, (el1 is MarkupTagElement ? (el1 as MarkupTagElement).Attributes : null)))
{
Elements[el1.FullName].Combine(el1);
}

View File

@ -82,7 +82,7 @@ namespace UniversalEditor.ObjectModels.Markup
item.ParentObjectModel = this._parentObjectModel;
base.Add(item);
}
public bool Contains(string fullName, string id = null)
public bool Contains(string fullName, string id = null, MarkupAttribute.MarkupAttributeCollection attributes = null)
{
MarkupElement el = this[fullName];
MarkupTagElement tag = (el as MarkupTagElement);
@ -92,6 +92,18 @@ namespace UniversalEditor.ObjectModels.Markup
MarkupAttribute attID = tag.Attributes["ID"];
if (attID != null) retval &= (id == attID.Value);
}
if (tag != null && attributes != null)
{
for (int i = 0; i < attributes.Count; i++)
{
MarkupAttribute att = tag.Attributes[attributes[i].Name];
if (att != null && att.Value != attributes[i].Value)
{
return false;
}
}
}
return retval;
}
public bool Contains(string fullName, Type elementType)