Is it possible to use Serilog in different classes in the same app? - serilog

I have a project and am using Serilog. I want to create a Log.Logger in one place that sinks to a single file and then use that Log in different classes. My first thought was to create a property in each class and then assign the Logger to the property when I instantiate the object. Serilog is static so that won't work.
Is it possible to have a simple way to have multiple classes log to the same file?

Related

Is there a way to create a static field in the model generated for swagger codegen?

I am trying to use swagger-codegen (the maven plugin) to generate my models. But I need one of my fields to be static. I was wondering if there's a property I could use in my yaml file to indicate that the field is static. Does anyone have an existing example I could look at?

read write file properties with PropertyHandler Shell Extension

I'm trying to create PropertyHandler shell extension.
What's the best way for embedding properties like (Title,Author,.....) to use the same file in multi computers or devices?
StgCreateStorageEx ? way or there is other ways to do it?
because StgCreateStorageEx dealing with NTFS files only and i'm not sure if the file hold these properties with it if i open it in other device with same PropertyHandler
Is there any way to save properties inside the my file ?
The StgCreateStorageEx function creates a new storage object using the IStorage interface. This allows storing multiple data objects within a single binary file, see for example https://en.wikipedia.org/wiki/COM_Structured_Storage. So, technically, you can save almost anything in this file including embedded properties.
I don't think that this is limited to NTFS: The old Microsoft Office .doc format (and many other Microsoft products) use this storage format and work also with FAT32.
If you want to use this binary file format is a completely different question. As you did not provide any information about the content and format of your file, I cannot recommend anything. One alternative would be to store the content of your file in an xml file. Properties like Title and Author then could be added easily.

Using Realm in a Swift framework creating challenges for host iOS apps also using Realm

I'm working on a closed source Swift framework that uses Realm internally. In the process of testing this framework, I'm using the framework within an iOS app that also uses Realm.
When the framework creates it's own Realm, it uses a Realm.Configuration specific to the framework. The host app creates Realm objects using the default Realm configuration. The Realms are 'separate'.
There are a couple problems:
When the host app creates a Realm reference, the underlying database ends up with tables for all the private Realm Object classes that are inside the framework. This exposes some knowledge of the internals of our framework to anyone that uses our framework and creates their own Realm.
Because all tables are getting created in all Realms, there is a problem when a migration is required. Inside our framework, we can provide a migration to run, but when the host app creates it's Realm, and the framework internal classes are updated, there is no migration for the host app to run, and the app crashes with a migration error.
Is there any way to use two completely separate Realms within one app?
I may be able to specify the list of classes for the framework Realm when using RealmConfiguation's objectTypes option, but that would require any user of our framework to do the same. That seems unreasonable, and also still allows 1. above to be a problem.
Yes, it's possible to have two separate libraries/frameworks/codebases in an app use Realm independently and keep their model objects completely separate.
If you have a collection of Realm Object subclasses that you would like to keep private, you can mark them so they won't automatically be added to the app's default schema by adding the following static method override:
public class MyModel: Object {
public override class func shouldIncludeInDefaultSchema() -> Bool {
return false
}
}
This class will then only be added to a Realm database if it is explicitly declared in the objectTypes property of that Realm's Configuration object.
This way, you can isolate all of your own Realm model classes to just your own framework, and the parent app can use Realm in the original context without any objects getting mixed up in it.

What is the purpose of RegisterFmxClasses?

What is the purpose of RegisterFmxClasses ? When i create some components, i always do RegisterComponents, but in the Delphi source file i see that they also do (not always) RegisterFmxClasses. But i can't understand what is the exact purpose of RegisterFmxClasses. In the help they say :
Registers a set of FireMonkey classes and adds a set of classes to the
FireMonkey group objects.
I create components for the firemonkey framework, but with or without RegisterFmxClasses they work well.
From the RegisterFmxClasses() documentation:
Call RegisterFmxClasses to register a set of custom classes in a single line. Each class is registered by calling RegisterClass. Unregistered classes cannot be loaded or saved by the component streaming system.
The GroupClasses classes are added to the group where TFmxObject resides by calling GroupDescendentsWith.

Where to store stored procedure/trigger/java classes?

I do understand that H2 supports stored procedure/trigger/using java classes to extend the functionality.
But, where to put those classes (.class files/.jar files)?
If we have to put it in file system, then moving the database file without that classes, will make the stored procedure/trigger/etc useless. is it true?
TIA.
Stored procedures can be stored as source code; however this requires that a Java compiler is available. Triggers can't currently; so trigger classes must be in the server class path.

Resources