Esempio n. 1
0
        internal override void Record <T>(ref T value, string label, Parameters parameters)
        {
            if (asThis)
            {
                Dbg.Err($"Attempting to write a second field after a RecordAsThis call");
                return;
            }

            if (parameters.asThis)
            {
                if (fields.Count > 0)
                {
                    Dbg.Err($"Attempting to make a RecordAsThis call after writing a field");
                    return;
                }

                asThis = true;

                Serialization.ComposeElement(node, value, typeof(T));

                return;
            }

            if (fields.Contains(label))
            {
                Dbg.Err($"Field '{label}' written multiple times");
                return;
            }

            fields.Add(label);

            Serialization.ComposeElement(node.CreateChild(label), value, typeof(T));
        }
Esempio n. 2
0
        /// <summary>
        /// Returns C# validation code starting at an option.
        /// </summary>
        public static string WriteValidation <T>(T target)
        {
            var writerContext = new WriterValidationRecord();

            Serialization.ComposeElement(writerContext.StartData(), target, target != null ? target.GetType() : typeof(T));

            return(writerContext.Finish());
        }
Esempio n. 3
0
        /// <summary>
        /// Returns a fully-formed XML document starting at an object.
        /// </summary>
        public static string Write <T>(T target, bool pretty = true)
        {
            var writerContext = new WriterXmlRecord();

            Serialization.ComposeElement(writerContext.StartData(), target, target != null ? target.GetType() : typeof(T));

            return(writerContext.Finish(pretty));
        }
Esempio n. 4
0
        public void ComposeNull()
        {
            var writerContext = new WriterNull(true);

            foreach (var decObj in Database.List)
            {
                Serialization.ComposeElement(WriterNodeNull.Start(writerContext), decObj, decObj.GetType(), isRootDec: true);
            }
        }
Esempio n. 5
0
        public string ComposeValidation()
        {
            var writerContext = new WriterValidationCompose();

            foreach (var decObj in Database.List)
            {
                Serialization.ComposeElement(writerContext.StartDec(decObj.GetType(), decObj.DecName), decObj, decObj.GetType(), isRootDec: true);
            }

            return(writerContext.Finish());
        }
Esempio n. 6
0
        public string ComposeXml(bool pretty)
        {
            var writerContext = new WriterXmlCompose();

            foreach (var decObj in Database.List)
            {
                Serialization.ComposeElement(writerContext.StartDec(decObj.GetType(), decObj.DecName), decObj, decObj.GetType(), new Recorder.Context(), isRootDec: true);
            }

            return(writerContext.Finish(pretty));
        }
Esempio n. 7
0
        /// <summary>
        /// Runs the Null writer, which is mostly useful for performance testing.
        /// </summary>
        public static void WriteNull <T>(T target)
        {
            var writerContext = new WriterNull(false);

            Serialization.ComposeElement(WriterNodeNull.Start(writerContext), target, target != null ? target.GetType() : typeof(T));
        }