aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/SimpleTupleDefinitionCreator.cs
blob: 6a86639ae934cffff46b0a4b3fd8d05e8cddb7a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// 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.

namespace WixToolset.Data
{
    using System.Collections.Generic;

    internal class SimpleTupleDefinitionCreator : ITupleDefinitionCreator
    {
        private Dictionary<string, IntermediateTupleDefinition> CustomDefinitionByName { get; } = new Dictionary<string, IntermediateTupleDefinition>();

        public void AddCustomTupleDefinition(IntermediateTupleDefinition definition)
        {
            this.CustomDefinitionByName.Add(definition.Name, definition);
        }

        public bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition)
        {
            tupleDefinition = TupleDefinitions.ByName(name);

            if (tupleDefinition == null)
            {
                tupleDefinition = this.CustomDefinitionByName.GetValueOrDefault(name);
            }

            return tupleDefinition != null;
        }
    }
}