-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
DesignerCategoryAttribute.cs
69 lines (57 loc) · 2.76 KB
/
DesignerCategoryAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
/// Specifies that the designer for a class belongs to a certain category.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class DesignerCategoryAttribute : Attribute
{
/// <summary>
/// Specifies that a component marked with this category uses a component
/// designer. This <see langword='static'/> field is read-only.
/// </summary>
public static readonly DesignerCategoryAttribute Component = new DesignerCategoryAttribute("Component");
/// <summary>
/// Specifies that a component marked with this category cannot use a visual
/// designer. This <see langword='static'/> field is read-only.
/// </summary>
public static readonly DesignerCategoryAttribute Default = new DesignerCategoryAttribute();
/// <summary>
/// Specifies that a component marked with this category uses a form designer.
/// This <see langword='static'/> field is read-only.
/// </summary>
public static readonly DesignerCategoryAttribute Form = new DesignerCategoryAttribute("Form");
/// <summary>
/// Specifies that a component marked with this category uses a generic designer.
/// This <see langword='static'/> field is read-only.
/// </summary>
public static readonly DesignerCategoryAttribute Generic = new DesignerCategoryAttribute("Designer");
/// <summary>
/// Initializes a new instance of the <see cref='System.ComponentModel.DesignerCategoryAttribute'/> class with the
/// default category.
/// </summary>
public DesignerCategoryAttribute() : this(string.Empty)
{
}
/// <summary>
/// Initializes a new instance of the <see cref='System.ComponentModel.DesignerCategoryAttribute'/> class with
/// the given category name.
/// </summary>
public DesignerCategoryAttribute(string category)
{
Category = category;
}
/// <summary>
/// Gets the name of the category.
/// </summary>
public string Category { get; }
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is DesignerCategoryAttribute other && other.Category == Category;
public override int GetHashCode() => Category?.GetHashCode() ?? 0;
public override bool IsDefaultAttribute() => Category == Default.Category;
public override object TypeId => GetType().FullName + Category;
}
}