Serialization Exception

4 posts, 1 answers
  1. Asuman
    Asuman avatar
    17 posts
    Member since:
    Dec 2014

    Posted 06 Sep 2015 Link to this post

    Hi,

    My localDataProvider's data structure is dynamic and like this.

    public class PeriodicData : CustomTypeHelper<PeriodicData>
        {
        }

    In app I'm adding these properties to PeriodicData as follows

    PeriodicData.AddProperty("Month", typeof(MyMonth));

    PeriodicData.AddProperty("Year", typeof(MyYear));

    PeriodicData.AddProperty("Name", typeof(string));

    PeriodicData.AddProperty("Sallary", typeof(double));

     

    MyMonth and MyYear are similiar structures and like this

        public class MyMonth : IComparable, IComparable<MyMonth>, IEquatable<MyMonth>
        {
            public MyMonth(int month)
            {
                this.Month = month;
            }

            private int _month;
            public int Month
            {
                get
                {
                    return _month;
                }
                set
                {
                    this.SortKey = value;
                    _month = value;
                }
            }

            private int _sortKey;
            public int SortKey
            {
                get
                {
                    return _sortKey;
                }
                private set
                {
                    _sortKey = value;
                }
            }

            public override string ToString()
            {
                return this.Month.ToString();
            }

            public int CompareTo(object obj)
            {
                return this.CompareTo(obj as MyMonth);
            }

            public override bool Equals(object obj)
            {
                return this.Equals(obj as MyMonth);
            }

            public override int GetHashCode()
            {
                return this.SortKey.GetHashCode();
            }

            public int CompareTo(MyMonth otherMonth)
            {
                if (otherMonth != null)
                {
                    return this.SortKey.CompareTo(otherMonth.SortKey);
                }

                return 0;
            }

            public bool Equals(MyMonth otherMonth)
            {
                if (otherMonth != null)
                {
                    return this.Month.Equals(otherMonth.Month);
                }

                return false;
            }
        }

     

    When I want to serialize the radpivotgrid data I'm getting the exception below and I don't know how to modify method below

            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;
            }

     

    Best regards...

  2. Asuman
    Asuman avatar
    17 posts
    Member since:
    Dec 2014

    Posted 06 Sep 2015 Link to this post

    Sorry, I've forgotten something again.

    I'm getting the exception just after I apply filter for MyYear or MyMonth and then trying to serialize the dataprovider.

    Best regards.

  3. DevCraft banner
  4. Asuman
    Asuman avatar
    17 posts
    Member since:
    Dec 2014

    Posted 07 Sep 2015 Link to this post

    Sory, I've found the solution at the telerik documentation link http://docs.telerik.com/devtools/silverlight/controls/radpivotgrid/features/localdatasourceprovider/serialization

     Best regards.​

  5. Answer
    Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 08 Sep 2015 Link to this post

    Hi Asuman,

    We are glad to here that you were able to achieve the desired using our documentation.

    Please, if you have any additional questions or concerns regarding Telerik control do not hesitate to contact us.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top