本文整理汇总了C#中PlayFab.Serialization.JsonFx.JsonWriter类的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter类的具体用法?C# JsonWriter怎么用?C# JsonWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JsonWriter类属于PlayFab.Serialization.JsonFx命名空间,在下文中一共展示了JsonWriter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJson
public override void WriteJson(JsonWriter writer)
{
writer.Writer.Write(JsonReader.OperatorObjectStart);
writer.WriteObjectProperty("Created", Created);
writer.Writer.Write(JsonReader.OperatorObjectEnd);
}
示例2: WriteJson
public override void WriteJson(JsonWriter writer)
{
writer.Writer.Write(JsonReader.OperatorObjectStart);
writer.WriteObjectProperty("SharedGroupId", SharedGroupId);
writer.Writer.Write(JsonReader.OperatorValueDelim);
writer.WriteObjectProperty("PlayFabIds", PlayFabIds);
writer.Writer.Write(JsonReader.OperatorObjectEnd);
}
示例3: Serialize
// <summary>
/// A helper method for serializing an object to JSON
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string Serialize(object value, JsonWriterSettings settings)
{
StringBuilder output = new StringBuilder();
using (JsonWriter writer = new JsonWriter(output, settings))
{
writer.Write(value);
}
return output.ToString();
}
示例4: WriteEcmaScriptRegExp
/// <summary>
/// Outputs a .NET Regex as an ECMAScript RegExp literal.
/// </summary>
/// <param name="writer"></param>
/// <param name="regex"></param>
/// <param name="isGlobal"></param>
/// <remarks>
/// http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
/// </remarks>
public static void WriteEcmaScriptRegExp(JsonWriter writer, Regex regex, bool isGlobal)
{
if (regex == null)
{
writer.TextWriter.Write(JsonReader.LiteralNull);
return;
}
// Regex.ToString() returns the original pattern
string pattern = regex.ToString();
if (String.IsNullOrEmpty(pattern))
{
// must output something otherwise becomes a code comment
pattern = EcmaScriptWriter.EmptyRegExpLiteral;
}
string modifiers = isGlobal ? "g" : "";
switch (regex.Options & (RegexOptions.IgnoreCase|RegexOptions.Multiline))
{
case RegexOptions.IgnoreCase:
{
modifiers += "i";
break;
}
case RegexOptions.Multiline:
{
modifiers += "m";
break;
}
case RegexOptions.IgnoreCase|RegexOptions.Multiline:
{
modifiers += "im";
break;
}
}
writer.TextWriter.Write(EcmaScriptWriter.RegExpLiteralDelim);
int length = pattern.Length;
int start = 0;
for (int i = start; i < length; i++)
{
switch (pattern[i])
{
case EcmaScriptWriter.RegExpLiteralDelim:
{
writer.TextWriter.Write(pattern.Substring(start, i - start));
start = i + 1;
writer.TextWriter.Write(EcmaScriptWriter.OperatorCharEscape);
writer.TextWriter.Write(pattern[i]);
break;
}
}
}
writer.TextWriter.Write(pattern.Substring(start, length - start));
writer.TextWriter.Write(EcmaScriptWriter.RegExpLiteralDelim);
writer.TextWriter.Write(modifiers);
}
示例5: WriteEcmaScriptDate
public static void WriteEcmaScriptDate(JsonWriter writer, DateTime value)
{
if (value.Kind == DateTimeKind.Unspecified)
{
// unknown timezones serialize directly to become browser-local
writer.TextWriter.Write(
EcmaScriptWriter.EcmaScriptDateCtor7,
value.Year, // yyyy
value.Month-1, // 0-11
value.Day, // 1-31
value.Hour, // 0-23
value.Minute, // 0-60
value.Second, // 0-60
value.Millisecond); // 0-999
return;
}
if (value.Kind == DateTimeKind.Local)
{
// convert server-local to UTC
value = value.ToUniversalTime();
}
// find the time since Jan 1, 1970
TimeSpan duration = value.Subtract(EcmaScriptWriter.EcmaScriptEpoch);
// get the total milliseconds
long ticks = (long)duration.TotalMilliseconds;
// write out as a Date constructor
writer.TextWriter.Write(
EcmaScriptWriter.EcmaScriptDateCtor1,
ticks);
}
示例6: WriteJson
public override void WriteJson(JsonWriter writer)
{
writer.Writer.Write(JsonReader.OperatorObjectStart);
writer.WriteObjectProperty("ItemInstanceId", ItemInstanceId);
writer.Writer.Write(JsonReader.OperatorValueDelim);
writer.WriteObjectProperty("RemainingUses", RemainingUses);
writer.Writer.Write(JsonReader.OperatorObjectEnd);
}
示例7: Write
public void Write (JsonWriter writer, Type type, object value) {
Dictionary<string,object> dict = WriteJson (type,value);
writer.Write (dict);
}
示例8:
void IJsonSerializable.WriteJson(JsonWriter writer)
{
if (String.IsNullOrEmpty(this.identifier))
{
writer.TextWriter.Write("null");
}
else
{
// TODO: determine if this should output parens around identifier
writer.TextWriter.Write(this.identifier);
}
}