public static async Task CloneDefinition(Guid projectGuid, int definitionId, Guid targetProjectGuid, string targetFolderPath, string newName)
        {
            var definition = await GetDefinitionAsync(projectGuid, definitionId);

            var clonedDefinition = CloningUtility.Clone(definition);

            clonedDefinition.Id   = 0;
            clonedDefinition.Name = newName;
            clonedDefinition.Path = targetFolderPath;

            await ClientService.BuildClient.CreateDefinitionAsync(clonedDefinition);
        }
示例#2
0
        private IEnumerable <IPolicy> GetPoliciesForException(Exception ex)
        {
            string exceptionTypeName = ex.GetType().Name;
            IEnumerable <string> pollyExceptionPoliciesFromXMLFileToBeAppliedForCurrentException = _pollyTransientFailureExceptions.TransientFailureExceptions
                                                                                                   .SingleOrDefault(x => x.CommaSeperatedTransientFailureExceptions.Contains(exceptionTypeName))
                                                                                                   .CommaSeperatedPollyPoliciesNames.Split(",", StringSplitOptions.RemoveEmptyEntries)
                                                                                                   .Distinct();
            IEnumerable <IPolicy> clonedPolicies = CloningUtility.Clone(_policies);

            clonedPolicies = clonedPolicies.Where(x => pollyExceptionPoliciesFromXMLFileToBeAppliedForCurrentException.Contains(x.GetType().Name));
            IEnumerable <string> pollyExceptionPoliciesPresentInXMLFileForCurrentExceptionButNotInjectedInDependencies =
                pollyExceptionPoliciesFromXMLFileToBeAppliedForCurrentException.Except(clonedPolicies.Select(x => x.GetType().Name));

            if (pollyExceptionPoliciesPresentInXMLFileForCurrentExceptionButNotInjectedInDependencies.IsNotNullOrEmpty())
            {
                _logger.LogWarning("The following transient failures are part of the polly exception xml file for the current exception viz. "
                                   + exceptionTypeName + " but not injected as part of the dependencies : " + Environment.NewLine
                                   + pollyExceptionPoliciesPresentInXMLFileForCurrentExceptionButNotInjectedInDependencies.Aggregate((a, b) => a + Environment.NewLine + b));
            }
            return(clonedPolicies);
        }