Beispiel #1
0
 static string TryGetArchitectureString(CommonPlatformDetection.CpuArchitecture arch)
 {
     if (arch == CommonPlatformDetection.CpuArchitecture.Unknown)
     {
         return(null);
     }
     return(arch.ToString().ToLowerInvariant());
 }
Beispiel #2
0
        public UserAgentStringProvider(string grpcCsharpVersion, string frameworkDescription, string clrVersion, string tfm, CommonPlatformDetection.CpuArchitecture arch)
        {
            var detailComponents = new List <string>();

            string sanitizedFrameworkDescription = SanitizeFrameworkDescription(frameworkDescription);

            if (sanitizedFrameworkDescription != null)
            {
                detailComponents.Add(sanitizedFrameworkDescription);
            }

            if (clrVersion != null)
            {
                detailComponents.Add($"CLR {clrVersion}");
            }

            if (tfm != null)
            {
                detailComponents.Add(tfm);
            }

            string architectureString = TryGetArchitectureString(arch);

            if (architectureString != null)
            {
                detailComponents.Add(architectureString);
            }

            // TODO(jtattermusch): consider adding details about running under unity / xamarin etc.
            var details = string.Join("; ", detailComponents);

            userAgentString = $"grpc-csharp/{grpcCsharpVersion} ({details})";
        }