@@ -13,16 +13,17 @@ namespace Umbraco.Cms.Core.Packaging
13
13
public class InstallationSummary
14
14
{
15
15
public InstallationSummary ( string packageName )
16
- {
17
- PackageName = packageName ;
18
- }
16
+ => PackageName = packageName ;
17
+
18
+ public string PackageName { get ; }
19
19
20
20
public InstallWarnings Warnings { get ; set ; } = new InstallWarnings ( ) ;
21
21
22
22
public IEnumerable < IDataType > DataTypesInstalled { get ; set ; } = Enumerable . Empty < IDataType > ( ) ;
23
23
public IEnumerable < ILanguage > LanguagesInstalled { get ; set ; } = Enumerable . Empty < ILanguage > ( ) ;
24
24
public IEnumerable < IDictionaryItem > DictionaryItemsInstalled { get ; set ; } = Enumerable . Empty < IDictionaryItem > ( ) ;
25
25
public IEnumerable < IMacro > MacrosInstalled { get ; set ; } = Enumerable . Empty < IMacro > ( ) ;
26
+ public IEnumerable < IPartialView > MacroPartialViewsInstalled { get ; set ; } = Enumerable . Empty < IPartialView > ( ) ;
26
27
public IEnumerable < ITemplate > TemplatesInstalled { get ; set ; } = Enumerable . Empty < ITemplate > ( ) ;
27
28
public IEnumerable < IContentType > DocumentTypesInstalled { get ; set ; } = Enumerable . Empty < IContentType > ( ) ;
28
29
public IEnumerable < IMediaType > MediaTypesInstalled { get ; set ; } = Enumerable . Empty < IMediaType > ( ) ;
@@ -31,73 +32,55 @@ public InstallationSummary(string packageName)
31
32
public IEnumerable < IPartialView > PartialViewsInstalled { get ; set ; } = Enumerable . Empty < IPartialView > ( ) ;
32
33
public IEnumerable < IContent > ContentInstalled { get ; set ; } = Enumerable . Empty < IContent > ( ) ;
33
34
public IEnumerable < IMedia > MediaInstalled { get ; set ; } = Enumerable . Empty < IMedia > ( ) ;
34
- public string PackageName { get ; }
35
35
36
36
public override string ToString ( )
37
37
{
38
38
var sb = new StringBuilder ( ) ;
39
- var macroConflicts = Warnings . ConflictingMacros . ToList ( ) ;
40
- if ( macroConflicts . Count > 0 )
41
- {
42
- sb . Append ( "Conflicting macros found, they will be overwritten:" ) ;
43
- foreach ( IMacro m in macroConflicts )
44
- {
45
- sb . Append ( m . Alias ) ;
46
- sb . Append ( ',' ) ;
47
- }
48
- sb . AppendLine ( ". " ) ;
49
- }
50
- var templateConflicts = Warnings . ConflictingTemplates . ToList ( ) ;
51
- if ( templateConflicts . Count > 0 )
39
+
40
+ void WriteConflicts < T > ( IEnumerable < T > source , Func < T , string > selector , string message , bool appendLine = true )
52
41
{
53
- sb . Append ( "Conflicting templates found, they will be overwritten:" ) ;
54
- foreach ( ITemplate m in templateConflicts )
42
+ var result = source ? . Select ( selector ) . ToList ( ) ;
43
+ if ( result ? . Count > 0 )
55
44
{
56
- sb . Append ( m . Alias ) ;
57
- sb . Append ( ',' ) ;
45
+ sb . Append ( message ) ;
46
+ sb . Append ( string . Join ( ", " , result ) ) ;
47
+
48
+ if ( appendLine )
49
+ {
50
+ sb . AppendLine ( ) ;
51
+ }
58
52
}
59
- sb . AppendLine ( ". " ) ;
60
53
}
61
- var stylesheetConflicts = Warnings . ConflictingStylesheets . ToList ( ) ;
62
- if ( stylesheetConflicts . Count > 0 )
54
+
55
+ void WriteCount < T > ( string message , IEnumerable < T > source , bool appendLine = true )
63
56
{
64
- sb . Append ( "Conflicting stylesheets found, they will be overwritten:" ) ;
65
- foreach ( IFile m in stylesheetConflicts )
57
+ sb . Append ( message ) ;
58
+ sb . Append ( source ? . Count ( ) ?? 0 ) ;
59
+
60
+ if ( appendLine )
66
61
{
67
- sb . Append ( m . Alias ) ;
68
- sb . Append ( ',' ) ;
62
+ sb . AppendLine ( ) ;
69
63
}
70
- sb . AppendLine ( ". " ) ;
71
64
}
72
65
73
- sb . Append ( "Content items installed: " ) ;
74
- sb . Append ( ContentInstalled . Count ( ) ) ;
75
- sb . AppendLine ( ". " ) ;
76
- sb . Append ( "Media items installed: " ) ;
77
- sb . Append ( MediaInstalled . Count ( ) ) ;
78
- sb . AppendLine ( ". " ) ;
79
- sb . Append ( "Dictionary items installed: " ) ;
80
- sb . Append ( DictionaryItemsInstalled . Count ( ) ) ;
81
- sb . AppendLine ( ". " ) ;
82
- sb . Append ( "Macros installed: " ) ;
83
- sb . Append ( MacrosInstalled . Count ( ) ) ;
84
- sb . AppendLine ( ". " ) ;
85
- sb . Append ( "Stylesheets installed: " ) ;
86
- sb . Append ( StylesheetsInstalled . Count ( ) ) ;
87
- sb . AppendLine ( ". " ) ;
88
- sb . Append ( "Templates installed: " ) ;
89
- sb . Append ( TemplatesInstalled . Count ( ) ) ;
90
- sb . AppendLine ( ) ;
91
- sb . Append ( "Document types installed: " ) ;
92
- sb . Append ( DocumentTypesInstalled . Count ( ) ) ;
93
- sb . AppendLine ( ". " ) ;
94
- sb . Append ( "Media types installed: " ) ;
95
- sb . Append ( MediaTypesInstalled . Count ( ) ) ;
96
- sb . AppendLine ( ". " ) ;
97
- sb . Append ( "Data types items installed: " ) ;
98
- sb . Append ( DataTypesInstalled . Count ( ) ) ;
66
+ WriteConflicts ( Warnings ? . ConflictingMacros , x => x . Alias , "Conflicting macros found, they will be overwritten: " ) ;
67
+ WriteConflicts ( Warnings ? . ConflictingTemplates , x => x . Alias , "Conflicting templates found, they will be overwritten: " ) ;
68
+ WriteConflicts ( Warnings ? . ConflictingStylesheets , x => x . Alias , "Conflicting stylesheets found, they will be overwritten: " ) ;
69
+ WriteCount ( "Data types installed: " , DataTypesInstalled ) ;
70
+ WriteCount ( "Languages installed: " , LanguagesInstalled ) ;
71
+ WriteCount ( "Dictionary items installed: " , DictionaryItemsInstalled ) ;
72
+ WriteCount ( "Macros installed: " , MacrosInstalled ) ;
73
+ WriteCount ( "Macro partial views installed: " , MacroPartialViewsInstalled ) ;
74
+ WriteCount ( "Templates installed: " , TemplatesInstalled ) ;
75
+ WriteCount ( "Document types installed: " , DocumentTypesInstalled ) ;
76
+ WriteCount ( "Media types installed: " , MediaTypesInstalled ) ;
77
+ WriteCount ( "Stylesheets installed: " , StylesheetsInstalled ) ;
78
+ WriteCount ( "Scripts installed: " , ScriptsInstalled ) ;
79
+ WriteCount ( "Partial views installed: " , PartialViewsInstalled ) ;
80
+ WriteCount ( "Content items installed: " , ContentInstalled ) ;
81
+ WriteCount ( "Media items installed: " , MediaInstalled , false ) ;
82
+
99
83
return sb . ToString ( ) ;
100
84
}
101
85
}
102
-
103
86
}
0 commit comments