예제 #1
0
        public Delegate GetDelegate(CallInfo_ callInfo, Func <Delegate> func)
        {
            Delegate action;
            bool     exist;

            readerWriterLock.EnterReadLock();
            try
            {
                exist = _Map.TryGetValue(callInfo, out action);
            }
            finally
            {
                readerWriterLock.ExitReadLock();
            }

            if (exist)
            {
                return(action);
            }

            readerWriterLock.EnterWriteLock();
            try
            {
                if (!_Map.ContainsKey(callInfo))
                {
                    action = func();
                    _Map.Add(callInfo, action);
                }
            }
            finally
            {
                readerWriterLock.ExitWriteLock();
            }
            return(action);
        }
예제 #2
0
 protected MemberInfo GetAttribute(CallInfo_ call)
 {
     if (call.MemberTypes == MemberTypes.Property)
     {
         PropertyInfo member = call.TargetType.GetProperty(call.Name, BindingFlags.NonPublic | BindingFlags.Public | ScopeFlag);
         if (member != null)
         {
             return(member);
         }
         throw new MissingMemberException((call.IsStatic ? "Static property" : "Property") + " '" + call.Name + "' does not exist");
     }
     if (call.MemberTypes == MemberTypes.Field)
     {
         FieldInfo field = call.TargetType.GetField(call.Name, BindingFlags.NonPublic | BindingFlags.Public | ScopeFlag);
         if (field != null)
         {
             return(field);
         }
         throw new MissingFieldException((call.IsStatic ? "Static field" : "Field") + " '" + call.Name + "' does not exist");
     }
     throw new ArgumentException(call.MemberTypes + " is not supported");
 }
예제 #3
0
 protected AttributeEmitter(CallInfo_ callInfo, DelegateCache cache)
     : base(callInfo, cache)
 {
 }
예제 #4
0
 public CtorInvocationEmitter_(CallInfo_ callInfo, DelegateCache cache)
     : base(callInfo, cache)
 {
 }
예제 #5
0
 protected BaseEmitter_(CallInfo_ callInfo, DelegateCache cache)
 {
     this.CallInfo = callInfo;
     this.Cache    = cache;
 }
예제 #6
0
 public AttributeSetEmitter(CallInfo_ callInfo, DelegateCache cache)
     : base(callInfo, cache)
 {
 }
예제 #7
0
 protected InvocationEmitter_(CallInfo_ callInfo, DelegateCache cache)
     : base(callInfo, cache)
 {
 }