MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / Init

Method Init

sdks/csharp/src/AuthToken.cs:104–124  ·  view source on GitHub ↗

Initializes the AuthToken class. This must be called before any other methods. The folder to store the config file in. Default is ".spacetime_csharp_sdk". The name of the config file. Default is "settings.ini". The root folder to store the config file in. Default is the user's home dir

(string configFolder = ".spacetime_csharp_sdk", string configFile = "settings.ini", string? configRoot = null)

Source from the content-addressed store, hash-verified

102 /// <param name="configRoot">The root folder to store the config file in. Default is the user's home directory.</param>
103 /// </summary>
104 public static void Init(string configFolder = ".spacetime_csharp_sdk", string configFile = "settings.ini", string? configRoot = null)
105 {
106 configRoot ??= Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
107
108 if (Environment.GetCommandLineArgs().Any(arg => arg == "--client"))
109 {
110 int clientIndex = Array.FindIndex(Environment.GetCommandLineArgs(), arg => arg == "--client");
111 var configFileParts = configFile.Split(".");
112 configFile = $"{configFileParts[0]}_{Environment.GetCommandLineArgs()[clientIndex + 1]}.{configFileParts[1]}";
113 }
114
115 settingsPath = Path.Combine(configRoot, configFolder, configFile);
116
117 if (File.Exists(settingsPath))
118 {
119 token =
120 File.ReadLines(settingsPath)
121 .FirstOrDefault(line => line.StartsWith(PREFIX))
122 ?[PREFIX.Length..];
123 }
124 }
125
126 /// <summary>
127 /// This is the auth token that was saved to local storage. Null if not never saved.

Callers

nothing calls this directly

Calls 2

AnyMethod · 0.80
SplitMethod · 0.80

Tested by

no test coverage detected