Exemple #1
0
        public CachedVariable(object syncTarget, String fieldName, bool IsLocked = false)
        {
            mLocker = new Locker(IsLocked);
            Type TargetType = syncTarget.GetType();

            this.mSyncTarget = syncTarget;

            MemberInfo[] infos = null;
            infos = TargetType.GetMember("set_" + fieldName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | BindingFlags.Instance);
            if (infos.Length > 0)
            {
                mMemberInfo = infos[0];
                mIsSetter   = true;
            }
            else
            {
                mMemberInfo = TargetType.GetMethod("set_" + fieldName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | BindingFlags.Instance);
                if (mMemberInfo != null)
                {
                    mIsSetter = true;
                }
                else
                {
                    TargetType.GetMember(fieldName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | BindingFlags.Instance);
                    if (infos.Length > 0)
                    {
                        mMemberInfo = infos[0];
                        if (mMemberInfo is System.Reflection.PropertyInfo)
                        {
                            mIsProperty = true;
                        }
                        else if (mMemberInfo is System.Reflection.FieldInfo)
                        {
                            mIsProperty = false;
                        }
                    }
                }
            }
        }
Exemple #2
0
 public DynamicAttributes(bool bLocked = true)
 {
     this.locked = bLocked;
     mLocker     = new Locker(this.locked);
 }