public ManifestEventFieldsLookup(IEnumerable <string> manifestFilePaths, LogErrorDelegate logErrorDelegate, bool verbose)
        {
            int taskEventNamesCollisionCount = 0;

            // constructing the lookup dictionary
            this.events = new Dictionary <Tuple <string, string>, Dictionary <string, FieldDefinition> >();

            // iterating over all manifest files
            foreach (var manifestFile in manifestFilePaths)
            {
                ManifestLoader manifestLoader = new ManifestLoader();
                ManifestDefinitionDescription manifestDefinitionDescription = manifestLoader.LoadManifest(manifestFile);

                // iterating over all providers in the manifest file
                foreach (var provider in manifestDefinitionDescription.Providers)
                {
                    // including all events from the provider to the dictionary
                    foreach (var ev in provider.Events.Values)
                    {
                        try
                        {
                            Dictionary <string, FieldDefinition> fieldDictionary = new Dictionary <string, FieldDefinition>();
                            this.events.Add(Tuple.Create(ev.TaskName, ev.EventName), fieldDictionary);

                            // including all fields from the event
                            foreach (var field in ev.Fields)
                            {
                                fieldDictionary.Add(field.Name, field);
                            }
                        }
                        catch (Exception)
                        {
                            if (verbose)
                            {
                                logErrorDelegate(LogSourceId, "(TaskName: {0}, EventName: {1}) collision for UnparsedEventName: {2}", ev.TaskName, ev.EventName, ev.UnparsedEventName);
                            }

                            taskEventNamesCollisionCount++;
                        }
                    }
                }

                if (taskEventNamesCollisionCount > 0)
                {
                    logErrorDelegate(LogSourceId, "Warning - Found {0} collisions on pairs (TaskName, EventName). Parser is using first occurence. For more details use verbose mode.", taskEventNamesCollisionCount);
                }
            }
        }
        public ManifestCache LoadManifests(string manifestPath, string cacheLocation, Version version)
        {
            string versionString = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";

            if (ManifestCache == null)
            {
                ManifestCache = new ManifestCache(cacheLocation);
            }

            ManifestLoader manifest = new ManifestLoader();

            if (Directory.Exists(manifestPath) && Directory.Exists(cacheLocation))
            {
                List <string> manifestFiles = Directory.GetFiles(manifestPath, $"*{Constants.EtwManifestExtension}").ToList();
                Log.Info("manifest files:", manifestFiles);

                if (version != new Version())
                {
                    manifestFiles = manifestFiles.Where(x => Regex.IsMatch(x, Regex.Escape(versionString))).ToList();
                }
                else
                {
                    Log.Info("getting latest version");
                    string        versionPattern           = @"_(\d+?\.\d+?\.\d+?\.\d+?)(?:_|\.)";
                    Version       maxVersion               = new Version();
                    List <string> versionedManifestFiles   = manifestFiles.Where(x => Regex.IsMatch(x, versionPattern)).ToList();
                    List <string> unVersionedManifestFiles = manifestFiles.Where(x => !Regex.IsMatch(x, versionPattern)).ToList();

                    foreach (string file in versionedManifestFiles)
                    {
                        Version fileVersion = new Version(Regex.Match(file, versionPattern).Groups[1].Value);
                        if (fileVersion > maxVersion)
                        {
                            Log.Info($"setting maxVersion:{maxVersion} -> {fileVersion}");
                            maxVersion = fileVersion;
                        }
                    }

                    versionedManifestFiles = manifestFiles.Where(x => Regex.IsMatch(x, $@"_{maxVersion.Major}\.{maxVersion.Minor}\.{maxVersion.Build}\.{maxVersion.Revision}(?:_|\.)")).ToList();
                    unVersionedManifestFiles.AddRange(versionedManifestFiles);
                    manifestFiles = unVersionedManifestFiles;
                }

                Log.Info("filtered manifest files:", ConsoleColor.Cyan, null, manifestFiles);

                foreach (string manifestFile in manifestFiles)
                {
                    ManifestDefinitionDescription        description          = manifest.LoadManifest(manifestFile);
                    List <ProviderDefinitionDescription> manifestProviderList = description.Providers.ToList();

                    if (!ManifestCache.ProviderDefinitions.Keys.Any(x => manifestProviderList.Any(y => y.Guid == x)))
                    {
                        ManifestCache.LoadManifest(manifestFile);
                    }
                    else
                    {
                        Log.Warning($"manifest already loaded:{manifestFile}");
                    }
                }
            }
            else
            {
                Log.Error($"manifest path does not exist:{manifestPath} or cachelocation does not exist:{cacheLocation}");
            }

            return(ManifestCache);
        }