实体和实体的集合-续3
1
using System;
2
using System.Collections;
3
using System.ComponentModel;
4![]()
5
namespace Entity
6
{
7
/// <summary>
8
/// 类OrderInfo的集合
9
/// </summary>
10
[Serializable]
11
public class OrderInfoCollection : CollectionBase
12
{
13
#region CollectionBase实现
14![]()
15
public OrderInfoCollection()
16
{
17
}
18![]()
19
public OrderInfoCollection(OrderInfo[] value)
20
{
21
this.AddRange(value);
22
}
23
24
public OrderInfo this[int index]
25
{
26
get{return ((OrderInfo)(this.List[index]));}
27
set{List[index] = value;}
28
}
29![]()
30
public int Add(OrderInfo value)
31
{
32
return this.List.Add(value);
33
}
34![]()
35
public OrderInfo AddNew()
36
{
37
return (OrderInfo)((IBindingList)this).AddNew();
38
}
39![]()
40
public void AddRange(OrderInfo[] value)
41
{
42
for (int i = 0; (i < value.Length); i = (i + 1))
43
{
44
this.Add(value[i]);
45
}
46
}
47![]()
48
public void AddRange(OrderInfoCollection value)
49
{
50
for (int i = 0; (i < value.Count); i = (i + 1))
51
{
52
this.Add((OrderInfo)value.List[i]);
53
}
54
}
55![]()
56
public bool Contains(OrderInfo value)
57
{
58
return this.List.Contains(value);
59
}
60![]()
61
public void CopyTo(OrderInfo[] array, int index)
62
{
63
this.List.CopyTo(array, index);
64
}
65![]()
66
public int IndexOf(OrderInfo value)
67
{
68
return this.List.IndexOf(value);
69
}
70![]()
71
public void Insert(int index, OrderInfo value)
72
{
73
List.Insert(index, value);
74
}
75![]()
76
public void Remove(OrderInfo value)
77
{
78
List.Remove(value);
79
}
80![]()
81
public new OrderInfoCollectionEnumerator GetEnumerator()
82
{
83
return new OrderInfoCollectionEnumerator(this);
84
}
85![]()
86
#endregion
87![]()
88![]()
89
#region OrderInfoCollectionEnumerator 实现
90![]()
91
public class OrderInfoCollectionEnumerator : IEnumerator
92
{
93
private IEnumerator _enumerator;
94
private IEnumerable _temp;
95
96
public OrderInfoCollectionEnumerator(OrderInfoCollection mappings)
97
{
98
_temp = ((IEnumerable)(mappings));
99
_enumerator = _temp.GetEnumerator();
100
}
101
102
public OrderInfo Current
103
{
104
get {return ((OrderInfo)(_enumerator.Current));}
105
}
106
107
object IEnumerator.Current
108
{
109
get {return _enumerator.Current;}
110
}
111
112
public bool MoveNext()
113
{
114
return _enumerator.MoveNext();
115
}
116
117
bool IEnumerator.MoveNext()
118
{
119
return _enumerator.MoveNext();
120
}
121
122
public void Reset()
123
{
124
_enumerator.Reset();
125
}
126
127
void IEnumerator.Reset()
128
{
129
_enumerator.Reset();
130
}
131
}
132
#endregion
133
}
134
}
using System;2
using System.Collections;3
using System.ComponentModel;4

5
namespace Entity6
{7
/// <summary>8
/// 类OrderInfo的集合9
/// </summary>10
[Serializable]11
public class OrderInfoCollection : CollectionBase12
{13
#region CollectionBase实现14

15
public OrderInfoCollection() 16
{17
}18

19
public OrderInfoCollection(OrderInfo[] value)20
{21
this.AddRange(value);22
}23
24
public OrderInfo this[int index] 25
{26
get{return ((OrderInfo)(this.List[index]));}27
set{List[index] = value;}28
}29

30
public int Add(OrderInfo value) 31
{32
return this.List.Add(value);33
}34

35
public OrderInfo AddNew() 36
{37
return (OrderInfo)((IBindingList)this).AddNew();38
}39

40
public void AddRange(OrderInfo[] value) 41
{42
for (int i = 0; (i < value.Length); i = (i + 1)) 43
{44
this.Add(value[i]);45
}46
}47

48
public void AddRange(OrderInfoCollection value) 49
{50
for (int i = 0; (i < value.Count); i = (i + 1)) 51
{52
this.Add((OrderInfo)value.List[i]);53
}54
}55

56
public bool Contains(OrderInfo value) 57
{58
return this.List.Contains(value);59
}60

61
public void CopyTo(OrderInfo[] array, int index) 62
{63
this.List.CopyTo(array, index);64
}65

66
public int IndexOf(OrderInfo value) 67
{68
return this.List.IndexOf(value);69
}70

71
public void Insert(int index, OrderInfo value) 72
{73
List.Insert(index, value);74
}75

76
public void Remove(OrderInfo value) 77
{78
List.Remove(value);79
}80

81
public new OrderInfoCollectionEnumerator GetEnumerator() 82
{83
return new OrderInfoCollectionEnumerator(this);84
}85

86
#endregion87

88

89
#region OrderInfoCollectionEnumerator 实现90

91
public class OrderInfoCollectionEnumerator : IEnumerator 92
{93
private IEnumerator _enumerator;94
private IEnumerable _temp;95
96
public OrderInfoCollectionEnumerator(OrderInfoCollection mappings)97
{98
_temp = ((IEnumerable)(mappings));99
_enumerator = _temp.GetEnumerator();100
}101
102
public OrderInfo Current103
{104
get {return ((OrderInfo)(_enumerator.Current));}105
}106
107
object IEnumerator.Current108
{109
get {return _enumerator.Current;}110
}111
112
public bool MoveNext()113
{114
return _enumerator.MoveNext();115
}116
117
bool IEnumerator.MoveNext()118
{119
return _enumerator.MoveNext();120
}121
122
public void Reset()123
{124
_enumerator.Reset();125
}126
127
void IEnumerator.Reset() 128
{129
_enumerator.Reset();130
}131
}132
#endregion133
}134
} 1
using System;
2
using System.Collections;
3
using System.ComponentModel;
4![]()
5
namespace Entity
6
{
7
/// <summary>
8
/// 类OrderInfo的集合
9
/// </summary>
10
[Serializable]
11
public class OrderInfoCollectionEx : OrderInfoCollection,IBindingList
12
{
13
#region IBindingList 成员
14![]()
15
private ListChangedEventArgs resetEvent = new ListChangedEventArgs(ListChangedType.Reset, -1);
16
private ListChangedEventHandler onListChanged;
17![]()
18
public bool AllowEdit
19
{
20
get {return true;}
21
}
22![]()
23
public bool AllowNew
24
{
25
get {return true;}
26
}
27![]()
28
public bool AllowRemove
29
{
30
get {return true;}
31
}
32![]()
33
public bool SupportsChangeNotification
34
{
35
get {return true;}
36
}
37![]()
38
public bool SupportsSearching
39
{
40
get {return false;}
41
}
42![]()
43
public bool SupportsSorting
44
{
45
get {return false;}
46
}
47![]()
48
public void AddIndex(PropertyDescriptor property)
49
{
50
throw new NotSupportedException();
51
}
52
public void ApplySort(PropertyDescriptor property, System.ComponentModel.ListSortDirection direction)
53
{
54
throw new NotSupportedException();
55
}
56
public PropertyDescriptor SortProperty
57
{
58
get{throw new NotSupportedException();
59
//return null;
60
}
61
}
62
public int Find(PropertyDescriptor property, object key)
63
{
64
throw new NotSupportedException();
65
//return 0;
66
}
67
public void RemoveSort()
68
{
69
throw new NotSupportedException();
70
}
71
public void RemoveIndex(PropertyDescriptor property)
72
{
73
throw new NotSupportedException();
74
}
75
public bool IsSorted
76
{
77
get { throw new NotSupportedException();
78
//return false;
79
}
80
}
81
public System.ComponentModel.ListSortDirection SortDirection
82
{
83
get{throw new NotSupportedException();
84
//return new System.ComponentModel.ListSortDirection ();
85
}
86
}
87
public event ListChangedEventHandler ListChanged
88
{
89
add{onListChanged += value;}
90
remove{onListChanged -= value;}
91
}
92![]()
93
protected virtual void OnListChanged(ListChangedEventArgs ev)
94
{
95
if (onListChanged != null)
96
{
97
onListChanged(this, ev);
98
}
99
}
100
protected override void OnClearComplete()
101
{
102
OnListChanged(resetEvent);
103
}
104![]()
105
object IBindingList.AddNew()
106
{
107
OrderInfoEx c = new OrderInfoEx();
108
List.Add(c);
109
return c;
110
}
111
private void RemoveChild(Object source, OrderInfoEx.OrderInfoEventArgs e)
112
{
113
List.Remove(source);
114
}
115
protected override void OnInsertComplete(int index, object value)
116
{
117
((OrderInfoEx)(value)).RemoveMe += new OrderInfoEx.OrderInfoEventHandler(RemoveChild);
118
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
119
}
120
protected override void OnRemoveComplete(int index, object value)
121
{
122
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
123
}
124
protected override void OnSetComplete(int index, object oldValue, object newValue)
125
{
126
if (oldValue != newValue)
127
{
128
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
129
}
130
}
131![]()
132![]()
133
#endregion
134
}
135
}
using System;2
using System.Collections;3
using System.ComponentModel;4

5
namespace Entity6
{7
/// <summary>8
/// 类OrderInfo的集合9
/// </summary>10
[Serializable]11
public class OrderInfoCollectionEx : OrderInfoCollection,IBindingList12
{13
#region IBindingList 成员14

15
private ListChangedEventArgs resetEvent = new ListChangedEventArgs(ListChangedType.Reset, -1);16
private ListChangedEventHandler onListChanged;17

18
public bool AllowEdit 19
{ 20
get {return true;}21
}22

23
public bool AllowNew 24
{ 25
get {return true;}26
}27

28
public bool AllowRemove 29
{ 30
get {return true;}31
}32

33
public bool SupportsChangeNotification 34
{ 35
get {return true;}36
}37

38
public bool SupportsSearching 39
{ 40
get {return false;}41
}42

43
public bool SupportsSorting44
{ 45
get {return false;}46
}47

48
public void AddIndex(PropertyDescriptor property)49
{50
throw new NotSupportedException();51
}52
public void ApplySort(PropertyDescriptor property, System.ComponentModel.ListSortDirection direction)53
{54
throw new NotSupportedException();55
}56
public PropertyDescriptor SortProperty57
{58
get{throw new NotSupportedException();59
//return null;60
}61
}62
public int Find(PropertyDescriptor property, object key)63
{64
throw new NotSupportedException(); 65
//return 0;66
}67
public void RemoveSort()68
{69
throw new NotSupportedException(); 70
}71
public void RemoveIndex(PropertyDescriptor property)72
{73
throw new NotSupportedException(); 74
}75
public bool IsSorted76
{77
get { throw new NotSupportedException();78
//return false;79
}80
}81
public System.ComponentModel.ListSortDirection SortDirection82
{83
get{throw new NotSupportedException();84
//return new System.ComponentModel.ListSortDirection ();85
}86
}87
public event ListChangedEventHandler ListChanged 88
{89
add{onListChanged += value;}90
remove{onListChanged -= value;}91
}92

93
protected virtual void OnListChanged(ListChangedEventArgs ev) 94
{95
if (onListChanged != null) 96
{97
onListChanged(this, ev);98
}99
}100
protected override void OnClearComplete() 101
{102
OnListChanged(resetEvent);103
}104

105
object IBindingList.AddNew()106
{107
OrderInfoEx c = new OrderInfoEx();108
List.Add(c);109
return c;110
}111
private void RemoveChild(Object source, OrderInfoEx.OrderInfoEventArgs e)112
{113
List.Remove(source);114
}115
protected override void OnInsertComplete(int index, object value) 116
{117
((OrderInfoEx)(value)).RemoveMe += new OrderInfoEx.OrderInfoEventHandler(RemoveChild); 118
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));119
}120
protected override void OnRemoveComplete(int index, object value) 121
{122
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));123
}124
protected override void OnSetComplete(int index, object oldValue, object newValue) 125
{126
if (oldValue != newValue) 127
{128
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));129
}130
}131

132

133
#endregion134
}135
}


浙公网安备 33010602011771号