Exemplo n.º 1
0
        public override object CreateObjectInstance(Type objectType)
        {
            object obj = null;

            if (objectType.IsAbstract || objectType.IsInterface || objectType == typeof(object))
            {
                CreateObjectDialog createDialog = new CreateObjectDialog();
                createDialog.BaseType       = objectType;
                createDialog.ShowNamespaces = objectType == typeof(object);
                DialogResult result = createDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    obj = createDialog.SelectedType.GetTypeInfo().CreateInstanceOf();
                }
                else
                {
                    return(null);
                }
            }

            return(obj ?? base.CreateObjectInstance(objectType));
        }