public void Ctor_DesignersIList(IDesignerHost[] designers)
        {
            var collection = new DesignerCollection((IList)designers);

            Assert.Equal(designers?.Length ?? 0, collection.Count);
            Assert.Equal(designers ?? Enumerable.Empty <IDesignerHost>(), collection.Cast <IDesignerHost>());
        }
        public void Indexer_Get_ReturnsExpected()
        {
            var designers  = new IDesignerHost[] { new TestDesignerHost(), new TestDesignerHost() };
            var collection = new DesignerCollection(designers);

            Assert.Same(designers[0], collection[0]);
        }
Example #3
0
        public void Ctor_DesignersIList(IDesignerHost[] designers)
        {
            var collection = new DesignerCollection((IList)designers);

            Assert.Equal(designers.Length, collection.Count);
            Assert.Equal(designers, collection.Cast <IDesignerHost>());
        }
        public void CopyTo_NullIList_Nop()
        {
            ICollection collection = new DesignerCollection((IList)null);
            var         array      = new object[] { 1, 2, 3 };

            collection.CopyTo(array, 1);
            Assert.Equal(new object[] { 1, 2, 3 }, array);
        }
Example #5
0
        public void Ctor_NullDesignersIList_Success()
        {
            var collection = new DesignerCollection((IList)null);

            Assert.Throws <NullReferenceException>(() => collection.Count);
            Assert.Throws <NullReferenceException>(() => collection.GetEnumerator());
            Assert.Throws <NullReferenceException>(() => collection[0]);
        }
Example #6
0
        internal DesignSurfaceCollection(DesignerCollection designers)
        {
            if (designers == null)
            {
                designers = new DesignerCollection(null);
            }

            _designers = designers;
        }
        public void CopyTo_Invoke_Success()
        {
            var         designers  = new IDesignerHost[] { new TestDesignerHost(), new TestDesignerHost() };
            ICollection collection = new DesignerCollection(designers);

            IDesignerHost[] destination = new IDesignerHost[4];
            collection.CopyTo(destination, 1);

            Assert.Equal(new IDesignerHost[] { null, designers[0], designers[1], null }, destination);
        }
        public void ICollection_PropertiesAndMethods_ReturnsExpected()
        {
            ICollection collection = new DesignerCollection(new TestDesignerHost[1]);

            Assert.Equal(1, collection.Count);
            Assert.Equal(1, collection.Cast <IDesignerHost>().Count());

            Assert.Null(collection.SyncRoot);
            Assert.False(collection.IsSynchronized);
        }
Example #9
0
 public ExampleComponent()
 {
     IDesignerHost designerhost1 = null, designerhost2 = null;
     //<Snippet1>
     // Create a DesignerCollection using a constructor
     // that accepts an array of IDesignerHost objects with
     // which to initialize the array.
     DesignerCollection collection = new DesignerCollection(
         new IDesignerHost[] { designerhost1, designerhost2 });
     //</Snippet1>
 }
        /// <include file='doc\DocumentManager.uex' path='docs/doc[@for="DocumentManager.OnDesignerCreated"]/*' />
        /// <devdoc>
        ///     The designer should call this after it successfully loads.
        /// </devdoc>
        public void OnDesignerCreated(DesignerEventArgs e)
        {
            designers.Add(e.Designer);
            documents = null;
            DesignerEventHandler handler = (DesignerEventHandler)eventTable[DOCUMENT_CREATED_EVENT];

            if (handler != null)
            {
                handler.Invoke(this, e);
            }
        }
Example #11
0
        public void OutputDesignerCollectionInfo(DesignerCollection collection)
        {
            //<Snippet2>
            // Get the number of elements in the collection.
            int count = collection.Count;

            //</Snippet2>

            //<Snippet3>
            // Access each IDesignerHost in the DesignerCollection using
            // the collection's indexer property, and output the class name
            // of the root component associated with each IDesignerHost.
            for (int i = 0; i < collection.Count; i++)
            {
                Console.WriteLine(collection[i].RootComponentClassName);
            }
            //</Snippet3>
        }
        /// <include file='doc\DocumentManager.uex' path='docs/doc[@for="DocumentManager.OnDesignerDisposed"]/*' />
        /// <devdoc>
        ///     The designer should call this before it disposes itself.
        /// </devdoc>
        public void OnDesignerDisposed(DesignerEventArgs e)
        {
            DesignerEventHandler handler = (DesignerEventHandler)eventTable[DOCUMENT_DISPOSED_EVENT];

            if (handler != null)
            {
                handler.Invoke(this, e);
            }
            if (designers.Contains(e.Designer))
            {
                designers.Remove(e.Designer);
            }
            if (activeDesigner == e.Designer)
            {
                activeDesigner = null;
            }
            documents = null;
        }