Exemple #1
0
 public SafeDynamicMethod(MethodInfo methodInfo)
 {
     state = (SafeMethodState)stateCache[methodInfo];
     if (state == null)
     {
         state = new SafeMethodState(DynamicReflectionManager.CreateMethod(methodInfo),
                                     new object[methodInfo.GetParameters().Length]);
         stateCache[methodInfo] = state;
     }
     this.methodInfo = methodInfo;
 }
Exemple #2
0
        /// <summary>
        /// Creates a new instance of the safe method wrapper.
        /// </summary>
        /// <param name="methodInfo">Method to wrap.</param>
        public SafeMethod(MethodInfo methodInfo)
        {
            AssertUtils.ArgumentNotNull(methodInfo, "You cannot create a dynamic method for a null value.");

            state = (SafeMethodState)stateCache[methodInfo];
            if (state == null)
            {
                state = new SafeMethodState(DynamicReflectionManager.CreateMethod(methodInfo),
                                            new object[methodInfo.GetParameters().Length]
                                            );
                stateCache[methodInfo] = state;
            }
            this.methodInfo = methodInfo;
        }
        /// <summary>
        ///     Creates a new instance of the safe method wrapper.
        /// </summary>
        /// <param name="methodInfo">Method to wrap.</param>
        public SafeMethod(MethodInfo methodInfo)
        {
            AssertUtils.ArgumentNotNull(methodInfo, "You cannot create a dynamic method for a null value.");

            _state = (SafeMethodState)_stateCache[methodInfo];
            if (_state == null)
            {
                var newState = new SafeMethodState(DynamicReflectionManager.CreateMethod(methodInfo),
                                                   new object[methodInfo.GetParameters().Length]);

                lock (_stateCache.SyncRoot)
                {
                    _state = (SafeMethodState)_stateCache[methodInfo];
                    if (_state == null)
                    {
                        _state = newState;
                        _stateCache[methodInfo] = _state;
                    }
                }
            }

            _methodInfo = methodInfo;
        }
        /// <summary>
        ///     Creates a new instance of the safe method wrapper.
        /// </summary>
        /// <param name="methodInfo">Method to wrap.</param>
        public SafeMethod(MethodInfo methodInfo)
        {
            AssertUtils.ArgumentNotNull(methodInfo, "You cannot create a dynamic method for a null value.");

            _state = (SafeMethodState) _stateCache[methodInfo];
            if (_state == null)
            {
                var newState = new SafeMethodState(DynamicReflectionManager.CreateMethod(methodInfo),
                    new object[methodInfo.GetParameters().Length]);

                lock (_stateCache.SyncRoot)
                {
                    _state = (SafeMethodState) _stateCache[methodInfo];
                    if (_state == null)
                    {
                        _state = newState;
                        _stateCache[methodInfo] = _state;
                    }
                }
            }

            _methodInfo = methodInfo;
        }
        /// <summary>
        /// Creates a new instance of the safe method wrapper.
        /// </summary>
        /// <param name="methodInfo">Method to wrap.</param>
        public SafeMethod(MethodInfo methodInfo)
        {
            AssertUtils.ArgumentNotNull(methodInfo, "You cannot create a dynamic method for a null value.");

            state = (SafeMethodState)stateCache[methodInfo];
            if (state == null)
            {
                state = new SafeMethodState(DynamicReflectionManager.CreateMethod(methodInfo),
                                            new object[methodInfo.GetParameters().Length]
                );
                stateCache[methodInfo] = state;
            }
            this.methodInfo = methodInfo;
        }