You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Serializing a "circular dictionary" (a dictionary made circular with overridden indexer) results in index out of range exception. #2
1st things 1st, thank you for your work, it is amazing and easy to use! I encountered a problem, however:
I implemented a simple CircularDictionary for a university project of mine: public class CircularDictionary<TValue> : Dictionary<int, TValue> { public new TValue this[int i] { get { return base[i % this.Count]; } set { base[i] = value; } } }
For some reason, SharpSerializer's serialization always results in an index out of range exception. When I copy/pasted my data from the ciruclar to a normal one, serialization worked perfectly. Strangely though, it has no problem with my likewise simple CircularList: (GetNextElement and WhatIsNext, as you can see, has no contribution to indexing)
` public class CircularList : ObservableCollection
{
int inc;
public CircularList()
{
inc = 0;
}
public new T this[int i]
{
get
{
return base[i % this.Count];
}
set
{
base[i] = value;
}
}
public T GetNextElement(int number = 1)
{
return this[inc+=number];
}
public T WhatIsNext()
{
return this[inc + 1];
}
}`
changed the title [-]Serializing a "circular dictionary" (a dictioanry made circular with overridden indexer) results in index out of range exception.[/-][+]Serializing a "circular dictionary" (a dictionary made circular with overridden indexer) results in index out of range exception.[/+]on Nov 4, 2017
Activity
[-]Serializing a "circular dictionary" (a dictioanry made circular with overridden indexer) results in index out of range exception.[/-][+]Serializing a "circular dictionary" (a dictionary made circular with overridden indexer) results in index out of range exception.[/+]