// (C) 2001, 2002 Ximian, Inc. http://www.ximian.com
//
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System.IO;
using System.Collections;
using System.Text;
throw new ArgumentException ("stream is not writable.");
this.stream=stream;
- resources=new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer());
+ resources=new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
}
public ResourceWriter (String fileName)
throw new ArgumentNullException ("fileName is null.");
stream=new FileStream(fileName, FileMode.Create, FileAccess.Write);
- resources=new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer());
+ resources=new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
}
public void AddResource (string name, byte[] value)
if (name == null) {
throw new ArgumentNullException ("name is null");
}
- if (value == null) {
- throw new ArgumentNullException ("value is null");
- }
if(resources==null) {
throw new InvalidOperationException ("ResourceWriter has been closed");
}
IDictionaryEnumerator res_enum=resources.GetEnumerator();
while(res_enum.MoveNext()) {
- Type type=res_enum.Value.GetType();
-
- /* Keep a list of unique types */
- if(!types.Contains(type)) {
- types.Add(type);
- }
-
/* Hash the name */
hashes[count]=GetHash((string)res_enum.Key);
res_name.Write((string)res_enum.Key);
res_name.Write((int)res_data.BaseStream.Position);
+ if (res_enum.Value == null) {
+ Write7BitEncodedInt (res_data, -1);
+ count++;
+ continue;
+ }
+
+ Type type=res_enum.Value.GetType();
+
+ /* Keep a list of unique types */
+ if(!types.Contains(type)) {
+ types.Add(type);
+ }
+
/* Write the data section */
Write7BitEncodedInt(res_data, types.IndexOf(type));
/* Strangely, Char is serialized
value = high;
} while(value != 0);
}
+
+ internal Stream Stream {
+ get {
+ return stream;
+ }
+ }
}
}