C# versioning with DataContract Serializaiton - datacontractserializer

I am using DataContract serialization to save my sceneario which is created in C# application.
I save several classes during the serialization.
I want to know that if a class changes in the future and there is a missing field or an extra field in the saved file, is it possible to inform the user saying that "Field 1 is missing" or "There is an extra field in saved file".
I know that datacontract serializer can deserialize in this kind of situations but i want to know which fields are missing or extra too.
Or should i use another save mechanism in order to provide this? (Some pattern, or should i write custom serializer?)

Related

Generated classes

I try to sync data via GraphQL from my backend. Therefore I use the artemis package to generate my classes. However I then want to cache the data localy and therefore use the sqfentity_gen package to generate classes to safe my data via sql. I can use a json constructor with each framework to convert the data between.However I want to encapsulate certain functionality since I dont want to just safe changed data localy but sync it to the backend and handle certain errors like merge conflicts or missing network. Therefore I am thinking about wrapping the classes with an other one since I cant change the generated code. Is this a good idea or are there other solutions which work better? Would you use a completly diffrent setup? Glad for any suggestions
Instead of generate and/or re-generate (update) classes which are based on db-tables (I assume), you can use solution from the box, in example, NReco.GraphQL
It allows you set db-schema in the json file and just set db-connection. If you have a lot of tables, you can just generate that json file based on metatable info.
Storing and updating classes, from my point of view is useless.

How to store only metadata for an object of type sys:base or cm:object in Alfresco Share?

How to store only metadata for an object of type sys:base or cm:object? I have a type which is sub-type of sys:base. I need to store the metadata of it.
My doubts are:
1. Where should the data be stored?
How to retrieve the data, as in content and folder you can see the appearance as icon in the company home or user home etc. How does the metadata appear in a folder(is it like an icon of cm:object)?
With reference to the question posted earlier in alfresco forum (http://forums.alfresco.com/forum/developer-discussions/content-modeling/can-i-store-only-metadata-alfresco-11292012-0437) should the object be of type cm:content to store the metadata (except that they do not have a content property). Is there anyway to create metadata other than being subtype of cm:content?
Thank you
You can store metadata on instances of any type as long as the content model includes properties that meet your needs. Those might be out-of-the-box types or they might be custom types.
If you need to create objects that have a content stream, use cm:content. If you don't need to set a content stream you might consider using one of the two types you mentioned. But it won't necessarily hurt anything if you elect to simply create instances of cm:content that don't have a content stream.
If you want to use sys:base or cm:object, simply create an instance of either of those types. Alternatively, define your own sub-type of those types then instantiate that custom type and set your metadata.
If you don't know how to define custom types or you are unsure about how to set, update, or query metadata, you could start by reading this tutorial.
Also note that if you create instances of any type other than cm:content, cm:folder, or a custom type that inherits from one of those two types, you will be unable to do that using CMIS. That isn't the end of the world, just be aware that it is currently a limitation. Someday Alfresco will support the "item" type which is new in CMIS 1.1, but until then, CMIS in Alfresco can only work with documents, folders, and your custom types that inherit from those types.

Data Mapper pattern implementation with zend

I am implementing data mapper in my zend framework 1.12 project and its working fine as expected. Now further more to enhance it i wants to optimize it in following way.
While fetching any data what id i wants to fetch any 3 field data out of 10 fields in my model table? - The current issue is if i fetches the only required values then other valus in domain object class remains blank and while saving that data i am saving while model object not a single field value.
Can any one suggest the efficient way of doing this so that i can fetch/update only required values and no need to fetch all field data to update the record.
If property is NULL ignore it when crafting the update? If NULLs are valid values, then I think you would need to track loaded/dirty states per property.
How do you go about white-listing the fields to retrieve when making the call to the mapper? If you can persist that information I think it would make sense to leverage that knowledge when going to craft the update.
I don't typically go down this path. I will lazy load certain fields on a model when it makes sense, but I don't allow loading parts of the object like this, rather I create an alternate object for use in rendering a list when loading the full object is too resource intensive. A generic dummy list object I just use with tabular data. It being populated from SQL or stored procedures result-sets, usually with my generic table mapper.

create new object template at runtime iPhone

I'm trying to figure out how to create a new object template at runtime (created by the user) and then use that template to create new objects to populate a list. For example, say you want a list of contacts. The user would create a template that has an NSMutable array of generic objects which contain name, phone, email, etc. Then when they are done creating the template, they can then add a new contact based on that template anytime they want without rebuilding the template. All the template object would consist of is the generic object nested inside of itself with it's value set as different data types, then all those generic objects stored inside of another generic object that contains just an array. I hope I'm not making this sound too confusing... Basically just the ability to create custom object templates at runtime, then be able to use those. Anyone know of a good approach to this? I'd like to make the data storage in my app universal so it can apply to anybody's data. Thanks.
I'm not exactly sure what your final goal is, but you could take an 'Interface Builder' approach. You have your view to build the template, and then you convert every element to xml form. All you would have to do to load it is read the xml, create the appropriate UI elements, and add them at the right location in a container view. One problem with this approach is if you need to send data to an element, it would be almost impossible to get the right element if there are multiple of that type in your template. You could use an array, dictionary, or even the xml to store a key (the name of the element), and a value (the element, this would not be required using the xml approach). Sorry if this is confusing.
There are several viable options for reading and writing objects to the disk on iOS. The most famous and widely used being Core Data and Plists.
If you are a beginner, I would recommend saving an array of attributes (possibly as strings?) for a custom object 'template'. See here for a tutorial, and search SO for anything else that might come up.

Can Core Data be used for objects with variable schemas?

I'm implementing a new iPhone app and am relatively new to Cocoa development overall. I am at the stage of choosing how the persistence layer of this app will work, and it looks like I'm basically choosing between Core Data and sqlite3.
The persisted models in this app are intended to have a schema that is loaded at runtime (from some kind of defn file, probably XML). By which I mean, this app is intended to have objects that are user-definable to some extent, e.g. the Customer type (which has certain built-in fields like "name" and "email") can be modified to have extra fields based on the user's specific needs (e.g. a user might want to add a "favourite fruit" field to their Customer type).
Having said that, will Core Data work for an app with a non-baked-in data model like this? I've just started playing around with the Core Data object designer thing in XCode and it seems like this thing wants to work with objects that have fixed fields that are compiled in.
I'm definitely trying to take the path of least resistance here, and I can see the benefits of using an Apple-supplied data framework, but don't want to start down that path if it's going to lock me into a data model that's defined at compile time.
The Core Data data model needs to be defined at compile time, but that does not mean you can't allow for custom fields to be added and used by end users.
It just means that you would define an entity for custom fields and create the fields as objects.
It is best to design a data model that meets your needs rather than think of how you would solve the problem in SQL.