private void ComputeNames(ClrStackFrame frame) { // start by parsing (short)type name var typeName = frame.Method.Type.Name; if (string.IsNullOrEmpty(typeName)) { // IL generated frames TypeName = string.Empty; } else { TypeName = typeName; } // generic methods are not well formatted by ClrMD // foo<...>() => foo[[...]]() #if ClrMD1 var fullName = frame.Method?.GetFullSignature(); #else var fullName = frame.Method?.Signature; #endif MethodName = frame.Method.Name; if (MethodName.EndsWith("]]")) { // fix ClrMD bug with method name MethodName = GetGenericMethodName(fullName); } Signature.AddRange(BuildSignature(fullName)); }
public CodeMemberMethod CreateApiFunction(WebApiDescription description, IPoco2Client poco2TsGen, bool stringAsString) { this.Description = description; this.Poco2TsGen = poco2TsGen; this.StringAsString = stringAsString; MethodName = TsCodeGenerationOptions.Instance.CamelCase ? Fonlow.Text.StringExtensions.ToCamelCase(description.ActionDescriptor.ActionName) : description.ActionDescriptor.ActionName; if (MethodName.EndsWith("Async")) { MethodName = MethodName.Substring(0, MethodName.Length - 5); //HTTP does not care about the server side async. } ReturnType = description.ResponseDescription?.ResponseType ?? description.ActionDescriptor.ReturnType; //create method Method = CreateMethodName(); CreateDocComments(); switch (description.HttpMethod) { case "GET": case "DELETE": case "POST": case "PUT": RenderImplementation(); break; default: Trace.TraceWarning("This HTTP method {0} is not yet supported", description.HttpMethod); break; } return(Method); }
private void InvokeHttpPost(object[] parameters) { string CompleteUrl; if (MethodName.EndsWith("/")) { CompleteUrl = Url + MethodName; } else { CompleteUrl = Url + "/" + MethodName; } HttpWebRequest request = (HttpWebRequest)WebRequest.Create(CompleteUrl); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; using (Stream s = request.GetRequestStream()) using (StreamWriter sw = new StreamWriter(s)) { for (int i = 0; i < Parameters.Count; ++i) { sw.Write(Parameters[i].Name + "=" + System.Web.HttpUtility.UrlEncodeUnicode(Convert.ToString(parameters[i])) + ((i < (Parameters.Count - 1)) ? "&" : "")); } sw.Flush(); } WebResponse response = request.GetResponse(); response.Close(); }
private void ProcessCallbackBinding() { // Trying to roughly follow http://msdn.microsoft.com/en-us/library/ms228974(v=vs.110).aspx // "Event-based async pattern" if (InputObject == null) { throw new PSArgumentNullException("InputObject", "InputObject may not be null."); } bool isStatic = false; Type targetType; if ((_baseObject as Type) != null) { targetType = (Type)_baseObject; isStatic = true; this.WriteVerbose("InputObject is a Type: " + targetType.Name); } else { targetType = _baseObject.GetType(); this.WriteVerbose("InputObject is an instance of " + targetType.Name); } // Func<T1, Tn..., AsyncCallback, object, IAsyncResult> begin, // Func<IAsyncResult, dynamic> end) // begin/end? if (MethodName.StartsWith("Begin", StringComparison.OrdinalIgnoreCase)) { WriteVerbose("Method is AsyncCallback Begin/End pairing style."); string verb = MethodName.Substring(5); string endMethodName = "End" + verb; MethodInfo endMethod = targetType.GetMethod(endMethodName, new[] { typeof(IAsyncResult) }); if (endMethod == null) { throw new PSArgumentException(String.Format( "No matching '{0}(IAsyncResult)' method found for APM call '{1}'.", endMethodName, MethodName)); // TODO: throw proper terminating error //this.ThrowTerminatingError(new ErrorRecord()); } //BindBeginEndStyleMethod(targetType, isStatic); } else if (MethodName.EndsWith("Async", StringComparison.OrdinalIgnoreCase)) { // determine if EAP or TAP mode call string verb = MethodName.Substring(0, MethodName.Length - 5); // e.g. "[Read]Async" this.WriteWarning("*Async method handling not implemented, yet."); } // winrt / task? // }
private bool MatchesMethod(AssemblyItem item) { if (MethodName == null) { return(true); } else if (MethodName.EndsWith('*')) { return(item.Method.Name.StartsWith( MethodName.Substring(0, MethodName.Length - 1), StringComparison.Ordinal)); } else { return(string.Equals(item.Method.Name, MethodName, StringComparison.Ordinal)); } }