internal ChatMessageContent(ChatMessageContentInternal chatMessageContentInternal)
        {
            if (chatMessageContentInternal.Initiator != null)
            {
                Initiator = new CommunicationUserIdentifier(chatMessageContentInternal.Initiator);
            }

            Message      = chatMessageContentInternal.Message;
            Topic        = chatMessageContentInternal.Topic;
            Participants = chatMessageContentInternal.Participants.Select(x => new ChatParticipant(x)).ToList().AsReadOnly();
        }
 internal ChatMessageInternal(string id, ChatMessageType type, string sequenceId, string version, ChatMessageContentInternal content, string senderDisplayName, DateTimeOffset createdOn, string senderId, DateTimeOffset?deletedOn, DateTimeOffset?editedOn)
 {
     Id                = id;
     Type              = type;
     SequenceId        = sequenceId;
     Version           = version;
     Content           = content;
     SenderDisplayName = senderDisplayName;
     CreatedOn         = createdOn;
     SenderId          = senderId;
     DeletedOn         = deletedOn;
     EditedOn          = editedOn;
 }
 internal ChatMessageInternal(string id, ChatMessageType type, string sequenceId, string version, ChatMessageContentInternal content, string senderDisplayName, DateTimeOffset createdOn, CommunicationIdentifierModel senderCommunicationIdentifier, DateTimeOffset?deletedOn, DateTimeOffset?editedOn, IReadOnlyDictionary <string, string> metadata)
 {
     Id                            = id;
     Type                          = type;
     SequenceId                    = sequenceId;
     Version                       = version;
     Content                       = content;
     SenderDisplayName             = senderDisplayName;
     CreatedOn                     = createdOn;
     SenderCommunicationIdentifier = senderCommunicationIdentifier;
     DeletedOn                     = deletedOn;
     EditedOn                      = editedOn;
     Metadata                      = metadata;
 }
示例#4
0
        internal static ChatMessageInternal DeserializeChatMessageInternal(JsonElement element)
        {
            string          id         = default;
            ChatMessageType type       = default;
            string          sequenceId = default;
            string          version    = default;
            Optional <ChatMessageContentInternal> content = default;
            Optional <string>         senderDisplayName   = default;
            DateTimeOffset            createdOn           = default;
            Optional <string>         senderId            = default;
            Optional <DateTimeOffset> deletedOn           = default;
            Optional <DateTimeOffset> editedOn            = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ChatMessageType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("sequenceId"))
                {
                    sequenceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("version"))
                {
                    version = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("content"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    content = ChatMessageContentInternal.DeserializeChatMessageContentInternal(property.Value);
                    continue;
                }
                if (property.NameEquals("senderDisplayName"))
                {
                    senderDisplayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdOn"))
                {
                    createdOn = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("senderId"))
                {
                    senderId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("deletedOn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    deletedOn = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("editedOn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    editedOn = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return(new ChatMessageInternal(id, type, sequenceId, version, content.Value, senderDisplayName.Value, createdOn, senderId.Value, Optional.ToNullable(deletedOn), Optional.ToNullable(editedOn)));
        }
示例#5
0
        internal static ChatMessageInternal DeserializeChatMessageInternal(JsonElement element)
        {
            string          id         = default;
            ChatMessageType type       = default;
            string          sequenceId = default;
            string          version    = default;
            Optional <ChatMessageContentInternal> content = default;
            Optional <string> senderDisplayName           = default;
            DateTimeOffset    createdOn = default;
            Optional <CommunicationIdentifierModel> senderCommunicationIdentifier = default;
            Optional <DateTimeOffset> deletedOn = default;
            Optional <DateTimeOffset> editedOn  = default;
            Optional <IReadOnlyDictionary <string, string> > metadata = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ChatMessageType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("sequenceId"))
                {
                    sequenceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("version"))
                {
                    version = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("content"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    content = ChatMessageContentInternal.DeserializeChatMessageContentInternal(property.Value);
                    continue;
                }
                if (property.NameEquals("senderDisplayName"))
                {
                    senderDisplayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdOn"))
                {
                    createdOn = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("senderCommunicationIdentifier"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    senderCommunicationIdentifier = CommunicationIdentifierModel.DeserializeCommunicationIdentifierModel(property.Value);
                    continue;
                }
                if (property.NameEquals("deletedOn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    deletedOn = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("editedOn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    editedOn = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("metadata"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    metadata = dictionary;
                    continue;
                }
            }
            return(new ChatMessageInternal(id, type, sequenceId, version, content.Value, senderDisplayName.Value, createdOn, senderCommunicationIdentifier.Value, Optional.ToNullable(deletedOn), Optional.ToNullable(editedOn), Optional.ToDictionary(metadata)));
        }