Esempio n. 1
0
        public ReleaseUseCase(IProject project, ReleaseData releaseData, ICatalogueRepository catalogueRepository)
        {
            ExplicitDestination = null;

            var releasePotentials = releaseData.ConfigurationsForRelease.Values.SelectMany(x => x).ToList();
            var releaseTypes      = releasePotentials.Select(rp => rp.GetType()).Distinct().ToList();

            if (releaseTypes.Count == 0)
            {
                throw new Exception("How did you manage to have multiple ZERO types in the extraction?");
            }

            if (releaseTypes.Count(t => t != typeof(NoReleasePotential)) > 1)
            {
                throw new Exception(
                          "You cannot release multiple configurations which have been extracted in multiple ways; e.g. " +
                          "one to DB and one to disk.  Your datasets have been extracted in the following ways:" +
                          Environment.NewLine + string.Join("," + Environment.NewLine, releaseTypes.Select(t => t.Name)));
            }

            var releasePotentialWithKnownDestination =
                releasePotentials.FirstOrDefault(rp => rp.DatasetExtractionResult != null);

            if (releasePotentialWithKnownDestination == null)
            {
                ExplicitSource = new NullReleaseSource <ReleaseAudit>();
            }
            else
            {
                var destinationType = catalogueRepository.MEF
                                      .GetType(
                    releasePotentialWithKnownDestination.DatasetExtractionResult.DestinationType,
                    typeof(IExecuteDatasetExtractionDestination));
                var constructor = new ObjectConstructor();
                var destinationUsedAtExtraction =
                    (IExecuteDatasetExtractionDestination)constructor.Construct(destinationType, catalogueRepository);

                FixedReleaseSource <ReleaseAudit> fixedReleaseSource =
                    destinationUsedAtExtraction.GetReleaseSource(catalogueRepository);

                ExplicitSource = fixedReleaseSource;
                // destinationUsedAtExtraction.GetReleaseSource(); // new FixedSource<ReleaseAudit>(notifier => CheckRelease(notifier));
            }

            AddInitializationObject(project);
            AddInitializationObject(releaseData);
            AddInitializationObject(catalogueRepository);

            GenerateContext();
        }
Esempio n. 2
0
 public void PreInitialize(ReleaseData value, IDataLoadEventListener listener)
 {
     _releaseData = value;
 }