private bool KeepAsyncContext(InterfaceMethod method) { if (method.Info.Name.StartsWith("get_") || method.Info.Name.StartsWith("set_")) { var property = method.InterfaceType.GetProperty( method.Info.Name.Substring(4)); if (KeepAsyncContext(property)) { return(true); } } else { if (Attribute.GetCustomAttribute(GetActualTypeMappedMethod(method), typeof(KeepAsyncContextAttribute)) is KeepAsyncContextAttribute keepAsyncContextAttributeOfActualType) { return(keepAsyncContextAttributeOfActualType.KeepContext); } if (Attribute.GetCustomAttribute(method.Info, typeof(KeepAsyncContextAttribute)) is KeepAsyncContextAttribute keepAsyncContextAttribute) { return(keepAsyncContextAttribute.KeepContext); } } if (Attribute.GetCustomAttribute(method.InterfaceType, typeof(KeepAsyncContextAttribute)) is KeepAsyncContextAttribute keepAsyncContextAttributeOfInterfaceType) { return(keepAsyncContextAttributeOfInterfaceType.KeepContext); } return(_keepAsyncContextByDefault); }
private bool BlockCaller(InterfaceMethod method) { if (method.Info.Name.StartsWith("get_") || method.Info.Name.StartsWith("set_")) { var property = method.InterfaceType.GetProperty( method.Info.Name.Substring(4)); if (BlockCaller(property)) { return(true); } } else { if (Attribute.GetCustomAttribute(GetActualTypeMappedMethod(method), typeof(BlockCallerAttribute)) is BlockCallerAttribute) { return(true); } if (Attribute.GetCustomAttribute(method.Info, typeof(BlockCallerAttribute)) is BlockCallerAttribute) { return(true); } } if (Attribute.GetCustomAttribute(method.InterfaceType, typeof(BlockCallerAttribute)) is BlockCallerAttribute) { return(true); } return(_blockCallerByDefault); }
private MethodInfo GetActualTypeMappedMethod(InterfaceMethod method) { var interfaceMapping = TypeOfObjectToWrap.GetInterfaceMap(method.InterfaceType); return(interfaceMapping.TargetMethods[ Array.IndexOf(interfaceMapping.InterfaceMethods, method.Info)]); }
public InterfaceProperty(InterfaceMethod getAccessor, InterfaceMethod setAccessor) { if (getAccessor == null && setAccessor == null) { throw new ArgumentException(); } GetAccessor = getAccessor; SetAccessor = setAccessor; }
private bool MethodAllowsConcurrentAccess(InterfaceMethod method) { if (method.Info.Name.StartsWith("get_")) { var property = method.InterfaceType.GetProperty( method.Info.Name.Substring(4)); if (PropertyGetAllowsConcurrentAccess(property)) { return(true); } } else if (method.Info.Name.StartsWith("set_")) { var property = method.InterfaceType.GetProperty( method.Info.Name.Substring(4)); if (PropertySetAllowsConcurrentAccess(property)) { return(true); } } else { if (Attribute.GetCustomAttribute(GetActualTypeMappedMethod(method), typeof(AllowConcurrentAccessAttribute)) is AllowConcurrentAccessAttribute) { return(true); } if (Attribute.GetCustomAttribute(method.Info, typeof(AllowConcurrentAccessAttribute)) is AllowConcurrentAccessAttribute) { return(true); } } return(false); }