public PropertyBindingInfo(PropertyInfo propertyInfo) { this.propertyInfo = propertyInfo; if (propertyInfo.CanRead && propertyInfo.GetMethod != null && propertyInfo.GetMethod.IsPublic) { if (propertyInfo.GetMethod.IsStatic) { staticPair.getterName = "BindStaticRead_" + propertyInfo.Name; } else { instancePair.getterName = "BindRead_" + propertyInfo.Name; } } if (propertyInfo.CanWrite && propertyInfo.SetMethod != null && propertyInfo.SetMethod.IsPublic) { if (propertyInfo.SetMethod.IsStatic) { staticPair.setterName = "BindStaticWrite_" + propertyInfo.Name; } else { instancePair.setterName = "BindWrite_" + propertyInfo.Name; } } this.regName = TypeBindingInfo.GetNamingAttribute(propertyInfo); }
public void AddMethod(MethodInfo methodInfo, bool isIndexer, string renameRegName) { if (this.transform != null) { if (this.transform.IsBlocked(methodInfo)) { bindingManager.Info("skip blocked method: {0}", methodInfo.Name); return; } } var isExtension = methodInfo.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute)); var isStatic = methodInfo.IsStatic && !isExtension; var group = isStatic ? staticMethods : methods; MethodBindingInfo overrides; var methodName = TypeBindingInfo.GetNamingAttribute(methodInfo); if (!group.TryGetValue(methodName, out overrides)) { overrides = new MethodBindingInfo(isIndexer, isStatic, methodName, renameRegName ?? methodName); group.Add(methodName, overrides); } overrides.Add(methodInfo, isExtension); CollectDelegate(methodInfo); bindingManager.Info("[AddMethod] {0}.{1}", type, methodInfo); }
public EventBindingInfo(Type declaringType, EventInfo eventInfo) { this.declaringType = declaringType; this.eventInfo = eventInfo; do { if (this.isStatic) { this.adderName = "BindStaticAdd_" + eventInfo.Name; this.removerName = "BindStaticRemove_" + eventInfo.Name; } else { this.adderName = "BindAdd_" + eventInfo.Name; this.removerName = "BindRemove_" + eventInfo.Name; this.proxyName = "BindProxy_" + eventInfo.Name; } } while (false); this.regName = TypeBindingInfo.GetNamingAttribute(eventInfo); }
public FieldBindingInfo(FieldInfo fieldInfo) { do { if (fieldInfo.IsLiteral) { try { var cv = fieldInfo.GetRawConstantValue(); var cvType = cv.GetType(); if (cvType == typeof(string)) { constantValue = $"\"{cv}\""; break; } if (cvType == typeof(int) || cvType == typeof(uint) || cvType == typeof(byte) || cvType == typeof(sbyte) || cvType == typeof(short) || cvType == typeof(ushort) || cvType == typeof(bool)) { constantValue = $"{cv}"; break; } if (cvType == typeof(float)) { var fcv = (float)cv; if (!float.IsInfinity(fcv) && !float.IsNaN(fcv)) { constantValue = $"{cv}"; break; } } // if (cvType.IsPrimitive && cvType.IsValueType) // { // constantValue = $"{cv}"; // break; // } } catch (Exception) { } } if (fieldInfo.IsStatic) { this.getterName = "BindStaticRead_" + fieldInfo.Name; if (!fieldInfo.IsInitOnly && !fieldInfo.IsLiteral) { this.setterName = "BindStaticWrite_" + fieldInfo.Name; } } else { this.getterName = "BindRead_" + fieldInfo.Name; if (!fieldInfo.IsInitOnly && !fieldInfo.IsLiteral) { this.setterName = "BindWrite_" + fieldInfo.Name; } } } while (false); this.regName = TypeBindingInfo.GetNamingAttribute(fieldInfo); this.fieldInfo = fieldInfo; }