3 static extern int g_mime_certificate_list_length (IntPtr list);
6 static extern void g_mime_certificate_list_clear (IntPtr list);
9 static extern int g_mime_certificate_list_add (IntPtr list, IntPtr ia);
12 static extern void g_mime_certificate_list_insert (IntPtr list, int index, IntPtr ia);
15 static extern bool g_mime_certificate_list_remove (IntPtr list, IntPtr ia);
18 static extern bool g_mime_certificate_list_remove_at (IntPtr list, int index);
21 static extern bool g_mime_certificate_list_contains (IntPtr list, IntPtr ia);
24 static extern int g_mime_certificate_list_index_of (IntPtr list, IntPtr ia);
27 static extern IntPtr g_mime_certificate_list_get_certificate (IntPtr list, int index);
30 static extern void g_mime_certificate_list_set_certificate (IntPtr list, int index, IntPtr ia);
33 Exception CannotAdd (object value)
36 return new ArgumentNullException ("value");
38 string message = String.Format ("Cannot add objects of type '{0}' to a CertificateCollection.",
39 value.GetType ().ToString ());
41 return new InvalidOperationException (message);
44 Exception CannotInsert (object value)
47 return new ArgumentNullException ("value");
49 string message = String.Format ("Cannot insert objects of type '{0}' into a CertificateCollection.",
50 value.GetType ().ToString ());
52 return new InvalidOperationException (message);
55 Exception CannotRemove (object value)
58 return new ArgumentNullException ("value");
60 string message = String.Format ("Cannot remove objects of type '{0}' from a CertificateCollection.",
61 value.GetType ().ToString ());
63 return new InvalidOperationException (message);
66 Exception CannotSet (object value)
69 return new ArgumentNullException ("value");
71 string message = String.Format ("Cannot set objects of type '{0}' on an CertificateCollection.",
72 value.GetType ().ToString ());
74 return new InvalidOperationException (message);
78 get { return g_mime_certificate_list_length (Handle); }
81 public bool IsFixedSize {
85 public bool IsReadOnly {
89 public bool IsSynchronized {
93 public object SyncRoot {
97 public int Add (Certificate cert)
100 throw CannotAdd (cert);
102 return g_mime_certificate_list_add (Handle, cert.Handle);
105 int IList.Add (object value)
107 Certificate cert = value as Certificate;
110 throw CannotAdd (value);
117 g_mime_certificate_list_clear (Handle);
120 public bool Contains (Certificate cert)
125 return g_mime_certificate_list_contains (Handle, cert.Handle);
128 bool IList.Contains (object value)
130 return Contains (value as Certificate);
133 public void CopyTo (Array array, int index)
136 throw new ArgumentNullException ("array");
139 throw new ArgumentOutOfRangeException ("index");
143 for (int i = 0; i < n; i++)
144 array.SetValue (((IList) this)[i], index + i);
147 public IEnumerator GetEnumerator ()
151 for (int i = 0; i < n; i++)
152 yield return this[i];
157 public int IndexOf (Certificate cert)
162 return g_mime_certificate_list_index_of (Handle, cert.Handle);
165 int IList.IndexOf (object value)
167 return IndexOf (value as Certificate);
170 public void Insert (int index, Certificate cert)
173 throw CannotInsert (cert);
176 throw new ArgumentOutOfRangeException ("index");
178 g_mime_certificate_list_insert (Handle, index, cert.Handle);
181 void IList.Insert (int index, object value)
183 Certificate cert = value as Certificate;
186 throw CannotInsert (value);
188 Insert (index, cert);
191 public void Remove (Certificate cert)
194 throw CannotRemove (cert);
196 g_mime_certificate_list_remove (Handle, cert.Handle);
199 void IList.Remove (object value)
201 Certificate cert = value as Certificate;
204 throw CannotRemove (value);
209 public void RemoveAt (int index)
211 if (index < 0 || index >= Count)
212 throw new ArgumentOutOfRangeException ("index");
214 g_mime_certificate_list_remove_at (Handle, index);
217 public Certificate this[int index] {
219 IntPtr raw = g_mime_certificate_list_get_certificate (Handle, index);
221 if (raw == IntPtr.Zero)
224 return GLib.Object.GetObject (raw) as Certificate;
229 throw CannotSet (value);
231 g_mime_certificate_list_set_certificate (Handle, index, value.Handle);
235 object IList.this[int index] {
241 this[index] = value as Certificate;