Beispiel #1
0
        /// <summary>
        /// Removes all extension objects from this collection and moves them to a new collection.
        /// </summary>
        /// <param name="from">The extension collection from which to remove the extensions.</param>
        /// <param name="to">The extension collection to which to add the extensions.</param>
        public static void MoveAllExtensionsTo(this IExtensionCollection from, IExtensionCollection to)
        {
            var list = from.ToList();

            from.Clear();
            to.AddRange(list);
        }
Beispiel #2
0
        public void T2_Tests()
        {
            IExtensionCollection <GraphObject, IExtension <GraphObject> > exts = _context.Extensions;

            ArborNode node = new ArborNode("");

            exts.Add(node);

            Assert.IsTrue(exts.Contains(node));
            Assert.AreEqual(1, exts.Count);

            IExtension <GraphObject> xt = exts.Find <ArborNode>();

            Assert.IsNotNull(xt);
            Assert.IsTrue(xt is ArborNode);
            Assert.AreEqual(node, xt);

            //

            Assert.IsTrue(exts.Remove(node));
            Assert.IsFalse(exts.Contains(node));
            Assert.AreEqual(0, exts.Count);

            //

            exts.Add(node);
            ArborNode node1 = new ArborNode("");

            exts.Add(node1);

            Assert.IsTrue(exts.Contains(node));
            Assert.IsTrue(exts.Contains(node1));
            Assert.AreEqual(2, exts.Count);

            Collection <ArborNode> cols = exts.FindAll <ArborNode>();

            Assert.AreEqual(2, cols.Count);

            Assert.IsTrue(exts.Remove(node));
            Assert.IsFalse(exts.Contains(node));
            Assert.IsTrue(exts.Contains(node1));
            Assert.AreEqual(1, exts.Count);

            //

            exts.Add(node); // adding second node, but internal array was length=2

            //

            exts.Clear();
            Assert.AreEqual(0, exts.Count);

            //

            Assert.IsFalse(exts.Remove(null));
            Assert.Throws(typeof(ArgumentNullException), () => { exts.Add(null); });
            Assert.Throws(typeof(ArgumentNullException), () => { new ExtensionCollection <GraphObject, IExtension <GraphObject> >(null); });
        }
 void ICollection <ISerializerExtension> .Clear() => _extensions.Clear();
Beispiel #4
0
 public void Clear()
 {
     UnderlyingObject.Clear();
 }