internal Invocation CreateInvocation(InvocationVersionOne v1Invocation)
        {
            Invocation invocation = null;

            if (v1Invocation != null)
            {
                invocation = new Invocation
                {
                    Account              = v1Invocation.Account,
                    CommandLine          = v1Invocation.CommandLine,
                    EndTime              = v1Invocation.EndTime,
                    EnvironmentVariables = v1Invocation.EnvironmentVariables,
                    Machine              = v1Invocation.Machine,
                    ProcessId            = v1Invocation.ProcessId,
                    Properties           = v1Invocation.Properties,
                    ResponseFiles        = CreateResponseFilesList(v1Invocation.ResponseFiles),
                    StartTime            = v1Invocation.StartTime,
                    WorkingDirectory     = v1Invocation.WorkingDirectory
                };

                if (!string.IsNullOrWhiteSpace(v1Invocation.FileName))
                {
                    invocation.ExecutableLocation = new FileLocation
                    {
                        Uri = new Uri(v1Invocation.FileName, UriKind.RelativeOrAbsolute)
                    };
                }
            }

            return(invocation);
        }
        internal InvocationVersionOne CreateInvocationVersionOne(Invocation v2Invocation)
        {
            InvocationVersionOne invocation = null;

            if (v2Invocation != null)
            {
                invocation = new InvocationVersionOne
                {
                    Account              = v2Invocation.Account,
                    CommandLine          = v2Invocation.CommandLine,
                    EndTime              = v2Invocation.EndTimeUtc,
                    EnvironmentVariables = v2Invocation.EnvironmentVariables,
                    FileName             = v2Invocation.ExecutableLocation?.Uri?.OriginalString,
                    Machine              = v2Invocation.Machine,
                    ProcessId            = v2Invocation.ProcessId,
                    Properties           = v2Invocation.Properties,
                    ResponseFiles        = CreateResponseFilesDictionary(v2Invocation.ResponseFiles),
                    StartTime            = v2Invocation.StartTimeUtc,
                    WorkingDirectory     = v2Invocation.WorkingDirectory?.Uri?.OriginalString
                };

                if (v2Invocation.ToolConfigurationNotifications != null)
                {
                    if (_currentRun.ConfigurationNotifications == null)
                    {
                        _currentRun.ConfigurationNotifications = new List <NotificationVersionOne>();
                    }

                    IEnumerable <NotificationVersionOne> notifications = v2Invocation.ToolConfigurationNotifications.Select(CreateNotificationVersionOne);
                    _currentRun.ConfigurationNotifications = _currentRun.ConfigurationNotifications.Union(notifications).ToList();
                }

                if (v2Invocation.ToolExecutionNotifications != null)
                {
                    if (_currentRun.ToolNotifications == null)
                    {
                        _currentRun.ToolNotifications = new List <NotificationVersionOne>();
                    }

                    List <NotificationVersionOne> notifications = v2Invocation.ToolExecutionNotifications.Select(CreateNotificationVersionOne).ToList();
                    _currentRun.ToolNotifications = _currentRun.ToolNotifications.Union(notifications).ToList();
                }
            }

            return(invocation);
        }
        internal Invocation CreateInvocation(InvocationVersionOne v1Invocation,
                                             IList <NotificationVersionOne> v1ToolNotifications,
                                             IList <NotificationVersionOne> v1ConfigurationNotifications)
        {
            Invocation           invocation                 = CreateInvocation(v1Invocation);
            IList <Notification> toolNotifications          = v1ToolNotifications?.Select(CreateNotification).ToList();
            IList <Notification> configurationNotifications = v1ConfigurationNotifications?.Select(CreateNotification).ToList();;

            if (toolNotifications?.Count > 0 || configurationNotifications?.Count > 0)
            {
                if (invocation == null)
                {
                    invocation = new Invocation();
                }

                invocation.ToolExecutionNotifications     = toolNotifications;
                invocation.ToolConfigurationNotifications = configurationNotifications;
            }

            return(invocation);
        }