| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolset.Data |
| 4 | { |
| 5 | using WixToolset.Data.Symbols; |
| 6 | |
| 7 | public static partial class SymbolDefinitions |
| 8 | { |
| 9 | public static readonly IntermediateSymbolDefinition WixFileSearch = new IntermediateSymbolDefinition( |
| 10 | SymbolDefinitionType.WixFileSearch, |
| 11 | new[] |
| 12 | { |
| 13 | new IntermediateFieldDefinition(nameof(WixFileSearchSymbolFields.Path), IntermediateFieldType.String), |
| 14 | new IntermediateFieldDefinition(nameof(WixFileSearchSymbolFields.MinVersion), IntermediateFieldType.String), |
| 15 | new IntermediateFieldDefinition(nameof(WixFileSearchSymbolFields.MaxVersion), IntermediateFieldType.String), |
| 16 | new IntermediateFieldDefinition(nameof(WixFileSearchSymbolFields.MinSize), IntermediateFieldType.Number), |
| 17 | new IntermediateFieldDefinition(nameof(WixFileSearchSymbolFields.MaxSize), IntermediateFieldType.Number), |
| 18 | new IntermediateFieldDefinition(nameof(WixFileSearchSymbolFields.MinDate), IntermediateFieldType.Number), |
| 19 | new IntermediateFieldDefinition(nameof(WixFileSearchSymbolFields.MaxDate), IntermediateFieldType.Number), |
| 20 | new IntermediateFieldDefinition(nameof(WixFileSearchSymbolFields.Languages), IntermediateFieldType.String), |
| 21 | new IntermediateFieldDefinition(nameof(WixFileSearchSymbolFields.Attributes), IntermediateFieldType.Number), |
| 22 | new IntermediateFieldDefinition(nameof(WixFileSearchSymbolFields.Type), IntermediateFieldType.Number), |
| 23 | }, |
| 24 | typeof(WixFileSearchSymbol)); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | namespace WixToolset.Data.Symbols |
| 29 | { |
| 30 | using System; |
| 31 | |
| 32 | public enum WixFileSearchSymbolFields |
| 33 | { |
| 34 | Path, |
| 35 | MinVersion, |
| 36 | MaxVersion, |
| 37 | MinSize, |
| 38 | MaxSize, |
| 39 | MinDate, |
| 40 | MaxDate, |
| 41 | Languages, |
| 42 | Attributes, |
| 43 | Type, |
| 44 | } |
| 45 | |
| 46 | [Flags] |
| 47 | public enum WixFileSearchAttributes |
| 48 | { |
| 49 | None = 0x000, |
| 50 | IsDirectory = 0x001, |
| 51 | MinVersionInclusive = 0x002, |
| 52 | MaxVersionInclusive = 0x004, |
| 53 | MinSizeInclusive = 0x008, |
| 54 | MaxSizeInclusive = 0x010, |
| 55 | MinDateInclusive = 0x020, |
| 56 | MaxDateInclusive = 0x040, |
| 57 | DisableFileRedirection = 0x080, |
| 58 | } |
| 59 | |
| 60 | public enum WixFileSearchType |
| 61 | { |
| 62 | Path, |
| 63 | Version, |
| 64 | Exists, |
| 65 | } |
| 66 | |
| 67 | public class WixFileSearchSymbol : IntermediateSymbol |
| 68 | { |
| 69 | public WixFileSearchSymbol() : base(SymbolDefinitions.WixFileSearch, null, null) |
| 70 | { |
| 71 | } |
| 72 | |
| 73 | public WixFileSearchSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SymbolDefinitions.WixFileSearch, sourceLineNumber, id) |
| 74 | { |
| 75 | } |
| 76 | |
| 77 | public IntermediateField this[WixFileSearchSymbolFields index] => this.Fields[(int)index]; |
| 78 | |
| 79 | public string Path |
| 80 | { |
| 81 | get => (string)this.Fields[(int)WixFileSearchSymbolFields.Path]; |
| 82 | set => this.Set((int)WixFileSearchSymbolFields.Path, value); |
| 83 | } |
| 84 | |
| 85 | public string MinVersion |
| 86 | { |
| 87 | get => (string)this.Fields[(int)WixFileSearchSymbolFields.MinVersion]; |
| 88 | set => this.Set((int)WixFileSearchSymbolFields.MinVersion, value); |
| 89 | } |
| 90 | |
| 91 | public string MaxVersion |
| 92 | { |
| 93 | get => (string)this.Fields[(int)WixFileSearchSymbolFields.MaxVersion]; |
| 94 | set => this.Set((int)WixFileSearchSymbolFields.MaxVersion, value); |
| 95 | } |
| 96 | |
| 97 | public int? MinSize |
| 98 | { |
| 99 | get => (int?)this.Fields[(int)WixFileSearchSymbolFields.MinSize]; |
| 100 | set => this.Set((int)WixFileSearchSymbolFields.MinSize, value); |
| 101 | } |
| 102 | |
| 103 | public int? MaxSize |
| 104 | { |
| 105 | get => (int?)this.Fields[(int)WixFileSearchSymbolFields.MaxSize]; |
| 106 | set => this.Set((int)WixFileSearchSymbolFields.MaxSize, value); |
| 107 | } |
| 108 | |
| 109 | public int? MinDate |
| 110 | { |
| 111 | get => (int?)this.Fields[(int)WixFileSearchSymbolFields.MinDate]; |
| 112 | set => this.Set((int)WixFileSearchSymbolFields.MinDate, value); |
| 113 | } |
| 114 | |
| 115 | public int? MaxDate |
| 116 | { |
| 117 | get => (int?)this.Fields[(int)WixFileSearchSymbolFields.MaxDate]; |
| 118 | set => this.Set((int)WixFileSearchSymbolFields.MaxDate, value); |
| 119 | } |
| 120 | |
| 121 | public string Languages |
| 122 | { |
| 123 | get => (string)this.Fields[(int)WixFileSearchSymbolFields.Languages]; |
| 124 | set => this.Set((int)WixFileSearchSymbolFields.Languages, value); |
| 125 | } |
| 126 | |
| 127 | public WixFileSearchAttributes Attributes |
| 128 | { |
| 129 | get => (WixFileSearchAttributes)this.Fields[(int)WixFileSearchSymbolFields.Attributes].AsNumber(); |
| 130 | set => this.Set((int)WixFileSearchSymbolFields.Attributes, (int)value); |
| 131 | } |
| 132 | |
| 133 | public WixFileSearchType Type |
| 134 | { |
| 135 | get => (WixFileSearchType)this.Fields[(int)WixFileSearchSymbolFields.Type].AsNumber(); |
| 136 | set => this.Set((int)WixFileSearchSymbolFields.Type, (int)value); |
| 137 | } |
| 138 | |
| 139 | public bool IsDirectory |
| 140 | { |
| 141 | get { return this.Attributes.HasFlag(WixFileSearchAttributes.IsDirectory); } |
| 142 | set |
| 143 | { |
| 144 | if (value) |
| 145 | { |
| 146 | this.Attributes |= WixFileSearchAttributes.IsDirectory; |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | this.Attributes &= ~WixFileSearchAttributes.IsDirectory; |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | public bool MinVersionInclusive |
| 156 | { |
| 157 | get { return this.Attributes.HasFlag(WixFileSearchAttributes.MinVersionInclusive); } |
| 158 | set |
| 159 | { |
| 160 | if (value) |
| 161 | { |
| 162 | this.Attributes |= WixFileSearchAttributes.MinVersionInclusive; |
| 163 | } |
| 164 | else |
| 165 | { |
| 166 | this.Attributes &= ~WixFileSearchAttributes.MinVersionInclusive; |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | public bool MaxVersionInclusive |
| 172 | { |
| 173 | get { return this.Attributes.HasFlag(WixFileSearchAttributes.MaxVersionInclusive); } |
| 174 | set |
| 175 | { |
| 176 | if (value) |
| 177 | { |
| 178 | this.Attributes |= WixFileSearchAttributes.MaxVersionInclusive; |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | this.Attributes &= ~WixFileSearchAttributes.MaxVersionInclusive; |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | public bool MinSizeInclusive |
| 188 | { |
| 189 | get { return this.Attributes.HasFlag(WixFileSearchAttributes.MinSizeInclusive); } |
| 190 | set |
| 191 | { |
| 192 | if (value) |
| 193 | { |
| 194 | this.Attributes |= WixFileSearchAttributes.MinSizeInclusive; |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | this.Attributes &= ~WixFileSearchAttributes.MinSizeInclusive; |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | public bool MaxSizeInclusive |
| 204 | { |
| 205 | get { return this.Attributes.HasFlag(WixFileSearchAttributes.MaxSizeInclusive); } |
| 206 | set |
| 207 | { |
| 208 | if (value) |
| 209 | { |
| 210 | this.Attributes |= WixFileSearchAttributes.MaxSizeInclusive; |
| 211 | } |
| 212 | else |
| 213 | { |
| 214 | this.Attributes &= ~WixFileSearchAttributes.MaxSizeInclusive; |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | public bool MinDateInclusive |
| 220 | { |
| 221 | get { return this.Attributes.HasFlag(WixFileSearchAttributes.MinDateInclusive); } |
| 222 | set |
| 223 | { |
| 224 | if (value) |
| 225 | { |
| 226 | this.Attributes |= WixFileSearchAttributes.MinDateInclusive; |
| 227 | } |
| 228 | else |
| 229 | { |
| 230 | this.Attributes &= ~WixFileSearchAttributes.MinDateInclusive; |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | public bool MaxDateInclusive |
| 236 | { |
| 237 | get { return this.Attributes.HasFlag(WixFileSearchAttributes.MaxDateInclusive); } |
| 238 | set |
| 239 | { |
| 240 | if (value) |
| 241 | { |
| 242 | this.Attributes |= WixFileSearchAttributes.MaxDateInclusive; |
| 243 | } |
| 244 | else |
| 245 | { |
| 246 | this.Attributes &= ~WixFileSearchAttributes.MaxDateInclusive; |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | public bool DisableFileRedirection |
| 252 | { |
| 253 | get { return this.Attributes.HasFlag(WixFileSearchAttributes.DisableFileRedirection); } |
| 254 | set |
| 255 | { |
| 256 | if (value) |
| 257 | { |
| 258 | this.Attributes |= WixFileSearchAttributes.DisableFileRedirection; |
| 259 | } |
| 260 | else |
| 261 | { |
| 262 | this.Attributes &= ~WixFileSearchAttributes.DisableFileRedirection; |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | } |