Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EnumVariantViewOfEnumerator.cs
Go to the documentation of this file.
3
5
7{
9
11 {
12 if (enumerator == null)
13 {
14 throw new ArgumentNullException("enumerator");
15 }
16 Enumerator = enumerator;
17 }
18
20 {
21 if (Enumerator is ICloneable cloneable)
22 {
23 return new EnumVariantViewOfEnumerator((System.Collections.IEnumerator)cloneable.Clone());
24 }
25 throw new COMException(SR.Arg_EnumNotCloneable, -2147467259);
26 }
27
28 public int Next(int celt, object[] rgVar, IntPtr pceltFetched)
29 {
30 int num = 0;
31 try
32 {
33 if (celt > 0 && rgVar == null)
34 {
35 return -2147024809;
36 }
37 while (num < celt && Enumerator.MoveNext())
38 {
39 rgVar[num++] = Enumerator.Current;
40 }
41 if (pceltFetched != IntPtr.Zero)
42 {
43 Marshal.WriteInt32(pceltFetched, num);
44 }
45 }
46 catch (Exception ex)
47 {
48 return ex.HResult;
49 }
50 if (num != celt)
51 {
52 return 1;
53 }
54 return 0;
55 }
56
57 public int Reset()
58 {
59 try
60 {
61 Enumerator.Reset();
62 }
63 catch (Exception ex)
64 {
65 return ex.HResult;
66 }
67 return 0;
68 }
69
70 public int Skip(int celt)
71 {
72 try
73 {
74 while (celt > 0 && Enumerator.MoveNext())
75 {
76 celt--;
77 }
78 }
79 catch (Exception ex)
80 {
81 return ex.HResult;
82 }
83 if (celt != 0)
84 {
85 return 1;
86 }
87 return 0;
88 }
89
90 public object GetUnderlyingObject()
91 {
92 return Enumerator;
93 }
94}
static void WriteInt32(object ptr, int ofs, int val)
Definition Marshal.cs:105
static string Arg_EnumNotCloneable
Definition SR.cs:2102
Definition SR.cs:7
static readonly IntPtr Zero
Definition IntPtr.cs:18