github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/testing/test/testdata/resource-args-python/dotnet/Utilities.cs (about) 1 // *** WARNING: this file was generated by test. *** 2 // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 4 namespace Pulumi.Example 5 { 6 static class Utilities 7 { 8 public static string? GetEnv(params string[] names) 9 { 10 foreach (var n in names) 11 { 12 var value = global::System.Environment.GetEnvironmentVariable(n); 13 if (value != null) 14 { 15 return value; 16 } 17 } 18 return null; 19 } 20 21 static string[] trueValues = { "1", "t", "T", "true", "TRUE", "True" }; 22 static string[] falseValues = { "0", "f", "F", "false", "FALSE", "False" }; 23 public static bool? GetEnvBoolean(params string[] names) 24 { 25 var s = GetEnv(names); 26 if (s != null) 27 { 28 if (global::System.Array.IndexOf(trueValues, s) != -1) 29 { 30 return true; 31 } 32 if (global::System.Array.IndexOf(falseValues, s) != -1) 33 { 34 return false; 35 } 36 } 37 return null; 38 } 39 40 public static int? GetEnvInt32(params string[] names) => int.TryParse(GetEnv(names), out int v) ? (int?)v : null; 41 42 public static double? GetEnvDouble(params string[] names) => double.TryParse(GetEnv(names), out double v) ? (double?)v : null; 43 44 [global::System.Obsolete("Please use WithDefaults instead")] 45 public static global::Pulumi.InvokeOptions WithVersion(this global::Pulumi.InvokeOptions? options) 46 { 47 var dst = options ?? new global::Pulumi.InvokeOptions{}; 48 dst.Version = options?.Version ?? Version; 49 return dst; 50 } 51 52 public static global::Pulumi.InvokeOptions WithDefaults(this global::Pulumi.InvokeOptions? src) 53 { 54 var dst = src ?? new global::Pulumi.InvokeOptions{}; 55 dst.Version = src?.Version ?? Version; 56 return dst; 57 } 58 59 private readonly static string version; 60 public static string Version => version; 61 62 static Utilities() 63 { 64 var assembly = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(Utilities)).Assembly; 65 using var stream = assembly.GetManifestResourceStream("Pulumi.Example.version.txt"); 66 using var reader = new global::System.IO.StreamReader(stream ?? throw new global::System.NotSupportedException("Missing embedded version.txt file")); 67 version = reader.ReadToEnd().Trim(); 68 var parts = version.Split("\n"); 69 if (parts.Length == 2) 70 { 71 // The first part is the provider name. 72 version = parts[1].Trim(); 73 } 74 } 75 } 76 77 internal sealed class ExampleResourceTypeAttribute : global::Pulumi.ResourceTypeAttribute 78 { 79 public ExampleResourceTypeAttribute(string type) : base(type, Utilities.Version) 80 { 81 } 82 } 83 }