public string Serialize(object context)
        {
            string serialized = string.Empty;

            IDataProvider dataProvider = context as IDataProvider;
            if (dataProvider != null)
            {
                MemoryStream stream = new MemoryStream();

                DataProviderSettings settings = new DataProviderSettings()
                {
                    Aggregates = dataProvider.Settings.AggregateDescriptions.OfType<object>().ToArray(),
                    Filters = dataProvider.Settings.FilterDescriptions.OfType<object>().ToArray(),
                    Rows = dataProvider.Settings.RowGroupDescriptions.OfType<object>().ToArray(),
                    Columns = dataProvider.Settings.ColumnGroupDescriptions.OfType<object>().ToArray(),
                    AggregatesLevel = dataProvider.Settings.AggregatesLevel,
                    AggregatesPosition = dataProvider.Settings.AggregatesPosition
                };

                DataContractSerializer serializer = new DataContractSerializer(typeof(DataProviderSettings), KnownTypes);
                serializer.WriteObject(stream, settings);

                stream.Position = 0;
                var streamReader = new StreamReader(stream);
                serialized += streamReader.ReadToEnd();
            }

            return serialized;
        }
        public string Serialize(object context)
        {
            string serialized = string.Empty;

            IDataProvider dataProvider = context as IDataProvider;

            if (dataProvider != null)
            {
                MemoryStream stream = new MemoryStream();

                DataProviderSettings settings = new DataProviderSettings()
                {
                    Aggregates         = dataProvider.Settings.AggregateDescriptions.OfType <object>().ToArray(),
                    Filters            = dataProvider.Settings.FilterDescriptions.OfType <object>().ToArray(),
                    Rows               = dataProvider.Settings.RowGroupDescriptions.OfType <object>().ToArray(),
                    Columns            = dataProvider.Settings.ColumnGroupDescriptions.OfType <object>().ToArray(),
                    AggregatesLevel    = dataProvider.Settings.AggregatesLevel,
                    AggregatesPosition = dataProvider.Settings.AggregatesPosition
                };

                DataContractSerializer serializer = new DataContractSerializer(typeof(DataProviderSettings), KnownTypes);
                serializer.WriteObject(stream, settings);

                stream.Position = 0;
                var streamReader = new StreamReader(stream);
                serialized += streamReader.ReadToEnd();
            }

            return(serialized);
        }