22
33public static class ListWrappers
44{
5- public static string RepeatedFieldGuidWrapper =
6- """
7- class RepeatedFieldGuidWrapper : System.Collections.Generic.IList<System.Guid>
8- {
9- private readonly Google.Protobuf.Collections.RepeatedField<string> _internList;
5+ public static string IListWithRangeAdd = """
6+ public interface IListWithRangeAdd<T> : System.Collections.Generic.IList<T>
7+ {
8+ void Add(IEnumerable<T> items);
9+ }
10+ """ ;
1011
11- public RepeatedFieldGuidWrapper(Google.Protobuf.Collections.RepeatedField<string> internList)
12- {
13- this._internList = internList;
14- }
12+ public static string RepeatedFieldGuidWrapper = """
13+ class RepeatedFieldGuidWrapper : IListWithRangeAdd<System.Guid>
14+ {
15+ private readonly Google.Protobuf.Collections.RepeatedField<string> _internList;
1516
16- public System.Collections.Generic.IEnumerator<System.Guid> GetEnumerator()
17- {
18- using var enumerator = _internList.GetEnumerator();
19- while (enumerator.MoveNext())
20- {
21- yield return System.Guid.Parse(enumerator.Current);
22- }
23- }
17+ public RepeatedFieldGuidWrapper(Google.Protobuf.Collections.RepeatedField<string> internList)
18+ {
19+ this._internList = internList;
20+ }
2421
25- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
26- {
27- return GetEnumerator();
28- }
22+ public System.Collections.Generic.IEnumerator<System.Guid> GetEnumerator()
23+ {
24+ using var enumerator = _internList.GetEnumerator();
25+ while (enumerator.MoveNext())
26+ {
27+ yield return System.Guid.Parse(enumerator.Current);
28+ }
29+ }
2930
30- public void Add( System.Guid item )
31- {
32- _internList.Add(item.ToString("D") );
33- }
31+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator( )
32+ {
33+ return GetEnumerator( );
34+ }
3435
35- public void Clear( )
36- {
37- _internList.Clear( );
38- }
36+ public void Add(System.Guid item )
37+ {
38+ _internList.Add(item.ToString("D") );
39+ }
3940
40- public bool Contains( System.Guid item )
41- {
42- return _internList.Contains(item. ToString("D"));
43- }
41+ public void Add(IEnumerable< System.Guid> items )
42+ {
43+ _internList.AddRange(items.Select(i => i. ToString("D") ));
44+ }
4445
45- public void CopyTo(System.Guid[] array, int arrayIndex )
46- {
47- System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(_internList, System.Guid.Parse)).CopyTo(array, arrayIndex );
48- }
46+ public void Clear( )
47+ {
48+ _internList.Clear( );
49+ }
4950
50- public bool Remove (System.Guid item)
51- {
52- return _internList.Remove (item.ToString("D"));
53- }
51+ public bool Contains (System.Guid item)
52+ {
53+ return _internList.Contains (item.ToString("D"));
54+ }
5455
55- public int Count => _internList.Count;
56-
57- public bool IsReadOnly => _internList.IsReadOnly;
58-
59- public int IndexOf(System.Guid item)
60- {
61- return _internList.IndexOf(item.ToString("D"));
62- }
56+ public void CopyTo(System.Guid[] array, int arrayIndex)
57+ {
58+ System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(_internList, System.Guid.Parse)).CopyTo(array, arrayIndex);
59+ }
6360
64- public void Insert(int index, System.Guid item)
65- {
66- _internList.Insert(index, item.ToString("D"));
67- }
61+ public bool Remove( System.Guid item)
62+ {
63+ return _internList.Remove( item.ToString("D"));
64+ }
6865
69- public void RemoveAt(int index)
70- {
71- _internList.RemoveAt(index);
72- }
66+ public int Count => _internList.Count;
67+
68+ public bool IsReadOnly => _internList.IsReadOnly;
69+
70+ public int IndexOf(System.Guid item)
71+ {
72+ return _internList.IndexOf(item.ToString("D"));
73+ }
7374
74- public System.Guid this[int index]
75- {
76- get => System.Guid.Parse(_internList[index]);
77- set => _internList[index] = value.ToString("D");
78- }
79- }
80- """ ;
75+ public void Insert(int index, System.Guid item)
76+ {
77+ _internList.Insert(index, item.ToString("D"));
78+ }
79+
80+ public void RemoveAt(int index)
81+ {
82+ _internList.RemoveAt(index);
83+ }
84+
85+ public System.Guid this[int index]
86+ {
87+ get => System.Guid.Parse(_internList[index]);
88+ set => _internList[index] = value.ToString("D");
89+ }
90+ }
91+ """ ;
8192}
0 commit comments