datacontract

DataContract not available at WCF client service reference

强颜欢笑 提交于 2019-12-08 07:02:31
I have this Data contract in my WCF service [DataContract] public class Department { [DataMember] public List<Section> Sections { get; set; } } [DataContract] public class Section { [DataMember] public List<Room> Rooms { get; set; } } [DataContract] public class Room { [DataMember] public uint RoomId { get; set; } } When I reference my service in client application,I only see Room class,Can any body explain me why contract for Department and Section class are not available at client side. In your ServiceContract interface add one single operation related to Department which will make

How to use interface data type without attribute “KnownType” in WCF?

青春壹個敷衍的年華 提交于 2019-12-08 04:09:33
问题 If I'm using "ServiceContract" that contains "OperationContract" operations. The operation return or received interface parameters. When I'm using the service I get an exception message: "The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver if you are using DataContractSerializer or add the type corresponding to '{%className%}' to the list of known types". I can add the attribute of KnowTypes to the interface but my interface project is

Nested [DataContract]'s not serialising through WCF

本小妞迷上赌 提交于 2019-12-08 02:43:29
I'm having an issue where a class decorated with the [DataContract] attribute and appropriate [DataMember] attributes on properties is not serialising nested [DataContract] classes. This is the class i'm trying to serialise: [DataContract(Namespace = "http://foo.bar.com.au")] [KnownType(typeof(Point))] [KnownType(typeof(Site))] public sealed class Alarm : IExtensibleDataObject { [DataMember] public Point SourcePoint { get; set; } [DataMember] public Site SourceSite { get; set; } [DataMember] public DateTime ActiveTime { get; set; } [DataMember] public int Priority { get; set; } [DataMember]

C# DataContract Attribute for Private Fields?

百般思念 提交于 2019-12-07 18:31:25
问题 For a class marked with the attribute, [DataContract], does its private fields, which should be serialized, be marked as [DataMember]? Example: [DataContract] public class Component { // [DataMember] is not needed since public fields get automatically serialized public int number; // do I need [DataMember] here? private string characters; // [DataMember] is required here, but I also need to include the // attribute [DataMember] in this class's definition private complexType cT; I'm reading

WCF: How to construct DataContracts for a type within a type

非 Y 不嫁゛ 提交于 2019-12-07 09:22:50
问题 I have a wcf service which exposes a function that returns a complex type as its return type. This response type in turn contains another complex object defined by me. I am looking at creating data contracts for my WCF and am wondering how this is supposed to be done. I currently have this (some properties removed for ease of reading): The Function ///<summary> /// Interface to describe a cluster query WCF service. ///</summary> [ServiceContract] public interface IClusterQueryWcfService { ///

Can I prevent a specific datamember from being deserialized?

元气小坏坏 提交于 2019-12-07 04:22:59
问题 I have a datacontract like this [DataContract] class MyDC { [DataMember] public string DM1; [DataMember] public string DM2; [DataMember] public string DM3; } and sometimes I want to prevent DM2 from being deserialized when being returned from an OperationContract. Something like this: [OperationContact] public MyDC GetMyDC() { MyDC mdc = new MyDC(); if (condition) { // Code to prevent DM2 from being deserialized } return mdc; } I could always make a new DataContract that has only DM1 and DM3

Including XML Comments in DataContract Serializer Metadata

左心房为你撑大大i 提交于 2019-12-07 03:13:05
问题 is there some way of sending the summary info of properties in a DataContract? e.g. [DataContract] public class MyClass { /// <summary> /// My Summary information /// </summary> [DataMember] public int MyProperty {get;set;} } can this be available to the client that gets the datacontract? I doubt it, just hoping somebody knows something I don't, which is quite likely. :) 回答1: Take a look at WCFExtras on CodePlex. I haven't used it, but it sounds like it does exactly what you want: Adding WSDL

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

懵懂的女人 提交于 2019-12-07 01:32:50
问题 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. {

Does ContentResolver notifyChange method notifies also detail Uri's?

房东的猫 提交于 2019-12-07 00:37:21
问题 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? 回答1: 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

How to use interface data type without attribute “KnownType” in WCF?

南楼画角 提交于 2019-12-06 22:11:36
If I'm using "ServiceContract" that contains "OperationContract" operations. The operation return or received interface parameters. When I'm using the service I get an exception message: "The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver if you are using DataContractSerializer or add the type corresponding to '{%className%}' to the list of known types". I can add the attribute of KnowTypes to the interface but my interface project is separated from the implementation project and they cannot have circular dependency reference so it's not