Ejemplo n.º 1
0
        /// <summary>
        /// Creates an appropriate type builder.
        /// </summary>
        /// <param name="name">The name to use for the proxy type name.</param>
        /// <param name="baseType">The type to extends if provided.</param>
        /// <returns>The type builder to use.</returns>
        protected virtual TypeBuilder CreateTypeBuilder(string name, Type baseType)
        {
            // Generates unique type name
            string typeName = String.Format("{0}_{1}",
                                            name, Guid.NewGuid().ToString("N"));

            return(DynamicProxyManager.CreateTypeBuilder(typeName, baseType));
        }
        private static void CallCreateTypeBuilder(object arg)
        {
            int nr = (int)arg;

            for (int i = 0; i < 100; i++)
            {
                DynamicProxyManager.CreateTypeBuilder("TestType" + nr + "_" + i, typeof(AbstractProxyTypeBuilder));
                Thread.Sleep(0);
            }
        }
        public void CreateTypeBuilderMustNotBeCalledTwiceWithSameArguments()
        {
            TypeBuilder tb1 = DynamicProxyManager.CreateTypeBuilder("testtypename", null);

            try
            {
                TypeBuilder tb2 = DynamicProxyManager.CreateTypeBuilder("testtypename", typeof(AbstractProxyTypeBuilder));
                Assert.Fail("Did not throw expected ArgumentException.");
            }
            catch (ArgumentException)
            {
            }
        }