Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ FromExisting()

static AttributeCollection System.ComponentModel.AttributeCollection.FromExisting ( AttributeCollection existing,
params Attribute?[] newAttributes )
inlinestatic

Definition at line 120 of file AttributeCollection.cs.

121 {
122 if (existing == null)
123 {
124 throw new ArgumentNullException("existing");
125 }
126 if (newAttributes == null)
127 {
128 newAttributes = Array.Empty<Attribute>();
129 }
130 Attribute[] array = new Attribute[existing.Count + newAttributes.Length];
131 int count = existing.Count;
132 existing.CopyTo(array, 0);
133 for (int i = 0; i < newAttributes.Length; i++)
134 {
135 if (newAttributes[i] == null)
136 {
137 throw new ArgumentNullException("newAttributes");
138 }
139 bool flag = false;
140 for (int j = 0; j < existing.Count; j++)
141 {
142 if (array[j].TypeId.Equals(newAttributes[i].TypeId))
143 {
144 flag = true;
145 array[j] = newAttributes[i];
146 break;
147 }
148 }
149 if (!flag)
150 {
151 array[count++] = newAttributes[i];
152 }
153 }
154 Attribute[] array2;
155 if (count < array.Length)
156 {
157 array2 = new Attribute[count];
158 Array.Copy(array, array2, count);
159 }
160 else
161 {
162 array2 = array;
163 }
164 return new AttributeCollection(array2);
165 }

References System.ComponentModel.AttributeCollection.AttributeCollection(), System.array, System.Array.Copy(), System.ComponentModel.AttributeCollection.CopyTo(), System.ComponentModel.AttributeCollection.Count, and System.count.

Referenced by System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptor.GetAttributes().