Exemplo n.º 1
0
		private static bool IsTypeAsVisibleAs (this TypeNode type, Member asThisMember)
		{
			if (type == null)
				return true;

			switch (type.NodeType) {
			case NodeType.Reference:
				return ((Reference) type).ElementType.IsTypeAsVisibleAs (asThisMember);
			default:
				if (type.HasGenericParameters)
					throw new NotImplementedException ();

				return IsDefinitionAsVisibleAs (type, asThisMember);
			}
		}
Exemplo n.º 2
0
		private static Member Unspecialize (Member member)
		{
			return member;
		}
Exemplo n.º 3
0
		private static bool IsInsideOf (this Member thisValue, Member thatValue)
		{
			var typeNode = thatValue as TypeNode;
			if (typeNode == null)
				return false;
			for (TypeNode declaringType = thisValue.DeclaringType; declaringType != null; declaringType = declaringType.DeclaringType) {
				if (declaringType == typeNode)
					return true;
			}
			return false;
		}
Exemplo n.º 4
0
		private static bool IsInsideSubclass (this Member member, Member thatValue)
		{
			var targetType = thatValue as TypeNode;
			if (targetType == null)
				return false;

			for (TypeNode declaringType = member.DeclaringType; declaringType != null; declaringType = declaringType.DeclaringType) {
				if (declaringType.IsAssignableTo (targetType))
					return true;
			}
			return false;
		}
Exemplo n.º 5
0
		private static bool IsDefinitionAsVisibleAs (this Member member, Member asThisMember)
		{
			Module memberModule = member.Module;
			Module asThisMemberModule = asThisMember.Module;

			for (Member mbr = member; mbr != null; mbr = mbr.DeclaringType) {
				if (!mbr.IsPublic) {
					bool visible = false;
					for (Member mbr1 = asThisMember; mbr1 != null; mbr1 = mbr1.DeclaringType) {
						if (mbr1.IsAssembly) {
							if ((mbr1.IsPrivate || mbr1.IsAssembly) && memberModule == asThisMemberModule)
								visible = true;
						} else if (mbr1.IsFamily) {
							if (mbr.IsPrivate) {
								if (IsInsideOf (mbr, mbr1) || IsInsideSubclass (mbr, mbr1.DeclaringType))
									visible = true;
							} else if (mbr.IsFamily && (mbr.DeclaringType == mbr1.DeclaringType || IsSubclassOf (mbr.DeclaringType, mbr1.DeclaringType)))
								visible = true;
						} else if (mbr1.IsFamilyOrAssembly) {
							if (mbr.IsPrivate) {
								if (memberModule == asThisMemberModule || IsInsideSubclass (mbr, mbr1.DeclaringType))
									visible = true;
							} else if (mbr.IsAssembly) {
								if (memberModule == asThisMemberModule)
									visible = true;
							} else if (mbr.IsFamily) {
								if (IsSubclassOf (mbr.DeclaringType, mbr1.DeclaringType))
									visible = true;
							} else if (mbr.IsFamilyOrAssembly && memberModule == asThisMemberModule && IsSubclassOf (mbr.DeclaringType, mbr1.DeclaringType))
								visible = true;
						} else if (mbr1.IsPrivate && mbr.IsPrivate && IsInsideOf (mbr, mbr1.DeclaringType))
							visible = true;
					}
					if (!visible)
						return false;
				}
			}
			return true;
		}
Exemplo n.º 6
0
		public static bool IsReferenceAsVisibleAs (Member member, Member asThisMember)
		{
			var type = member as TypeNode;
			if (type != null)
				return IsTypeAsVisibleAs (type, asThisMember);
			var method = member as Method;
			Member member1;
			if (method != null) {
				if (method.HasGenericParameters)
					throw new NotImplementedException ();
				member1 = method;
			} else
				member1 = Unspecialize (member);

			return IsDefinitionAsVisibleAs (member1, asThisMember);
		}