-
Notifications
You must be signed in to change notification settings - Fork 727
/
ThirdPartyNamespaceType.cs
45 lines (41 loc) · 2.05 KB
/
ThirdPartyNamespaceType.cs
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Collections.Immutable;
using Bicep.Core.TypeSystem.Providers;
using Bicep.Core.TypeSystem.Providers.ThirdParty;
using Bicep.Core.TypeSystem.Types;
using static Bicep.Core.TypeSystem.Providers.ThirdParty.ThirdPartyResourceTypeLoader;
namespace Bicep.Core.Semantics.Namespaces
{
public static class ThirdPartyNamespaceType
{
public static NamespaceSettings Settings { get; } = new(
IsSingleton: true,
BicepProviderName: string.Empty,
ConfigurationType: null,
ArmTemplateProviderName: string.Empty,
ArmTemplateProviderVersion: string.Empty);
public static NamespaceType Create(string name, string aliasName, IResourceTypeProvider resourceTypeProvider)
{
// NamespaceConfig is not null
if (resourceTypeProvider is ThirdPartyResourceTypeProvider thirdPartyProvider && thirdPartyProvider.GetNamespaceConfiguration() is NamespaceConfiguration namespaceConfig && namespaceConfig != null)
{
return new NamespaceType(
aliasName,
new NamespaceSettings(
IsSingleton: namespaceConfig.IsSingleton,
BicepProviderName: namespaceConfig.Name,
ConfigurationType: (ObjectType?)namespaceConfig.ConfigurationObject,
ArmTemplateProviderName: namespaceConfig.Name,
ArmTemplateProviderVersion: namespaceConfig.Version),
ImmutableArray<TypeProperty>.Empty,
ImmutableArray<FunctionOverload>.Empty,
ImmutableArray<BannedFunction>.Empty,
ImmutableArray<Decorator>.Empty,
resourceTypeProvider);
}
// NamespaceConfig is required to be set for 3PProviders
throw new ArgumentException($"Please provide the following required Settings properties: Name, Version, & IsSingleton.");
}
}
}