/// <summary> /// Loads configuration from the provided location. /// </summary> /// <param name="builder">The builder.</param> /// <param name="configurationFile"></param> /// <returns>The builder.</returns> public static IClientBuilder LoadConfiguration(this IClientBuilder builder, FileInfo configurationFile) { var config = ClientConfiguration.LoadFromFile(configurationFile.FullName); if (config == null) { throw new ArgumentException( $"Error loading client configuration file {configurationFile.FullName}", nameof(configurationFile)); } builder.UseConfiguration(config); return(builder); }
private static async Task Run() { ClientConfiguration clientConfig = ClientConfiguration.LoadFromFile("ClientConfiguration.xml"); IClientBuilder clientBuilder = ClientBuilder.CreateDefault(); IClusterClient clusterClient = clientBuilder.UseConfiguration(clientConfig) .Build(); await clusterClient.Connect(); Console.WriteLine("输入手机号"); var number = Console.ReadLine(); var userService = clusterClient.GetGrain <IUserService>(1); var result = userService.Exist(number); while (!result.IsCompleted) { } if (result.Status == TaskStatus.Faulted) { foreach (var exceptionInnerException in result.Exception.InnerExceptions) { Console.WriteLine(exceptionInnerException.Message); } } //try //{ // result.Wait(); //} //catch (AggregateException e) //{ // foreach (var eInnerException in e.InnerExceptions) // { // Console.WriteLine(eInnerException.Message); // } // Console.WriteLine(e.Message); //} Console.WriteLine(result.Result); await clusterClient.Close(); }
/// <summary> /// Loads configuration from the standard client configuration locations. /// </summary> /// <param name="builder">The builder.</param> /// <remarks> /// This method loads the first client configuration file it finds, searching predefined directories for predefined file names. /// The following file names are tried in order: /// <list type="number"> /// <item>ClientConfiguration.xml</item> /// <item>OrleansClientConfiguration.xml</item> /// <item>Client.config</item> /// <item>Client.xml</item> /// </list> /// The following directories are searched in order: /// <list type="number"> /// <item>The directory of the executing assembly.</item> /// <item>The approot directory.</item> /// <item>The current working directory.</item> /// <item>The parent of the current working directory.</item> /// </list> /// Each directory is searched for all configuration file names before proceeding to the next directory. /// </remarks> /// <returns>The builder.</returns> public static IClientBuilder LoadConfiguration(this IClientBuilder builder) { builder.UseConfiguration(ClientConfiguration.StandardLoad()); return(builder); }