protected void Queue(_MemberInfo aItem, object aSrc, string aSrcType, string sourceItem = null) { if (aItem == null) { throw new ArgumentNullException(nameof(aItem)); } var xMemInfo = aItem as MemberInfo; //TODO: fix this, as each label/symbol should also contain an assembly specifier. if ((xMemInfo != null) && (xMemInfo.DeclaringType != null) && (xMemInfo.DeclaringType.FullName == "System.ThrowHelper") && (xMemInfo.DeclaringType.Assembly.GetName().Name != "mscorlib")) { // System.ThrowHelper exists in MS .NET twice... // Its an internal class that exists in both mscorlib and system assemblies. // They are separate types though, so normally the scanner scans both and // then we get conflicting labels. MS included it twice to make exception // throwing code smaller. They are internal though, so we cannot // reference them directly and only via finding them as they come along. // We find it here, not via QueueType so we only check it here. Later // we might have to checkin QueueType also. // So now we accept both types, but emit code for only one. This works // with the current Nasm assembler as we resolve by name in the assembler. // However with other assemblers this approach may not work. // If AssemblerNASM adds assembly name to the label, this will allow // both to exist as they do in BCL. // So in the future we might be able to remove this hack, or change // how it works. // // Do nothing // } else if (!mItems.Contains(aItem)) { if (mLogEnabled) { LogMapPoint(aSrc, aSrcType, aItem); } mItems.Add(aItem); mItemsList.Add(aItem); MethodBase methodBaseSource = aSrc as MethodBase; if (methodBaseSource != null) { aSrc = methodBaseSource.DeclaringType + "::" + aSrc; } mQueue.Enqueue(new ScannerQueueItem { Item = aItem, QueueReason = aSrcType, SourceItem = aSrc + Environment.NewLine + sourceItem }); } }
public static T GetCustomAttribute <T>(this _MemberInfo member, bool inherit = true) { T t = default(T); var attrs = member.GetCustomAttributes(typeof(T), inherit); if (attrs.Length > 0) { t = (T)attrs[0]; } return(t); }
public static IEnumerable <T> GetCustomAttributes <T>(this _MemberInfo type, bool inherit) { IList <T> list = new List <T>(); object[] array = type.GetCustomAttributes(typeof(T), inherit); if (array != null) { foreach (var a in array) { list.Add((T)a); } } return(list); }
public void SetValue(object obj, string name, object value) { try { _typeAccessor[obj, name] = value; } catch { _MemberInfo member = _type.GetMember(name).FirstOrDefault(); if (member != null) { try { switch (member.MemberType) { case MemberTypes.Field: { ((FieldInfo)member).SetValue(obj, value); break; } case MemberTypes.Property: { ((PropertyInfo)member).SetValue(obj, value); break; } } } catch { return; } } } }