//- ~Write -// internal static void Write(DojoRpcServiceBase dojoService) { DojoServiceDescription desc = new DojoServiceDescription(); desc.ServiceURL = HttpContext.Current.Request.Url.AbsoluteUri; //+ Type t = dojoService.GetType(); ScanMethods(t, desc); //+ DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(DojoServiceDescription)); s.WriteObject(HttpContext.Current.Response.OutputStream, desc); }
//- $ScanMethods -// private static void ScanMethods(Type type, DojoServiceDescription desc) { foreach (MethodInfo method in type.GetMethods()) { Object[] os = method.GetCustomAttributes(typeof(DojoOperationAttribute), false); if (os.Length > 0) { DojoServiceDescriptionMethod m = new DojoServiceDescriptionMethod(method.Name); SearchAttributes(os, m); desc.MethodList.Add(m); } } desc.ServiceType = "JSON-RPC"; }
//- ~CreateDescription -// internal static DojoServiceDescription CreateDescription(Type type, String url) { DojoServiceDescription desc = new DojoServiceDescription(); desc.ServiceURL = url.Substring(0, url.Length - 4); MethodCatalog mc = ReflectionCache.GetSpecificMethodCatalog(type.FullName); foreach (String m in mc.Keys) { DojoServiceDescriptionMethod dm = new DojoServiceDescriptionMethod(m); foreach (String p in mc[m].Parameters.Keys) { dm.ParameterList.Add(new DojoServiceDescriptionMethodParameter(p)); } desc.MethodList.Add(dm); } //+ return desc; }
//- ~CreateDescription -// internal static DojoServiceDescription CreateDescription(Type type, String url) { DojoServiceDescription desc = new DojoServiceDescription(); desc.ServiceURL = url.Substring(0, url.Length - 4); MethodCatalog mc = ReflectionCache.GetSpecificMethodCatalog(type.FullName); foreach (String m in mc.Keys) { DojoServiceDescriptionMethod dm = new DojoServiceDescriptionMethod(m); foreach (String p in mc[m].Parameters.Keys) { dm.ParameterList.Add(new DojoServiceDescriptionMethodParameter(p)); } desc.MethodList.Add(dm); } //+ return(desc); }
//- @AddServiceDescription -// public static void AddServiceDescription(String type, DojoServiceDescription serviceDescription) { ServiceDescription.Add(type, serviceDescription); }