Exemplo n.º 1
0
        private static void InitOrReset(IEnumerable <SuppressionManagerInitInfo> suppressionFileInfos,
                                        Func <ISuppressionFileSystemService> fileSystemServiceFabric,
                                        Func <IIOErrorProcessor> errorProcessorFabric,
                                        Func <ICustomBuildActionSetter> buildActionSetterFabric)
        {
            suppressionFileInfos = suppressionFileInfos ?? Enumerable.Empty <SuppressionManagerInitInfo>();

            lock (_initializationLocker)
            {
                if (Instance == null)
                {
                    ISuppressionFileSystemService fileSystemService;

                    if (fileSystemServiceFabric == null)
                    {
                        IIOErrorProcessor errorProcessor = errorProcessorFabric?.Invoke();
                        fileSystemService = new SuppressionFileWithChangesTrackingSystemService(errorProcessor);
                    }
                    else
                    {
                        fileSystemService = fileSystemServiceFabric();
                    }

                    ICustomBuildActionSetter customBuildActionSetter = buildActionSetterFabric?.Invoke();
                    Instance = new SuppressionManager(fileSystemService, customBuildActionSetter);
                }
                else
                {
                    Instance.Clear();
                }

                Instance.LoadSuppressionFiles(suppressionFileInfos);
            }
        }
        public static SuppressionFileSchemaValidator Create(IXmlSchemaProvider customXmlSchemaProvider = null,
                                                            IIOErrorProcessor errorProcessor           = null)
        {
            IXmlSchemaProvider xmlSchemaProvider = customXmlSchemaProvider ?? new EmbeddedResourceXmlSchemaProvider();
            XmlSchema          schema;

            try
            {
                schema = xmlSchemaProvider.GetXmlSchema();
            }
            catch (Exception e)
            {
                schema = null;
                errorProcessor?.ProcessError(e);
            }

            if (schema == null)
            {
                Exception exception = new Exception("Failed to load schema for the suppression file. The suppression file won't be validated");
                errorProcessor?.ProcessError(exception);
                return(null);
            }

            return(new SuppressionFileSchemaValidator(schema));
        }
 protected SuppressionFileSystemServiceBase(IIOErrorProcessor errorProcessor, SuppressionFileValidation customValidation)
 {
     ErrorProcessor = errorProcessor ?? new DefaultIOErrorProcessor();
     FileValidation = customValidation ?? new SuppressionFileValidation(ErrorProcessor);
 }
 public SuppressionFileWithChangesTrackingSystemService(IIOErrorProcessor errorProcessor, SuppressionFileValidation customValidation) :
     base(errorProcessor, customValidation)
 {
 }
 public SuppressionFileWithChangesTrackingSystemService(IIOErrorProcessor errorProcessor) :
     base(errorProcessor, null)
 {
 }
        protected virtual IEnumerable <ISuppressionFileValidator> GetAggregatedValidators(IIOErrorProcessor errorProcessor)
        {
            var xmlSchemaValidator = SuppressionFileSchemaValidator.Create(errorProcessor: errorProcessor);

            if (xmlSchemaValidator != null)
            {
                yield return(xmlSchemaValidator);
            }
        }
 public SuppressionFileValidation(IIOErrorProcessor errorProcessor)
 {
     ErrorProcessor       = errorProcessor;
     AggregatedValidators = GetAggregatedValidators(errorProcessor)?.Where(validator => validator != null).ToImmutableArray() ??
                            ImmutableArray <ISuppressionFileValidator> .Empty;
 }
 public SuppressionFileTestService(IIOErrorProcessor errorProcessor, SuppressionFileValidation customValidation) :
     base(errorProcessor, customValidation)
 {
 }
 public SuppressionFileTestService(IIOErrorProcessor errorProcessor) :
     base(errorProcessor, null)
 {
 }
 public SuppressionFileSystemService(IIOErrorProcessor errorProcessor)
 {
     ErrorProcessor = errorProcessor ?? new DefaultIOErrorProcessor();
 }