예제 #1
0
        private static void SetDynamicCachedCallSite(BinderHash hash, int knownBinderType, CallSite callSite)
        {
            switch (knownBinderType)
            {
            default:
                _unknownBinderCache[hash] = callSite;
                break;

            case KnownGet:
                _getBinderCache[hash] = callSite;
                break;

            case KnownSet:
                _setBinderCache[hash] = callSite;
                break;

            case KnownMember:
                _memberBinderCache[hash] = callSite;
                break;

            case KnownDirect:
                _directBinderCache[hash] = callSite;
                break;

            case KnownConstructor:
                _constructorBinderCache[hash] = callSite;
                break;
            }
        }
예제 #2
0
        internal static CallSite <T> CreateCallSite <T>(
            Type specificBinderType,
            int knownType,
            LazyBinder binder,
            String_OR_InvokeMemberName name,
            Type context,
            string[] argNames  = null,
            bool staticContext = false,
            bool isEvent       = false
            )
            where T : class
        {
            var tHash = BinderHash <T> .Create(name, context, argNames, specificBinderType, staticContext, isEvent, knownType != Unknown);

            lock (_binderCacheLock)
            {
                CallSite tOut;
                if (!TryDynamicCachedCallSite(tHash, knownType, out tOut))
                {
                    tOut = CallSite <T> .Create(binder());

                    SetDynamicCachedCallSite(tHash, knownType, tOut);
                }
                return((CallSite <T>)tOut);
            }
        }
예제 #3
0
        public virtual bool Equals(BinderHash other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            var tArgNames      = ArgNames;
            var tOtherArgNames = other.ArgNames;

            return
                (!(tOtherArgNames == null ^ tArgNames == null) &&
                 other.IsEvent == IsEvent &&
                 other.StaticContext == StaticContext &&
                 Equals(other.Context, Context) &&
                 (KnownBinder || Equals(other.BinderType, BinderType)) &&
                 Equals(other.DelegateType, DelegateType) &&
                 Equals(other.Name, Name) &&
                 (tArgNames == null
                  // ReSharper disable AssignNullToNotNullAttribute
                  //Exclusive Or Makes Sure this doesn't happen

                  || tOtherArgNames.SequenceEqual(tArgNames)));
            // ReSharper restore AssignNullToNotNullAttribute
        }
예제 #4
0
        private static bool TryDynamicCachedCallSite(BinderHash hash, int knownBinderType, out CallSite callSite)
        {
            switch (knownBinderType)
            {
            default:
                return(_unknownBinderCache.TryGetValue(hash, out callSite));

            case KnownGet:
                return(_getBinderCache.TryGetValue(hash, out callSite));

            case KnownSet:
                return(_setBinderCache.TryGetValue(hash, out callSite));

            case KnownMember:
                return(_memberBinderCache.TryGetValue(hash, out callSite));

            case KnownDirect:
                return(_directBinderCache.TryGetValue(hash, out callSite));

            case KnownConstructor:
                return(_constructorBinderCache.TryGetValue(hash, out callSite));
            }
        }
예제 #5
0
        public virtual bool Equals(BinderHash other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;

            var tArgNames = ArgNames;
            var tOtherArgNames = other.ArgNames;

            return
                !(tOtherArgNames == null ^ tArgNames == null)
                && other.IsEvent == IsEvent
                && other.StaticContext == StaticContext
                && Equals(other.Context, Context)
                && (KnownBinder || Equals(other.BinderType, BinderType))
                && Equals(other.DelegateType, DelegateType)
                && Equals(other.Name, Name)
                && (tArgNames == null
                // ReSharper disable AssignNullToNotNullAttribute
                //Exclusive Or Makes Sure this doesn't happen

                                 || tOtherArgNames.SequenceEqual(tArgNames));
            // ReSharper restore AssignNullToNotNullAttribute
        }