Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
не сериализируется коллекция
|
|||
|---|---|---|---|
|
#18+
есть следующая коллекция: [SerializableAttribute()] public class TemplateCollection<T> : CollectionBase, IBindingList { bool isSorted = false; ListSortDirection sortDirection = ListSortDirection.Ascending; PropertyDescriptor sortProperty = null; ArrayList sortIndex; ArrayList list; public T this[int index] { get { return ((T)List[index]); } set { List[index] = value; } } public int Add(T value) { return (List.Add(value)); } public int IndexOf(T value) { return (List.IndexOf(value)); } public void Insert(int index, T value) { List.Insert(index, value); } public void Remove(T value) { List.Remove(value); } public bool Contains(T value) { // If value is not of type T, this will return false. return (List.Contains(value)); } protected override void OnInsert(int index, Object value) { // Insert additional code to be run only when inserting values. } protected override void OnRemove(int index, Object value) { // Insert additional code to be run only when removing values. } protected override void OnSet(int index, Object oldValue, Object newValue) { // Insert additional code to be run only when setting values. } #region IBindingList Members public void AddIndex(PropertyDescriptor property) { throw new Exception("The method or operation is not implemented."); } public object AddNew() { throw new Exception("The method or operation is not implemented."); } public bool AllowEdit { get { throw new Exception("The method or operation is not implemented."); } } public bool AllowNew { get { throw new Exception("The method or operation is not implemented."); } } public bool AllowRemove { get { throw new Exception("The method or operation is not implemented."); } } public void ApplySort(PropertyDescriptor property, ListSortDirection direction) { if (!this.SupportsSorting) throw new NotSupportedException(); sortProperty = property; sortDirection = direction; DoSort(); } #region DoSort protected void DoSort() { SortIndex.Clear(); if (SortProperty == null) foreach (object obj in this.InnerList) SortIndex.Add(new ListItem(obj.ToString(), obj.ToString())); else foreach (object obj in this.InnerList) SortIndex.Add(new ListItem(SortProperty.GetValue(obj).ToString(), obj.ToString())); SortIndex.Sort(new ItemComparer()); isSorted = true; OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1)); } #endregion public int Find(PropertyDescriptor property, object key) { throw new Exception("The method or operation is not implemented."); } public bool IsSorted { get { return false; } } public event ListChangedEventHandler ListChanged; public void RemoveIndex(PropertyDescriptor property) { throw new Exception("The method or operation is not implemented."); } public void RemoveSort() { throw new Exception("The method or operation is not implemented."); } public ListSortDirection SortDirection { get { throw new Exception("The method or operation is not implemented."); } } public PropertyDescriptor SortProperty { get { return sortProperty; } } public bool SupportsChangeNotification { get { return true; } } public bool SupportsSearching { get { throw new Exception("The method or operation is not implemented."); } } public bool SupportsSorting { get { return true; } } #endregion protected ArrayList SortIndex { get { if (this.sortIndex == null) { this.sortIndex = new ArrayList(); } return this.sortIndex; } } #region OnListChanged protected void OnListChanged(ListChangedEventArgs e) { if (ListChanged != null) ListChanged(this, e); } #endregion } и есть класс: [SerializableAttribute()] public class Pair { public Pair() { // // TODO: Add constructor logic here // } public Pair(string txt, string value) { Txt = txt; Value = value; } private string _txt; public string Txt { get { return _txt; } set { _txt = value; } } private string _value; public string Value { get { return _value; } set { _value = value; } } } теперь когда: cl.TemplateCollection<Pair> linkColl = new cl.TemplateCollection<Pair>(); protected void btn_Click(object sender, EventArgs e) { linkColl.Add(new Pair("a", "b")); } и пытаюсь это загнать в ViewState — получаю ошибку: Exception Details: System.Runtime.Serialization.SerializationException: Type 'System.ComponentModel.PropertyDescriptor' in Assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable. почему это не сериализируется? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.09.2006, 12:38 |
|
||
|
не сериализируется коллекция
|
|||
|---|---|---|---|
|
#18+
Здравствуйте, parapet, Вы писали: P>и пытаюсь это загнать в ViewState — получаю ошибку: P>Exception Details: System.Runtime.Serialization.SerializationException: Type 'System.ComponentModel.PropertyDescriptor' in Assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable. P>почему это не сериализируется? так все написано: Type ' System.ComponentModel.PropertyDescriptor ' ... is not marked as serializable он пытается сериализовать все филды. bool isSorted = false; ListSortDirection sortDirection = ListSortDirection.Ascending; PropertyDescriptor sortProperty = null; ArrayList sortIndex; ArrayList list; из них PropertyDescriptor — не сериализуемый.... << RSDN@Home 1.1.4 stable SR1 rev. 568>> ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.09.2006, 12:45 |
|
||
|
не сериализируется коллекция
|
|||
|---|---|---|---|
|
#18+
Здравствуйте, mogadanez, Вы писали: M>так все написано: M>M>Type ' System.ComponentModel.PropertyDescriptor ' ... is not marked as serializable M>он пытается сериализовать все филды. M> M>bool isSorted = false; M>ListSortDirection sortDirection = ListSortDirection.Ascending; M>PropertyDescriptor sortProperty = null; M>ArrayList sortIndex; M>ArrayList list; M> M>из них PropertyDescriptor — не сериализуемый. спасибо. Пометил его как [NonSerialized()] — все работает :super: ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.09.2006, 13:41 |
|
||
|
не сериализируется коллекция
|
|||
|---|---|---|---|
|
#18+
P>спасибо. Пометил его как [NonSerialized()] — все работает :super: только надо понимать что после востановления информация в этом поле пропадет... << RSDN@Home 1.1.4 stable SR1 rev. 568>> ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.09.2006, 13:48 |
|
||
|
не сериализируется коллекция
|
|||
|---|---|---|---|
|
#18+
Здравствуйте, mogadanez, Вы писали: P>>спасибо. Пометил его как [NonSerialized()] — все работает :super: M>только надо понимать что после востановления информация в этом поле пропадет нк это понятно :shuffle: ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.09.2006, 14:57 |
|
||
|
|

start [/forum/topic.php?fid=18&fpage=874&tid=1389368]: |
0ms |
get settings: |
5ms |
get forum list: |
12ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
25ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
23ms |
get tp. blocked users: |
1ms |
| others: | 212ms |
| total: | 292ms |

| 0 / 0 |
