本文整理汇总了C#中System.Methods类的典型用法代码示例。如果您正苦于以下问题:C# Methods类的具体用法?C# Methods怎么用?C# Methods使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Methods类属于System命名空间,在下文中一共展示了Methods类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public void Build(TypeBuilder typeBuilder, FieldBuilder injectionSetField, Type injectionType)
{
var parameterTypes = new[] { typeof(string) };
var methods = new Methods(typeBuilder, _methodName, parameterTypes);
var injectionMethod = injectionType.GetMethod(_methodName, new[] { typeof(BaseType), typeof(string) });
var il = methods.GetILGenerator(injectionType);
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldarg_1);
il.Emit(OpCodes.Call, methods.BaseMethod);
il.EmitGetInjections(injectionSetField, injectionType);
il.EmitInjectionLoop(x =>
{
x.Emit(OpCodes.Ldarg_0);
x.Emit(OpCodes.Ldarg_1);
x.Emit(OpCodes.Callvirt, injectionMethod);
});
il.Emit(OpCodes.Ret);
}
示例2: GetResponse
private static BaseResponse GetResponse(Methods methodCalled, returntype sfgReturn)
{
string className = "SFGWrapper.HeartbeatTranslators";
BaseResponse baseResponse = new BaseResponse();
foreach (var item in sfgReturn.error)
{
Message ahError = new Message(item.errno, MessageSources.Heartbeat);
foreach (string message in item.errmsg)
{
ahError.SfgMessages.Add(message);
}
baseResponse.Messages.Add(ahError);
}
switch (methodCalled)
{
case Methods.PING:
PingResponse heartbeatServiceResponse = new PingResponse();
heartbeatServiceResponse.Success = sfgReturn.success;
baseResponse.TypedResponse = heartbeatServiceResponse;
break;
}
baseResponse.TypedResponse.Success = sfgReturn.success;
baseResponse.TypedResponse.Info = Utilities.GetInfo(sfgReturn.response.INFO);
baseResponse.TypedResponse.MemoryUsed = sfgReturn.response.MEMORY_USED;
baseResponse.TypedResponse.Protocol = sfgReturn.response.PROTOCOL;
baseResponse.TypedResponse.RoundtripTime = sfgReturn.response.ROUNDTRIP_TIME;
baseResponse.TypedResponse.Server = sfgReturn.response.SERVER;
baseResponse.TypedResponse.TimeElapsed = sfgReturn.response.TIME_ELAPSED;
baseResponse.TypedResponse.Version = sfgReturn.response.VERSION;
return baseResponse;
}
示例3: DescribeMethods
internal virtual Methods DescribeMethods()
{
Methods methods = new Methods();
methods.Add(new Method("GetWorklistItems", MethodType.List, new MetaData("Get Worklist Items", "Returns a collection of worklist items."), GetRequiredProperties("GetWorklistItems"), GetMethodParameters("GetWorklistItems"), GetInputProperties("GetWorklistItems"), GetReturnProperties("GetWorklistItems")));
methods.Add(new Method("LoadWorklistItem", MethodType.Read, new MetaData("Load Worklist Item", "Returns the specified worklist item."), GetRequiredProperties("LoadWorklistItem"), GetMethodParameters("LoadWorklistItem"), GetInputProperties("LoadWorklistItem"), GetReturnProperties("LoadWorklistItem")));
return methods;
}
示例4: SelectNonMethodCallExpressionWithoutReturnThrows
public void SelectNonMethodCallExpressionWithoutReturnThrows()
{
var sut = new Methods<ClassWithMethods>();
Expression<Action<ClassWithMethods>> nonMethodCallExpression =
_ => new object();
Assert.Throws<ArgumentException>(
() => sut.Select(nonMethodCallExpression));
}
示例5: Sut_ProcessCommand_VerifyGuardClauses
public void Sut_ProcessCommand_VerifyGuardClauses(
GuardClauseAssertion assertion,
IAsyncCommand command)
{
var method = new Methods<ConcurrencyExecutionAsyncCommandBus>()
.Select(sut => sut.ProcessCommand(command));
assertion.Verify(method);
}
示例6: Abort
/// <summary>
/// Aborts the specified method detour.
/// </summary>
/// <param name="method">The method.</param>
public static void Abort(Methods method)
{
MethodDetoursBase detours;
if (TryGetMethodDetours(method, out detours))
{
detours.Abort();
}
}
示例7: VerifyMethodMemberCallsVerifyMethod
public void VerifyMethodMemberCallsVerifyMethod()
{
var sut = new Mock<IdiomaticAssertion> { CallBase = true }.Object;
var method = new Methods<ClassWithMembers>().Select(x => x.PublicMethod());
sut.Verify((MemberInfo)method);
sut.ToMock().Verify(x => x.Verify(method));
}
示例8: LoadBindings
private void LoadBindings()
{
this.treeView1.Nodes.Clear();
this.treeView1.DrawMode = TreeViewDrawMode.OwnerDrawText;
this.treeView1.DrawNode += new DrawTreeNodeEventHandler(DrawNode);
Methods _methods = new Methods();
TemplateCustomXML tXML = _methods.ReadXML<TemplateCustomXML>(Globals.ThisAddIn.Application.ActiveDocument);
Tools.Models.Template _temp = null;
if (tXML != null)
{
_temp = _temp = ThisAddIn._document<Tools.Models.Template>(tXML.TemplateID);//
_temp.AutoDocuments.ForEach(au =>
{
au = _unitOfWork.AutoDocumentRepository.FindBy(id => id.AutoDocumentID == au.AutoDocumentID, "BookMarkDatas");
TreeNode document = new TreeNode(au.Name);
document.Name = au.AutoDocumentID;
_temp.BookMarks.ForEach(bkmk =>
{
var bkd = au.BookMarkDatas.Where(aubd => aubd.BookMarkID == bkmk.BookMarkID).FirstOrDefault();
if (bkd == null)
{
var node = new TreeNode(bkmk.BookmarkName);
node.Tag = bkmk.BookmarkName;
node.Name = bkmk.BookMarkID;
node.ForeColor = System.Drawing.Color.Red;
document.Nodes.Add(node);
// document.ForeColor = System.Drawing.Color.Black;
document.ForeColor = System.Drawing.Color.Red;
}
else
{
var node = new TreeNode((bkmk.BookmarkName + " = " + bkd.BookMarkValue));
node.Tag = bkmk.BookmarkName;
node.Name = bkmk.BookMarkID;
document.Nodes.Add(node);
}
});
document.Checked = document.Nodes.Descendants().Where(n => n.ForeColor == System.Drawing.Color.Red).Any() ? false : true;
this.treeView1.Nodes.Add(document);
this.treeView1.CheckBoxes = true;
});
}
}
示例9: NestedSummary
public void NestedSummary()
{
serializer = new XmlSerializer(typeof (Methods));
var methods =new Methods(null);
serializer.Serialize(writer, methods);
string result = textWriter.ToString();
Assert.AreEqual(null, result);
}
示例10: QueryParameterLessMethodWithReturnValueUsingLinqSyntax
public void QueryParameterLessMethodWithReturnValueUsingLinqSyntax()
{
var sut = new Methods<ClassWithMethods>();
var actual = from x in sut select x.OmitParametersWithReturnValue();
var expected = typeof(ClassWithMethods).GetMethod("OmitParametersWithReturnValue");
Assert.Equal(expected, actual);
}
示例11: CreateReturnsEmptyCommandIfTestMethodIsParameterized
public void CreateReturnsEmptyCommandIfTestMethodIsParameterized()
{
var sut = new FactCommandFactory();
var method = new Methods<FactCommandFactoryTest>().Select(x => x.ParameterizedMethod(null, 0));
var actual = sut.Create(Reflector.Wrap(method), null);
Assert.Empty(actual);
}
示例12: RequestAsync
/// <summary>
/// Create a client that connects to the SendGrid Web API
/// </summary>
/// <param name="method">HTTP verb, case-insensitive</param>
/// <param name="endpoint">Resource endpoint, do not prepend slash</param>
/// <param name="data">An JObject representing the resource's data</param>
/// <returns>An asyncronous task</returns>
private async Task<HttpResponseMessage> RequestAsync(Methods method, string endpoint, JObject data)
{
using (var client = new HttpClient())
{
try
{
client.BaseAddress = _baseUri;
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaType));
if (!string.IsNullOrWhiteSpace(_userName) && !string.IsNullOrWhiteSpace(_password))
{
var byteArray = Encoding.ASCII.GetBytes(string.Format("{0}:{1}", _userName, _password));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
}
else
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _apiKey);
}
client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "sendgrid/" + Version + ";csharp");
switch (method)
{
case Methods.GET:
return await client.GetAsync(endpoint);
case Methods.POST:
return await client.PostAsJsonAsync(endpoint, data);
case Methods.PATCH:
endpoint = _baseUri + endpoint;
StringContent content = new StringContent(data.ToString(), Encoding.UTF8, MediaType);
HttpRequestMessage request = new HttpRequestMessage
{
Method = new HttpMethod("PATCH"),
RequestUri = new Uri(endpoint),
Content = content
};
return await client.SendAsync(request);
case Methods.DELETE:
return await client.DeleteAsync(endpoint);
default:
HttpResponseMessage response = new HttpResponseMessage();
response.StatusCode = HttpStatusCode.MethodNotAllowed;
var message = "{\"errors\":[{\"message\":\"Bad method call, supported methods are GET, POST, PATCH and DELETE\"}]}";
response.Content = new StringContent(message);
return response;
}
}
catch (Exception ex)
{
HttpResponseMessage response = new HttpResponseMessage();
string message;
message = (ex is HttpRequestException) ? ".NET HttpRequestException" : ".NET Exception";
message = message + ", raw message: \n\n";
response.Content = new StringContent(message + ex.Message);
return response;
}
}
}
示例13: SelectParameterLessReturnsCorrectMethod
public void SelectParameterLessReturnsCorrectMethod()
{
var sut = new Methods<ClassWithMethods>();
MethodInfo actual = sut.Select(x => x.OmitParameters());
var expected = typeof(ClassWithMethods).GetMethod("OmitParameters");
Assert.Equal(expected, actual);
}
示例14: CreateDoesNotCreateTestFixtureForNonParameterizedMethod
public void CreateDoesNotCreateTestFixtureForNonParameterizedMethod()
{
var sut = new TestCaseCommandFactory();
var method = new Methods<TestClass>().Select(x => x.TestMethod());
var factory = Mocked.Of<ISpecimenBuilderFactory>();
sut.Create(Reflector.Wrap(method), factory);
factory.ToMock().Verify(x => x.Create(It.IsAny<ITestMethodContext>()), Times.Never());
}
示例15: Server
public Server(int port)
{
Version = 1;
Methods = new Methods();
Subscriptions = new Subscriptions();
Publications = new Publications();
new PublicationMethods(this).AttachMethods();
var messageMethods = new MessageMethods(this).GetMethods();
var messageProcessor = new MessageProcessor(messageMethods);
_messageQueue = new ResultQueue<KeyValuePair<IWebSocketConnection, string>>(messageProcessor);
_connector = new Connector(this, "127.0.0.1", port);
}