/// <summary>
 /// Creates dynamic constructor instance for the specified <see cref="ConstructorInfo"/>.
 /// </summary>
 /// <param name="constructorInfo">Constructor info to create dynamic constructor for.</param>
 /// <returns>Dynamic constructor for the specified <see cref="ConstructorInfo"/>.</returns>
 public static IDynamicConstructor Create(ConstructorInfo constructorInfo)
 {
     constructorInfo.ThrowIfNull("constructorInfo", "You cannot create a dynamic constructor for a null value.");
     return new SafeCtorWrapper(constructorInfo);
 }
        ///<summary>
        /// Creates a new delegate for the specified constructor.
        ///</summary>
        ///<param name="constructorInfo">the constructor to create the delegate for</param>
        ///<returns>delegate that can be used to invoke the constructor.</returns>
        public static ConstructorDelegate CreateConstructor(ConstructorInfo constructorInfo)
        {
            constructorInfo.ThrowIfNull("constructorInfo", "You cannot create a dynamic constructor for a null value.");

            bool skipVisibility = true; //!IsPublic(constructorInfo);
            System.Reflection.Emit.DynamicMethod dmGetter;
            Type[] argumentTypes = new Type[] { typeof(object[]) };
            dmGetter = CreateDynamicMethod(constructorInfo.Name, typeof(object), argumentTypes, constructorInfo, skipVisibility);
            ILGenerator il = dmGetter.GetILGenerator();
            EmitInvokeConstructor(il, constructorInfo, false);
            ConstructorDelegate ctor = (ConstructorDelegate)dmGetter.CreateDelegate(typeof(ConstructorDelegate));
            return ctor;
        }