本文整理汇总了C#中Functions.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Functions.ToString方法的具体用法?C# Functions.ToString怎么用?C# Functions.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Functions
的用法示例。
在下文中一共展示了Functions.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetButton
public Button GetButton(Functions funcName)
{
var fields = _element.GetFields(typeof(IButton));
if (fields.Count == 1)
return (Button) fields[0].GetValue(_element);
var buttons = fields.Select(f => (Button) f.GetValue(_element)).ToList();
var button = buttons.FirstOrDefault(b => b.Function.Equals(funcName));
if (button != null) return button;
var name = funcName.ToString();
button = buttons.FirstOrDefault(b => NamesEqual(ToButton(b.Name), ToButton(name)));
if (button == null)
throw Exception($"Can't find button '{name}' for Element '{ToString()}'");
return button;
}
示例2: Method
public JObject Method(Functions funcName, JObject request, MethodCheckRequestParameters check)
{
if (!string.IsNullOrEmpty(Token)) request[FieldKeyword.Token] = Token;
if (!string.IsNullOrEmpty(Language)) request[FieldKeyword.Language] = Language;
JObject response = new JObject();
if (ServerAddr==null|| request == null || (check != null && !check(request)))
{
response[FieldKeyword.Success] = false;
response[FieldKeyword.CommonError] = ErrorNumber.CommonBadParameter.ToString();
return response;
}
var webBinding = new WebHttpBinding();
webBinding.AllowCookies = true;
webBinding.MaxReceivedMessageSize = 1000 * 1024 * 1024;
webBinding.ReaderQuotas.MaxStringContentLength = 1000 * 1024 * 1024;
webBinding.SendTimeout = new TimeSpan(0, 500, 0);
webBinding.ReceiveTimeout = new TimeSpan(0, 500, 0);
using (var factory = new WebChannelFactory<IService>(webBinding, ServerAddr))
{
factory.Endpoint.Behaviors.Add(new WebHttpBehavior());
var session = factory.CreateChannel();
if (session == null || (session as IContextChannel)==null)
{
response[FieldKeyword.Success] = false;
response[FieldKeyword.CommonError] = ErrorNumber.CommonBadContext.ToString();
}
else
using (OperationContextScope scope = new OperationContextScope(session as IContextChannel))
{
var temp = request.ToString();
Stream stream = new MemoryStream(KORT.Util.Tools.GZipCompress(Encoding.UTF8.GetBytes(temp)));
System.Diagnostics.Debug.WriteLine(request.ToString());
try
{
using (var responseStream = session.Method(funcName.ToString(), stream))
{
using (var decompressStream = new MemoryStream())
{
KORT.Util.Tools.GZipDecompress(responseStream, decompressStream);
decompressStream.Position = 0;
StreamReader reader = new StreamReader(decompressStream, Encoding.UTF8);
string text = reader.ReadToEnd();
System.Diagnostics.Debug.WriteLine(text);
response = JObject.Parse(text);
}
}
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
response[FieldKeyword.Success] = false;
response[FieldKeyword.CommonError] = ErrorNumber.Other.ToString();
response[FieldKeyword.ErrorDetail] = e.Message;
}
}
return response;
}
}
示例3: GetMessage
public static string GetMessage(Functions function, string language)
{
return GetMessage(function.ToString(), language);
}
示例4: Post
private Response Post(Functions function, String payload)
{
HttpWebRequest request = GetHttpWebRequest(webMethod.POST, String.Format(addrTinkerAPICallFunction, this.CoreID, function.ToString()), payload);
object jsonObj = GetHttpWebResponseAsJSONData(request, typeof(Response));
Response jsonResponse = jsonObj as Response;
// check for not connected
if (jsonResponse.Connected == false)
{
throw new ApplicationException("SparkCore not connected.");
}
return jsonResponse;
}