本文整理汇总了C#中MethodData类的典型用法代码示例。如果您正苦于以下问题:C# MethodData类的具体用法?C# MethodData怎么用?C# MethodData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodData类属于命名空间,在下文中一共展示了MethodData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArgumentNullException
/// <summary>
/// Sets up an errored execute setup.
/// </summary>
/// <param name="methodData">The method data.</param>
/// <returns>A <see cref="Func{T}"/> returning an errored <see cref="Task"/> setup with the <see cref="Exception"/>.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="methodData"/> parameter is <see langword="null"/>.</exception>
Func<Task> IExecutionSetup.Setup(MethodData methodData)
{
if (methodData == null)
throw new ArgumentNullException("methodData");
return Execute;
}
示例2: StateContext
public StateContext(string jobId, MethodData methodData)
{
if (String.IsNullOrEmpty(jobId)) throw new ArgumentNullException("jobId");
JobId = jobId;
MethodData = methodData;
}
示例3: GetBaseAndImplementedMethods
public static IEnumerable<MethodData> GetBaseAndImplementedMethods(MethodData method)
{
if (!(method.Inner is MethodInfo)) // constructor
return Enumerable.Empty<MethodData>();
return Inheritance.GetBaseAndImplementedMethodsForMethod(method);
}
示例4: ToCode_given_ConstructorDataWithoutParameters_should_ReturnDefaultConstructorCode
public void ToCode_given_ConstructorDataWithoutParameters_should_ReturnDefaultConstructorCode()
{
// # Arrange.
var sut = new MethodData();
sut.Comment = new CommentData("Default constructor.");
sut.IsConstructor = true;
sut.Scope = Common.VisibilityScope.Public;
sut.Name = "MyClassName";
// # Act.
var res = sut.ToCode();
// # Assert.
Assert.AreEqual(5, res.Count);
CollectionAssert.AreEqual(
new[]
{
"/// <summary> Default constructor.",
"/// </summary>",
"public MyClassName()",
"{",
"}",
},
res.ToList());
}
示例5: GetBaseAndImplementedMethodsForMethod
private static IEnumerable<MethodData> GetBaseAndImplementedMethodsForMethod(MethodData method)
{
var bases = Inheritance.GetBaseMethods(method);
var implements = Inheritance.GetImplementedMethods(method);
return Enumerable.Concat(bases, implements);
}
示例6: JobType
public static string JobType(MethodData methodData)
{
if (methodData == null)
{
return "Could not find the target method.";
}
return methodData.Type.FullName;
}
示例7: DisplayMethod
public static string DisplayMethod(MethodData methodData)
{
if (methodData == null)
{
return null;
}
var separator = methodData.MethodInfo.IsStatic ? "." : "::";
return String.Format("{0}{1}{2}", methodData.Type.Name, separator, methodData.MethodInfo.Name);
}
示例8: Ctor_CorrectlySets_PropertyValues
public void Ctor_CorrectlySets_PropertyValues()
{
var type = typeof (TestJob);
var methodInfo = type.GetMethod("Perform");
var method = new MethodData(type, methodInfo);
Assert.Equal(type, method.Type);
Assert.Equal(methodInfo, method.MethodInfo);
Assert.False(method.OldFormat);
}
示例9: JobAsMethodPerformStrategy
public JobAsMethodPerformStrategy(
MethodData methodData,
string[] arguments)
{
if (methodData == null) throw new ArgumentNullException("methodData");
if (arguments == null) throw new ArgumentNullException("arguments");
_methodData = methodData;
_arguments = arguments;
}
示例10: GetFilters
public virtual IEnumerable<JobFilter> GetFilters(MethodData methodData)
{
var typeFilters = GetTypeAttributes(methodData)
.Select(attr => new JobFilter(attr, JobFilterScope.Type, null));
var methodFilters = GetMethodAttributes(methodData)
.Select(attr => new JobFilter(attr, JobFilterScope.Method, null));
return typeFilters.Union(methodFilters).ToList();
}
示例11: JobAsClassPerformStrategy
public JobAsClassPerformStrategy(
MethodData methodData,
Dictionary<string, string> arguments)
{
if (methodData == null) throw new ArgumentNullException("methodData");
if (arguments == null) throw new ArgumentNullException("arguments");
_methodData = methodData;
_arguments = arguments;
}
示例12: ApplyStateContextFacts
public ApplyStateContextFacts()
{
_methodData = MethodData.FromExpression(() => Console.WriteLine());
_newStateMock = new Mock<State>();
_newStateMock.Setup(x => x.Name).Returns(NewState);
_transaction = new Mock<IWriteOnlyTransaction>();
_filters = new List<IApplyStateFilter>();
_handlers = new StateHandlerCollection();
}
示例13: GetImplementedMethods
public static IEnumerable<MethodData> GetImplementedMethods(MethodData method)
{
var type = method.DeclaringType;
if (type.Inner.IsInterface)
return Enumerable.Empty<MethodData>();
return from implementation in type.ImplementedInterfaces
from map in implementation.Members.AsEnumerable()
where map.Value == method
select (MethodData)map.Key;
}
示例14: ArgumentNullException
/// <summary>
/// Sets up a reflected asynchronous <see cref="MethodBase"/> execution.
/// </summary>
/// <param name="methodData">The method data.</param>
/// <returns>A reflected asynchronous <see cref="MethodBase"/> execution.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="methodData"/> parameter is <see langword="null"/>.</exception>
Func<Task> IExecutionSetup.Setup(MethodData methodData)
{
if (methodData == null)
throw new ArgumentNullException("methodData");
_methodUnderTest = methodData.MethodUnderTest;
_parameters = methodData.Parameters;
_sut = methodData.InstanceUnderTest;
return Execute;
}
示例15: GetBaseMethods
public static IEnumerable<MethodData> GetBaseMethods(MethodData method)
{
var lastBaseMethod = method;
var baseMethod = method.Base;
while (lastBaseMethod != baseMethod) {
yield return baseMethod;
lastBaseMethod = baseMethod;
baseMethod = baseMethod.Base;
}
}