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

◆ InternalParamGetCustomAttributes()

static Attribute[] System.Attribute.InternalParamGetCustomAttributes ( ParameterInfo param,
Type type,
bool inherit )
inlinestaticprivateinherited

Definition at line 175 of file Attribute.cs.

176 {
177 List<Type> list = new List<Type>();
178 if ((object)type == null)
179 {
180 type = typeof(Attribute);
181 }
182 object[] customAttributes = param.GetCustomAttributes(type, inherit: false);
183 for (int i = 0; i < customAttributes.Length; i++)
184 {
185 Type type2 = customAttributes[i].GetType();
187 if (!attributeUsageAttribute.AllowMultiple)
188 {
189 list.Add(type2);
190 }
191 }
192 Attribute[] array = ((customAttributes.Length != 0) ? ((Attribute[])customAttributes) : CreateAttributeArrayHelper(type, 0));
193 if ((object)param.Member.DeclaringType == null)
194 {
195 return array;
196 }
197 if (!inherit)
198 {
199 return array;
200 }
202 {
203 customAttributes = parentDefinition.GetCustomAttributes(type, inherit: false);
204 int num = 0;
205 for (int j = 0; j < customAttributes.Length; j++)
206 {
207 Type type3 = customAttributes[j].GetType();
209 if (attributeUsageAttribute2.Inherited && !list.Contains(type3))
210 {
211 if (!attributeUsageAttribute2.AllowMultiple)
212 {
213 list.Add(type3);
214 }
215 num++;
216 }
217 else
218 {
219 customAttributes[j] = null;
220 }
221 }
223 num = 0;
224 foreach (object obj in customAttributes)
225 {
226 if (obj != null)
227 {
228 array2[num] = (Attribute)obj;
229 num++;
230 }
231 }
234 Array.Copy(array3, array, array3.Length);
235 int num2 = array3.Length;
236 for (int l = 0; l < array2.Length; l++)
237 {
238 array[num2 + l] = array2[l];
239 }
240 }
241 return array;
242 }
static AttributeUsageAttribute InternalGetAttributeUsage(Type type)
Definition Attribute.cs:319
static Attribute[] CreateAttributeArrayHelper(Type elementType, int elementCount)
Definition Attribute.cs:333
static PropertyInfo GetParentDefinition(PropertyInfo property, Type[] propertyParameters)
Definition Attribute.cs:71
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)

References System.array, System.Collections.Generic.Dictionary< TKey, TValue >.Contains(), System.Array.Copy(), System.Attribute.CreateAttributeArrayHelper(), System.Attribute.GetParentDefinition(), System.Attribute.InternalGetAttributeUsage(), System.list, System.obj, and System.type.

Referenced by System.Attribute.GetCustomAttributes(), and System.Attribute.GetCustomAttributes().