Beispiel #1
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            QueryableEntitySerializationProxy proxy;

            if (value is IEntity)
            {
                proxy = new QueryableEntitySerializationProxy()
                {
                    ReferencedId  = ((IEntity)value).UniqueId,
                    ReferenceType = QueryableEntitySerializationProxy.ReferenceTypes.EntityReference
                };
            }
            else
            {
                proxy = new QueryableEntitySerializationProxy()
                {
                    ReferencedId  = ((ITemplate)value).TemplateId,
                    ReferenceType = QueryableEntitySerializationProxy.ReferenceTypes.TemplateReference
                };
            }

            serializer.Serialize(writer, proxy);
        }
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
            QueryableEntitySerializationProxy proxy;

            if (value is IEntity) {
                proxy = new QueryableEntitySerializationProxy() {
                    ReferencedId = ((IEntity)value).UniqueId,
                    ReferenceType = QueryableEntitySerializationProxy.ReferenceTypes.EntityReference
                };
            }
            else {
                proxy = new QueryableEntitySerializationProxy() {
                    ReferencedId = ((ITemplate)value).TemplateId,
                    ReferenceType = QueryableEntitySerializationProxy.ReferenceTypes.TemplateReference
                };
            }

            serializer.Serialize(writer, proxy);
        }