コード例 #1
0
ファイル: Platform.cs プロジェクト: qipa/gax-dotnet
        private static async Task <Platform> LoadInstanceAsync()
        {
            // The order matters here:
            // * GAE runs on GCE, so do GAE before GCE.
            // * GKE runs on GCE, so do GKE before GCE.
            // * Metadata server access can take time, so do GAE first.
            GaePlatformDetails gaeDetails = LoadGaeDetails();

            if (gaeDetails != null)
            {
                return(new Platform(gaeDetails));
            }
            var metadataJson = await LoadMetadataAsync().ConfigureAwait(false);

            if (metadataJson != null)
            {
                var kubernetesData = await GkePlatformDetails.LoadKubernetesDataAsync().ConfigureAwait(false);

                if (kubernetesData != null)
                {
                    GkePlatformDetails gkeDetails = GkePlatformDetails.TryLoad(metadataJson, kubernetesData);
                    if (gkeDetails != null)
                    {
                        return(new Platform(gkeDetails));
                    }
                }
                GcePlatformDetails gceDetails = GcePlatformDetails.TryLoad(metadataJson);
                if (gceDetails != null)
                {
                    return(new Platform(gceDetails));
                }
            }
            return(new Platform());
        }
コード例 #2
0
ファイル: Platform.cs プロジェクト: qipa/gax-dotnet
 /// <summary>
 /// Construct with details of Google Compute Engine.
 /// </summary>
 /// <param name="gceDetails">Details of Google Compute Engine.</param>
 public Platform(GcePlatformDetails gceDetails)
 {
     GceDetails = GaxPreconditions.CheckNotNull(gceDetails, nameof(gceDetails));
 }