Beispiel #1
0
            public void Write(IFormatWriter writer, RootClass instance)
            {
                System.Xml.XmlWriter native = writer.Get().AsValid <System.Xml.XmlWriter>();                // if you need it.

                writer.Content(_name, instance.ManyToOneReference.Name);
                _serializer.Write(writer, instance);
            }
Beispiel #2
0
        public ImmutableArray <object> Get(IFormatWriter parameter)
        {
            var root   = _root.Get(parameter.Get());
            var result = root != null?_references.Get(root) : ImmutableArray <object> .Empty;

            return(result);
        }
Beispiel #3
0
                public void Write(IFormatWriter writer, RandomType instance)
                {
                    var xml = writer.Get().To <System.Xml.XmlWriter>();

                    xml.WriteAttributeString("DescriptionOverride", $"Override: {instance.Description}");

                    _serializer.Write(writer, instance);
                }
Beispiel #4
0
            public void Write(IFormatWriter writer, object instance)
            {
                var item = writer.Get();

                if (_conditions.IsSatisfiedBy(item))
                {
                    _instances.Assign(item, instance);
                }
                _container.Write(writer, instance);
            }
        static string[] Pack(IFormatWriter writer, ImmutableArray <Type> arguments)
        {
            var length = arguments.Length;
            var result = new string[length];

            for (var i = 0; i < length; i++)
            {
                result[i] = writer.Get(arguments[i].GetTypeInfo());
            }
            return(result);
        }
            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);
            }
Beispiel #7
0
 public void Write(IFormatWriter writer, MemberInfo instance) => writer.Content(writer.Get(instance));
Beispiel #8
0
 public void Write(IFormatWriter writer, object instance)
 => _custom.Serializer(writer.Get()
                       .AsValid <System.Xml.XmlWriter>(), instance);
Beispiel #9
0
 public object Get() => _writer.Get();
Beispiel #10
0
 public ImmutableArray <object> Get(IFormatWriter parameter) => _references.Get(_root.Get(parameter.Get()));