I am using app.config appsetting to write configuration. How will we use Header in file sink using app.config - app-config

Using code i am able to add header in file log:
WriteTo.File("logheadertest123.dll",
hooks: new Serilog.Sinks.File.Header.HeaderWriter(headerFactory))
We should be able to Add Header in Files using app.config
How can i achieve this in app.config?

Related

Is it possible to use properties file for translation in reactjs

I want to add i18n to my project by using intl module in reactjs. I've tried to translate by using json files. I achieved this purpose by using json files. But i want to use .properties files. It was very easy to translate content by using .json files. When i use properties or properties-reader modules i got error as "fs.fileRead is not a function" or "fs.fileReadAsync is not a function!" Is there any way to translate the content if i convert json files to properties files?
Here is properties file:
mainDashboard=Main Dashboard
el=Entity Library
cl=Content Library
elPerson=Person
elCompany=Company
elGroup=Group
elActivity=Activity
clManagement=Content Management
user=User user

react storybook load csv file

I have a quick question regarding how to load a static file in React storybook framework. Currently, I created a storybook by following the instruction in create-react-app.
Now, I am trying to load a csv file containing some data to visualize. For this, I placed the csv file under public folder by following the instruction here.
However, I couldn't load the file. Any suggestions?
The default webpack config storybook provides would not allow importing csv files; it only supports media files like images in the example.
What you'll want to do is add this custom loader, dsv-loader, to your storybook webpack config using Extend Mode. You will then be able to import the csv data as a javascript object.

Custom bower dependency using ng-translate : 404 error when loading JSON resource file

I have created a directive that uses angular-translate and it is working fine with this configuration :
$translateProvider.useSanitizeValueStrategy('escape');
$translateProvider.useStaticFilesLoader({
prefix: 'i18n/messages_',
suffix: '.json'
});
$translateProvider.preferredLanguage('fr');
$translateProvider.fallbackLanguage('fr');
$translateProvider.useLocalStorage();
and two files in i18n folders :
* messages_en.json
* messages_fr.json
Now I want this directive to be usable in another angular application so I use it as a bower dependency of my new application with all necessary .js and .html needed but the json files in a single .js file using templateCache.
The directive is working in my new application, however my new application is trying to load the json file from http://localhost:9000/i18n/messages_fr.json ans gives a 404 error.
This error is normal as I do not include the json files in my dependency, however I do not not know where and how I should. If I include them in my bower depdency or add it in templateCache, it is not working.
An easy solution is to copy the file in a i18n/ folder of my application but it is not what I want, I want to reuse the files defined with my directive. I tried modifying the useStatidFilesLoader attributes but without success so far.
EDIT
I figured the real problem was I intended to use two configurations of the translateProvider :
- one with common messages file in my dependency config
- another one with another message file name in my new application config.
But as it is a provider, hence a singleton, only one configuration gets executed. So it is not possible to load messages from two different files or I missed something in ngtranslate configuration.
What I did is including the common messages file in my bower dependency and add a grunt task in my new application that merge this message file with my new application message file. To do this I use grunt-merge-json.
I had the same question and here is your answer. All you need is
$translateProvider.useLoaderCache('$templateCache');
Would it be possible to support the $templateCache?

Re-compile config file for WPF application?

After build my solution (WPF application), the config file is created in project\bin\debug folder. Whenever a change is made to this config file, I have to re-compile/rebuild the project to pull the changes from the config file.
Is there a way to avoid re-compiling the project after making a change in config?
This somehow throws the whole purpose of config file.
If you talk about the App.config file (an XML file where you usually put appSettings, connectionStrings, etc): it is possible to modify this one without to recompile your project / solution. Just navigate to the project\bin\debug folder, there you'll find a file that is called {AssemblyName}.exe.config which you can edit (actually, this is a renamed version of the App.config file, this happens when the build process copies it to the output directory).
If you talk about XAML related files: these are by default not configurable because they get translated to BAML (Binary Application Markup Language) files that are embedded to the assembly in a default WPF project. If you change those you have to recompile.
You do not need to recompile your project. Your assumption is wrong.
if you edit OutputDir\{appname}.exe.config, then it will take effect immediatelly. However, if you rebuild your app, this config file is overwritten by app.config from your project folder

Passing in a file path to FileReader

Using Netbeans, I am trying to pack some text file resources that are read by a FileReader into a JAR file, but since the text files aren't located in the resources folder, the JAR cannot find them. How can I tell the filereader where to look for the files? (Such as "/src/resources/maps/level1.txt" in my case.)
Currently, the text files are stored in the project folder and can be read from there using "filename.txt"
Hmm. this sounds like two questions. First, resources get packed into a JAR file and can't be read directly as files (yes, you can execute classes on "exploded" directory mode but your code shouldnt depend on this). Once you have generated a JAR file containing your classes and the resources, you can access the resource using an InputStreamReader, not a FileReader
new InputStreamReader(this.getClass().getResourceAsStream("/maps/level1.txt"));
The reason that getResourceAsStream() is on the Class object, is that sometimes resources are placed in same package as a class. Using..
this.getClass().getResourceAsStream("level1.txt")
without a / slash at the front of the path, this would try to locate this in the same package as "this" object.
When resources are in the root package, or have their own directory structure, /maps/ for example. You can call this.getClass() on any class (in the same classloader) to find the resource.

Resources