本文整理汇总了C#中IMethodRemover.RemoveMethod方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodRemover.RemoveMethod方法的具体用法?C# IMethodRemover.RemoveMethod怎么用?C# IMethodRemover.RemoveMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodRemover
的用法示例。
在下文中一共展示了IMethodRemover.RemoveMethod方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder spec) {
var attr = type.GetCustomAttribute<NakedObjectsTypeAttribute>();
if (attr == null) {
RemoveExplicitlyIgnoredMembers(type, methodRemover);
} else {
switch (attr.ReflectionScope) {
case ReflectOver.All:
RemoveExplicitlyIgnoredMembers(type, methodRemover);
break;
case ReflectOver.TypeOnlyNoMembers:
foreach (MethodInfo method in type.GetMethods()) {
methodRemover.RemoveMethod(method);
}
break;
case ReflectOver.ExplicitlyIncludedMembersOnly:
foreach (MethodInfo method in type.GetMethods()) {
if (method.GetCustomAttribute<NakedObjectsIncludeAttribute>() == null) {
methodRemover.RemoveMethod(method);
}
}
break;
case ReflectOver.None:
throw new ReflectionException("Attempting to introspect a class that has been marked with NakedObjectsType with ReflectOver.None");
default:
throw new ReflectionException(String.Format("Unhandled value for ReflectOver: {0}", attr.ReflectionScope));
}
}
}
示例2: Process
/// <summary>
/// If no title or ToString can be used then will use Facets provided by
/// <see cref="FallbackFacetFactory" /> instead.
/// </summary>
public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder facetHolder) {
IList<MethodInfo> attributedMethods = new List<MethodInfo>();
foreach (PropertyInfo propertyInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
if (propertyInfo.GetCustomAttribute<TitleAttribute>() != null) {
if (attributedMethods.Count > 0) {
Log.Warn("Title annotation is used more than once in " + type.Name + ", this time on property " + propertyInfo.Name + "; this will be ignored");
}
attributedMethods.Add(propertyInfo.GetGetMethod());
}
}
if (attributedMethods.Count > 0) {
return FacetUtils.AddFacet(new TitleFacetViaProperty(attributedMethods.First(), facetHolder));
}
try {
MethodInfo titleMethod = FindMethod(type, MethodType.Object, PrefixesAndRecognisedMethods.TitleMethod, typeof (string), Type.EmptyTypes);
IFacet titleFacet = null;
if (titleMethod != null) {
methodRemover.RemoveMethod(titleMethod);
titleFacet = new TitleFacetViaTitleMethod(titleMethod, facetHolder);
}
MethodInfo toStringMethod = FindMethod(type, MethodType.Object, PrefixesAndRecognisedMethods.ToStringMethod, typeof (string), Type.EmptyTypes);
if (toStringMethod != null && !toStringMethod.DeclaringType.Equals(typeof (object))) {
methodRemover.RemoveMethod(toStringMethod);
}
else {
// on object do not use
toStringMethod = null;
}
MethodInfo maskMethod = FindMethod(type, MethodType.Object, PrefixesAndRecognisedMethods.ToStringMethod, typeof (string), new[] {typeof (string)});
if (maskMethod != null) {
methodRemover.RemoveMethod(maskMethod);
}
if (titleFacet == null && toStringMethod == null) {
// nothing to use
return false;
}
if (titleFacet == null) {
titleFacet = new TitleFacetViaToStringMethod(toStringMethod, maskMethod, facetHolder);
}
return FacetUtils.AddFacet(titleFacet);
}
catch {
return false;
}
}
示例3: Process
/// <summary>
/// If no title or ToString can be used then will use Facets provided by
/// <see cref="FallbackFacetFactory" /> instead.
/// </summary>
public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
IList<MethodInfo> attributedMethods = new List<MethodInfo>();
foreach (PropertyInfo propertyInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
if (propertyInfo.GetCustomAttribute<TitleAttribute>() != null) {
if (attributedMethods.Count > 0) {
Log.Warn("Title annotation is used more than once in " + type.Name + ", this time on property " + propertyInfo.Name + "; this will be ignored");
}
attributedMethods.Add(propertyInfo.GetGetMethod());
}
}
if (attributedMethods.Count > 0) {
// attributes takes priority
FacetUtils.AddFacet(new TitleFacetViaProperty(attributedMethods.First(), specification));
return;
}
try {
MethodInfo titleMethod = FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.TitleMethod, typeof (string), Type.EmptyTypes);
IFacet titleFacet = null;
if (titleMethod != null) {
methodRemover.RemoveMethod(titleMethod);
titleFacet = new TitleFacetViaTitleMethod(titleMethod, specification);
}
MethodInfo toStringMethod = FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.ToStringMethod, typeof (string), Type.EmptyTypes);
if (toStringMethod != null && !(toStringMethod.DeclaringType == typeof (object))) {
methodRemover.RemoveMethod(toStringMethod);
}
else {
// on object do not use
toStringMethod = null;
}
MethodInfo maskMethod = FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.ToStringMethod, typeof(string), new[] { typeof(string) });
if (maskMethod != null) {
methodRemover.RemoveMethod(maskMethod);
}
if (titleFacet == null && toStringMethod != null) {
titleFacet = new TitleFacetViaToStringMethod(maskMethod, specification);
}
FacetUtils.AddFacet(titleFacet);
}
catch (Exception e) {
Log.Warn("Unexpected Exception", e);
}
}
示例4: Process
public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
if (typeof (IEnumerable).IsAssignableFrom(type) && !TypeUtils.IsSystem(type)) {
MethodInfo method = FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.GetEnumeratorMethod, null, Type.EmptyTypes);
if (method != null) {
methodRemover.RemoveMethod(method);
}
}
}
示例5: Process
public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
if (IsDynamicProxyType(type)) {
foreach (MethodInfo method in type.GetMethods().Join(MethodsToRemove, mi => mi.Name, s => s, (mi, s) => mi)) {
if (methodRemover != null && method != null) {
methodRemover.RemoveMethod(method);
}
}
}
}
示例6: Process
public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder holder) {
if (typeof (IEnumerable).IsAssignableFrom(type) && !TypeUtils.IsSystem(type)) {
MethodInfo method = FindMethod(type, MethodType.Object, PrefixesAndRecognisedMethods.GetEnumeratorMethod, null, Type.EmptyTypes);
if (method != null) {
methodRemover.RemoveMethod(method);
}
}
return false;
}
示例7: Process
public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
try {
foreach (string methodName in FixedPrefixes) {
MethodInfo methodInfo = FindMethod(reflector, type, MethodType.Object, methodName, typeof (string), Type.EmptyTypes);
if (methodInfo != null) {
methodRemover.RemoveMethod(methodInfo);
}
}
}
catch (Exception e) {
Log.Error("Unexpected exception", e);
}
}
示例8: Process
public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder facetHolder) {
try {
foreach (string methodName in FixedPrefixes) {
MethodInfo methodInfo = FindMethod(type, MethodType.Object, methodName, typeof (string), Type.EmptyTypes);
if (methodInfo != null) {
methodRemover.RemoveMethod(methodInfo);
}
}
return false;
}
catch {
return false;
}
}
示例9: Process
public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
var methodPeers = new List<ValidateObjectFacet.NakedObjectValidationMethod>();
MethodInfo[] methods = FindMethods(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.ValidatePrefix, typeof (string));
if (methods.Any()) {
foreach (MethodInfo method in methods) {
ParameterInfo[] parameters = method.GetParameters();
if (parameters.Length >= 2) {
bool parametersMatch = parameters.Select(parameter => parameter.Name).Select(name => name[0].ToString(Thread.CurrentThread.CurrentCulture).ToUpper() + name.Substring(1)).All(p => ContainsField(p, type));
if (parametersMatch) {
methodPeers.Add(new ValidateObjectFacet.NakedObjectValidationMethod(method));
methodRemover.RemoveMethod(method);
}
}
}
}
IValidateObjectFacet validateFacet = methodPeers.Any() ? (IValidateObjectFacet) new ValidateObjectFacet(specification, methodPeers) : new ValidateObjectFacetNull(specification);
FacetUtils.AddFacet(validateFacet);
}
示例10: FindAndRemoveHideMethod
protected void FindAndRemoveHideMethod(IReflector reflector, IList<IFacet> facets, IMethodRemover methodRemover, Type type, MethodType methodType, string capitalizedName, ISpecification specification) {
MethodInfo method = FindMethod(reflector, type, methodType, RecognisedMethodsAndPrefixes.HidePrefix + capitalizedName, typeof (bool), Type.EmptyTypes);
if (method != null) {
methodRemover.RemoveMethod(method);
facets.Add(new HideForContextFacet(method, specification));
AddOrAddToExecutedWhereFacet(method, specification);
}
}
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:8,代码来源:MethodPrefixBasedFacetFactoryAbstract.cs
示例11: RemoveMethod
protected static void RemoveMethod(IMethodRemover methodRemover, MethodInfo method) {
if (methodRemover != null && method != null) {
methodRemover.RemoveMethod(method);
}
}
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:5,代码来源:MethodPrefixBasedFacetFactoryAbstract.cs
示例12: RemoveExplicitlyIgnoredMembers
private static void RemoveExplicitlyIgnoredMembers(Type type, IMethodRemover methodRemover) {
foreach (MethodInfo method in type.GetMethods().Where(m => m.GetCustomAttribute<NakedObjectsIgnoreAttribute>() != null)) {
methodRemover.RemoveMethod(method);
}
}