Beispiel #1
0
        /// <summary>
        /// Creates a new instance of accessors type.
        /// </summary>
        /// <returns>A new instance of accessors type.</returns>
        public object Create()
        {
            LateBoundConstructor constructor = this._lateBoundConstructor.Value;

            if (constructor == null)
            {
                throw new InvalidOperationException(string.Format("Could not find constructor for '{0}'.", this.Type.Name));
            }
            return(constructor());
        }
        public void CreateConstructorInternal()
        {
            Type                 type  = typeof(InternalClass);
            Stopwatch            watch = Stopwatch.StartNew();
            LateBoundConstructor c     = DelegateFactory.CreateConstructor(type);

            watch.Stop();
            Console.WriteLine("Time: {0}ms", watch.ElapsedMilliseconds);

            Assert.IsNotNull(c);

            object o = c.Invoke();

            Assert.IsNotNull(o);
            Assert.IsTrue(o.GetType() == type);
        }