Ejemplo n.º 1
0
        protected override void Serialize(IDictionary <string, object> json)
        {
            if (CustomRead != null)
            {
                json["read"] = CustomRead;
            }
            else if (FunctionRead.HasValue())
            {
                json["read"] = FunctionRead;
            }
            else
            {
                var read = Read.ToJson();
                if (read.Keys.Any())
                {
                    json["read"] = read;
                }
            }

            if (SerializeEmptyPrefix)
            {
                json["prefix"] = Prefix.HasValue() ? Prefix : string.Empty;
            }
            else if (Prefix.HasValue())
            {
                json["prefix"] = Prefix;
            }

            if (CustomUpdate != null)
            {
                json["update"] = CustomUpdate;
            }
            else if (FunctionUpdate.HasValue())
            {
                json["update"] = FunctionUpdate;
            }
            else
            {
                var update = Update.ToJson();

                if (update.Keys.Any())
                {
                    json["update"] = update;
                }
            }

            if (CustomCreate != null)
            {
                json["create"] = CustomCreate;
            }
            else if (FunctionCreate.HasValue())
            {
                json["create"] = FunctionCreate;
            }
            else
            {
                var create = Create.ToJson();

                if (create.Keys.Any())
                {
                    json["create"] = create;
                }
            }

            if (CustomDestroy != null)
            {
                json["destroy"] = CustomDestroy;
            }
            else if (FunctionDestroy.HasValue())
            {
                json["destroy"] = FunctionDestroy;
            }
            else
            {
                var destroy = Destroy.ToJson();

                if (destroy.Keys.Any())
                {
                    json["destroy"] = destroy;
                }
            }

            if (StringifyDates)
            {
                json["stringifyDates"] = StringifyDates;
            }

            if (!string.IsNullOrEmpty(IdField))
            {
                json["idField"] = IdField;
            }

            if (ParameterMap.HasValue())
            {
                json["parameterMap"] = ParameterMap;
            }

            var signalR = SignalR.ToJson();

            if (signalR.Keys.Any())
            {
                json["signalr"] = signalR;
            }
        }