Ejemplo n.º 1
0
        public void WriteDictionary(object writer, IDictionary receiver, BaseDictionaryAttribute attribute,
                                    string modelName, WriteSettings settings, QName root, object serializerData)
        {
            SerializerUtil.CheckSimpleDictionary(attribute, this);

            DataRow row = writer.Convert <DataRow>();
            DataColumnCollection cols = row.Table.Columns;
            var info = new DictionaryListObjectPropertyInfo(receiver, attribute, root);
            DictionaryAttribute dictAttr = attribute.Convert <DictionaryAttribute>();

            foreach (DataColumn column in cols)
            {
                string columnName = column.ColumnName;

                SetValue(writer, columnName, receiver[columnName], info, settings);
            }
        }
        public void ReadDictionary(object reader, IDictionary receiver, BaseDictionaryAttribute attribute,
                                   string modelName, ReadSettings settings, QName root, object serializerData)
        {
            SerializerUtil.CheckSimpleDictionary(attribute, this);

            QueryStringBuilder builder = reader.Convert <QueryStringBuilder>();
            var info = new DictionaryListObjectPropertyInfo(receiver, attribute, root);
            DictionaryAttribute dictAttr = attribute.Convert <DictionaryAttribute>();

            foreach (string key in builder.AllKeys)
            {
                var    value    = builder[key];
                string strValue = value.ToString();
                receiver[key] = SerializerUtil.GetPropertyObject(receiver, settings,
                                                                 info, strValue, dictAttr.AutoTrim);
            }
        }
Ejemplo n.º 3
0
        public void ReadDictionary(object reader, IDictionary receiver, BaseDictionaryAttribute attribute,
                                   string modelName, ReadSettings settings, QName root, object serializerData)
        {
            SerializerUtil.CheckSimpleDictionary(attribute, this);

            DataRow row = reader.Convert <DataRow>();
            DataColumnCollection cols = row.Table.Columns;
            var info = new DictionaryListObjectPropertyInfo(receiver, attribute, root);
            DictionaryAttribute dictAttr = attribute.Convert <DictionaryAttribute>();

            foreach (DataColumn column in cols)
            {
                string columnName = column.ColumnName;

                receiver[columnName] = SerializerUtil.GetPropertyObject(receiver, settings,
                                                                        info, GetValue(reader, columnName), dictAttr.AutoTrim);
            }
        }