• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IRuntimeEnvironment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IRuntimeEnvironment的典型用法代码示例。如果您正苦于以下问题:C# IRuntimeEnvironment类的具体用法?C# IRuntimeEnvironment怎么用?C# IRuntimeEnvironment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IRuntimeEnvironment类属于命名空间,在下文中一共展示了IRuntimeEnvironment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GenerateErrorHtml

        public static byte[] GenerateErrorHtml(bool showDetails, IRuntimeEnvironment runtimeEnvironment, Exception exception)
        {
            // Build the message for each error
            var builder = new StringBuilder();
            var rawExceptionDetails = new StringBuilder();

            if (!showDetails)
            {
                WriteMessage("An error occurred while starting the application.", builder);
            }
            else
            {
                Debug.Assert(exception != null);
                var wasSourceCodeWrittenOntoPage = false;
                var flattenedExceptions = FlattenAndReverseExceptionTree(exception);
                foreach (var innerEx in flattenedExceptions)
                {
                    WriteException(innerEx, builder, ref wasSourceCodeWrittenOntoPage);
                }

                WriteRawExceptionDetails("Show raw exception details", exception.ToString(), rawExceptionDetails);
            }

            // Generate the footer
            var footer = showDetails ? GenerateFooterEncoded(runtimeEnvironment) : null;

            // And generate the full markup
            return Encoding.UTF8.GetBytes(string.Format(CultureInfo.InvariantCulture, _errorPageFormatString, builder, rawExceptionDetails, footer));
        }
开发者ID:leloulight,项目名称:Hosting,代码行数:29,代码来源:StartupExceptionPage.cs


示例2: Register

        public static void Register(CommandLineApplication cmdApp, IApplicationEnvironment appEnvironment, IAssemblyLoadContextAccessor loadContextAccessor, IRuntimeEnvironment runtimeEnvironment)
        {
            cmdApp.Command("graph", (Action<CommandLineApplication>)(c => {
            c.Description = "Perform parsing, static analysis, semantic analysis, and type inference";

            c.HelpOption("-?|-h|--help");

            c.OnExecute((Func<System.Threading.Tasks.Task<int>>)(async () => {
              var jsonIn = await Console.In.ReadToEndAsync();
              var sourceUnit = JsonConvert.DeserializeObject<SourceUnit>(jsonIn);

              var root = Directory.GetCurrentDirectory();
              var dir = Path.Combine(root, sourceUnit.Dir);
              var context = new GraphContext
              {
            RootPath = root,
            SourceUnit = sourceUnit,
            ProjectDirectory = dir,
            HostEnvironment = appEnvironment,
            LoadContextAccessor = loadContextAccessor,
            RuntimeEnvironment = runtimeEnvironment
              };

              var result = await GraphRunner.Graph(context);

              Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
              return 0;
            }));
              }));
        }
开发者ID:YoloDev,项目名称:srclib-csharp,代码行数:30,代码来源:GraphConsoleCommand.cs


示例3: GetAllRuntimeIdentifiersWithoutOverride

 // This is intentionally NOT an extension method because it is only really here for testing
 internal static IEnumerable<string> GetAllRuntimeIdentifiersWithoutOverride(IRuntimeEnvironment env)
 {
     if (!string.Equals(env.OperatingSystem, RuntimeOperatingSystems.Windows, StringComparison.Ordinal))
     {
         yield return GetRuntimeIdentifierWithoutOverride(env);
     }
     else
     {
         var arch = env.RuntimeArchitecture.ToLowerInvariant();
         if (env.OperatingSystemVersion.Equals("6.1", StringComparison.Ordinal))
         {
             yield return "win7-" + arch;
         }
         else if (env.OperatingSystemVersion.Equals("6.2", StringComparison.Ordinal))
         {
             yield return "win8-" + arch;
             yield return "win7-" + arch;
         }
         else if (env.OperatingSystemVersion.Equals("6.3", StringComparison.Ordinal))
         {
             yield return "win81-" + arch;
             yield return "win8-" + arch;
             yield return "win7-" + arch;
         }
         else if (env.OperatingSystemVersion.Equals("10.0", StringComparison.Ordinal))
         {
             yield return "win10-" + arch;
             yield return "win81-" + arch;
             yield return "win8-" + arch;
             yield return "win7-" + arch;
         }
     }
 }
开发者ID:adwardliu,项目名称:dnx,代码行数:34,代码来源:RuntimeEnvironmentExtensions.cs


示例4: Register

    public static void Register(CommandLineApplication cmdApp, IApplicationEnvironment appEnv, IRuntimeEnvironment runtimeEnv)
    {
      if (runtimeEnv.OperatingSystem == "Windows")
      {
        _dnuPath = new Lazy<string>(FindDnuWindows);
      }
      else
      {
        _dnuPath = new Lazy<string>(FindDnuNix);
      }

      cmdApp.Command("depresolve", c => {
        c.Description = "Perform a combination of parsing, static analysis, semantic analysis, and type inference";

        c.HelpOption("-?|-h|--help");

        c.OnExecute(async () => {
          //System.Diagnostics.Debugger.Launch();
          var jsonIn = await Console.In.ReadToEndAsync();
          var sourceUnit = JsonConvert.DeserializeObject<SourceUnit>(jsonIn);

          var dir = Path.Combine(Directory.GetCurrentDirectory(), sourceUnit.Dir);
          var deps = await DepResolve(dir);

          var result = new List<Resolution>();
          foreach(var dep in deps)
          {
            result.Add(Resolution.FromLibrary(dep));
          }

          Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
          return 0;
        });
      });
    }
开发者ID:YoloDev,项目名称:srclib-csharp,代码行数:35,代码来源:DepresolveConsoleCommand.cs


示例5: GetDefaultDotNetReferenceAssembliesPath

 private static string GetDefaultDotNetReferenceAssembliesPath(IFileSystem fileSystem, IRuntimeEnvironment runtimeEnvironment)
 {            
     var os = runtimeEnvironment.OperatingSystemPlatform;
     
     if (os == Platform.Windows)
     {
         return null;
     }
     
     if (os == Platform.Darwin && 
         fileSystem.Directory.Exists("/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks"))
     {
         return "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks";
     }
     
     if (fileSystem.Directory.Exists("/usr/local/lib/mono/xbuild-frameworks"))
     {
         return "/usr/local/lib/mono/xbuild-frameworks";
     }
     
     if (fileSystem.Directory.Exists("/usr/lib/mono/xbuild-frameworks"))
     {
         return "/usr/lib/mono/xbuild-frameworks";
     }
     
     return null;
 }
开发者ID:krytarowski,项目名称:cli,代码行数:27,代码来源:DotNetReferenceAssembliesPathResolver.cs


示例6: GenerateKey

        internal static RSA GenerateKey(IRuntimeEnvironment environment) {
            if (string.Equals(environment.OperatingSystem, "Windows", StringComparison.OrdinalIgnoreCase)) {
#if DNXCORE50
                // On CoreCLR, use RSACng.
                return new RSACng(2048);
#else
                // On desktop CLR, use RSACryptoServiceProvider.
                return new RSACryptoServiceProvider(2048);
#endif
            }

            // When the runtime is identified as Mono, use RSACryptoServiceProvider, independently of the operating system.
            if (string.Equals(environment.RuntimeType, "Mono", StringComparison.OrdinalIgnoreCase)) {
                return new RSACryptoServiceProvider(2048);
            }

#if DNXCORE50
            // On Linux and Darwin, use RSAOpenSsl when running on CoreCLR.
            if (string.Equals(environment.OperatingSystem, "Linux", StringComparison.OrdinalIgnoreCase) ||
                string.Equals(environment.OperatingSystem, "Darwin", StringComparison.OrdinalIgnoreCase)) {
                return new RSAOpenSsl(2048);
            }
#endif

            // If no appropriate implementation can be found, throw an exception.
            throw new PlatformNotSupportedException("No RSA implementation compatible with your configuration can be found.");
        }
开发者ID:Fosol,项目名称:Example.Oauth,代码行数:27,代码来源:OpenIdConnectServerHelpers.cs


示例7: Program

        public Program(IRuntimeEnvironment runtimeEnvironment)
        {
            _loggerFactory = new LoggerFactory();

            var commandProvider = new CommandOutputProvider(runtimeEnvironment);
            _loggerFactory.AddProvider(commandProvider);
        }
开发者ID:robbert229,项目名称:dnx-watch,代码行数:7,代码来源:Program.cs


示例8: Startup

 public Startup(IHostingEnvironment hostingEnvironment, IApplicationEnvironment applicationEnvironment, IRuntimeEnvironment runtimeEnvironment)
 {
   log("Startup");
   log("Platform = " + runtimeEnvironment.OperatingSystem);
   string PrjFolder = "";
   // Set up configuration sources.
   var builder = new ConfigurationBuilder()
       .AddJsonFile("appsettings.json")
       .AddEnvironmentVariables();
   Configuration = builder.Build();
   try
   {
     PrjFolder = Directory.GetParent(hostingEnvironment.WebRootPath).FullName;
   }
   catch
   {
     // bei migrations klappts nicht mit der Ermittlung des Pfads aus env
     PrjFolder = Directory.GetCurrentDirectory();
     log("Could't get project folder from HostingEnvironment, using CurDir: " + PrjFolder);
   }
   _DataFolder = Path.Combine(PrjFolder, "data");
   log("DataFolder = " + _DataFolder);
   // Ordner überprüfen
   try
   {
     string AcessTestFileName = Path.Combine(_DataFolder, "_accestest.accestest");
     File.Create(AcessTestFileName);
   }
   catch (Exception E)
   {
     log("Could't write in DataFolder: " + E.Message);
   }
 }
开发者ID:gerry123,项目名称:g42,代码行数:33,代码来源:Startup.cs


示例9: VerifyMemberSignatures

        /// <summary>
        /// Uses Reflection to verify that the specified member signatures are present in emitted metadata
        /// </summary>
        /// <param name="appDomainHost">Unit test AppDomain host</param>
        /// <param name="expectedSignatures">Baseline signatures - use the Signature() factory method to create instances of SignatureDescription</param>
        internal static void VerifyMemberSignatures(
            IRuntimeEnvironment appDomainHost, params SignatureDescription[] expectedSignatures)
        {
            Assert.NotNull(expectedSignatures);
            Assert.NotEmpty(expectedSignatures);

            var succeeded = true;
            var expected = new List<string>();
            var actual = new List<string>();

            foreach (var signature in expectedSignatures)
            {
                List<string> actualSignatures = null;
                var expectedSignature = signature.ExpectedSignature;

                if (!VerifyMemberSignatureHelper(
                    appDomainHost, signature.FullyQualifiedTypeName, signature.MemberName,
                    ref expectedSignature, out actualSignatures))
                {
                    succeeded = false;
                }

                expected.Add(expectedSignature);
                actual.AddRange(actualSignatures);
            }

            if (!succeeded)
            {
                TriggerSignatureMismatchFailure(expected, actual);
            }
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:36,代码来源:MetadataSignatureUnitTestHelper.cs


示例10: Program

 public Program(IRuntimeEnvironment runtimeEnv)
 {
     var loggerFactory = new LoggerFactory();
     CommandOutputProvider = new CommandOutputProvider(runtimeEnv);
     loggerFactory.AddProvider(CommandOutputProvider);
     Logger = loggerFactory.CreateLogger<Program>();
 }
开发者ID:leloulight,项目名称:UserSecrets,代码行数:7,代码来源:Program.cs


示例11: Create

 public static PlatformServices Create(
     PlatformServices basePlatformServices,
     IApplicationEnvironment application = null,
     IRuntimeEnvironment runtime = null,
     IAssemblyLoaderContainer container = null,
     IAssemblyLoadContextAccessor accessor = null,
     ILibraryManager libraryManager = null)
 {
     if (basePlatformServices == null)
     {
         return new DefaultPlatformServices(
             application,
             runtime,
             container,
             accessor,
             libraryManager
         );
     }
     return new DefaultPlatformServices(
             application ?? basePlatformServices.Application,
             runtime ?? basePlatformServices.Runtime,
             container ?? basePlatformServices.AssemblyLoaderContainer,
             accessor ?? basePlatformServices.AssemblyLoadContextAccessor,
             libraryManager ?? basePlatformServices.LibraryManager
         );
 }
开发者ID:adwardliu,项目名称:dnx,代码行数:26,代码来源:PlatformServices.cs


示例12: CompilationEngineContext

 public CompilationEngineContext(IApplicationEnvironment applicationEnvironment,
                                 IRuntimeEnvironment runtimeEnvironment,
                                 IAssemblyLoadContext defaultLoadContext,
                                 CompilationCache cache)
     : this(applicationEnvironment, runtimeEnvironment, defaultLoadContext, cache, NoopWatcher.Instance)
 {
 }
开发者ID:rajeevkb,项目名称:dnx,代码行数:7,代码来源:CompilationEngineContext.cs


示例13: RuntimeInfoMiddleware

        /// <summary>
        /// Initializes a new instance of the <see cref="RuntimeInfoMiddleware"/> class
        /// </summary>
        /// <param name="next"></param>
        /// <param name="options"></param>
        public RuntimeInfoMiddleware(
            RequestDelegate next,
            RuntimeInfoPageOptions options,
            ILibraryManager libraryManager,
            IRuntimeEnvironment runtimeEnvironment)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (libraryManager == null)
            {
                throw new ArgumentNullException(nameof(libraryManager));
            }

            if (runtimeEnvironment == null)
            {
                throw new ArgumentNullException(nameof(runtimeEnvironment));
            }

            _next = next;
            _options = options;
            _libraryManager = libraryManager;
            _runtimeEnvironment = runtimeEnvironment;
        }
开发者ID:leloulight,项目名称:Diagnostics,代码行数:36,代码来源:RuntimeInfoMiddleware.cs


示例14: VerifyMemberSignatureHelper

        /// <summary>
        /// Uses Reflection to verify that the specified member signature is present in emitted metadata
        /// </summary>
        /// <param name="appDomainHost">Unit test AppDomain host</param>
        /// <param name="fullyQualifiedTypeName">
        /// Fully qualified type name for member
        /// Names must be in format recognized by reflection
        /// e.g. MyType&lt;T&gt;.MyNestedType&lt;T, U&gt; => MyType`1+MyNestedType`2
        /// </param>
        /// <param name="memberName">
        /// Name of member on specified type whose signature needs to be verified
        /// Names must be in format recognized by reflection
        /// e.g. For explicitly implemented member - I1&lt;string&gt;.Method => I1&lt;System.String&gt;.Method
        /// </param>
        /// <param name="expectedSignature">
        /// Baseline string for signature of specified member
        /// Skip this argument to get an error message that shows all available signatures for specified member
        /// This argument is passed by reference and it will be updated with a formatted form of the baseline signature for error reporting purposes
        /// </param>
        /// <param name="actualSignatures">List of found signatures matching member name</param>
        /// <returns>True if a matching member signature was found, false otherwise</returns>
        private static bool VerifyMemberSignatureHelper(
            IRuntimeEnvironment appDomainHost, string fullyQualifiedTypeName, string memberName,
            ref string expectedSignature, out List<string> actualSignatures)
        {
            Assert.False(string.IsNullOrWhiteSpace(fullyQualifiedTypeName), "'fullyQualifiedTypeName' can't be null or empty");
            Assert.False(string.IsNullOrWhiteSpace(memberName), "'memberName' can't be null or empty");

            var retVal = true; actualSignatures = new List<string>();
            var signatures = appDomainHost.GetMemberSignaturesFromMetadata(fullyQualifiedTypeName, memberName);
            var signatureAssertText = "Signature(\"" + fullyQualifiedTypeName + "\", \"" + memberName + "\", \"{0}\"),";

            if (!string.IsNullOrWhiteSpace(expectedSignature))
            {
                expectedSignature = expectedSignature.Replace("\"", "\\\"");
            }
            expectedSignature = string.Format(signatureAssertText, expectedSignature);

            if (signatures.Count > 1)
            {
                var found = false;
                foreach (var signature in signatures)
                {
                    var actualSignature = signature.Replace("\"", "\\\"");
                    actualSignature = string.Format(signatureAssertText, actualSignature);

                    if (actualSignature == expectedSignature)
                    {
                        actualSignatures.Clear();
                        actualSignatures.Add(actualSignature);
                        found = true; break;
                    }
                    else
                    {
                        actualSignatures.Add(actualSignature);
                    }
                }
                if (!found)
                {
                    retVal = false;
                }
            }
            else if (signatures.Count == 1)
            {
                var actualSignature = signatures.First().Replace("\"", "\\\"");
                actualSignature = string.Format(signatureAssertText, actualSignature);
                actualSignatures.Add(actualSignature);

                if (expectedSignature != actualSignature)
                {
                    retVal = false;
                }
            }
            else
            {
                retVal = false;
            }

            return retVal;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:80,代码来源:MetadataSignatureUnitTestHelper.cs


示例15: GenerateErrorHtml

        public static byte[] GenerateErrorHtml(bool showDetails, IRuntimeEnvironment runtimeEnvironment, params object[] errorDetails)
        {
            if (!showDetails)
            {
                errorDetails = new[] { "An error occurred while starting the application." };
            }

            // Build the message for each error
            var wasSourceCodeWrittenOntoPage = false;
            var builder = new StringBuilder();
            var rawExceptionDetails = new StringBuilder();

            foreach (object error in errorDetails ?? new object[0])
            {
                var ex = error as Exception;
                if (ex == null && error is ExceptionDispatchInfo)
                {
                    ex = ((ExceptionDispatchInfo)error).SourceException;
                }

                if (ex != null)
                {
                    var flattenedExceptions = FlattenAndReverseExceptionTree(ex);

                    var compilationException = flattenedExceptions.OfType<ICompilationException>()
                                                                  .FirstOrDefault();
                    if (compilationException != null)
                    {
                        WriteException(compilationException, builder, ref wasSourceCodeWrittenOntoPage);

                        var compilationErrorMessages = compilationException.CompilationFailures
                            .SelectMany(f => f.Messages.Select(m => m.FormattedMessage))
                            .Take(MaxCompilationErrorsToShow);

                        WriteRawExceptionDetails("Show raw compilation error details", compilationErrorMessages, rawExceptionDetails);
                    }
                    else
                    {
                        foreach (var innerEx in flattenedExceptions)
                        {
                            WriteException(innerEx, builder, ref wasSourceCodeWrittenOntoPage);
                        }

                        WriteRawExceptionDetails("Show raw exception details", new[] { ex.ToString() }, rawExceptionDetails);
                    }
                }
                else
                {
                    var message = Convert.ToString(error, CultureInfo.InvariantCulture);
                    WriteMessage(message, builder);
                }
            }

            // Generate the footer
            var footer = showDetails ? GenerateFooterEncoded(runtimeEnvironment) : null;

            // And generate the full markup
            return Encoding.UTF8.GetBytes(string.Format(CultureInfo.InvariantCulture, _errorPageFormatString, builder, rawExceptionDetails, footer));
        }
开发者ID:qiudesong,项目名称:Hosting,代码行数:59,代码来源:StartupExceptionPage.cs


示例16: Update

 public static void Update(this RuntimeEnvironment source, IRuntimeEnvironment environment)
 {
     source.OperatingSystem = environment.OperatingSystem;
     source.OperatingSystemVersion = environment.OperatingSystemVersion;
     source.RuntimeArchitecture = environment.RuntimeArchitecture;
     source.RuntimeType = environment.RuntimeType;
     source.RuntimeVersion = environment.RuntimeVersion;
 }
开发者ID:yonglehou,项目名称:Bolt,代码行数:8,代码来源:PerformanceExtensions.cs


示例17: Startup

        public Startup(IApplicationEnvironment env, IRuntimeEnvironment runtimeEnvironment)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder(env.ApplicationBasePath)
                .AddJsonFile("config.json");

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
开发者ID:salerth,项目名称:aspnet5test,代码行数:9,代码来源:Startup.cs


示例18: Startup

        //  private readonly Platform _platform;
        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv, IRuntimeEnvironment runtimeEnvironment)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddEnvironmentVariables();

            Configuration = builder.Build();
        }
开发者ID:mikeandersun,项目名称:experimental,代码行数:10,代码来源:Startup.cs


示例19: EnvironmentController

        public EnvironmentController(
            ILoggerFactory loggerFactory,
            IRuntimeEnvironment runtimeEnv)
            : base(loggerFactory.CreateLogger(nameof(EnvironmentController)))
        {
            this.runtimeEnv = runtimeEnv;

            this.hostname = Environment.MachineName;
        }
开发者ID:colemickens,项目名称:dotkube_____old,代码行数:9,代码来源:EnvironmentController.cs


示例20: TestLogger

        public TestLogger(IRuntimeEnvironment runtimeEnv, bool debug = false)
        {
            var commandOutputProvider = new CommandOutputProvider(runtimeEnv);
            if (debug)
            {
                commandOutputProvider.LogLevel = LogLevel.Debug;
            }

            _commandOutputLogger = (CommandOutputLogger)commandOutputProvider.CreateLogger("");
        }
开发者ID:leloulight,项目名称:UserSecrets,代码行数:10,代码来源:TestLogger.cs



注:本文中的IRuntimeEnvironment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IRuntimeMethodInfo类代码示例发布时间:2022-05-24
下一篇:
C# IRuntimeContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap