1
- using System ;
2
- using System . Collections . Generic ;
1
+ using System . Collections . Generic ;
3
2
using System . Linq ;
4
3
using Rubberduck . Parsing . Symbols ;
5
4
using Rubberduck . Parsing . VBA ;
6
5
using Rubberduck . VBEditor ;
6
+ using Rubberduck . Refactorings . CodeBlockInsert ;
7
7
8
8
namespace Rubberduck . Refactorings . EncapsulateField
9
9
{
@@ -19,6 +19,8 @@ public class EncapsulateFieldModel : IRefactoringModel
19
19
20
20
private IDictionary < Declaration , ( Declaration , IEnumerable < Declaration > ) > _udtFieldToUdtDeclarationMap = new Dictionary < Declaration , ( Declaration , IEnumerable < Declaration > ) > ( ) ;
21
21
22
+ private Dictionary < NewContentType , List < string > > _newContent { set ; get ; }
23
+
22
24
public EncapsulateFieldModel (
23
25
Declaration target ,
24
26
IEnumerable < IEncapsulateFieldCandidate > candidates ,
@@ -54,7 +56,10 @@ public EncapsulateFieldStrategy EncapsulateFieldStrategy
54
56
get => _encapsulationFieldStategy ;
55
57
set
56
58
{
57
- if ( _encapsulationFieldStategy == value ) { return ; }
59
+ if ( _encapsulationFieldStategy == value )
60
+ {
61
+ return ;
62
+ }
58
63
59
64
_encapsulationFieldStategy = value ;
60
65
@@ -96,27 +101,36 @@ public IEnumerable<IEncapsulateFieldCandidate> SelectedFieldCandidates
96
101
97
102
public IEnumerable < IUserDefinedTypeCandidate > UDTFieldCandidates
98
103
=> EncapsulationCandidates
99
- . Where ( v => v is IUserDefinedTypeCandidate )
100
- . Cast < IUserDefinedTypeCandidate > ( ) ;
104
+ . Where ( v => v is IUserDefinedTypeCandidate )
105
+ . Cast < IUserDefinedTypeCandidate > ( ) ;
101
106
102
107
public IEnumerable < IUserDefinedTypeCandidate > SelectedUDTFieldCandidates
103
108
=> SelectedFieldCandidates
104
- . Where ( v => v is IUserDefinedTypeCandidate )
105
- . Cast < IUserDefinedTypeCandidate > ( ) ;
109
+ . Where ( v => v is IUserDefinedTypeCandidate )
110
+ . Cast < IUserDefinedTypeCandidate > ( ) ;
106
111
107
112
public IEncapsulateFieldCandidate this [ string encapsulatedFieldTargetID ]
108
113
=> EncapsulationCandidates . Where ( c => c . TargetID . Equals ( encapsulatedFieldTargetID ) ) . Single ( ) ;
109
114
110
115
public IEncapsulateFieldCandidate this [ Declaration fieldDeclaration ]
111
116
=> EncapsulationCandidates . Where ( c => c . Declaration == fieldDeclaration ) . Single ( ) ;
112
-
117
+
118
+ public void AddContentBlock ( NewContentType contentType , string block )
119
+ => _newContent [ contentType ] . Add ( block ) ;
120
+
121
+ public Dictionary < NewContentType , List < string > > NewContent
122
+ {
123
+ set => _newContent = value ;
124
+ get => _newContent ;
125
+ }
126
+
113
127
private IObjectStateUDT _activeObjectStateUDT ;
114
128
public IObjectStateUDT ObjectStateUDTField
115
129
{
116
130
get
117
131
{
118
132
_activeObjectStateUDT = ObjectStateUDTCandidates
119
- . SingleOrDefault ( os => os . IsSelected ) ?? _newObjectStateUDT ;
133
+ . SingleOrDefault ( os => os . IsSelected ) ?? _newObjectStateUDT ;
120
134
121
135
return _activeObjectStateUDT ;
122
136
}
0 commit comments