More in this section

Forums / Developing with Sitefinity / Extend TelerikProvider to binary types and and support carts

Extend TelerikProvider to binary types and and support carts

3 posts, 0 answered
  1. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    24 Jun 2010
    Link to this post
    Hi Team,

    I need some help to extend TelerikProvider to support my custom type as Binary. I have write one custom class for my types as serializable and working perfect using custom cookie providers but not able to store in the Default provider as Binary. It's possible to extend the TelerikProvider to support the Binary types like or other solution.

    <providers>
    <add name="UserReserving" serializeAs="Binary" type="UserReserving" />
    </providers>

    UserReserving is a serializable class. 

    I have tried but have one error like :

    unable to convert object type  'System.String' to type  '...UserReserving'


    Thanks, Romi
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 Jun 2010
    Link to this post
    Hello Pierre,

    You are trying  to apply a custom format to the strings, using an inappropriate overload of the String.ToString method or you are calling some custom method where there is no provision for providing a format string which you are doing.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    24 Jun 2010
    Link to this post
    Hi Ivan,

    Always the problem.
    I use this same cart in Cookie provider and work as like a charm but is not stored outside session. I try to port to be stored in Defaut provider serializing as Binary. I not use any overload. The class is only composed by strings, ints or doubles, dateTime. The custom types are made with this types. The class as marked Serializable and use customsetting. I have simplified to understand. Cart Stored is another cart storing simple types and also Serialized and marked as Binary identical to this one. Always error .. string....to UserReserved
    UserReserved is a cart containing CartItemRes.
    thanks.
    namespace
    {
        [Serializable]
        [SettingsSerializeAsAttribute(SettingsSerializeAs.Binary)]
        public class CartItemRes
        {
            private int _productID;     
            private Cart _cart;
            ..
            public CartItemRes()
            {
            }
            public CartItemRes(int ProductID, Cart CartStored, ...others string, int or double )
            {
                _productID = ProductID;
                _cart = CartStored;         
                ..others
            }
            public Cart CartStored
            {
                get
                {
                    return _cart;
                }
                set
                {
                    _cart = value;
                }
            }
            public int ProductID
            {
                get
                {
                    return _productID;
                }
                set
                {
                    _productID = value;
                }
            }
        ...OTHERS string int or double
        }
        [Serializable]
        [SettingsSerializeAsAttribute(SettingsSerializeAs.Binary)]
        public class UserReserved
        {
            private DateTime _dateCreated;
            private DateTime _lastUpdate;
            private List<CartItemRes> _items;
            public UserReserved()
            {
                if (this._items == null)
                {
                    this._items = new List<CartItemRes>();
                    this._dateCreated = DateTime.Now;
                }
            }
            public List<CartItemRes> Items
            {
            get { return _items;}
            set { _items = value;}
            }
            public void Insert(int ProductID,Cart CartStored, ...others string, int, double)
            {
                int ItemIndex = ItemIndexOfID(ProductID);
                if (ItemIndex == -1)
                {
                    CartItemRes NewItem = new CartItemRes();
                    NewItem.ProductID = ProductID;
                    NewItem.CartStored = CartStored;
                    NewItem.Quantity = 1;
                    _items.Add(NewItem);
                }
                else
                {
                    _items[ItemIndex].Quantity += 1;
                }
                _lastUpdate = DateTime.Now;
     
            }
     
            public void Update(int RowID, int ProductID, Cart CartStored....others string, double or int)
            {
                CartItemRes Item = _items[RowID];
                Item.ProductID = ProductID;
                Item.CartStored = CartStored;
                Item.Quantity = 1;
                _lastUpdate = DateTime.Now;
            }
     
        }
         
    }
Register for webinar
3 posts, 0 answered