private async Task Run()

in ADTTools/UploadModels/Program.cs [33:79]


        private async Task Run()
        {
            // Expand globs and wildcards for all file specs.
            IEnumerable<string> fileNames = GetFileNames(options.FileSpecs);

            // Load all the model text.
            var modelTexts = new Dictionary<string, string>();
            foreach (string fileName in fileNames)
            {
                modelTexts.Add(fileName, File.ReadAllText(fileName));
                Log.Write($"Loaded: {fileName}");
            }

            Log.Write(string.Empty);

            // Check that all model text is valid JSON (for better error reporting).
            if (!ParseModelJson(modelTexts))
            {
                return;
            }

            // Parse models.
            IReadOnlyDictionary<Dtmi, DTEntityInfo> entities = await ParseModelsAsync(modelTexts);
            if (entities == null)
            {
                return;
            }

            // Get interfaces.
            IEnumerable<DTInterfaceInfo> interfaces = from entity in entities.Values
                                                      where entity.EntityKind == DTEntityKind.Interface
                                                      select (DTInterfaceInfo)entity;
            Log.Ok($"Parsed {interfaces.Count()} models successfully.");
            Log.Write(string.Empty);

            // Order interfaces for upload.
            IEnumerable<DTInterfaceInfo> orderedInterfaces = OrderInterfaces(interfaces);

            if (options.WhatIf)
            {
                DisplayOrderedInterfaces(orderedInterfaces);
            }
            else
            {
                await UploadOrderedInterfaces(orderedInterfaces);
            }
        }