private UserdataVariable GetVariable(string name) { if (this.m_Variables.ContainsKey(name)) { return(this.m_Variables[name]); } FieldInfo field = base.m_Type.GetTypeInfo().GetField(name); if (field != null) { UserdataVariable variable; this.m_Variables[name] = variable = new UserdataField(base.m_Script, field); return(variable); } PropertyInfo property = base.m_Type.GetTypeInfo().GetProperty(name, BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); if (property != null) { UserdataVariable variable2; this.m_Variables[name] = variable2 = new UserdataProperty(base.m_Script, property); return(variable2); } EventInfo info = base.m_Type.GetTypeInfo().GetEvent(name); if (info != null) { UserdataVariable variable3; this.m_Variables[name] = variable3 = new UserdataEvent(base.m_Script, info); return(variable3); } return(null); }
private UserdataVariable GetVariable(string name) { if (m_Variables.ContainsKey(name)) { return(m_Variables[name]); } FieldInfo fInfo = m_Type.GetField(name); if (fInfo != null) { return(m_Variables[name] = new UserdataField(m_Script, fInfo)); } PropertyInfo pInfo = m_Type.GetProperty(name, Script.BindingFlag); if (pInfo != null) { return(m_Variables[name] = new UserdataProperty(m_Script, pInfo)); } EventInfo eInfo = m_Type.GetEvent(name); if (eInfo != null) { return(m_Variables[name] = new UserdataEvent(m_Script, eInfo)); } return(null); }
//获取一个变量 private UserdataVariable GetVariable(string name) { if (m_Variables.TryGetValue(name, out var value)) { return(value); } FieldInfo fInfo = m_Type.GetField(name, Script.BindingFlag); if (fInfo != null) { return(m_Variables[name] = new UserdataField(fInfo)); } PropertyInfo pInfo = m_Type.GetProperty(name, Script.BindingFlag); if (pInfo != null) { return(m_Variables[name] = new UserdataProperty(m_Type, pInfo)); } //EventInfo eInfo = m_Type.GetTypeInfo().GetEvent(name, Script.BindingFlag); //if (eInfo != null) return m_Variables[name] = new UserdataEvent(m_Script, eInfo); return(null); }
private UserdataVariable GetVariable(string name) { if (m_Variables.ContainsKey(name)) return m_Variables[name]; FieldInfo fInfo = m_Type.GetTypeInfo().GetField(name); if (fInfo != null) return m_Variables[name] = new UserdataField(m_Script, fInfo); PropertyInfo pInfo = m_Type.GetTypeInfo().GetProperty(name, Script.BindingFlag); if (pInfo != null) return m_Variables[name] = new UserdataProperty(m_Script, pInfo); EventInfo eInfo = m_Type.GetTypeInfo().GetEvent(name); if (eInfo != null) return m_Variables[name] = new UserdataEvent(m_Script, eInfo); return null; }