Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reducing need to create an empty NameValueCollection #174

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions DarkRift.Server/ClusterSpawnData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ public static ClusterSpawnData CreateFromXml(string filePath, NameValueCollectio
return CreateFromXml(XDocument.Load(filePath, LoadOptions.SetLineInfo), variables);
}

/// <summary>
/// Creates a cluster spawn data from specified XML configuration file.
/// </summary>
/// <param name="filePath">The path of the XML file.</param>
/// <returns>The ClusterSpawnData created.</returns>
public static ClusterSpawnData CreateFromXml(string filePath)
{
return CreateFromXml(filePath, new NameValueCollection());
}

/// <summary>
/// Creates a cluster spawn data from specified XML configuration file.
/// </summary>
Expand All @@ -181,6 +191,16 @@ public static ClusterSpawnData CreateFromXml(XDocument document, NameValueCollec
return spawnData;
}

/// <summary>
/// Creates a cluster spawn data from specified XML configuration file.
/// </summary>
/// <param name="document">The XML file.</param>
/// <returns>The ClusterSpawnData created.</returns>
public static ClusterSpawnData CreateFromXml(XDocument document)
{
return CreateFromXml(document, new NameValueCollection());
}

/// <summary>
/// Creates a new cluster spawn data with necessary settings.
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions DarkRift.Server/ServerSpawnData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,16 @@ public static ServerSpawnData CreateFromXml(string filePath, NameValueCollection
return CreateFromXml(XDocument.Load(filePath, LoadOptions.SetLineInfo), variables);
}

/// <summary>
/// Creates a server spawn data from specified XML configuration file.
/// </summary>
/// <param name="filePath">The path of the XML file.</param>
/// <returns>The ServerSpawnData created.</returns>
public static ServerSpawnData CreateFromXml(string filePath)
{
return CreateFromXml(filePath, new NameValueCollection());
}

/// <summary>
/// Creates a server spawn data from specified XML configuration file.
/// </summary>
Expand Down Expand Up @@ -1131,6 +1141,16 @@ public static ServerSpawnData CreateFromXml(XDocument document, NameValueCollect
return spawnData;
}

/// <summary>
/// Creates a server spawn data from specified XML configuration file.
/// </summary>
/// <param name="document">The XML file.</param>
/// <returns>The ServerSpawnData created.</returns>
public static ServerSpawnData CreateFromXml(XDocument document)
{
return CreateFromXml(document, new NameValueCollection());
}

/// <summary>
/// Default constructor.
/// </summary>
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ First, we start a server that gets its settings from the local file server.confi
```csharp
using DarkRift;
using DarkRift.Server;
using System.Collections.Specialized;

ServerSpawnData spawnData = ServerSpawnData.CreateFromXml("Server.config", new NameValueCollection());
ServerSpawnData spawnData = ServerSpawnData.CreateFromXml("Server.config");

var server = new DarkRiftServer(spawnData);

Expand Down Expand Up @@ -118,7 +117,7 @@ void Client_MessageReceived(object? sender, MessageReceivedEventArgs e)

client.MessageReceived += Client_MessageReceived;

client.Connect(IPAddress.Loopback, tcpPort:4296, udpPort: 4297, noDelay:true);
client.Connect(IPAddress.Loopback, tcpPort:4296, udpPort:4297, noDelay:true);

Console.WriteLine("Connected!");

Expand Down