예제 #1
0
        public PropertyInfo Property(IPropertyDeclaration propertyDeclaration)
        {
            if (_propertyCorrespondence.ContainsKey(propertyDeclaration))
            {
                return _propertyCorrespondence[propertyDeclaration];
            }

            var getMethod = propertyDeclaration.GetMethod == null ? null : propertyDeclaration.GetMethod.Resolve();
            var setMethod = propertyDeclaration.SetMethod == null ? null : propertyDeclaration.SetMethod.Resolve();

            var propertyInfo = new PropertyInfo
            {
                Text = propertyDeclaration.ToString(),
                Name = propertyDeclaration.Name,
                FullName = propertyDeclaration.Name,
                IsVirtual = getMethod != null && getMethod.Virtual
                            || setMethod != null && setMethod.Virtual,
                IsOverride = getMethod != null
                             && getMethod.Virtual
                             && !getMethod.NewSlot
                             || setMethod != null
                             && setMethod.Virtual
                             && !setMethod.NewSlot,
                IsStatic = getMethod != null && getMethod.Static
                           || setMethod != null && setMethod.Static,
                IsFinal = getMethod != null && getMethod.Final
                          || setMethod != null && setMethod.Final,
                MemberReference = propertyDeclaration
            };
            AdjustPropertyVisibility(propertyInfo, propertyDeclaration);

            _propertyCorrespondence.Add(propertyDeclaration, propertyInfo);

            propertyInfo.Icon = Images.Images.GetPropertyIcon(propertyInfo);

            return propertyInfo;
        }
예제 #2
0
        private void AdjustPropertyVisibility(PropertyInfo propertyInfo, IPropertyDeclaration propertyDeclaration)
        {
            var firstAccessor = propertyDeclaration.GetMethod == null ? null : propertyDeclaration.GetMethod.Resolve();
            var secondAccessor = propertyDeclaration.SetMethod == null ? null : propertyDeclaration.SetMethod.Resolve();
            if (firstAccessor == null)
            {
                firstAccessor = secondAccessor;
            }
            else if (secondAccessor == null)
            {
                secondAccessor = firstAccessor;
            }

            if (firstAccessor.Visibility == MethodVisibility.Public || secondAccessor.Visibility == MethodVisibility.Public)
            {
                propertyInfo.IsPublic = true;
                return;
            }
            if (firstAccessor.Visibility == MethodVisibility.Family || secondAccessor.Visibility == MethodVisibility.Family)
            {
                propertyInfo.IsProtected = true;
                return;
            }
            if (firstAccessor.Visibility == MethodVisibility.FamilyOrAssembly || secondAccessor.Visibility == MethodVisibility.FamilyOrAssembly)
            {
                propertyInfo.IsProtectedOrInternal = true;
                return;
            }
            if (firstAccessor.Visibility == MethodVisibility.Assembly || secondAccessor.Visibility == MethodVisibility.Assembly)
            {
                propertyInfo.IsInternal = true;
                return;
            }
            if (firstAccessor.Visibility == MethodVisibility.FamilyAndAssembly || secondAccessor.Visibility == MethodVisibility.FamilyAndAssembly)
            {
                propertyInfo.IsProtectedAndInternal = true;
                return;
            }
            propertyInfo.IsPrivate = true;
        }
 public PropertyViewModel(PropertyInfo propertyInfo)
     : base(propertyInfo)
 {
     _propertyInfo = propertyInfo;
 }