Mono.Embedding.NativeDelegateServices.Create C# (CSharp) Method

Create() private method

private Create ( Type delegateType, IntPtr icallAddr, IntPtr context, bool &created ) : NativeDelegateWrapper
delegateType System.Type
icallAddr System.IntPtr
context System.IntPtr
created bool
return NativeDelegateWrapper
        public static NativeDelegateWrapper Create(Type delegateType, IntPtr icallAddr, IntPtr context, out bool created)
        {
            created = false;

            if (delegateType == null)
                throw new ArgumentNullException("delegateType");

            if (!typeof (Delegate).IsAssignableFrom(delegateType))
                throw new ArgumentException("Must be a delegate type", "delegateType");

            Type wrapperType;

            lock (locker)
            {
                var key = new KeyValuePair<Type, IntPtr>(delegateType, icallAddr);
                if (!wrapperCache.TryGetValue(key, out wrapperType))
                {
                    wrapperType = EmitWrapper(delegateType);
                    wrapperCache.Add(key, wrapperType);
                    created = true;
                }
            }

            return (NativeDelegateWrapper) Activator.CreateInstance(wrapperType, new object[] {context});
        }