Is there a similar approach to CustomCreationConverter in System.Text.Json? - system.text.json

I have used CustomCreationConverter in Newtonsoft.Json for many years. Nowadays, I am trying to migrate to System.Text.Json. Is there a similar approach? I just want to add something in the method "Create".

Related

NestJS Schema First GraphQL Serialization

I've done some research into the subject of response serialization for NestJS/GraphQL. There's some helpful information to be found here, but the documentation seems to be completely focused on a code first approach. My project happens to be taking schema first approach, and from what I've read across a few sources, the option available for a schema-first project would be to implement interceptors for the resolvers, and carry out the serialization there.
Before I run off and start writing these interceptors, my question is this; is there any better options provided by nestjs to implement serialization for a schema first approach?
If it's just transformation of values then an interceptor is a great tool for that. Everything shown for "code-first" should work for "schema-first" in terms of high level ideas of the framework (interceptors, pipes, filters, etc). In fact, once the server is running, there shouldn't be a distinguishable difference between the two approaches, and how they operate. The big thing you'd need to be concerned with is that you won't be easily able to take advantage of class-transformer and class-validator because the original class definitions are created via the gql-codegen, but you can still extend those types and add on the decorators necessary if you choose.

How do I compartmentalize classes in objective-c w/o namespaces?

Having worked w/ languages that utilized namespaces for the past 10 years I am trying to figure out the best approach to project structure and class names in objective-c (iOS4+). Should you simply give all your classes, view controllers, etc. unique names? It seems archaic there is not a way to encapsulate groups of functionality with something like namespaces, especially if you build libraries and have a large development team.
Is there functionality equivalent to namespaces that I am missing? If not, what is a good approach to this problem?
Thanks
Should you simply give all your classes, view controllers, etc. unique names?
Yes.
The standard approach is to prefix class names with a short code. For instance, traditional Cocoa uses NS (from NextStep), while Cocoa Touch uses UI (for user interface, I guess).

How to do enumerations in Rails 3?

In Rails 2 I know of a few plugins for enumerations such as acts_as_enumeration and enumerate_by but they don't seem to be maintained or updated for Rails 3. Preferably, the solution would store the enum in memory rather than a database for performance reasons but really any method would be useful since it can always be cached.
I did find enumerated_attribute that claims to work with Rails 3 but quite honestly I don't like the API and was hoping for another good solution.
(Sorry for only linking to the one plugin but it won't let me post more than one link until I get a higher reputation)
I am currently using lwe's simple_enum which seems to be actively developed and stores values on memory or if you prefer on a table.
If you're using DataMapper as your ORM have a look at dm-types which includes an Enum type.
There is this gem, enumerate_it, it has good documentation and very well done!

WCF code generation for large/complex schema (HR-XML/OAGIS) - is there an alternative?

and thank you for reading.
I am implementing a WCF Service based on a predefined specification (HR-XML 3.0). As such, I am starting with the schema, and working my way back to code. There are a number of large Schema documents (which import yet more Schema documents) related to my implementation, provided by this specification.
I am able to generate code using xsd.exe, by supplying the "main" and "supporting" xsd files as arguments. But there are several issues, and I am wondering if this is the right approach.
there are litterally hundreds of classes - the code file is half a meg in size
duplicate classes (ex. Type, Type1 - which both represent the same type)
there are classes declared as inheriting from a base class, but that base class is not generated/defined
I understand that there are limitations to the types of Schema supported by svcutil.exe/xsd.exe when targeting the DataContractSerializer and even XmlSerializer. My question is two-fold:
Are code generation "issues" fairly common when dealing with larger, modular xsd files? Has anyone had success with generating data contracts from OAGIS or HR-XML schema?
Given the above issues, are there better approaches to this task, avoiding generating code and working with concrete objects? Does it make better sence to read and compose a SOAP message directly, while still taking advantage of the rest of the WCF framework? I understand that I am loosing the convenience of working with .NET objects, and the framekwork-provided (de)serialization; given these losses, would it still be advantageous to base my Service on WCF? Is there some "middle ground" between working with .NET types and pure XML?
Thank you very much!
-Sasha Borodin
DFWHC.org
Sasha, If you are going to use code generation, you likely should never start with the modular schemas. When you put a code generator against the modular schemas, you'll generate a class for all the common compoents in the HR-XML library and a good bit of the common components in OAGIS. You don't want this. HR-XML is distributed with standalone schemas, which are a better starting point. An even better starting point would be to create a flattened package xsd containing only the types brought in by the WSDL. If you use a couple standalone schemas, you are going to at least have some duplications among your generated code.
Well, you could try and do something like this:
convert your XSD to C# code separately, using something like the xsd.exe tool from Microsoft, or something like Xsd2Code as a Visual Studio Plugin.
Xsd2Code in Visual Studio http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Xsd2Code&DownloadId=41336
once you have your C# classes, weed out any inconsistencies, duplications, and so forth
package everything up into a separate class library assembly
now, when generating your WCF service from the WSDL, either using Add Service Reference from Visual Studio or the svcutil.exe tool, reference that assembly with all the data classes. Doing so, WCF should skip re-creating the whole set of classes again, and use whatever is available in that data assembly
With this, you might be able to get this mess under control.

What's the most productive way to do NHibernate mapping?

I know annotations to do the hibernate mapping in Java and am looking now for a similar way to do the same in C# and NHibernate. I found out that there exists several approaches
do the mapping in xml files
NHibernate.Mapping.Attributes (NHMA)
Fluent
are there any more??
I tried NHMA and found out it had some blocking points for me...
I don't want you to discuss, whats the best way to map models to NHibernate, but I was looking for a good comparison on the internet.
Do you know such sites? What facts are the main points to consider, if I choose one of the "frameworks" listed above? I'm thinking of aspects like 'is this project offically supported by the NH-Developers?', 'are there models that can be mapped in xml-mapping but not in fluent/NHMA/etc...?'
What can you recommend?
Why?
Fluent NHibnernate auto mapping or code generation (CodeSmith, MyGeneration, T4, etc.) are the most productive ways to create the mapping files. I dislike the attributes approach because I like to keep my POCOs plain.
Another option, if you don't mind attributes, is Castle ActiveRecord.
Here's an article that might help you decide.