private void SaveFlattenedResources()

in src/Analyzer.TemplateProcessor/ArmTemplateProcessor.cs [342:376]


        private void SaveFlattenedResources(TemplateResource[] resources, string parentName = null, string parentType = null, string parentExpandedPath = "")
        {
            for (int i = 0; i < resources.Length; i++)
            {
                string dictionaryKey;
                var resource = resources[i];

                if (parentName != null && parentType != null)
                {
                    resource.Path = $"{flattenedResources[$"{parentName} {parentType}"].resource.Path}.resources[{i}]";

                    dictionaryKey = $"{parentName}/{resource.Name.Value} {parentType}/{resource.Type.Value}";
                }
                else
                {
                    if (resource.Path == "")
                    {
                        resource.Path = $"resources[{i}]";
                    }

                    dictionaryKey = $"{resource.Name.Value} {resource.Type.Value}";
                }

                var resourceExpandedPath = $"{(parentExpandedPath != "" ? parentExpandedPath + "." : "")}resources[{i}]";
                flattenedResources.Add(dictionaryKey, (resource, resourceExpandedPath));

                if (resource.Resources != null)
                {
                    string resourceNamePrefix = parentName == null ? "" : $"{parentName}/";
                    string resourceTypePrefix = parentType == null ? "" : $"{parentType}/";

                    SaveFlattenedResources(resource.Resources, $"{resourceNamePrefix}{resource.Name.Value}", $"{resourceTypePrefix}{resource.Type.Value}", resourceExpandedPath);
                }
            }
        }