public WfApprovalMatrix ClientToServer(WfClientApprovalMatrix client, ref WfApprovalMatrix server)
        {
            client.NullCheck("client");

            if (server == null)
                server = new WfApprovalMatrix();

            server.ID = client.ID;

            foreach (WfClientRolePropertyDefinition cpd in client.PropertyDefinitions)
            {
                SOARolePropertyDefinition spd = null;

                WfClientRolePropertyDefinitionConverter.Instance.ClientToServer(cpd, ref spd);

                server.PropertyDefinitions.Add(spd);
            }

            foreach (WfClientRolePropertyRow cRow in client.Rows)
            {
                SOARolePropertyRow sRow = null;

                WfClientRolePropertyRowConverter.Instance.ClientToServer(cRow, server.PropertyDefinitions, ref sRow);

                server.Rows.Add(sRow);
            }

            return server;
        }
        public WfClientApprovalMatrix ServerToClient(WfApprovalMatrix server, ref WfClientApprovalMatrix client)
        {
            server.NullCheck("server");

            if (client == null)
                client = new WfClientApprovalMatrix();

            client.ID = server.ID;

            foreach (SOARolePropertyDefinition spd in server.PropertyDefinitions)
            {
                WfClientRolePropertyDefinition cpd = null;

                WfClientRolePropertyDefinitionConverter.Instance.ServerToClient(spd, ref cpd);

                client.PropertyDefinitions.Add(cpd);
            }

            foreach (SOARolePropertyRow sRow in server.Rows)
            {
                WfClientRolePropertyRow cRow = null;

                WfClientRolePropertyRowConverter.Instance.ServerToClient(sRow, client.PropertyDefinitions, ref cRow);

                client.Rows.Add(cRow);
            }

            return client;
        }
        public static WfClientApprovalMatrix PrepareClientApprovalMatrix()
        {
            WfClientApprovalMatrix matrix = new WfClientApprovalMatrix() { ID = UuidHelper.NewUuidString() };

            matrix.PropertyDefinitions.CopyFrom(PrepareClientPropertiesDefinition());
            matrix.Rows.CopyFrom(PrepareClientRows(matrix.PropertyDefinitions));

            return matrix;
        }
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfClientApprovalMatrix resource = new WfClientApprovalMatrix();

            resource.ID = dictionary.GetValue("id", string.Empty);

            JSONSerializerExecute.FillDeserializedCollection(dictionary["definitions"], resource.PropertyDefinitions);
            JSONSerializerExecute.FillDeserializedCollection(dictionary["rows"], resource.Rows);

            return resource;
        }
        public static void AreSame(this WfClientApprovalMatrix expected, WfClientApprovalMatrix actual)
        {
            AssertStringEqual(expected.ID, actual.ID);

            AreSame(expected.PropertyDefinitions, actual.PropertyDefinitions);
            AreSame(expected.Rows, actual.Rows);
        }