datacontract

WCF datacontract vs class serialize

泪湿孤枕 提交于 2019-12-05 05:33:03
I understand that we can have more controls on a class if we use datacontract, however, consider the following 2 cases [DataContract] public class Customer { [DataMember] public string CustomerName {get; set;} [DataMember] public int Age{get; set;} } and public class Customer { public string CustomerName {get; set;} public int Age{get; set;} } They both get serialized correctly on .net client. And personally I do not use second example. Can anybody point me the differences in the 2 classes? I meant to send all public properties in both classes. The second version is the POCO (plain old CLR

WCF Client how can I deserialize an incompatible date format from the JSON response?

喜夏-厌秋 提交于 2019-12-05 05:29:43
I have scoured the Net for info on this, but most of the results are about creating WCF services or situations where the service is under your control. I am building a WCF client proxy for a RESTful JSON service which is out of my control. I am using the basic ServiceContract/DataContract pattern, and trying to let the framework do as much of the work as possible. Mostly this is working fine, but all the datetime fields coming from this external service are in a particular format, e.g. {"SomeObject": {"details":"blue and round", "lastmodified":"2013/01/02 23:14:55 +0000"} } So I get an error:

Does ContentResolver notifyChange method notifies also detail Uri's?

一曲冷凌霜 提交于 2019-12-05 03:45:47
During applying data I use notifyChange with an Uri . Let's say I notify content://com.package.my/items . I have also detail Activity that displays data from content://com.package.my/items/1 . Does notifying 'general' Uri results also in 'detail' Uri being notified? thaussma The method notifyChange sends a notification for the detailed URI. But if you register a ContentObserver at ContentResolver.registerContentObserver(Uri uri, boolean notifyForDescendents, ContentObserver observer) you can register a base Uri to be notified if any descendant Uri has been changed (is used to send change

WCF DataContractSerializer doesn't pick up contract attributes… why not?

随声附和 提交于 2019-12-05 02:00:04
问题 I have the following type which I use as a message contract in WCF: [MessageContract(IsWrapped = true, WrapperNamespace = "http://example.com/services", WrapperName = "EchoRequest")] public class EchoRequest { public EchoRequest() { } public EchoRequest(String value) { Value = value; } [MessageBodyMember(Name = "Value", Namespace = "http://example.com/services", Order = 0)] public String Value { get; set; } } When I generate a proxy to this type using svcutil.exe , I get a client which is

How to configure ServiceStack.Text to use EnumMember when deserializing?

孤街浪徒 提交于 2019-12-04 05:29:04
问题 I am using ServiceStack.Text to deserialize json received in rest api calls to objects C#. The model classes I use have defined the string representation using EnumMember attributes. The problem is that ServiceStack.Text does not seem to use those values. ServiceStack.Text documentation has a section called Custom enum serialization that discusses EnumMember attribute, but it talks only about serialization with no mention of deserialization. It is possible to configure ServiceStack.Text to

WCF: Returning a derived object for a contract with base object (DataContractResolver)

烂漫一生 提交于 2019-12-04 05:27:38
问题 I have have a WCF derived/base contract issue. I have a server interface/contract that returns a BaseThing object: [OperationContract] BaseThing Get_base_thing(); The server that implements this has a DerivedThing (derived from BaseThing ) and wants to return this as a BaseThing . How to tell WCF that I only want to transport the BaseThing part of DerivedThing ? If in Get_base_thing I just return a reference to a DerivedThing then I get a SerializationException server side. I think I need to

What does it mean to put DataMemberAttribute on interface member?

孤街浪徒 提交于 2019-12-04 04:40:49
What does it mean to put a DataMemberAttribute on an interface member? How does this affect derived classes? As shown in the following signature, the DataMember attribute is not inheritable [AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, Inherited = false, AllowMultiple = false)] public sealed class DataMemberAttribute : Attribute Therefore, it makes very little sense to decorate interface members with this attribute as you will have to decorate the implementing classes' members with this attribute too. In my case, I use this attributes with my WCF services. When I

How to expose part of Entity as DataContract?

筅森魡賤 提交于 2019-12-04 04:12:42
问题 Up to now, when working with WCF, I have always been exposing the whole either EF generated entities, or POCOs(by modifying the T4 template to include DataContract and DataMember on POCOs and properties) as DataContract. Now, I have come across a situation that I cannot expose the whole thing, and need to explicitly specify my DataContract to be a subset of the entities. It worth saying that one of my entities is something like below: And I want to just expose Id, Name, CategoryId, Price.

WCF DataContractSerializer doesn't pick up contract attributes… why not?

我怕爱的太早我们不能终老 提交于 2019-12-03 20:00:20
I have the following type which I use as a message contract in WCF: [MessageContract(IsWrapped = true, WrapperNamespace = "http://example.com/services", WrapperName = "EchoRequest")] public class EchoRequest { public EchoRequest() { } public EchoRequest(String value) { Value = value; } [MessageBodyMember(Name = "Value", Namespace = "http://example.com/services", Order = 0)] public String Value { get; set; } } When I generate a proxy to this type using svcutil.exe , I get a client which is able to communicate to a service which hosts it, with the XML namespaces on the elements correct according

C# DataContractJsonSerializer fails when value can be an array or a single item

拟墨画扇 提交于 2019-12-03 17:03:02
I use the DataContractJsonSerializer to parse a json string into a object hierarchie. The json string looks like this: { "groups": [ { "attributes": [ { "sortOrder": "1", "value": "A" }, { "sortOrder": "2", "value": "B" } ] }, { "attributes": { "sortOrder": "1", "value": "C" } } ] } As you can see the sub value of "attributes" can be an array or a single item. I found the code part where the problem occures: [DataContract] public class ItemGroup { [DataMember(Name="attributes")] public List<DetailItem> Items { get; set; } } This works for the first one but fails on the second one. Has anyone