Beispiel #1
0
        public void Write(object instance, INodeWriter parentNode, Type referencedAsType)
        {
            var typeName = typeNamesCache.GetTypeName(instance.GetType());

            using (
                var node = ownerDocument.CreateValueElement(typeName, parentNode))
            {
                using (var membersNode = ownerDocument.CreateMembersElement(node))
                {
                    memberWriter.Write(instance, membersNode, instance.GetType());
                }
            }
        }
        public void WriteMembers(object instance, ISerialiserNode parentNode, Type type)
        {
            var typeName = typeNamesCache.GetTypeName(type);

            using (
                var baseClassNode = ownerDocument.CreateBaseClassElement(typeName, parentNode))
            {
                using (var membersNode = ownerDocument.CreateMembersElement(baseClassNode))
                {
                    memberWriter.Write(instance, membersNode, type);
                }
                baseTypeMembersWriter.WriteMembers(instance, baseClassNode, type);
            }
        }
Beispiel #3
0
        public void Write(object instance, INodeWriter parentNode, Type referencedAsType)
        {
            var objectID = valuesCache.Add(instance);
            var typeName = typeNamesCache.GetTypeName(instance.GetType());

            using (var classNode = ownerDocument.CreateClassElement(typeName, objectID, parentNode))
            {
                using (var membersNode = ownerDocument.CreateMembersElement(classNode))
                {
                    memberWriter.Write(instance, membersNode, instance.GetType());
                }

                baseTypeMembersWriter.WriteMembers(instance, classNode, instance.GetType());
            }
        }