Пример #1
0
        public Compilation(INamespaceProvider namespaceProvider, SourceFileGrouping sourceFileGrouping, RootConfiguration configuration, ImmutableDictionary <ISourceFile, ISemanticModel>?modelLookup = null)
        {
            this.SourceFileGrouping = sourceFileGrouping;
            this.NamespaceProvider  = namespaceProvider;
            this.Configuration      = configuration;

            var fileResolver = SourceFileGrouping.FileResolver;

            this.lazySemanticModelLookup = sourceFileGrouping.SourceFiles.ToImmutableDictionary(
                sourceFile => sourceFile,
                sourceFile => (modelLookup is not null && modelLookup.TryGetValue(sourceFile, out var existingModel)) ?
                new(existingModel) :
                new Lazy <ISemanticModel>(() => sourceFile switch
            {
                BicepFile bicepFile => new SemanticModel(this, bicepFile, fileResolver, configuration),
                ArmTemplateFile armTemplateFile => new ArmTemplateSemanticModel(armTemplateFile),
                TemplateSpecFile templateSpecFile => new TemplateSpecSemanticModel(templateSpecFile),
                _ => throw new ArgumentOutOfRangeException(nameof(sourceFile)),
            }));
Пример #2
0
 public TemplateSpecSemanticModel(TemplateSpecFile sourceFile)
 {
     this.mainTemplateSemanticModel = new ArmTemplateSemanticModel(sourceFile.MainTemplateFile);
     this.SourceFile = sourceFile;
 }