public IDictionary <string, object> EncodeParseObject(AVObject value, bool isPointer) { if (isPointer) { return(EncodeParseObject(value)); } var operations = value.GetCurrentOperations(); var operationJSON = AVObject.ToJSONObjectForSaving(operations); var objectJSON = value.ToDictionary(kvp => kvp.Key, kvp => EncodeProperty(kvp.Value)); foreach (var kvp in operationJSON) { objectJSON[kvp.Key] = kvp.Value; } if (value.CreatedAt.HasValue) { objectJSON["createdAt"] = value.CreatedAt.Value.ToString(DateFormatStrings.First(), CultureInfo.InvariantCulture); } if (value.UpdatedAt.HasValue) { objectJSON["updatedAt"] = value.UpdatedAt.Value.ToString(DateFormatStrings.First(), CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(value.ObjectId)) { objectJSON["objectId"] = value.ObjectId; } objectJSON["className"] = value.ClassName; objectJSON["__type"] = "Object"; return(objectJSON); }
/// <summary> /// AVIMConversation Build 驱动器 /// </summary> /// <param name="source"></param> /// <param name="name"></param> /// <param name="creator"></param> /// <param name="members"></param> /// <param name="muteMembers"></param> /// <param name="isTransient"></param> /// <param name="isSystem"></param> /// <param name="attributes"></param> /// <param name="state"></param> /// <param name="isUnique"></param> /// <param name="isTemporary"></param> internal AVIMConversation(AVIMConversation source = null, string name = null, string creator = null, IEnumerable <string> members = null, IEnumerable <string> muteMembers = null, bool isTransient = false, bool isSystem = false, IEnumerable <KeyValuePair <string, object> > attributes = null, AVObject state = null, bool isUnique = true, bool isTemporary = false, int ttl = 86400) { convState = source != null ? source.convState : new AVObject("_Conversation"); this.Name = source?.Name; this.MemberIds = source?.MemberIds; this.Creator = source?.Creator; this.MuteMemberIds = source?.MuteMemberIds; if (!string.IsNullOrEmpty(name)) { this.Name = name; } if (!string.IsNullOrEmpty(creator)) { this.Creator = creator; } if (members != null) { this.MemberIds = members.ToList(); } if (muteMembers != null) { this.MuteMemberIds = muteMembers.ToList(); } this.IsTransient = isTransient; this.IsSystem = isSystem; this.IsUnique = isUnique; this.IsTemporary = isTemporary; this.expiredAt = DateTime.Now + new TimeSpan(0, 0, ttl); if (state != null) { convState = state; this.ConversationId = state.ObjectId; this.CreatedAt = state.CreatedAt; this.UpdatedAt = state.UpdatedAt; this.MergeMagicFields(state.ToDictionary(x => x.Key, x => x.Value)); } if (attributes != null) { this.MergeMagicFields(attributes.ToDictionary(x => x.Key, x => x.Value)); } }