Пример #1
0
        /// <summary>
        /// Used for testing or situations where not all properties need to be specified.
        /// </summary>
        public static SampleItemsContext Create(
            ImmutableArray <SampleItem> sampleItems                = default(ImmutableArray <SampleItem>),
            ImmutableArray <ItemCardViewModel> itemCards           = default(ImmutableArray <ItemCardViewModel>),
            ImmutableArray <InteractionType> interactionTypes      = default(ImmutableArray <InteractionType>),
            ImmutableArray <InteractionType> aboutInteractionTypes = default(ImmutableArray <InteractionType>),
            ImmutableArray <Subject> subjects = default(ImmutableArray <Subject>),
            AppSettings appSettings           = null)
        {
            var context = new SampleItemsContext(
                sampleItems: sampleItems,
                itemCards: itemCards,
                interactionTypes: interactionTypes,
                subjects: subjects,
                appSettings: appSettings,
                aboutInteractionTypes: aboutInteractionTypes);

            return(context);
        }
Пример #2
0
        public static SampleItemsContext LoadContext(AppSettings appSettings, ILogger logger)
        {
            CoreStandardsXml standardsXml     = LoadCoreStandards(appSettings.SettingsConfig.CoreStandardsXMLPath);
            var accessibilityResourceFamilies = LoadAccessibility(appSettings.SettingsConfig.AccommodationsXMLPath);
            var interactionGroup = LoadInteractionGroup(appSettings.SettingsConfig.InteractionTypesXMLPath);
            ImmutableArray <Subject> subjects = LoadSubjects(appSettings.SettingsConfig.ClaimsXMLPath, interactionGroup.InteractionFamilies);

            var itemDigests = LoadItemDigests(appSettings).Result;

            var itemPatchPath   = appSettings.SettingsConfig.PatchXMLPath;
            var itemPatchRoot   = XmlSerialization.DeserializeXml <ItemPatchRoot>(filePath: itemPatchPath);
            var brailleFileInfo = BrailleManifestReader.GetBrailleFileInfo(appSettings).Result;

            var sampleItems = SampleItemTranslation.ToSampleItems(
                digests: itemDigests,
                settings: appSettings,
                resourceFamilies: accessibilityResourceFamilies,
                interactionTypes: interactionGroup.InteractionTypes,
                subjects: subjects,
                patches: itemPatchRoot.Patches,
                standardsXml: standardsXml,
                brailleFileInfo: brailleFileInfo);

            var itemCards = sampleItems
                            .Select(i => i.ToItemCardViewModel())
                            .ToImmutableArray();

            var aboutInteractionTypes = LoadAboutInteractionTypes(interactionGroup);

            SampleItemsContext context = new SampleItemsContext(
                sampleItems: sampleItems,
                itemCards: itemCards,
                interactionTypes: interactionGroup.InteractionTypes,
                subjects: subjects,
                appSettings: appSettings,
                aboutInteractionTypes: aboutInteractionTypes);

            logger.LogInformation($"Loaded {sampleItems.Length} sample items");
            logger.LogInformation($"Context loaded successfully");

            return(context);
        }