public void RegisterProxy(IPythonProxy pythonProxy) { if (pythonProxy == null) { throw new ArgumentNullException(nameof(pythonProxy)); } _proxies.Add(pythonProxy); }
public void RegisterSingletonProxy(IPythonProxy proxy) { if (proxy == null) { throw new ArgumentNullException(nameof(proxy)); } _pythonProxyFactory.RegisterProxy(proxy); }
static void GenerateModuleReferenceDocument(IPythonProxy pythonProxy, StringBuilder output) { output.AppendLine($"### _{pythonProxy.ModuleName}_ module"); output.AppendLine(); var methods = pythonProxy.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly) .Where(m => !m.IsSpecialName) .OrderBy(m => m.Name); foreach (var method in methods) { output.AppendLine($"#### Method _{method.Name}_"); output.AppendLine("Signature:"); output.AppendLine(); output.Append($"`wirehome.{pythonProxy.ModuleName}.{method.Name}("); var parameters = method.GetParameters(); if (parameters.Length > 0) { foreach (var parameter in method.GetParameters()) { output.Append(parameter.Name + ", "); } output.Remove(output.Length - 2, 2); } output.AppendLine(")`"); output.AppendLine(); if (parameters.Length > 0) { output.AppendLine("Parameters:"); foreach (var parameter in parameters) { output.AppendLine($"* {parameter.Name} : `{GetPythonTypeName(parameter.ParameterType)}`"); } output.AppendLine(); } output.AppendLine("Return value: "); if (method.ReturnType == typeof(void)) { output.AppendLine("_This method has no return value._"); } else { output.AppendLine($"`{GetPythonTypeName(method.ReturnType)}`"); } } output.AppendLine(); }