Skip to content

Commit 0fe8f72

Browse files
committed
#17 Fixed DeployServerSnapshot method of QueryRunner
1 parent 1c897d0 commit 0fe8f72

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

TS3QueryLib.Core.Silverlight/CommandHandling/Command.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public Command(string commandName, params string[] options)
5454

5555
#region Public Methods
5656

57+
public void AddRaw(string rawText)
58+
{
59+
ParameterGroups.AddRaw(rawText);
60+
}
61+
5762
public void AddParameter(string parameterName)
5863
{
5964
ParameterGroups.AddParameter(parameterName, null, 0);

TS3QueryLib.Core.Silverlight/CommandHandling/CommandParameter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class CommandParameter
1111
public string EncodedName { get { return Ts3Util.EncodeString(Name); } }
1212
public string Value { get; set; }
1313
public string EncodedValue { get { return Ts3Util.EncodeString(Value); } }
14+
public bool EncodeNameWhenValueIsNull { get; set; }
1415

1516
#endregion
1617

@@ -21,13 +22,14 @@ public CommandParameter(string name) : this(name, null)
2122

2223
}
2324

24-
public CommandParameter(string name, string value)
25+
public CommandParameter(string name, string value, bool encodeNameWhenValueIsNull = true)
2526
{
2627
if (name.IsNullOrTrimmedEmpty())
2728
throw new ArgumentException("name is null or trimmed empty", "name");
2829

2930
Name = name.Trim();
3031
Value = value == null? null : value.Trim();
32+
EncodeNameWhenValueIsNull = encodeNameWhenValueIsNull;
3133
}
3234

3335
#endregion
@@ -36,7 +38,7 @@ public CommandParameter(string name, string value)
3638

3739
public override string ToString()
3840
{
39-
return Value == null ? EncodedName : string.Format("{0}={1}", Name, EncodedValue);
41+
return Value == null ? (EncodeNameWhenValueIsNull ? EncodedName : Name) : string.Format("{0}={1}", Name, EncodedValue);
4042
}
4143

4244
#endregion

TS3QueryLib.Core.Silverlight/CommandHandling/CommandParameterGroupList.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public CommandParameterGroupList(int capacity): base(capacity)
2929

3030
#region Public Methods
3131

32+
public void AddRaw(string rawText)
33+
{
34+
AddParameter(rawText, null, 0, false);
35+
}
36+
3237
public void AddParameter(string name)
3338
{
3439
AddParameter(name, null);
@@ -39,17 +44,17 @@ public void AddParameter(string name, string value)
3944
AddParameter(name, value, null);
4045
}
4146

42-
public void AddParameter(string name, string value, uint? groupIndex)
47+
public void AddParameter(string name, string value, uint? groupIndex, bool encodeNameWhenValueIsNull = true)
4348
{
4449
groupIndex = groupIndex ?? 0;
4550

4651
if (groupIndex > Count)
4752
throw new ArgumentOutOfRangeException(string.Format("Can not add parameter '{0}' with value '{1}' to group with index '{2}', because the index is '{3}' too big.", name, value, groupIndex, Count-groupIndex));
4853

4954
if (groupIndex == Count)
50-
Add(new CommandParameterGroup{new CommandParameter(name, value)});
55+
Add(new CommandParameterGroup{new CommandParameter(name, value, encodeNameWhenValueIsNull) });
5156
else
52-
this[(int) groupIndex].Add(new CommandParameter(name, value));
57+
this[(int) groupIndex].Add(new CommandParameter(name, value, encodeNameWhenValueIsNull));
5358
}
5459

5560
public CommandParameter GetParameter(string name)

TS3QueryLib.Core.Silverlight/Server/QueryRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ public SimpleResponse DeployServerSnapshot(string snapshotData)
874874
throw new ArgumentException("snapshotData is null or trimmed empty", "snapshotData");
875875

876876
Command command = CommandName.ServerSnapshotDeploy.CreateCommand();
877-
command.AddParameter(snapshotData);
877+
command.AddRaw(snapshotData);
878878

879879
return ResponseBase<SimpleResponse>.Parse(SendCommand(command));
880880
}

0 commit comments

Comments
 (0)