github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/testing/test/testdata/other-owned/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 Other.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 dst.PluginDownloadURL = src?.PluginDownloadURL ?? "example.com/download"; 57 return dst; 58 } 59 60 private readonly static string version; 61 public static string Version => version; 62 63 static Utilities() 64 { 65 var assembly = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(Utilities)).Assembly; 66 using var stream = assembly.GetManifestResourceStream("Other.Example.version.txt"); 67 using var reader = new global::System.IO.StreamReader(stream ?? throw new global::System.NotSupportedException("Missing embedded version.txt file")); 68 version = reader.ReadToEnd().Trim(); 69 var parts = version.Split("\n"); 70 if (parts.Length == 2) 71 { 72 // The first part is the provider name. 73 version = parts[1].Trim(); 74 } 75 } 76 } 77 78 internal sealed class ExampleResourceTypeAttribute : global::Pulumi.ResourceTypeAttribute 79 { 80 public ExampleResourceTypeAttribute(string type) : base(type, Utilities.Version) 81 { 82 } 83 } 84 }