コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        private MethodInfo GetActualTypeMappedMethod(InterfaceMethod method)
        {
            var interfaceMapping = TypeOfObjectToWrap.GetInterfaceMap(method.InterfaceType);

            return(interfaceMapping.TargetMethods[
                       Array.IndexOf(interfaceMapping.InterfaceMethods, method.Info)]);
        }
コード例 #4
0
        public InterfaceProperty(InterfaceMethod getAccessor, InterfaceMethod setAccessor)
        {
            if (getAccessor == null && setAccessor == null)
            {
                throw new ArgumentException();
            }

            GetAccessor = getAccessor;
            SetAccessor = setAccessor;
        }
コード例 #5
0
        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);
        }