您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

31 行
1.3 KiB

using System;
namespace Unity.Services.Core.Environments
{
/// <summary>
/// Initialization option extensions related to environments.
/// </summary>
public static class EnvironmentsOptionsExtensions
{
internal const string EnvironmentNameKey = "com.unity.services.core.environment-name";
/// <summary>
/// An extension to set the environment to use.
/// </summary>
/// <param name="self">The InitializationOptions object to modify</param>
/// <param name="environmentName">The name of the environment to use</param>
/// <exception cref="ArgumentException">Throws a <see cref="ArgumentException"/> if environmentName is null or empty.</exception>
/// <returns>
/// Return <paramref name="self"/>.
/// Fluent interface pattern to make it easier to chain set options operations.
/// </returns>
public static InitializationOptions SetEnvironmentName(this InitializationOptions self, string environmentName)
{
if (string.IsNullOrEmpty(environmentName))
throw new ArgumentException("Environment name cannot be null or empty.", nameof(environmentName));
self.SetOption(EnvironmentNameKey, environmentName);
return self;
}
}
}