1 //------------------------------------------------------------------------------
2 // <copyright file="TemplateInstanceAttribute.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //------------------------------------------------------------------------------
6 
7 namespace System.Web.UI {
8 
9     using System;
10     using System.Collections;
11     using System.ComponentModel;
12 
13     /// <devdoc>
14     /// Whether a template is instantiated single or multiple times.
15     /// The code generator generates fields corresponding to controls in the template
16     /// for single instance templates.
17     /// </devdoc>
18     [AttributeUsage(AttributeTargets.Property)]
19     public sealed class TemplateInstanceAttribute : Attribute {
20 
21 
22         public static readonly TemplateInstanceAttribute Multiple = new TemplateInstanceAttribute(TemplateInstance.Multiple);
23 
24 
25         public static readonly TemplateInstanceAttribute Single = new TemplateInstanceAttribute(TemplateInstance.Single);
26 
27 
28         public static readonly TemplateInstanceAttribute Default = Multiple;
29 
30         private TemplateInstance _instances;
31 
32 
33         /// <devdoc>
34         /// </devdoc>
TemplateInstanceAttribute(TemplateInstance instances)35         public TemplateInstanceAttribute(TemplateInstance instances) {
36             _instances = instances;
37         }
38 
39 
40         /// <devdoc>
41         /// <para>[To be supplied.]</para>
42         /// </devdoc>
43         public TemplateInstance Instances {
44             get {
45                 return _instances;
46             }
47         }
48 
49 
50         /// <internalonly/>
Equals(object obj)51         public override bool Equals(object obj) {
52             if (obj == this) {
53                 return true;
54             }
55 
56             TemplateInstanceAttribute other = obj as TemplateInstanceAttribute;
57             if (other != null) {
58                 return (other.Instances == Instances);
59             }
60             return false;
61         }
62 
63 
64         /// <internalonly/>
GetHashCode()65         public override int GetHashCode() {
66             return _instances.GetHashCode();
67         }
68 
69 
70         /// <internalonly/>
IsDefaultAttribute()71         public override bool IsDefaultAttribute() {
72             return this.Equals(Default);
73         }
74     }
75 }
76