Example #1
0
        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);
            }
Example #3
0
 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);
 }
Example #5
0
 public void Write(IFormatWriter writer, Array instance)
 {
     _writer.Write(writer, instance);
     _property.Write(writer, _dimensions(instance));
 }
Example #6
0
 public void Write(IFormatWriter writer, object instance)
 {
     _serializers.Get(instance.GetType())
     .Write(writer, instance);
 }
 public void OnSerialized(IFormatWriter writer, object instance)
 {
 }
Example #8
0
 public void Write(IFormatWriter writer, IInterface instance)
 {
     writer.Content(instance.GetType().AssemblyQualifiedName);
 }
Example #9
0
 public void Write(IFormatWriter writer, object instance)
 {
     _serializer.Write(writer, _write.Get(instance));
 }
Example #10
0
 /// <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));
 }
Example #11
0
 public IEncounters Get(IFormatWriter parameter)
 => new DeferredEncounters(_encounters.Get(parameter), _reserved.Get(parameter));
Example #12
0
 public void Write(IFormatWriter writer, object instance) => _serializer()
 .Write(writer, instance);
Example #13
0
 /// <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);
 }
Example #16
0
 public void Write(IFormatWriter writer, string instance)
 {
     writer.Content($"Hello World! {instance}");
 }
Example #17
0
 public void Write(IFormatWriter writer, AdornedImage instance)
 {
 }
Example #18
0
 /// <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);
 }
Example #19
0
 public void OnSerializing(IFormatWriter writer, string instance)
 {
 }
Example #20
0
 public void Write(IFormatWriter writer, object instance)
 {
 }
Example #21
0
 public void Write(IFormatWriter writer, MemberInfo instance) => writer.Content(writer.Get(instance));
Example #22
0
 /// <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());
 }
Example #23
0
 public void Write(IFormatWriter writer, string instance)
 {
     _serializers.Get(typeof(string)).Write(writer, $"Hello world! {instance}");
 }
Example #24
0
 public void OnSerialized(IFormatWriter writer, string instance)
 {
     _store.Add(instance);
 }
Example #25
0
 public void Write(IFormatWriter writer, Array instance)
 {
     _identity.Write(writer, instance);
     _property.Write(writer, _element);
 }
Example #26
0
 public string Get(IFormatWriter writer, T instance) => _source(writer).Get(instance);
Example #27
0
 public void Write(IFormatWriter writer, T instance) => _writer.Write(writer, instance);
 public void Write(IFormatWriter writer, object instance) => _content.Write(writer, instance);
Example #29
0
 void IWriter <object> .Write(IFormatWriter writer, object instance)
 => throw new InvalidOperationException("This exists for static type-checking purposes only.");
Example #30
0
 public void Write(IFormatWriter writer, T instance) => writer.Content(_identity, _formatter(writer, instance));
 public void Write(IFormatWriter writer, DecoratedImage instance)
 {
 }