/// <summary> /// Configures the container services to use components from /// <c>Cadmus.Core</c> and <c>Cadmus.Seed</c>, plus the assemblies /// specified by <paramref name="additionalAssemblies"/>. /// This is just a helper method: at any rate, the configuration of /// the container is external to the VSM factory. You could use this /// method as a model and create your own, or call this method to /// register the components from these two assemblies, and then /// further configure the container, or add more assemblies when /// calling this via <paramref name="additionalAssemblies"/>. /// </summary> /// <param name="container">The container.</param> /// <param name="partTypeProvider">The part type provider.</param> /// <param name="additionalAssemblies">The optional additional /// assemblies.</param> /// <exception cref="ArgumentNullException">container or part type /// provider</exception> public static void ConfigureServices(Container container, IPartTypeProvider partTypeProvider, params Assembly[] additionalAssemblies) { if (container == null) { throw new ArgumentNullException(nameof(container)); } if (partTypeProvider is null) { throw new ArgumentNullException(nameof(partTypeProvider)); } // https://simpleinjector.readthedocs.io/en/latest/advanced.html?highlight=batch#batch-registration Assembly[] assemblies = new[] { // Cadmus.Seed typeof(PartSeederFactory).Assembly, // Cadmus.Core typeof(StandardItemSortKeyBuilder).Assembly }; if (additionalAssemblies?.Length > 0) { assemblies = assemblies.Concat(additionalAssemblies).ToArray(); } container.RegisterInstance(partTypeProvider); container.Collection.Register <IItemSortKeyBuilder>(assemblies); container.Collection.Register <IPartSeeder>(assemblies); container.Collection.Register <IFragmentSeeder>(assemblies); }
/// <summary> /// Initializes a new instance of the <see cref="AppRepositoryProvider"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <exception cref="ArgumentNullException">configuration</exception> public AppRepositoryProvider(IConfiguration configuration) { _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _map = new TagAttributeToTypeMap(); _map.Add(new[] { // Cadmus.Parts typeof(NotePart).GetTypeInfo().Assembly, // Cadmus.Philology.Parts typeof(ApparatusLayerFragment).GetTypeInfo().Assembly }); _partTypeProvider = new StandardPartTypeProvider(_map); }
/// <summary> /// Configures the container services to use components from /// <c>Cadmus.Core</c> and <c>Cadmus.Seed</c>, plus the assemblies /// specified by <paramref name="additionalAssemblies"/>. /// This is just a helper method: at any rate, the configuration of /// the container is external to the VSM factory. You could use this /// method as a model and create your own, or call this method to /// register the components from these two assemblies, and then /// further configure the container, or add more assemblies when /// calling this via <paramref name="additionalAssemblies"/>. /// </summary> /// <param name="container">The container.</param> /// <param name="partTypeProvider">The part type provider.</param> /// <param name="additionalAssemblies">The optional additional /// assemblies.</param> /// <exception cref="ArgumentNullException">container or part type /// provider</exception> public static void ConfigureServices(Container container, IPartTypeProvider partTypeProvider, params Assembly[] additionalAssemblies) { if (container == null) { throw new ArgumentNullException(nameof(container)); } if (partTypeProvider is null) { throw new ArgumentNullException(nameof(partTypeProvider)); } // https://simpleinjector.readthedocs.io/en/latest/advanced.html?highlight=batch#batch-registration Assembly[] assemblies = additionalAssemblies ?? Array.Empty <Assembly>(); container.RegisterInstance(partTypeProvider); container.Collection.Register <IItemSortKeyBuilder>(assemblies); container.Collection.Register <IItemBrowser>(assemblies); }
public IActionResult GetPartPins( [FromRoute] string database, [FromRoute] string id) { ICadmusRepository repository = _repositoryProvider.CreateRepository(database); string json = repository.GetPartContent(id); if (json == null) { return(new NotFoundResult()); } // remove ISODate(...) function (this seems to be a Mongo artifact) json = Regex.Replace(json, @"ISODate\(([^)]+)\)", "$1"); // Pascal-case properties json = _camelPropRegex.Replace(json, m => $"\"{m.Groups[1].Value.ToUpperInvariant()}{m.Groups[2].Value}\":"); Match typeMatch = Regex.Match(json, "\"TypeId\":\\s*\"([^\"]+)\""); if (!typeMatch.Success) { return(NotFound()); } Match roleMatch = Regex.Match(json, "\"RoleId\":\\s*\"([^\"]+)\""); string role = roleMatch.Success ? roleMatch.Groups[1].Value : null; IPartTypeProvider provider = _repositoryProvider.GetPartTypeProvider(); Type t = provider.Get(typeMatch.Groups[1].Value); IPart part = (IPart)JsonConvert.DeserializeObject(json, t); var result = (from p in part.GetDataPins() select new { p.Name, p.Value }).ToList(); return(Ok(result)); }