public static T Deserialize <T>(BixReader reader, BixContext ctx = null) where T : TypedDoc { var(got, ok) = TryDeserializeRootOrInternal <T>(true, reader, ctx); if (!ok) { throw new BixException(StringConsts.BIX_TYPE_NOT_SUPPORTED_ERROR.Args(typeof(T).FullName)); } return(got); }
/// <summary> /// Recycles the instance so it can be re-used by the next call to .Obtain() /// </summary> public virtual void Dispose() { m_Default = false; m_TargetName = TargetedAttribute.ANY_TARGET; Version = Format.VERSION; m_Nesting = 0; m_MaxDepth = DEFAULT_MAX_DEPTH; m_HasHeader = false; m_PolymorphicRoot = false; m_PolymorphicMembers = true; State = null; ts_Instance = this; }
/// <summary> /// Returns an instance of context initialized for making local blocking call. /// The instance needs to be released by calling .Dispose() /// </summary> public static T Obtain <T>() where T : BixContext, new() { var self = ts_Instance as T; if (self == null) { self = new T(); } else { ts_Instance = null; } return(self); }
internal static BixContext ObtainDefault() { var self = ts_Instance; if (self == null) { self = new BixContext(); } else { ts_Instance = null; } self.m_Default = true; return(self); }
/// <summary> /// Serializes data document /// </summary> public static void Serialize(BixWriter writer, TypedDoc root, BixContext ctx = null) { if (!writer.IsAssigned) { throw new BixException(StringConsts.ARGUMENT_ERROR + "{0}.!Assigned".Args(nameof(BixWriter))); } if (ctx == null) { ctx = BixContext.ObtainDefault(); } //1 Header if (ctx.HasHeader) { Writer.WriteHeader(writer, ctx); } //2 Payload Writer.WriteDoc(writer, root, ctx, isRoot: true); ctx.DisposeDefault(); }
public static object DeserializeAny(BixReader reader, BixContext ctx = null) { return(null); }
/// <summary> /// Deserializes typed data document from BixReader /// </summary> public abstract void Deserialize(BixReader reader, TypedDoc doc, BixContext ctx);
/// <summary> /// Serializes typed data document into BixWriter /// </summary> public abstract void Serialize(BixWriter writer, TypedDoc doc, BixContext ctx);