public CliMethodInfo GetFunctionsWithAttribute(string name) { if (functionsWithAttributeCache.ContainsKey(name)) { return((CliMethodInfo)functionsWithAttributeCache [name]); } ArrayList methods = new ArrayList(); foreach (EcmaScriptFunctionAttribute funAttr in FunctionAttributes) { if (0 == string.Compare(funAttr.Name, name)) { methods.Add(funAttr.MethodInfo); } } CliMethodInfo mis = null; if (methods.Count > 0) { mis = new CliMethodInfo(name, (MethodInfo [])methods.ToArray(typeof(MethodInfo)), null); } lock (functionsWithAttributeCache) { functionsWithAttributeCache [name] = mis; } return(mis); }
public CliMethodInfo GetFunctions(string name) { if (functionCache.ContainsKey(name)) { return((CliMethodInfo)functionCache [name]); } ArrayList methods = new ArrayList(); foreach (MethodInfo mi in m_Type.GetMethods()) { if (0 == string.Compare(name, mi.Name)) { methods.Add(mi); } } CliMethodInfo nmi = null; if (methods.Count > 0) { nmi = new CliMethodInfo(name, (MethodInfo [])methods.ToArray(typeof(MethodInfo)), null); } lock (functionCache) { functionCache [name] = nmi; } return(nmi); }
public CliMethodInfo GetFunctionsWithAttribute(string name) { if (functionsWithAttributeCache.ContainsKey (name)) return (CliMethodInfo)functionsWithAttributeCache [name]; ArrayList methods = new ArrayList (); foreach (EcmaScriptFunctionAttribute funAttr in FunctionAttributes) { if (0 == string.Compare (funAttr.Name, name)) { methods.Add (funAttr.MethodInfo); } } CliMethodInfo mis = null; if (methods.Count > 0) { mis = new CliMethodInfo (name, (MethodInfo [])methods.ToArray (typeof (MethodInfo)), null); } lock (functionsWithAttributeCache) { functionsWithAttributeCache [name] = mis; } return mis; }
public override object Get(string name, IScriptable start) { object result = base.Get(name, start); if (result != UniqueTag.NotFound || name == "Object") { return(result); } if (m_Type.ClassAttribute != null) { CliMethodInfo mi = m_Type.GetFunctionsWithAttribute(name); if (mi != null) { return(mi); } return(UniqueTag.NotFound); } // Compatiblity with Microsoft.JScript if (typeof(IReflect).IsAssignableFrom(m_Type.UnderlyingType)) { MemberInfo [] mis = ((IReflect)m_Object).GetMember(name, BindingFlags.Default); if (mis.Length > 0) { if (mis [0] is PropertyInfo) { return(((PropertyInfo)mis [0]).GetValue(m_Object, null)); } else if (mis [0] is FieldInfo) { return(((FieldInfo)mis [0]).GetValue(m_Object)); } else { return(new CliMethodInfo(name, mis, null)); } } return(UniqueTag.NotFound); } // 1. Search froperty PropertyInfo pi = m_Type.GetCachedProperty(name); if (pi != null) { if (!pi.CanRead) { throw Context.ReportRuntimeErrorById("msg.undef.prop.read", name, ClassName); } return(pi.GetValue(m_Object, null)); } // 2. Search field FieldInfo fi = m_Type.GetCachedField(name); if (fi != null) { if (!fi.IsPublic) { throw Context.ReportRuntimeErrorById("msg.undef.prop.read", name, ClassName); } return(fi.GetValue(m_Object)); } // 3. Search function CliMethodInfo nmi = m_Type.GetFunctions(name); if (nmi != null) { return(nmi); } // 4. Indexer foreach (MethodInfo mi in m_Type.IndexGetter) { ParameterInfo [] pis = mi.GetParameters(); if (pis.Length == 1 && pis [0].ParameterType == typeof(string)) { return(mi.Invoke(m_Object, new object [] { name })); } } // 4. Event EventInfo ei = m_Type.GetCachedEvent(name); if (ei != null) { CliEventInfo ncei = new CliEventInfo(ei); ncei.ParentScope = this; return(ncei); } return(UniqueTag.NotFound); }
public CliMethodInfo GetFunctions(string name) { if (functionCache.ContainsKey (name)) return (CliMethodInfo)functionCache [name]; ArrayList methods = new ArrayList (); foreach (MethodInfo mi in m_Type.GetMethods ()) { if (0 == string.Compare (name, mi.Name)) { methods.Add (mi); } } CliMethodInfo nmi = null; if (methods.Count > 0) { nmi = new CliMethodInfo (name, (MethodInfo [])methods.ToArray (typeof (MethodInfo)), null); } lock (functionCache) { functionCache [name] = nmi; } return nmi; }