示例#1
0
        /// <summary>
        /// Serialises all body properties. The output will be a dictionary containing the
        /// body of the request in a form that can easily be converted to Json. Will return
        /// an empty dictionary if there is no body.
        /// </summary>
        ///
        /// <returns>The body Json in dictionary form.</returns>
        public IDictionary <string, object> SerialiseBody()
        {
            var dictionary = new Dictionary <string, object>();

            // Match Id
            dictionary.Add("MatchID", MatchId);

            // State Data
            if (StateData != null)
            {
                dictionary.Add("StateData", StateData.Serialise());
            }

            // Turn Order
            if (TurnOrder != null)
            {
                var serialisedTurnOrder = JsonSerialisation.Serialise(TurnOrder, (string element) =>
                {
                    return(element);
                });
                dictionary.Add("TurnOrder", serialisedTurnOrder);
            }

            return(dictionary);
        }
        /// <summary>
        /// Serialises all properties. The output will be a dictionary containing the
        /// objects properties in a form that can easily be converted to Json.
        /// </summary>
        ///
        /// <returns>The serialised object in dictionary form.</returns>
        public IDictionary <string, object> Serialise()
        {
            var dictionary = new Dictionary <string, object>();

            // State Data
            if (StateData != null)
            {
                dictionary.Add("StateData", StateData.Serialise());
            }

            // Completed
            if (Completed != null)
            {
                dictionary.Add("Completed", Completed);
            }

            // Outcome Data
            if (OutcomeData != null)
            {
                dictionary.Add("OutcomeData", OutcomeData.Serialise());
            }

            // Outcome Attachment
            if (OutcomeAttachment != null)
            {
                dictionary.Add("OutcomeAttachment", OutcomeAttachment);
            }

            return(dictionary);
        }
        /// <summary>
        /// Serialises all body properties. The output will be a dictionary containing the
        /// body of the request in a form that can easily be converted to Json. Will return
        /// an empty dictionary if there is no body.
        /// </summary>
        ///
        /// <returns>The body Json in dictionary form.</returns>
        public IDictionary <string, object> SerialiseBody()
        {
            var dictionary = new Dictionary <string, object>();

            // Match Id
            dictionary.Add("MatchID", MatchId);

            // State Data
            if (StateData != null)
            {
                dictionary.Add("StateData", StateData.Serialise());
            }

            // Turn Data
            if (TurnData != null)
            {
                dictionary.Add("TurnData", TurnData.Serialise());
            }

            // Write Lock
            if (WriteLock != null)
            {
                dictionary.Add("WriteLock", WriteLock);
            }

            // Completed
            if (Completed != null)
            {
                dictionary.Add("Completed", Completed);
            }

            // Outcome Data
            if (OutcomeData != null)
            {
                dictionary.Add("OutcomeData", OutcomeData.Serialise());
            }

            // Outcome Attachment
            if (OutcomeAttachment != null)
            {
                dictionary.Add("OutcomeAttachment", OutcomeAttachment);
            }

            return(dictionary);
        }
示例#4
0
        /// <summary>
        /// Serialises all properties. The output will be a dictionary containing the
        /// objects properties in a form that can easily be converted to Json.
        /// </summary>
        ///
        /// <returns>The serialised object in dictionary form.</returns>
        public IDictionary <string, object> Serialise()
        {
            var dictionary = new Dictionary <string, object>();

            // Match Id
            dictionary.Add("MatchID", MatchId);

            // Match Type Key
            dictionary.Add("MatchTypeKey", MatchTypeKey);

            // State
            dictionary.Add("State", State);

            // Write Lock
            dictionary.Add("WriteLock", WriteLock);

            // Properties
            if (Properties != null)
            {
                var serialisedProperties = JsonSerialisation.Serialise(Properties, (MultiTypeValue element) =>
                {
                    return(element.Serialise());
                });
                dictionary.Add("Properties", serialisedProperties);
            }

            // State Data
            if (StateData != null)
            {
                dictionary.Add("StateData", StateData.Serialise());
            }

            // Outcome Data
            if (OutcomeData != null)
            {
                dictionary.Add("OutcomeData", OutcomeData.Serialise());
            }

            // Turn Timeout
            if (TurnTimeout != null)
            {
                dictionary.Add("TurnTimeout", TurnTimeout.Serialise());
            }

            // Waiting Timeout
            if (WaitingTimeout != null)
            {
                dictionary.Add("WaitingTimeout", WaitingTimeout.Serialise());
            }

            // Turn Type
            dictionary.Add("TurnType", TurnType);

            // Turn Order Type
            if (TurnOrderType != null)
            {
                dictionary.Add("TurnOrderType", TurnOrderType);
            }

            // Player Limit
            if (PlayerLimit != null)
            {
                dictionary.Add("PlayerLimit", PlayerLimit);
            }

            // Players
            if (Players != null)
            {
                var serialisedPlayers = JsonSerialisation.Serialise(Players, (Player element) =>
                {
                    return(element.Serialise());
                });
                dictionary.Add("Players", serialisedPlayers);
            }

            // Auto Start
            dictionary.Add("AutoStart", AutoStart);

            // Is Private
            dictionary.Add("IsPrivate", IsPrivate);

            // Turn Number
            if (TurnNumber != null)
            {
                dictionary.Add("TurnNumber", TurnNumber);
            }

            // Last Turn
            if (LastTurn != null)
            {
                dictionary.Add("LastTurn", LastTurn.Serialise());
            }

            // Current Turn
            if (CurrentTurn != null)
            {
                dictionary.Add("CurrentTurn", CurrentTurn.Serialise());
            }

            // Created By
            if (CreatedBy != null)
            {
                dictionary.Add("CreatedBy", CreatedBy.Serialise());
            }

            // Date Created
            dictionary.Add("DateCreated", JsonSerialisation.Serialise(DateCreated));

            return(dictionary);
        }
        /// <summary>
        /// Serialises all body properties. The output will be a dictionary containing the
        /// body of the request in a form that can easily be converted to Json. Will return
        /// an empty dictionary if there is no body.
        /// </summary>
        ///
        /// <returns>The body Json in dictionary form.</returns>
        public IDictionary <string, object> SerialiseBody()
        {
            var dictionary = new Dictionary <string, object>();

            // Match Type Key
            dictionary.Add("MatchTypeKey", MatchTypeKey);

            // Turn Type
            dictionary.Add("TurnType", TurnType);

            // Player Limit
            dictionary.Add("PlayerLimit", PlayerLimit);

            // Properties
            if (Properties != null)
            {
                var serialisedProperties = JsonSerialisation.Serialise(Properties, (MultiTypeValue element) =>
                {
                    return(element.Serialise());
                });
                dictionary.Add("Properties", serialisedProperties);
            }

            // State Data
            if (StateData != null)
            {
                dictionary.Add("StateData", StateData.Serialise());
            }

            // Turn Timeout
            if (TurnTimeout != null)
            {
                dictionary.Add("TurnTimeout", TurnTimeout);
            }

            // Waiting Timeout
            if (WaitingTimeout != null)
            {
                dictionary.Add("WaitingTimeout", WaitingTimeout);
            }

            // Turn Order Type
            if (TurnOrderType != null)
            {
                dictionary.Add("TurnOrderType", TurnOrderType);
            }

            // Players
            if (Players != null)
            {
                var serialisedPlayers = JsonSerialisation.Serialise(Players, (string element) =>
                {
                    return(element);
                });
                dictionary.Add("Players", serialisedPlayers);
            }

            // Auto Start
            if (AutoStart != null)
            {
                dictionary.Add("AutoStart", AutoStart);
            }

            // Private
            if (Private != null)
            {
                dictionary.Add("Private", Private);
            }

            return(dictionary);
        }