// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NET_2_1
+
using System;
using System.Collections;
using System.Globalization;
values [name] = Int32.Parse (se.Text);
break;
case "bytearray":
- Convert.FromBase64String (se.Text);
+ values [name] = Convert.FromBase64String (se.Text);
break;
case "string":
values [name] = se.Text;
public void SetValue (string name, object value, RegistryValueKind valueKind)
{
SetDirty ();
+
+ if (name == null)
+ name = string.Empty;
+
switch (valueKind){
case RegistryValueKind.String:
if (value is string){
SecurityElement se = new SecurityElement ("values");
+ // With SecurityElement.Text = value, and SecurityElement.AddAttribute(key, value)
+ // the values must be escaped prior to being assigned.
foreach (DictionaryEntry de in values){
object val = de.Value;
SecurityElement value = new SecurityElement ("value");
- value.AddAttribute ("name", (string) de.Key);
+ value.AddAttribute ("name", SecurityElement.Escape ((string) de.Key));
if (val is string){
value.AddAttribute ("type", "string");
- value.Text = (string) val;
+ value.Text = SecurityElement.Escape ((string) val);
} else if (val is int){
value.AddAttribute ("type", "int");
value.Text = val.ToString ();
value.Text = Convert.ToBase64String ((byte[]) val);
} else if (val is ExpandString){
value.AddAttribute ("type", "expand");
- value.Text = val.ToString ();
+ value.Text = SecurityElement.Escape (val.ToString ());
} else if (val is string []){
value.AddAttribute ("type", "string-array");
foreach (string ss in (string[]) val){
SecurityElement str = new SecurityElement ("string");
- str.Text = ss;
+ str.Text = SecurityElement.Escape (ss);
value.AddChild (str);
}
}
RegistryKey result = self.Probe (rkey, ToUnix (keyname), writable);
if (result == null && IsWellKnownKey (rkey.Name, keyname)) {
// create the subkey even if its parent was opened read-only
- result = CreateSubKey (rkey, keyname, false);
+ result = CreateSubKey (rkey, keyname, writable);
}
return result;
}
if (throw_if_missing && !self.ValueExists (name))
- throw new ArgumentException ("the given value does not exist", "name");
+ throw new ArgumentException ("the given value does not exist");
self.RemoveValue (name);
}
// key is marked for deletion
if (!throw_if_missing)
return;
- throw new ArgumentException ("the given value does not exist", "value");
+ throw new ArgumentException ("the given value does not exist");
}
string dir = Path.Combine (self.Dir, ToUnix (keyname));
Directory.Delete (dir, true);
KeyHandler.Drop (dir);
} else if (throw_if_missing)
- throw new ArgumentException ("the given value does not exist", "value");
+ throw new ArgumentException ("the given value does not exist");
}
public string [] GetSubKeyNames (RegistryKey rkey)
}
}
}
+
+#endif // NET_2_1
+