private static void CopyAnnotations(XObject source, XObject target) { foreach (var annotation in source.Annotations <object>()) { target.AddAnnotation(annotation); } }
private static void ValidateAnnotations <T>(XObject xo, T[] values) where T : class { // // use inefficent n^2 algorithm, which is OK for our testing purposes // assumes that all items are unique // int count = CountAnnotations <T>(xo); TestLog.Compare(count, values.Length, "unexpected number of annotations"); foreach (T value in values) { // // use non-generics enum first // bool found = false; foreach (T annotation in xo.Annotations(typeof(T))) { if (annotation.Equals(value)) { found = true; break; } } TestLog.Compare(found, "didn't find value using non-generic enumeration"); // // now double check with generics one // found = false; foreach (T annotation in xo.Annotations <T>()) { if (annotation.Equals(value)) { found = true; break; } } TestLog.Compare(found, "didn't find value using generic enumeration"); } }
public void GetAllNull(XObject xo) { Assert.Throws <ArgumentNullException>("type", () => xo.Annotations(null)); Assert.Throws <ArgumentNullException>("type", () => xo.Annotations(null)); }