1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
6
using System.Reflection;
7
using System.Windows.Forms;
10
namespace ICSharpCode.SharpDevelop.Gui.XmlForms
13
/// Default implementation of the IObjectCreator interface.
15
public class DefaultObjectCreator : IObjectCreator
17
public virtual Type GetType(string name)
19
Type t = typeof(Control).Assembly.GetType(name);
21
// try to create System.Drawing.* objects
23
t = typeof(Point).Assembly.GetType(name);
26
// try to create System.* objects
28
t = typeof(String).Assembly.GetType(name);
31
// try to create the object from some assembly which is currently
32
// loaded by the running application.
34
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
36
foreach (Assembly assembly in assemblies) {
37
t = assembly.GetType(name);
46
public virtual object CreateObject(string name, XmlElement el)
49
// try to create System.Windows.Forms.* objects
50
object newObject = typeof(Control).Assembly.CreateInstance(name);
52
// try to create System.Drawing.* objects
53
if (newObject == null) {
54
newObject = typeof(Point).Assembly.CreateInstance(name);
57
// try to create System.* objects
58
if (newObject == null) {
59
newObject = typeof(String).Assembly.CreateInstance(name);
62
// try to create the object from some assembly which is currently
63
// loaded by the running application.
64
if (newObject == null) {
65
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
67
foreach (Assembly assembly in assemblies) {
68
newObject = assembly.CreateInstance(name);
69
if (newObject != null) {
75
if (newObject is Control) {
76
((Control)newObject).SuspendLayout();