-
Notifications
You must be signed in to change notification settings - Fork 144
Optionally support DataContract in Mono/Unity #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
b0b2053
c124e3f
88fb1bf
55e27b5
924ebd2
98929dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,10 @@ | |
// NOTE: uncomment the following line to enable DataContract support. | ||
//#define SIMPLE_JSON_DATACONTRACT | ||
|
||
// NOTE: uncomment the following line to use alternate definitions of DataContract/DataMember/IgnoreDataMember. | ||
// define if you want to use DataContract with Mono, which does not implement all WCF classes. | ||
//#define ALTERNATE_DATACONTRACT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can think of these possible names:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll vote for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure. go for it before I can merge |
||
|
||
// NOTE: uncomment the following line to enable IReadOnlyCollection<T> and IReadOnlyList<T> support. | ||
//#define SIMPLE_JSON_READONLY_COLLECTIONS | ||
|
||
|
@@ -486,6 +490,29 @@ public override IEnumerable<string> GetDynamicMemberNames() | |
|
||
namespace SimpleJson | ||
{ | ||
#region Alternate DataContract for Unity/Mono | ||
|
||
#if ALTERNATE_DATACONTRACT | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum, Inherited = false, AllowMultiple = false)] | ||
public sealed class DataContractAttribute : Attribute | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add #if SIMPLE_JSON_INTERNAL
internal
#else
public
#endif There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And Done. |
||
{ | ||
public string Name { get; set; } | ||
} | ||
|
||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
public sealed class DataMemberAttribute : Attribute | ||
{ | ||
public string Name { get; set; } | ||
} | ||
|
||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
public sealed class IgnoreDataMemberAttribute : Attribute | ||
{ | ||
} | ||
#endif | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// This class encodes and decodes JSON strings. | ||
/// Spec. details, see http://www.json.org/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add Unity/Mono
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done