Abp.io Data seeder from external module - abp

Abp.io data seeder works when the class implementing IDataSeedContributor is in the *.Domain project, but it's not being executed when the class is in another AbpModule.
Is there a way to tell Abp to check my module when searching for seeders?
https://docs.abp.io/en/abp/4.4/Data-Seeding

If you need to seed a data related to an other domain, it means you are dependent on to an other module. You need to add reference of the Domain project of the other module.
If you don't care about DDD layering or bounded contexts seperation to seed, just create a shared project and add your DataSeedContributors and reference to that project.
They will get executed as long as you have reference.

Related

dnn how to uniquely identify instances of the same module

I am currently building a page that is supposed to have multiple instances of the same DNN module but I'm having trouble uniquely identifying each instance. I thought the ModuleId property would do the trick but further research revealed that ModuleId is shared across all instances of that module. Does anyone know of a way to uniquely identify each instance of a DNN module?
Try using TabModuleId instead, though ModuleId is shared across all "copies" of a module, not all instances of a module.
If you were to add a module to a Page A (via the control panel), then add the same module to that same page (via the control panel), you would get a new ModuleID and a new TabModuleId
If you were to COPY a module to another page (via the control panel add existing), choosing the modules on the first page. The ModuleId of the two modules would be the same, but the TabModuleIds would be unique.

Angular: how do I init module (or service) with parameters?

I need to create a module that will be used by different applications.
Each application is using its own set of vars (application name, REST urls, ...).
How do I set inner variable, by the hosting application, in module (or in service)?
Need to init these parameters as soon as possible as the application loads.
Thanks.
In your module have a provider. That way the client application can bootstrap configuration.
Read the "Provider Recipe" section on angular's site for an example of this.
You should use the Provider recipe only when you want to expose an API for application-wide configuration that must be made before the application starts. This is usually interesting only for reusable services whose behavior might need to vary slightly between applications.

What resources do angular modules share

I would like to have more theoretical understanding how angular modules work.
When I would create one module 'clientApp' and I 'register' controller, services, factories, scope etc..., inject other services, factories, scope into the controllers. What objects are known to the 'clientApp' module?
Angular Modules
An efficient, production-ready controllers by encapsulating our functionality in a single core unit called a module.
In Angular, a module is the main way to define an AngularJS app. The module of an app is where
we’ll contain all of our application code. An app can contain several modules, each one containing
code that pertains to specific functionality.
Using modules gives us a lot of advantages, such as:
• Keeping our global namespace clean
• Making tests easier to write and keeping them clean so as to more easily target isolated
functionality
• Making it easy to share code between applications
• Allowing our app to load different parts of the code in any order
The Angular module API allows us to declare a module using the angular.module() API method.
When declaring a module, we need to pass two parameters to the method. The first is the name of
the module we are creating. The second is the list of dependencies, otherwise known as injectables.
angular.module('myApp', []);
When writing large applications, we’ll create several different modules to contain our logic. Creating a module for each piece of functionality gives us the advantage of isolation in which to write and test large features.
Properties
Angular modules have properties that we can use to inspect the module.
name (string)
The name property on the modules gives us the name of the module as a string.
requires (array of strings)
The requires property contains a list of modules (as strings) that the injector loads before the
module itself is loaded.
Better Read
ng-book -
The Complete Book on AngularJS
Ari Lerner
Download ng-book

WPF MEF Prism dependency discovery within modules

I have a WPF Prism app with a main project containing the shell and basic bootstrapping, then I have two modules for different functionality. I also have a separate Data Access project which exports the IDataRepository and DataContext objects to the MEF container. I have added the data project to my assembly catalog in the main bootsrapper and I can see it discovers those two data types.
My problem is that when in Module A, A view model tries to load an IDataRepository object through constructor injection, it throws an error. If I try the constructor injection in my main project it works fine, so it is only within the Module A that I cannot load this shared dependency.
If I export interface types within Module A, it recognises those. So it seems within a module, I can only resolve dependencies that were exported within the module, it doesn't pick up any interface types from outside the module. Is there something basic I am doing wrong?

Unity to return new instance of service

I have come across a bit of a problem while using Unity and WPF. The scenario is I have a WPF application which follows the MVVM design pattern. A have a module called ViewKDI. Within this module I have a service called ViewKDIService, the ViewKDIService service utilises another service called UserService.
Every time I load the module ViewKDI I want Unity to return me a new instance of both the ViewKDIService and the UserService.
I have put the below in the shell bootstrapper:
Container.RegisterType<IUserService, UserService>();
In the ViewKDI module I have put the following:
Container.RegisterType<IViewKDIService, ViewKDIService>();
Each time the ViewKDI module loads the ViewKDIService constructor is called. However the UserService constructor is only called the first time, this means that I am not getting a new instance of UserService.
I require unity to give me a new instance of UserService too so that I can manage this session separately from the rest of the application.
Any ideas?
Thanks
Faisal
Unity's default behaviour is to create a new instance of each object each time one is requested, so you shouldn't be seeing this behaviour.
From what I can gather from the source code and MSDN documentation (this is a good read), you can specify a "lifetime manager" object when you register a type to tell Unity how the type should be constructed and cached. Using the TransientLifetimeManager (which essentially does no caching) will cause Unity to re-create the class each time. So try this:
Container.RegisterType<IUserService, UserService>(new TransientLifetimeManager());
... and see if it creates a new UserService each time.

Resources