//- ~GetMethod -// internal static Method GetMethod(Type type, String name) { MethodCatalog mc = ReflectionCache.GetSpecificMethodCatalog(type.FullName); if (mc.ContainsKey(name)) { return(mc[name]); } //+ return(null); }
//- ~SetMappedMethods -// internal static void SetMappedMethods(Type type) { foreach (MethodInfo m in type.GetMethods()) { DojoOperationAttribute[] doa = (DojoOperationAttribute[])Attribute.GetCustomAttributes(m, typeof(DojoOperationAttribute), false); if (doa != null && doa.Length > 0) { Method md = new Method(m.Name); md.MethodInfo = m; ParameterInfo[] ps = m.GetParameters(); if (ps != null && ps.Length > 0) { foreach (ParameterInfo p in ps) { md.Parameters.Add(p.Name, p.ParameterType.Name); } } ReflectionCache.AddMethodToCatalog(type.FullName, doa[0].Name, md); } } }
//- @ProcessRequest -// public void ProcessRequest(HttpContext context) { if (!ReflectionCache.ContainsSpecificMethodCatalog(this.TypeFullName)) { TypeScanner.SetMappedMethods(this.GetType()); } Stream stream = context.Request.InputStream; if (context.Request.Url.AbsoluteUri.EndsWith("?smd")) { if (!ReflectionCache.ContainsSpecificServiceDescription(this.TypeFullName)) { String url = context.Request.Url.AbsoluteUri; ReflectionCache.AddServiceDescription(this.TypeFullName, DescriptionCreator.CreateDescription(this.GetType(), url)); } DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(DojoServiceDescription)); s.WriteObject(context.Response.OutputStream, ReflectionCache.GetSpecificServiceDescription(this.TypeFullName)); } else { if (stream != null && stream.Length > 0) { DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(DojoMessage)); DojoMessage o = null; try { o = (DojoMessage)s.ReadObject(stream); } catch { context.Response.Write("Error in JSON message"); } if (o != null) { Object r = CallServiceMethod(o); s.WriteObject(context.Response.OutputStream, r); } } } }