| 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.Sql |
| 4 | { |
| 5 | using System; |
| 6 | using WixToolset.Data; |
| 7 | |
| 8 | public enum SqlSymbolDefinitionType |
| 9 | { |
| 10 | SqlDatabase, |
| 11 | SqlFileSpec, |
| 12 | SqlScript, |
| 13 | SqlString, |
| 14 | } |
| 15 | |
| 16 | public static partial class SqlSymbolDefinitions |
| 17 | { |
| 18 | public static IntermediateSymbolDefinition ByName(string name) |
| 19 | { |
| 20 | if (!Enum.TryParse(name, out SqlSymbolDefinitionType type)) |
| 21 | { |
| 22 | return null; |
| 23 | } |
| 24 | |
| 25 | return ByType(type); |
| 26 | } |
| 27 | |
| 28 | public static IntermediateSymbolDefinition ByType(SqlSymbolDefinitionType type) |
| 29 | { |
| 30 | switch (type) |
| 31 | { |
| 32 | case SqlSymbolDefinitionType.SqlDatabase: |
| 33 | return SqlSymbolDefinitions.SqlDatabase; |
| 34 | |
| 35 | case SqlSymbolDefinitionType.SqlFileSpec: |
| 36 | return SqlSymbolDefinitions.SqlFileSpec; |
| 37 | |
| 38 | case SqlSymbolDefinitionType.SqlScript: |
| 39 | return SqlSymbolDefinitions.SqlScript; |
| 40 | |
| 41 | case SqlSymbolDefinitionType.SqlString: |
| 42 | return SqlSymbolDefinitions.SqlString; |
| 43 | |
| 44 | default: |
| 45 | throw new ArgumentOutOfRangeException(nameof(type)); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |