Questions tagged [datamember]

204 questions
3
votes
1 answer

WCF - Custom name for a DataMember of a generic class

I have an existing WCF REST / JSON service that returns lists of different types of Data. I'd like to add to each response a single attribute which represents a revision number. Say I have a 'Car' class [DataContract] public class Car { …
skav
  • 1,400
  • 10
  • 16
3
votes
1 answer

WCF DataContract With List of RegExs Won't Serialize Properly

I have a class that looks something like this: [DataContract] public class InboundMailbox { public const char EmailSeparator = ';'; [DataMember] public string POP3Host { get; set; } [DataMember] public string EmailId { get;…
Jacobs Data Solutions
  • 4,850
  • 4
  • 33
  • 38
3
votes
2 answers

Winforms data-binding: Period-delimited navigation path as DataMember causes exception. Why?

I keep having problems with Winforms data-binding, more specifically, whenever I specify a period-separated property path to be used as DataMember. For example: public partial class SomeForm : System.Windows.Forms.Form { public SomeForm(Book…
stakx - no longer contributing
  • 83,039
  • 20
  • 168
  • 268
3
votes
2 answers

WCF Serialization Information outside class definition

Suppose this simple scenario: My client has an already working .net application and he/she wants to expose some functionality through WCF. So he gives me an assembly, containg a public class that exposes the followig method. OrderDetail…
3
votes
2 answers

How to have C# interface with readonly member

Interface inconvenience I recently found myself in need of something, which should very much be possible in C# (I know it is in C++): Several classes need an api key, which absolutely has to be a private, immutable field (except for being declared…
alexpanter
  • 1,222
  • 10
  • 25
3
votes
2 answers

C# - Serializing private property as attribute (Data Contract)

After learning I can't serialize private properties in a class, I started using DataContract and DataMember annotations. I have a private string property in my class that I would like to serialize as an attribute and not as an…
Shay Lugassy
  • 119
  • 1
  • 2
  • 6
3
votes
0 answers

How to set [DataMember] on all class members

I have a class with countless members. I want to use DataContract serialization/deserialization and so the class has the [DataContract] attribute. If I put the [DataMember] attribute that works otherwise it doesn't. Am I to put [DataMember] on all…
Patrick
  • 3,073
  • 2
  • 22
  • 60
3
votes
5 answers

WCF DataContract/ServiceOperation involving .NET XmlDocument type

im just wondering about data contracts to be sent over the wire in WCF communication. i know for the sake of interoperability it is not advisable (maybe not even allowed?) to send native .NET types as part of a data contract. I wish to have a…
Nick
3
votes
2 answers

Adding a DataMember to a different namespace to the DataContract

With the XmlSerializer I can have my members in different namespaces to the parent type. Can I do the same thing with DataContractSerializer? I would like the following XML:
2
votes
1 answer

Data member default values, how to figure out whether something was really sent?

By default, WCF deserializes missing elements into default values like null, 0 or false. The problem with this approach is that if it's a basic type like number 0 I'm not sure whether it means the real value sent by an external system or a default…
user405723
  • 481
  • 3
  • 7
  • 21
2
votes
2 answers

confusion of address of a pointer

I see a piece of code like this: #include struct person{ int age; float weight; }; int main(){ struct person *personPtr, person1; personPtr = &person1; printf("Enter age: "); scanf("%d", &personPtr->age); // why use…
hodondo
  • 83
  • 1
  • 5
2
votes
1 answer

Restrict use of instance variable to single method in C#

I want to be able to restrict usage of a instance variable to one method, and other usages should not be possible (compile error, or warning). For instance public class Example { public string Accessor() { if (SuperPrivate == null)…
MrZarq
  • 258
  • 3
  • 12
2
votes
1 answer

how to access class private data members in method parameter of class , i get an error invalid use of non static data members

i have two classes Node and AvlTree , i will make other methods of AvlTree later but i can't access root data member of AvlTree in it's own class , how can i access root in AvlTree class inOrder method. My code is following here class Node { …
user14066820
2
votes
2 answers

Using smart pointers to keep track of data members that may be deleted

I have two classes A and B. I compute a B deterministically from an A. For each A, I want to keep track of the B with my_B for as long as it exists. Once the B is destructed, I want the my_B to be changed to something like nullptr. class A{ //…
mana
  • 545
  • 4
  • 12
2
votes
1 answer

WCF DataMember EmitDefaultValue on value type? (but set my own default value)

I have the following: [DataContract] public class Foo { [DataMember(EmitDefaultValue = true) public bool Bar { get; set; } } 2 Questions: What really happens here because my bool can't really be null, so if I emit the default value then…
michael
  • 14,844
  • 28
  • 89
  • 177
1 2
3
13 14