public void Write(IFormatWriter writer, object instance) { var type = instance?.GetType(); if (type != null) { if (_type.IsSatisfiedBy(type)) { _property.Write(writer, type.GetTypeInfo()); _runtime.Write(writer, instance); } else { _body.Write(writer, instance); } } else { writer.Content(null); } }
public void Write(IFormatWriter writer, object instance) { if (_conditions.IsSatisfiedBy(writer.Get())) { var references = _references.Get(instance); if (references.Any()) { var typeInfo = instance.GetType() .GetTypeInfo(); var line = Environment.NewLine; var message = $"{line}{line}Here is a list of found references:{line}{string.Join(line, references.Select(x => $"- {x}"))}"; throw new CircularReferencesDetectedException( $"The provided instance of type '{typeInfo}' contains circular references within its graph. Serializing this instance would result in a recursive, endless loop. To properly serialize this instance, please create a serializer that has referential support enabled by extending it with the ReferencesExtension.{message}", _container); } } _container.Write(writer, instance); }
public string Serialize(SerializableStructure serialized, IFormatWriter formatter, bool includeType = true) { return formatter.Write(Dump(serialized, includeType)); }
public void Write(IFormatWriter writer, string instance) { writer.Verbatim(instance); }
public void Write(IFormatWriter writer, Array instance) { _writer.Write(writer, instance); _property.Write(writer, _dimensions(instance)); }
public void Write(IFormatWriter writer, object instance) { _serializers.Get(instance.GetType()) .Write(writer, instance); }
public void OnSerialized(IFormatWriter writer, object instance) { }
public void Write(IFormatWriter writer, IInterface instance) { writer.Content(instance.GetType().AssemblyQualifiedName); }
public void Write(IFormatWriter writer, object instance) { _serializer.Write(writer, _write.Get(instance)); }
/// <summary> /// Writes property for the specified container. /// </summary> /// <param name="writer">The writer.</param> /// <param name="container">The container.</param> public override void Write(IFormatWriter writer, object container) { writer.WriteLong(this.Tag, (long)this.GetAction(container)); }
public IEncounters Get(IFormatWriter parameter) => new DeferredEncounters(_encounters.Get(parameter), _reserved.Get(parameter));
public void Write(IFormatWriter writer, object instance) => _serializer() .Write(writer, instance);
/// <summary> /// Saves the specified value. /// </summary> /// <param name="value">The value.</param> /// <param name="writer">The writer.</param> public void Save(object value, IFormatWriter writer) { this.GetWriter(value.GetType()).Write(writer, value); }
/// <summary> /// Writes the collection. /// </summary> /// <param name="writer">The writer.</param> /// <param name="collection">The collection.</param> protected override void WriteCollection(IFormatWriter writer, ICollection <TElement> collection) { writer.WriteString("Type", collection.GetType().AssemblyQualifiedName); }
/// <summary> /// Writes an element. /// </summary> /// <param name="writer">The writer.</param> /// <param name="element">The element.</param> protected override void WriteElement(IFormatWriter writer, TElement element) { writer.WriteString("Type", element.GetType().AssemblyQualifiedName); Cementery.Serializer.Save(element, writer); }
public void Write(IFormatWriter writer, string instance) { writer.Content($"Hello World! {instance}"); }
public void Write(IFormatWriter writer, AdornedImage instance) { }
/// <summary> /// Writes the specified value. /// </summary> /// <param name="writer">The writer.</param> /// <param name="value">The value.</param> public override void Write(IFormatWriter writer, double value) { writer.WriteDouble("Value", value); }
public void OnSerializing(IFormatWriter writer, string instance) { }
public void Write(IFormatWriter writer, object instance) { }
public void Write(IFormatWriter writer, MemberInfo instance) => writer.Content(writer.Get(instance));
/// <summary> /// Writes the specified guid. /// </summary> /// <param name="writer">The writer.</param> /// <param name="value">The value.</param> public override void Write(IFormatWriter writer, Guid value) { writer.WriteString("Value", value.ToString()); }
public void Write(IFormatWriter writer, string instance) { _serializers.Get(typeof(string)).Write(writer, $"Hello world! {instance}"); }
public void OnSerialized(IFormatWriter writer, string instance) { _store.Add(instance); }
public void Write(IFormatWriter writer, Array instance) { _identity.Write(writer, instance); _property.Write(writer, _element); }
public string Get(IFormatWriter writer, T instance) => _source(writer).Get(instance);
public void Write(IFormatWriter writer, T instance) => _writer.Write(writer, instance);
public void Write(IFormatWriter writer, object instance) => _content.Write(writer, instance);
void IWriter <object> .Write(IFormatWriter writer, object instance) => throw new InvalidOperationException("This exists for static type-checking purposes only.");
public void Write(IFormatWriter writer, T instance) => writer.Content(_identity, _formatter(writer, instance));
public void Write(IFormatWriter writer, DecoratedImage instance) { }