1 implementation of Container
System.Windows.Forms.Design (1)
System\ComponentModel\Design\DesignerHost.cs (1)
871IContainer IDesignerHost.Container => this;
241 references to Container
System.Windows.Forms.Design (50)
System\ComponentModel\Design\DesignSurface.cs (1)
76return ((IDesignerHost)_host).Container;
System\ComponentModel\Design\Serialization\CodeDomDesignerLoader.cs (4)
807typeDeclaration = _typeSerializer.Serialize(manager, LoaderHost.RootComponent, LoaderHost.Container.Components); 980return css.Deserialize(data, LoaderHost.Container); 1161if (Modified && LoaderHost.Container.Components[name] is not null) 1254if (!dup && Modified && LoaderHost.Container.Components[name] is not null)
System\ComponentModel\Design\Serialization\DesignerSerializationManager.cs (2)
70_container = host.Container; 261if (GetService(typeof(IDesignerHost)) is IDesignerHost host && host.Container == Container)
System\ComponentModel\Design\UndoEngine.cs (2)
442if (Enabled && _host is not null && _host.Container is not null && ComponentChangeService is not null) 445foreach (IComponent comp in _host.Container.Components)
System\ComponentModel\Design\UndoEngine.UndoUnit.AddRemoveUndoEvent.cs (2)
78engine._serializationService.DeserializeTo(_serializedData, host.Container); 86IComponent? component = host.Container.Components[_componentName];
System\ComponentModel\Design\UndoEngine.UndoUnit.ChangeUndoEvent.cs (2)
119component = host.Container.Components[_componentName]; 160engine._serializationService.DeserializeTo(_before, host.Container);
System\ComponentModel\Design\UndoEngine.UndoUnit.RenameUndoEvent.cs (1)
29IComponent? comp = engine._host.Container.Components[_after];
System\Windows\Forms\Design\Behavior\BehaviorService.cs (1)
796foreach (Component comp in host.Container.Components)
System\Windows\Forms\Design\Behavior\DragAssistanceManager.cs (1)
586foreach (IComponent comp in host.Container.Components)
System\Windows\Forms\Design\Behavior\DropSourceBehavior.cs (1)
225_destHost.Container.Add(c);
System\Windows\Forms\Design\BindingNavigatorDesigner.cs (1)
104host?.Container.Add(item, DesignerUtils.GetUniqueSiteName(host, item.Name));
System\Windows\Forms\Design\CommandSet.cs (4)
2206ComponentCollection components = host.Container.Components; 3007if (obj is IComponent { Site: { } objSite } && objSite.Container == host.Container) 3056if (obj is IComponent comp && (comp.Site is null || comp.Site.Container != host.Container)) 3130cmd.Enabled = host.Container.Components.Count > 1;
System\Windows\Forms\Design\ComponentTray.cs (3)
518if (host is not null && host.Container is not null) 520if (host.Container.Components[name] is not null) 525host.Container.Add(component, name);
System\Windows\Forms\Design\ControlCodeDomSerializer.cs (1)
234foreach (IComponent component in host.Container.Components)
System\Windows\Forms\Design\ControlCommandSet.cs (3)
854ComponentCollection components = host.Container.Components; 1296ComponentCollection comps = host.Container.Components; 1375IContainer container = host.Container;
System\Windows\Forms\Design\DataGridViewAddColumnDialog.cs (3)
156IContainer? container = host?.Container; 637container = host.Container; 771IContainer? container = host?.Container;
System\Windows\Forms\Design\DataGridViewColumnDesigner.cs (1)
58IContainer? container = host?.Container;
System\Windows\Forms\Design\DataGridViewDesigner.cs (1)
673host?.Container.Add(dataGridViewColumn, nameFromText);
System\Windows\Forms\Design\DesignBindingPicker.cs (3)
596container = _designerHost.Container; 1287_designerHost.Container.Add(bs, uniqueSiteName); 1427IContainer? container = _designerHost?.Container;
System\Windows\Forms\Design\DesignerUtils.cs (1)
633object? existingComponent = host.Container.Components[name];
System\Windows\Forms\Design\DocumentDesigner.cs (1)
842IContainer container = host.Container;
System\Windows\Forms\Design\StandardMenuStripVerb.cs (4)
115while (_host.Container.Components[name] is not null) 289while (_host.Container.Components[name] is not null) 494object existingComponent = _host.Container.Components[baseName]; 501return nameCreationService.CreateName(_host.Container, itemType);
System\Windows\Forms\Design\ToolStripInSituService.cs (1)
232ComponentCollection comps = _designerHost.Container.Components;
System\Windows\Forms\Design\ToolStripItemDesigner.cs (3)
809serializationService.DeserializeTo(serializedData, host.Container, false, true); 811newItem = (ToolStripItem)host.Container.Components[name]; 885host.Container.Add(ToolStripItem);
System\Windows\Forms\Design\ToolStripKeyboardHandlingService.cs (3)
456ComponentCollection comps = _designerHost.Container.Components; 1678IContainer container = host.Container; 1769IContainer container = host.Container;
System.Windows.Forms.Design.Tests (186)
System\ComponentModel\Design\DesignerHostTests.cs (173)
36Assert.Same(host, host.Container); 279host.Container.Add(component1); 280Assert.Same(component1, Assert.Single(host.Container.Components)); 290host.Container.Add(component2); 291Assert.Equal(new IComponent[] { component1, component2 }, host.Container.Components.Cast<IComponent>()); 301host.Container.Add(component3); 302Assert.Equal(new IComponent[] { component1, component2, component3 }, host.Container.Components.Cast<IComponent>()); 312host.Container.Add(component4); 313Assert.Equal(new IComponent[] { component1, component2, component3, component4 }, host.Container.Components.Cast<IComponent>()); 334host.Container.Add(component1, "name1"); 335Assert.Same(component1, Assert.Single(host.Container.Components)); 345host.Container.Add(component2, "name2"); 346Assert.Equal(new IComponent[] { component1, component2 }, host.Container.Components.Cast<IComponent>()); 356host.Container.Add(component3, string.Empty); 357Assert.Equal(new IComponent[] { component1, component2, component3 }, host.Container.Components.Cast<IComponent>()); 367host.Container.Add(component4, null); 368Assert.Equal(new IComponent[] { component1, component2, component3, component4 }, host.Container.Components.Cast<IComponent>()); 428host.Container.Add(component); 429Assert.Same(component, Assert.Single(host.Container.Components)); 435host.Container.Add(component); 436Assert.Same(component, Assert.Single(host.Container.Components)); 442host.Container.Add(component, "name"); 443Assert.Same(component, Assert.Single(host.Container.Components)); 498host.Container.Add(component); 499Assert.Same(component, Assert.Single(host.Container.Components)); 505host.Container.Add(component); 506Assert.Same(component, Assert.Single(host.Container.Components)); 512host.Container.Add(component, "name"); 513Assert.Same(component, Assert.Single(host.Container.Components)); 571host.Container.Add(component); 572Assert.Same(component, Assert.Single(host.Container.Components)); 584host.Container.Add(component); 585Assert.Same(component, Assert.Single(host.Container.Components)); 596host.Container.Add(component); 597Assert.Same(component, Assert.Single(host.Container.Components)); 601host.Container.Add(component); 602Assert.Same(component, Assert.Single(host.Container.Components)); 606host.Container.Add(component, "name"); 607Assert.Same(component, Assert.Single(host.Container.Components)); 637host.Container.Add(component); 639mockNameCreationService.Verify(s => s.CreateName(host.Container, typeof(RootDesignerComponent)), Times.Once()); 641host.Container.Add(component, null); 643mockNameCreationService.Verify(s => s.CreateName(host.Container, typeof(RootDesignerComponent)), Times.Once()); 692host.Container.Add(component); 694mockNameCreationService.Verify(s => s.CreateName(host.Container, typeof(RootDesignerComponent)), Times.Once()); 696host.Container.Add(component, null); 698mockNameCreationService.Verify(s => s.CreateName(host.Container, typeof(RootDesignerComponent)), Times.Once()); 727host.Container.Add(component1, name); 734host.Container.Add(component2, "name2"); 787host.Container.Add(component1, "name1"); 798host.Container.Add(component2, "name2"); 834host.Container.Add(component, "name1"); 878host.Container.Add(component, "name1"); 892host.Container.Add(component); 897Assert.Throws<Exception>(() => host.Container.Add(newComponent)); 913host.Container.Add(component); 926host.Container.Add(component); 945host.Container.Add(component); 957host.Container.Add(component); 975host.Container.Add(component); 987host.Container.Add(component); 1005host.Container.Add(component); 1041host.Container.Add(component); 1068host.Container.Add(component); 1101host.Container.Add(component); 1131host.Container.Add(component); 1165host.Container.Add(component); 1203host.Container.Add(component); 1238host.Container.Add(component); 1267host.Container.Add(component, oldName); 1284host.Container.Add(component, "name"); 1302host.Container.Add(component1); 1303host.Container.Add(component2, null); 1304host.Container.Add(component3, "name3"); 1355host.Container.Add(component, oldName); 1385host.Container.Add(component, "oldName"); 1434host.Container.Add(component, "oldName"); 1450host.Container.Add(component1, "name1"); 1451host.Container.Add(component2, "name2"); 1477host.Container.Add(component); 1502host.Container.Add(component); 1515host.Container.Add(component); 1549host.Container.Add(component); 1562host.Container.Add(component); 1572host.Container.Add(component); 1582host.Container.Add(component); 1592host.Container.Add(component); 1623host.Container.Add(component); 1624Assert.Same(host.Container, component.Container); 1629host.Container.Add(component); 1630Assert.Same(host.Container, component.Container); 1637host.Container.Add(component); 1638Assert.Same(host.Container, component.Container); 1655Assert.Throws<NotImplementedException>(() => host.Container.Add(component)); 1656Assert.Throws<NotImplementedException>(() => host.Container.Add(component, "name")); 1657Assert.Empty(host.Container.Components); 1666host.Container.Add(component, component.GetType().FullName); 1668Assert.Throws<InvalidOperationException>(() => host.Container.Add(component)); 1669Assert.Throws<InvalidOperationException>(() => host.Container.Add(new RootDesignerComponent(), host.RootComponentClassName)); 1678Assert.Throws<InvalidOperationException>(() => host.Container.Add(component)); 1679Assert.Throws<InvalidOperationException>(() => host.Container.Add(component, "name")); 1688Assert.Throws<DivideByZeroException>(() => host.Container.Add(component)); 1692Assert.Throws<DivideByZeroException>(() => host.Container.Add(component, "name")); 1707host.Container.Add(component); 1715Assert.Same(host.Container, component.Container); 1718host.Container.Add(component, "name"); 1719Assert.Same(host.Container, component.Container); 1811host.Container.Add(component); 1826host.Container.Add(component); 2253host.Container.Add(component); 2531host.Container.Add(rootComponent); 2532host.Container.Add(component); 2533host.Container.Remove(rootComponent); 2534Assert.Same(component, Assert.Single(host.Container.Components)); 2541Assert.Same(host.Container, component.Container); 2545host.Container.Remove(rootComponent); 2546Assert.Same(component, Assert.Single(host.Container.Components)); 2553Assert.Same(host.Container, component.Container); 2557host.Container.Remove(component); 2558Assert.Empty(host.Container.Components); 2619host.Container.Add(component); 2620Assert.Same(component, Assert.Single(host.Container.Components)); 2625host.Container.Remove(component); 2626Assert.Empty(host.Container.Components); 2632host.Container.Remove(component); 2633Assert.Empty(host.Container.Components); 2688host.Container.Add(component); 2689Assert.Same(component, Assert.Single(host.Container.Components)); 2695host.Container.Remove(component); 2696Assert.Empty(host.Container.Components); 2702host.Container.Remove(component); 2703Assert.Empty(host.Container.Components); 2718host.Container.Add(component); 2719Assert.Same(component, Assert.Single(host.Container.Components)); 2722host.Container.Remove(component); 2723Assert.Empty(host.Container.Components); 2735host.Container.Add(component); 2736Assert.Same(component, Assert.Single(host.Container.Components)); 2739host.Container.Remove(component); 2740Assert.Empty(host.Container.Components); 2754host1.Container.Add(otherComponent); 2755host2.Container.Add(component); 2756host2.Container.Remove(otherComponent); 2757host2.Container.Remove(new Component()); 2758Assert.Same(otherComponent, Assert.Single(host1.Container.Components)); 2759Assert.Same(component, Assert.Single(host2.Container.Components)); 2771host1.Container.Add(otherComponent); 2772host2.Container.Remove(otherComponent); 2773host2.Container.Remove(new Component()); 2774Assert.Same(otherComponent, Assert.Single(host1.Container.Components)); 2775Assert.Empty(host2.Container.Components); 2808host.Container.Add(component1); 2809host.Container.Add(component2); 2812host.Container.Remove(component1); 2815Assert.Same(host.Container, component2.Container); 2817Assert.Same(component2, Assert.Single(host.Container.Components)); 2822host.Container.Remove(component1); 2825Assert.Same(host.Container, component2.Container); 2827Assert.Same(component2, Assert.Single(host.Container.Components)); 2834host.Container.Remove(component2); 2839Assert.Empty(host.Container.Components); 2860host.Container.Add(component); 2861host.Container.Remove(component); 2873host.Container.Add(component); 2878host.Container.Remove(component); 3092Assert.Equal(typeof(IDesignerHost).GetMember(nameof(IDesignerHost.Container)), reflect.GetMember(nameof(IDesignerHost.Container), BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)); 3125Assert.Equal(typeof(IDesignerHost).GetProperty(nameof(IDesignerHost.Container)), reflect.GetProperty(nameof(IDesignerHost.Container), BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)); 3126Assert.Equal(typeof(IDesignerHost).GetProperty(nameof(IDesignerHost.Container)), reflect.GetProperty(nameof(IDesignerHost.Container), BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, null, typeof(IContainer), Array.Empty<Type>(), Array.Empty<ParameterModifier>())); 3142Assert.Equal(surface.Host.Container, reflect.InvokeMember(nameof(IDesignerHost.Container), BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.GetProperty, null, surface.Host, Array.Empty<object>(), Array.Empty<ParameterModifier>(), null, Array.Empty<string>()));
System\ComponentModel\Design\DesignSurfaceTests.cs (5)
21Assert.Same(surface.Host, surface.Host.Container); 60Assert.Same(surface.Host, surface.Host.Container); 82Assert.Same(surface.Host, surface.Host.Container); 104Assert.Same(surface.Host, surface.Host.Container); 151Assert.Same(surface.Host, surface.Host.Container);
System\ComponentModel\Design\Serialization\DesignerSerializationManagerTests.cs (3)
44.Setup(h => h.Container) 722.Setup(h => h.Container) 810.Setup(h => h.Container)
System\ComponentModel\Design\SiteNestedContainerTests.cs (4)
83Assert.Empty(host.Container.Components); 90Assert.Empty(host.Container.Components); 100Assert.Empty(host.Container.Components); 971Assert.Empty(host.Container.Components);
System\Windows\Forms\Design\FlowPanelDesignerTests.cs (1)
19mockHost.Setup(host => host.Container).Returns(mockContainer.Object);
System.Windows.Forms.Tests (5)
System\Windows\Forms\PropertyGridTests.cs (5)
2717.Setup(h => h.Container) 2817.Setup(h => h.Container) 2841.Setup(h => h.Container) 2937.Setup(h => h.Container) 2971.Setup(h => h.Container)