0

I'm using WCF & Redis as caching layer, but unfortunately both WCF and the driver I used, are looking for the DataContractAttribute & DataMemberAttribute - and I want to hide some fields from WCF (sensitive information) but they should get serialized down to Redis (Uses StackService.JsonSerializer).

I want to achieve this without writing 2 different classes and want to switch between them at runtime, but I'm not sure if it's possible or not.

Thanks!

Ron
  • 1,806
  • 3
  • 18
  • 31
  • if there's no distinguishing feature, you cannot distinguish. Disregarding technical/budgetary feasibility, you'd have to create a new attribute to be able to distinguish. Then wrap/decorate one of the serializers to look at the other attribute. – Marvin Smit Aug 28 '14 at 10:12
  • 1
    See this answer on how to [ignore fields with ServiceStack JSON Serializer](http://stackoverflow.com/a/14859968/85785). – mythz Aug 28 '14 at 14:42

1 Answers1

0

I don't know, how StackService.JsonSerialzer works.

But for DataContract you can remove DataMember attribute from sensitive fields and they will not be serialized

Vladmir
  • 1,255
  • 9
  • 13
  • On classes marked with DataContract, StackService.JsonSerialzer doesn't serialize any member not marked with DataMember – Ron Aug 28 '14 at 07:16