Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read CSLA config values from .NET Core config subsystem #967

Closed
rockfordlhotka opened this issue Nov 4, 2018 · 8 comments
Closed

Read CSLA config values from .NET Core config subsystem #967

rockfordlhotka opened this issue Nov 4, 2018 · 8 comments
Assignees

Comments

@rockfordlhotka
Copy link
Member

CSLA should have its own configuration section in appsettings.json file for this and further configurations.

Example (just a few of them):

{
   "csla": {
      "proxyType":"name",
      "authentication":"windows",
      "serializationFormatter":"MobileFormatter"
    }
}

Beside fluent interface, existing configuration mechanism implemented in .NET Core can be used to read from appsettings.json and other sources supported by .NET Core.

@rockfordlhotka
Copy link
Member Author

My understanding is that the .NET Core config subsystem takes the names of your settings (like you have in the json @itgoran) and flattens them for use in ENV variables or other scenarios. I don't know the exact algorithm, but something like csla-proxyType I think.

They use a precedence scheme (I don't remember the specifics) so they'll read the value from the config file, ENV variables, and maybe other sources, and there are rules as to which values ultimately "win" - which overrides the others.

In the end, the code throughout CSLA itself uses ConfigurationManager.AppSettings to access all the values, using hard-coded config value names.

So it seems to me that what we need to do is load the values from the .NET Core config subsystem, then map those values into the pre-defined AppSettings dictionary for use by all the existing code.

That doesn't seem too difficult.

@rockfordlhotka
Copy link
Member Author

rockfordlhotka commented Nov 5, 2018

I assembled a list of the settings keys:

CslaAuthentication
CslaAuthorizationProvider
CslaAutoCloneOnUpdate
CslaDataPortalActivator
CslaDataPortalExceptionInspector
CslaDataPortalInterceptor
CslaDataPortalProxy
CslaDataPortalProxyFactory
CslaDataPortalReturnObjectOnException
CslaDataPortalUrl
CslaDefaultTransactionIsolationLevel
CslaDefaultTransactionTimeoutInSeconds
CslaIsInRoleProvider
CslaMobileFactoryLoader
CslaObjectFactoryLoader
CslaPrincipalCacheSize
CslaPropertyChangedMode
CslaPropertyInfoFactory
CslaReader
CslaSerializationFormatter
CslaWriter
dbProvider

The new fluent types in Csla.Configuration should provide a guide to the hierarchy we'd want to use in the json. This is also a good opportunity to have someone (@itgoran) really review the choices I made in how I grouped things in the fluent API - so if I put something in an odd place we can discuss where it should belong.

@rockfordlhotka rockfordlhotka moved this from To do to In progress in Version 4.9.0 Nov 5, 2018
@itgoran
Copy link
Member

itgoran commented Nov 5, 2018

Great @rockfordlhotka , I was doing exactly the same thing.
Do you agree with the idea to use json like syntax, without CSLA prefix, since it will be in csla section?
Example:
1.

"csla": {
    "Authentication":"windows",
    "AuthorizationProvider":"...",
    "AutoCloneOnUpdate":"..."
}

or
2. we should proceed with the same key names under "csla" section?

@rockfordlhotka
Copy link
Member Author

I like it without the CSLA prefix - much cleaner.

Also, if we sub-group things like in the fluent API then (excuse my poor json):

"csla": {
     "dataportal": {
          "AutoCloneOnUpdate":"..."
      },
    "Authentication":"windows",
    "AuthorizationProvider":"...",
}

Is that possible?

@itgoran
Copy link
Member

itgoran commented Nov 5, 2018

Yes, it is.

Also, additional 'grouping' for 'PropertyChanged' and 'DefaultTransaction' can be performed.

  1. Should we do this?
"csla": {
   "DefaultTransaction": {
        "IsolationLevel":"..."
        "TimeoutInSeconds":"..."
    },
    "Property": {
      "ChangedMode":"..",
      "InfoFactory":"..."
    }
}

  1. Additionally, where a limited set of values can be applied (such as SerializationFormatter), should we log a warning and use the default value?

@rockfordlhotka
Copy link
Member Author

Again, I'd like the fluent API and this json model to line up. Right now I've broken the fluent API into fairly coarse groups

image

https://github.com/MarimerLLC/csla/tree/master/Source/Csla.Shared/Configuration

The groups are based on the subsystem of CSLA that uses/needs the config setting value.

@rockfordlhotka
Copy link
Member Author

Additionally, where a limited set of values can be applied (such as SerializationFormatter), should we log a warning and use the default value?

This is a good idea, though unfortunately some of the config values are overloaded in their meaning.

For example, CslaSerializationFormatter can be one of:

  • BinaryFormatter
  • MobileFormatter
  • NetDataContractSerializer
  • MyProject.MyFormatter, MyProject (assembly qualified type name)

itgoran added a commit to itgoran/csla that referenced this issue Nov 14, 2018
Load configuration for csla using 'csla' section from appsettings.json file.
Add tests for testing configurations.
itgoran added a commit to itgoran/csla that referenced this issue Nov 15, 2018
itgoran added a commit to itgoran/csla that referenced this issue Nov 21, 2018
All configurations are written into ConfigurationManager.AppSettings
Add clean context before and after tests
Version 4.9.0 automation moved this from In progress to Done Nov 21, 2018
rockfordlhotka added a commit to rockfordlhotka/csla that referenced this issue Jan 3, 2019
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Version 4.9.0
  
Done
Development

No branches or pull requests

2 participants