public UserDefinedTypeMemberCandidate(IEncapsulateFieldCandidate candidate, IUserDefinedTypeCandidate udtField)
 {
     WrappedCandidate   = candidate;
     UDTField           = udtField;
     PropertyIdentifier = IdentifierName;
     BackingIdentifier  = IdentifierName;
     _hashCode          = TargetID.GetHashCode();
 }
        public IObjectStateUDT CreateObjectStateField(IUserDefinedTypeCandidate userDefinedTypeField)
        {
            if ((userDefinedTypeField.Declaration.AsTypeDeclaration?.Accessibility ?? Accessibility.Implicit) != Accessibility.Private)
            {
                throw new ArgumentException();
            }

            return(new ObjectStateFieldCandidate(userDefinedTypeField));
        }
 public UserDefinedTypeMemberCandidate(IEncapsulateFieldCandidate candidate, IUserDefinedTypeCandidate udtField)
 {
     _wrappedCandidate           = candidate;
     _rhsParameterIdentifierName = Resources.Refactorings.Refactorings.CodeBuilder_DefaultPropertyRHSParam;
     UDTField           = udtField;
     PropertyIdentifier = IdentifierName;
     BackingIdentifier  = IdentifierName;
     _uniqueID          = BuildUniqueID(candidate, UDTField);
     _hashCode          = _uniqueID.GetHashCode();
 }
Beispiel #4
0
 private void LoadUDTMemberCandidates(IUserDefinedTypeCandidate udtCandidate)
 {
     foreach (var member in udtCandidate.Members)
     {
         if (member.WrappedCandidate is IUserDefinedTypeCandidate udt)
         {
             LoadUDTMemberCandidates(udt);
         }
         _udtMemberCandidates.Add(member);
     }
 }
Beispiel #5
0
        public ObjectStateFieldCandidate(IUserDefinedTypeCandidate udtField)
            : this(udtField.IdentifierName, udtField.Declaration.AsTypeName)
        {
            if (!udtField.TypeDeclarationIsPrivate)
            {
                throw new ArgumentException();
            }

            QualifiedModuleName = udtField.QualifiedModuleName;
            _wrappedUDTField    = udtField;
        }
Beispiel #6
0
        public ObjectStateUDT(IUserDefinedTypeCandidate udt)
            : this(udt.Declaration.AsTypeName)
        {
            if (!udt.TypeDeclarationIsPrivate)
            {
                throw new ArgumentException();
            }

            FieldIdentifier = udt.IdentifierName;
            _wrappedUDT     = udt;
            _hashCode       = ($"{_qmn.Name}.{_wrappedUDT.IdentifierName}").GetHashCode();
        }
        private IEnumerable <PropertyAttributeSet> CreatePropertyAttributeSets(IUserDefinedTypeCandidate candidate)
        {
            if (candidate.TypeDeclarationIsPrivate)
            {
                var allPropertyAttributeSets = new List <PropertyAttributeSet>();
                foreach (var member in candidate.Members)
                {
                    var propertyAttributeSets = CreatePropertyAttributeSets(member);
                    var modifiedSets          = QualifyBackingField(propertyAttributeSets, propertyAttributeSet => _backingFieldQualifierFunc(candidate, propertyAttributeSet.BackingField));
                    allPropertyAttributeSets.AddRange(modifiedSets);
                }
                return(allPropertyAttributeSets);
            }

            return(new List <PropertyAttributeSet>()
            {
                CreatePropertyAttributeSet(candidate)
            });
        }
        private (Declaration TypeDeclaration, IEnumerable <Declaration> Members) GetUDTAndMembersForField(IUserDefinedTypeCandidate udtField)
        {
            var userDefinedTypeDeclaration = udtField.Declaration.AsTypeDeclaration;

            var udtMembers = _declarationFinderProvider.DeclarationFinder
                             .UserDeclarations(DeclarationType.UserDefinedTypeMember)
                             .Where(utm => userDefinedTypeDeclaration == utm.ParentDeclaration);

            return(userDefinedTypeDeclaration, udtMembers);
        }