public JObject ToJson() { var json = new JObject(); json["id"] = Id?.ToBase64(); json["ownerID"] = OwnerId?.ToJson(); json["lifetime"] = Lifetime?.ToJson(); json["sessionKey"] = SessionKey.ToBase64(); if (ContextCase == ContextOneofCase.Object) { json["object"] = Object.ToJson(); } else if (ContextCase == ContextOneofCase.Container) { json["container"] = Container.ToJson(); } return(json); }