Inheritance: System.Attribute
Exemplo n.º 1
0
		[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));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        // 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);
            }
        }
Exemplo n.º 5
0
        // 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);
        }
Exemplo n.º 6
0
		[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");
		}
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
		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) {
			}
		}
Exemplo n.º 9
0
		[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");
		}
Exemplo n.º 10
0
		[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");
		}