当前位置: 首页>>代码示例>>C#>>正文


C# Script.Compile方法代码示例

本文整理汇总了C#中Script.Compile方法的典型用法代码示例。如果您正苦于以下问题:C# Script.Compile方法的具体用法?C# Script.Compile怎么用?C# Script.Compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Script的用法示例。


在下文中一共展示了Script.Compile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScriptedMapping

 public ScriptedMapping(string name, string scriptBody)
     : base(name)
 {
     _script = CSharpScript.Create<string>(scriptBody, globalsType: typeof(ScriptGlobals));
     var diagnostic = _script.Compile();
     if (diagnostic.Any())
     {
         foreach (var message in diagnostic)
         {
             Console.WriteLine(message);
         }
     }
     Globals = new ScriptGlobals();
 }
开发者ID:sinkingsugar,项目名称:BulletSharpPInvoke,代码行数:14,代码来源:SymbolMapping.cs

示例2: CheckScriptValidity

        private bool CheckScriptValidity(Script script)
        {
            var diagnostics = script.Compile();
            if(!diagnostics.Any(d => d.WarningLevel == 0))
            {
                return true;
            }

            using (var sw = new StreamWriter(errorLogPath, true))
            {
                sw.WriteLine($"{DateTime.Now.ToLongDateString()}, {DateTime.Now.ToLongTimeString()}");
                foreach (var d in diagnostics)
                {
                    sw.WriteLine(d.ToString());
                }
                sw.WriteLine();
            }
            return false;
        }
开发者ID:malaybaku,项目名称:RoslynScriptForMMM,代码行数:19,代码来源:ScriptRunner.cs

示例3: Compile

        private void Compile(string filepath, string sourceCode)
        {
            var options = ScriptOptions.Default
                .WithReferences(Assembly.GetExecutingAssembly())
                .WithReferences(typeof(object).Assembly)
                .WithReferences(Path.Combine(MayaRootPath, "bin", "openmayacs.dll"))
                .WithFilePath(filepath);

            _script = CSharpScript.Create(sourceCode, options);

            var diags = _script.Compile();
            if (diags.Length > 0)
            {
                foreach (var diag in diags)
                {
                    MGlobal.displayError(diag.ToString());
                }
                throw new InvalidProgramException();
            }
        }
开发者ID:hal1932,项目名称:MayaCsi,代码行数:20,代码来源:CSharpInterpreter.cs

示例4: CreateScript

        private void CreateScript()
        {
            var scriptText = ScriptText;
            lock (typeof(ScriptingEngine))
            {
                Script<IQueryResult> existingScript;

                if (_scripts.TryGetValue(scriptText, out existingScript))
                {
                    _script = existingScript;
                    return;
                }                
            }

            _script = CSharpScript.Create<IQueryResult>(scriptText, globalsType: typeof (Globals), options: _options);
            _script.Compile();

            lock (typeof (ScriptingEngine))
            {
                _scripts[scriptText] = _script;
            }
        }
开发者ID:RF77,项目名称:sharp-tsdb,代码行数:22,代码来源:ScriptingEngine.cs


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