/// <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>();

            // Object Id
            dictionary.Add("ObjectID", ObjectId);

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

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

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

            // Date Modified
            if (DateModified.HasValue)
            {
                dictionary.Add("DateModified", JsonSerialisation.Serialise(DateModified.Value));
            }

            // Value
            dictionary.Add("Value", Value.Serialise());

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

            return(dictionary);
        }
Esempio n. 2
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);
        }