protected override void Serialize(IntermediateWriter output,
                                          SharedResourceDictionary <TKey, TValue> value,
                                          ContentSerializerAttribute format)
        {
            foreach (TKey key in value.Keys)
            {
                if (default(TKey) is ValueType)
                {
                    output.WriteObject(key, Keyformat);
                }
                else
                {
                    output.WriteSharedResource(key, Keyformat);
                }

                if (default(TValue) is ValueType)
                {
                    output.WriteObject(value[key], Valueformat);
                }
                else
                {
                    output.WriteSharedResource(value[key], Valueformat);
                }
            }
        }
Exemple #2
0
 protected override void Serialize(IntermediateWriter output,
                                   SharedResourceList <T> value,
                                   ContentSerializerAttribute format)
 {
     foreach (T item in value)
     {
         output.WriteSharedResource(item, itemFormat);
     }
 }
        protected internal override void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format)
        {
            // First serialize the base type.
            if (_baseSerializer != null)
                _baseSerializer.Serialize(output, value, format);

            // Now serialize our own elements.
            foreach (var info in _elements)
            {
                var elementValue = info.Getter(value);

                if (info.Attribute.SharedResource)
                    output.WriteSharedResource(elementValue, info.Attribute);
                else
                    output.WriteObjectInternal(elementValue, info.Attribute, info.Serializer, info.Serializer.TargetType);
            }
        }