public static NameType TryGetName(ReflectedType dt, FieldInfo fi, out string name) { Debug.Assert(dt.IsSubclassOf(DynamicType.GetDeclaringType(fi))); NameType nt = NameType.PythonField; name = null; // hide MinValue & MaxValue on int, Empty on string, Epsilon, Min/Max, etc.. on double if (fi.DeclaringType == typeof(string) || fi.DeclaringType == typeof(int) || fi.DeclaringType == typeof(double) || fi.IsDefined(typeof(PythonHiddenFieldAttribute), false)) nt = NameType.Field; string namePrefix = ""; if (fi.IsPrivate || (fi.IsAssembly && !fi.IsFamilyOrAssembly)) { if (!Options.PrivateBinding) { return NameType.None; } else { // mangle protectes to private namePrefix = "_" + dt.Name + "__"; nt = NameType.Field; } } name = namePrefix + fi.Name; return nt; }
public static NameType TryGetName(ReflectedType dt, EventInfo ei, MethodInfo eventMethod, out string name) { Debug.Assert(dt.IsSubclassOf(DynamicType.GetDeclaringType(ei))); name = ei.Name; NameType res = dt.IsClsType ? NameType.PythonEvent : NameType.Event; return GetNameFromMethod(dt, eventMethod, res, ref name); }
public static NameType TryGetName(ReflectedType dt, MethodInfo mi, out string name) { Debug.Assert(dt.IsSubclassOf(DynamicType.GetDeclaringType(mi))); NameType res = dt.IsClsType ? NameType.PythonMethod : NameType.Method; name = mi.Name; return GetNameFromMethod(dt, mi, res, ref name); }
public static NameType TryGetName(ReflectedType dt, PropertyInfo pi, MethodInfo prop, out string name) { Debug.Assert(dt.IsSubclassOf(DynamicType.GetDeclaringType(pi))); name = pi.Name; NameType res = dt.IsClsType ? NameType.PythonProperty : NameType.Property; return GetNameFromMethod(dt, prop, res, ref name); }