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); }); }
/// <summary> /// Adds a sequence of extension objects to an extension collection. /// </summary> /// <param name="this">The extension collection to which to add the extensions.</param> /// <param name="extensions">The sequence of extension objects to add to the extension collection.</param> public static void AddRange(this IExtensionCollection @this, IEnumerable <IExtension> extensions) { foreach (var extension in extensions) { @this.Add(extension); } }
public RootContext(ITypeConfigurations types, IExtensionCollection extensions, IServicesFactory factory) { Types = types; _extensions = extensions; _factory = factory; _extensions.Add(new RootContextExtension(this)); }
private WcfOperationContextStorageExtension <T> GetWcfStorageExtension() { Fail.IfNull(OperationContext.Current, "There is no WCF " + nameof(OperationContext) + " available"); IExtensionCollection <OperationContext> extensions = OperationContext.Current.Extensions; var instance = extensions.Find <WcfOperationContextStorageExtension <T> >(); if (instance == null) { instance = new WcfOperationContextStorageExtension <T>(); extensions.Add(instance); } return(instance); }
void ICollection <ISerializerExtension> .Add(ISerializerExtension item) => _extensions.Add(item);
public void Add(IExtension <IOperationContext> item) { IWrap <IExtension <OperationContext> > wrap = (OperationContextExtensionWrap)item; UnderlyingObject.Add(wrap.UnderlyingObject); }