[Test] // ctor (Type) public void Constructor2 () { DesignerAttribute da = new DesignerAttribute (typeof (string)); Assert.AreEqual (typeof (IDesigner).FullName, da.DesignerBaseTypeName, "#1"); Assert.AreEqual (typeof (string).AssemblyQualifiedName, da.DesignerTypeName, "#2"); Assert.AreEqual (typeof (DesignerAttribute).FullName + da.DesignerBaseTypeName, da.TypeId, "#3"); }
public override bool Equals(object obj) { if (obj == this) { return(true); } DesignerAttribute attribute = obj as DesignerAttribute; return(((attribute != null) && (attribute.designerBaseTypeName == this.designerBaseTypeName)) && (attribute.designerTypeName == this.designerTypeName)); }
public override bool Equals(object obj) { if (obj == this) { return(true); } DesignerAttribute other = obj as DesignerAttribute; return((other != null) && other.designerBaseTypeName == designerBaseTypeName && other.designerTypeName == designerTypeName); }
// Determine if two instances of this class are equal. public override bool Equals(Object obj) { DesignerAttribute other = (obj as DesignerAttribute); if (other != null) { return(type == other.type && baseType == other.baseType); } else { return(false); } }
// Create a designer for a specific component. public static IDesigner CreateDesigner (IComponent component, Type designerBaseType) { // Get the attributes for the component. AttributeCollection attrs = GetAttributes(component, false); // Scan the attributes to find a designer attribute. foreach (Attribute attr in attrs) { DesignerAttribute dattr = (attr as DesignerAttribute); if (dattr != null) { Type type = Type.GetType(dattr.DesignerBaseTypeName); if (type != null && type == designerBaseType) { if (component.Site != null) { ITypeResolutionService trs; trs = (ITypeResolutionService) component.Site.GetService (typeof(ITypeResolutionService)); if (trs != null) { type = trs.GetType(dattr.DesignerTypeName); } else { type = Type.GetType(dattr.DesignerTypeName); } if (type != null) { return((IDesigner)Activator.CreateInstance (type, BindingFlags.CreateInstance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null)); } } } } } // We were unable to find a suitable designer declaration. return(null); }
[Test] // ctor (String, String) public void Constructor3 () { DesignerAttribute da; da = new DesignerAttribute ("Mono.Components.CategoryType", "Mono.Design.CompositeAttribute"); Assert.AreEqual ("Mono.Design.CompositeAttribute", da.DesignerBaseTypeName, "#A1"); Assert.AreEqual ("Mono.Components.CategoryType", da.DesignerTypeName, "#A2"); Assert.AreEqual (typeof (DesignerAttribute).FullName + da.DesignerBaseTypeName, da.TypeId, "#A3"); da = new DesignerAttribute ("CategoryType", "CompositeAttribute"); Assert.AreEqual ("CompositeAttribute", da.DesignerBaseTypeName, "#B1"); Assert.AreEqual ("CategoryType", da.DesignerTypeName, "#B2"); Assert.AreEqual (typeof (DesignerAttribute).FullName + da.DesignerBaseTypeName, da.TypeId, "#B3"); da = new DesignerAttribute (string.Empty, string.Empty); Assert.AreEqual (string.Empty, da.DesignerBaseTypeName, "#C1"); Assert.AreEqual (string.Empty, da.DesignerTypeName, "#C2"); Assert.AreEqual (typeof (DesignerAttribute).FullName, da.TypeId, "#C3"); }
public static IDesigner CreateDesigner(IComponent component, Type designerBaseType) { string tn = designerBaseType.AssemblyQualifiedName; AttributeCollection col = GetAttributes(component); foreach (Attribute at in col) { DesignerAttribute dat = at as DesignerAttribute; if (dat != null && tn == dat.DesignerBaseTypeName) { Type designerType = GetTypeFromName(component, dat.DesignerTypeName); if (designerType != null) { return((IDesigner)Activator.CreateInstance(designerType)); } } } return(null); }
public void Constructor3_DesignerBaseType_Null () { DesignerAttribute da = new DesignerAttribute ( "CategoryType", (string) null); Assert.IsNull (da.DesignerBaseTypeName, "#1"); Assert.AreEqual ("CategoryType", da.DesignerTypeName, "#2"); try { object typeId = da.TypeId; Assert.Fail ("#3: " + typeId); } catch (NullReferenceException) { } }
[Test] // ctor (Type, Type) public void Constructor5 () { DesignerAttribute da; da = new DesignerAttribute (typeof (int), typeof (string)); Assert.AreEqual (typeof (string).AssemblyQualifiedName, da.DesignerBaseTypeName, "#A1"); Assert.AreEqual (typeof (int).AssemblyQualifiedName, da.DesignerTypeName, "#A2"); Assert.AreEqual (typeof (DesignerAttribute).FullName + typeof (string).FullName, da.TypeId, "#A3"); da = new DesignerAttribute (typeof (string), typeof (int)); Assert.AreEqual (typeof (int).AssemblyQualifiedName, da.DesignerBaseTypeName, "#B1"); Assert.AreEqual (typeof (string).AssemblyQualifiedName, da.DesignerTypeName, "#B2"); Assert.AreEqual (typeof (DesignerAttribute).FullName + typeof (int).FullName, da.TypeId, "#B3"); }
[Test] // ctor (String, Type) public void Constructor4 () { DesignerAttribute da; da = new DesignerAttribute ("Mono.Components.CategoryType", typeof (string)); Assert.AreEqual (typeof (string).AssemblyQualifiedName, da.DesignerBaseTypeName, "#A1"); Assert.AreEqual ("Mono.Components.CategoryType", da.DesignerTypeName, "#A2"); Assert.AreEqual (typeof (DesignerAttribute).FullName + typeof (string).FullName, da.TypeId, "#A3"); da = new DesignerAttribute ("CategoryType", typeof (int)); Assert.AreEqual (typeof (int).AssemblyQualifiedName, da.DesignerBaseTypeName, "#B1"); Assert.AreEqual ("CategoryType", da.DesignerTypeName, "#B2"); Assert.AreEqual (typeof (DesignerAttribute).FullName + typeof (int).FullName, da.TypeId, "#B3"); da = new DesignerAttribute (string.Empty, typeof (string)); Assert.AreEqual (typeof (string).AssemblyQualifiedName, da.DesignerBaseTypeName, "#C1"); Assert.AreEqual (string.Empty, da.DesignerTypeName, "#C2"); Assert.AreEqual (typeof (DesignerAttribute).FullName + typeof (string).FullName, da.TypeId, "#C3"); }