public override object ConvertFrom()

in tools/simpleresgen/mono/ResXFileRef.cs [59:107]


			public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
				byte[]		buffer;

				if ( !(value is String)) {
					return null;
				}

				string [] parts = ResXFileRef.Parse ((string) value);
				if (parts.Length == 1)
					throw new ArgumentException ("value");

				string filename = parts [0];
				if (Path.DirectorySeparatorChar == '/')
					filename = filename.Replace ("\\", "/");

				Type type = Type.GetType (parts [1]);
				if (type == typeof(string)) {
					Encoding encoding;
					if (parts.Length > 2) {
						encoding = Encoding.GetEncoding (parts [2]);
					} else {
						encoding = Encoding.Default;
					}

					using (TextReader reader = new StreamReader(filename, encoding)) {
						return reader.ReadToEnd();
					}
				}

				using (FileStream file = new FileStream (filename, FileMode.Open, FileAccess.Read, FileShare.Read)) {
					buffer = new byte [file.Length];
					file.Read(buffer, 0, (int) file.Length);
				}

				if (type == typeof(System.Byte[]))
					return buffer;

				//if (type == typeof (Bitmap) && Path.GetExtension (filename) == ".ico") {
				//	MemoryStream ms = new MemoryStream (buffer);
				//	return new Icon (ms).ToBitmap ();
				//}

				if (type == typeof (MemoryStream))
					return new MemoryStream (buffer);

				return Activator.CreateInstance(type, BindingFlags.CreateInstance
					| BindingFlags.Public | BindingFlags.Instance, null, 
					new object[] { new MemoryStream (buffer) }, culture);
			}