diff options
Diffstat (limited to 'src/WixToolset.Core/Bind/ResolveFieldsCommand.cs')
| -rw-r--r-- | src/WixToolset.Core/Bind/ResolveFieldsCommand.cs | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs index 3e680a98..af7e262a 100644 --- a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs +++ b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs | |||
| @@ -4,7 +4,9 @@ namespace WixToolset.Core.Bind | |||
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 7 | using System.Linq; | ||
| 7 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 9 | using WixToolset.Data.Tuples; | ||
| 8 | using WixToolset.Extensibility; | 10 | using WixToolset.Extensibility; |
| 9 | using WixToolset.Extensibility.Data; | 11 | using WixToolset.Extensibility.Data; |
| 10 | using WixToolset.Extensibility.Services; | 12 | using WixToolset.Extensibility.Services; |
| @@ -42,6 +44,9 @@ namespace WixToolset.Core.Bind | |||
| 42 | 44 | ||
| 43 | var fileResolver = new FileResolver(this.BindPaths, this.Extensions); | 45 | var fileResolver = new FileResolver(this.BindPaths, this.Extensions); |
| 44 | 46 | ||
| 47 | // Build the column lookup only when needed. | ||
| 48 | Dictionary<string, WixCustomTableColumnTuple> customColumnsById = null; | ||
| 49 | |||
| 45 | foreach (var sections in this.Intermediate.Sections) | 50 | foreach (var sections in this.Intermediate.Sections) |
| 46 | { | 51 | { |
| 47 | foreach (var tuple in sections.Tuples) | 52 | foreach (var tuple in sections.Tuples) |
| @@ -53,13 +58,37 @@ namespace WixToolset.Core.Bind | |||
| 53 | continue; | 58 | continue; |
| 54 | } | 59 | } |
| 55 | 60 | ||
| 61 | var fieldType = field.Type; | ||
| 62 | |||
| 63 | // Custom table cells require an extra look up to the column definition as the | ||
| 64 | // cell's data type is always a string (because strings can store anything) but | ||
| 65 | // the column definition may be more specific. | ||
| 66 | if (tuple.Definition.Type == TupleDefinitionType.WixCustomTableCell) | ||
| 67 | { | ||
| 68 | // We only care about the Data in a CustomTable cell. | ||
| 69 | if (field.Name != nameof(WixCustomTableCellTupleFields.Data)) | ||
| 70 | { | ||
| 71 | continue; | ||
| 72 | } | ||
| 73 | |||
| 74 | if (customColumnsById == null) | ||
| 75 | { | ||
| 76 | customColumnsById = this.Intermediate.Sections.SelectMany(s => s.Tuples.OfType<WixCustomTableColumnTuple>()).ToDictionary(t => t.Id.Id); | ||
| 77 | } | ||
| 78 | |||
| 79 | if (customColumnsById.TryGetValue(tuple.Fields[(int)WixCustomTableCellTupleFields.TableRef].AsString() + "/" + tuple.Fields[(int)WixCustomTableCellTupleFields.ColumnRef].AsString(), out var customColumn)) | ||
| 80 | { | ||
| 81 | fieldType = customColumn.Type; | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 56 | var isDefault = true; | 85 | var isDefault = true; |
| 57 | 86 | ||
| 58 | // Check to make sure we're in a scenario where we can handle variable resolution. | 87 | // Check to make sure we're in a scenario where we can handle variable resolution. |
| 59 | if (null != delayedFields) | 88 | if (null != delayedFields) |
| 60 | { | 89 | { |
| 61 | // resolve localization and wix variables | 90 | // resolve localization and wix variables |
| 62 | if (field.Type == IntermediateFieldType.String) | 91 | if (fieldType == IntermediateFieldType.String) |
| 63 | { | 92 | { |
| 64 | var original = field.AsString(); | 93 | var original = field.AsString(); |
| 65 | if (!String.IsNullOrEmpty(original)) | 94 | if (!String.IsNullOrEmpty(original)) |
| @@ -87,7 +116,7 @@ namespace WixToolset.Core.Bind | |||
| 87 | } | 116 | } |
| 88 | 117 | ||
| 89 | // Resolve file paths | 118 | // Resolve file paths |
| 90 | if (field.Type == IntermediateFieldType.Path) | 119 | if (fieldType == IntermediateFieldType.Path) |
| 91 | { | 120 | { |
| 92 | var objectField = field.AsPath(); | 121 | var objectField = field.AsPath(); |
| 93 | 122 | ||
| @@ -226,29 +255,5 @@ namespace WixToolset.Core.Bind | |||
| 226 | 255 | ||
| 227 | this.DelayedFields = delayedFields; | 256 | this.DelayedFields = delayedFields; |
| 228 | } | 257 | } |
| 229 | |||
| 230 | #if false | ||
| 231 | private string ResolveFile(string source, string type, SourceLineNumber sourceLineNumbers, BindStage bindStage = BindStage.Normal) | ||
| 232 | { | ||
| 233 | string path = null; | ||
| 234 | foreach (var extension in this.Extensions) | ||
| 235 | { | ||
| 236 | path = extension.ResolveFile(source, type, sourceLineNumbers, bindStage); | ||
| 237 | if (null != path) | ||
| 238 | { | ||
| 239 | break; | ||
| 240 | } | ||
| 241 | } | ||
| 242 | |||
| 243 | throw new NotImplementedException(); // need to do default binder stuff | ||
| 244 | |||
| 245 | //if (null == path) | ||
| 246 | //{ | ||
| 247 | // throw new WixFileNotFoundException(sourceLineNumbers, source, type); | ||
| 248 | //} | ||
| 249 | |||
| 250 | //return path; | ||
| 251 | } | ||
| 252 | #endif | ||
| 253 | } | 258 | } |
| 254 | } | 259 | } |
