Exemple #1
0
        private void WriteAObject(object writer, object receiver, string modelName,
                                  WriteSettings settings, JsonTextWriter jsonWriter)
        {
            ObjectInfo info = ObjectInfo.Create(receiver, modelName);

            if (info.IsObjectContext)
            {
                TkDebug.ThrowIfNoGlobalVariable();
                BaseGlobalVariable.Current.ObjectContext.Push(receiver);
            }
            jsonWriter.WriteStartObject();
            foreach (var attr in info.Attributes)
            {
                SerializerUtil.WritePropertyInfo(this, writer, receiver, settings, attr, null);
            }

            if (info.Content != null)
            {
                SerializerUtil.WritePropertyInfo(this, writer, receiver, settings, info.Content, null);
            }
            else
            {
                SerializerUtil.WriteElements(this, info, writer, receiver, settings);
            }
            jsonWriter.WriteEndObject();
            jsonWriter.Flush();

            if (info.IsObjectContext)
            {
                BaseGlobalVariable.Current.ObjectContext.Pop();
            }
        }
Exemple #2
0
        private void InternalWriteXml(object writer, object receiver, WriteSettings settings,
                                      XElement current, string modelName)
        {
            ObjectInfo info = ObjectInfo.Create(receiver, modelName);

            if (info.IsObjectContext)
            {
                TkDebug.ThrowIfNoGlobalVariable();
                BaseGlobalVariable.Current.ObjectContext.Push(receiver);
            }

            foreach (var attr in info.Attributes)
            {
                SerializerUtil.WritePropertyInfo(this, writer, receiver, settings, attr, current);
            }
            if (info.Content != null)
            {
                SerializerUtil.WritePropertyInfo(this, writer, receiver,
                                                 settings, info.Content, current);
            }
            else
            {
                SerializerUtil.WriteChildElement(this, writer, info.Elements, settings, receiver,
                                                 (objValue, propInfo) => propInfo.GetValue(objValue), current);
            }

            if (info.IsObjectContext)
            {
                BaseGlobalVariable.Current.ObjectContext.Pop();
            }
        }
Exemple #3
0
        public static void Write(IObjectSerializer serializer, object writer, object receiver,
                                 string modelName, WriteSettings settings)
        {
            ObjectInfo info = ObjectInfo.Create(receiver, modelName);

            if (info.IsObjectContext)
            {
                TkDebug.ThrowIfNoGlobalVariable();
                BaseGlobalVariable.Current.ObjectContext.Push(receiver);
            }

            foreach (var attr in info.Attributes)
            {
                SerializerUtil.WritePropertyInfo(serializer, writer,
                                                 receiver, settings, attr, null);
            }
            if (info.Content != null)
            {
                SerializerUtil.WritePropertyInfo(serializer, writer,
                                                 receiver, settings, info.Content, null);
            }
            else
            {
                SerializerUtil.WriteElements(serializer, info, writer,
                                             receiver, settings);
            }
            if (info.IsObjectContext)
            {
                BaseGlobalVariable.Current.ObjectContext.Pop();
            }
        }
        private void WriteAObject(object writer, object receiver, string modelName,
                                  WriteSettings settings)
        {
            ObjectInfo info = ObjectInfo.Create(receiver, modelName);

            foreach (var attr in info.Attributes)
            {
                SerializerUtil.WritePropertyInfo(this, writer, receiver, settings, attr, null);
            }

            SerializerUtil.WriteElements(this, info, writer, receiver, settings);
        }
        public void WriteObject(object writer, object receiver, string modelName,
                                WriteSettings settings, QName root, object serializerData)
        {
            XmlWriter xmlWriter   = writer.Convert <XmlWriter>();
            var       prefixTable = serializerData.Convert <PrefixTable>();

            WriteStartElement(xmlWriter, root, prefixTable);
            ObjectInfo info = ObjectInfo.Create(receiver, modelName);

            if (info.IsObjectContext)
            {
                TkDebug.ThrowIfNoGlobalVariable();
                BaseGlobalVariable.Current.ObjectContext.Push(receiver);
            }

            foreach (var attr in info.Attributes)
            {
                SerializerUtil.WritePropertyInfo(this, writer, receiver,
                                                 settings, attr, prefixTable);
            }
            if (info.Content != null)
            {
                SerializerUtil.WritePropertyInfo(this, writer, receiver,
                                                 settings, info.Content, prefixTable);
            }
            else
            {
                SerializerUtil.WriteChildElement(this, writer, info.Elements, settings, receiver,
                                                 (objValue, propInfo) => propInfo.GetValue(objValue), prefixTable);
            }

            if (info.IsObjectContext)
            {
                BaseGlobalVariable.Current.ObjectContext.Pop();
            }
            xmlWriter.WriteEndElement();
        }