Esempio n. 1
0
        public bool CanAccess(INetObject obj)
        {
            if (obj.Access.IsEmpty)
            {
                return(true);
            }

            IScope from = CurrentScope;

            AccessModifier grantedAccess = new AccessModifier();

            grantedAccess.Add(AccessModifier.PUBLIC);

            bool sameAssembly = false;

            /*
             * if (currentAssembly == to.Assembly)
             * {
             *  sameAssembly = true;
             *  grantedAccess.Add(AccessModifier.ASSEMBLY);
             * }
             */

            if (HasAncestor(from, obj.ParentScope))
            {
                grantedAccess.Add(AccessModifier.FAMORASSEM);
                grantedAccess.Add(AccessModifier.FAMILY);
                grantedAccess.Add(AccessModifier.PRIVATE);

                if (sameAssembly)
                {
                    grantedAccess.Add(AccessModifier.FAMANDASSEM);
                }
            }

            IType fromObject = GetEnclosingType(from);

            if (fromObject != null)
            {
                if (fromObject.IsInstanceOf(GetEnclosingType(obj.ParentScope)))
                {
                    grantedAccess.Add(AccessModifier.FAMILY);

                    if (sameAssembly)
                    {
                        grantedAccess.Add(AccessModifier.FAMANDASSEM);
                    }
                }
            }

            return(grantedAccess.AccessTo(obj.Access));
        }