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

C# ScriptOptions类代码示例

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

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



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

示例1: JavaScript

        public static void JavaScript(Page page, string script, ScriptOptions options)
        {
            if (page == null) throw new ArgumentNullException("page");

            if (page.Items[script] == null)
            {
                PlaceHolder holder = GetPlaceHolder(page);

                if (Is(options, ScriptOptions.Include))
                {
                    AddScriptInclude(page, script, holder, Is(options, ScriptOptions.Prioritize));
                }
                else if (Is(options, ScriptOptions.None))
                {
                    holder.Page.Items[script] = AddString(script, holder, Is(options, ScriptOptions.Prioritize));
                }
                else
                {
                    Script scriptHolder = GetScriptHolder(page);
                    if (Is(options, ScriptOptions.ScriptTags))
                    {
                        holder.Page.Items[script] = AddString(script + Environment.NewLine, scriptHolder, Is(options, ScriptOptions.Prioritize));
                    }
                    else if (Is(options, ScriptOptions.DocumentReady))
                    {
                        JQuery(page);
                        holder.Page.Items[script] = AddString(EmbedDocumentReady(script) + Environment.NewLine, scriptHolder, Is(options, ScriptOptions.Prioritize));
                    }
                }
            }
        }
开发者ID:spmason,项目名称:n2cms,代码行数:31,代码来源:Register.cs


示例2: JavaScript

        /// <summary>Registers a script block on a page.</summary>
        /// <param name="page">The page onto which to added the script.</param>
        /// <param name="script">The script to add.</param>
        /// <param name="position">Where to add the script.</param>
        /// <param name="options">Script registration options.</param>
        public static void JavaScript(Page page, string script, ScriptPosition position, ScriptOptions options)
        {
            if (page == null) throw new ArgumentNullException("page");

            if (position == ScriptPosition.Header)
            {
                JavaScript(page, script, options);
            }
            else if (position == ScriptPosition.Bottom)
            {
                string key = script.GetHashCode().ToString();
                if (Is(options, ScriptOptions.None))
                    page.ClientScript.RegisterClientScriptBlock(typeof (Register), key, script);
                else if (Is(options, ScriptOptions.ScriptTags))
                    page.ClientScript.RegisterClientScriptBlock(typeof (Register), key, script, true);
                else if (Is(options, ScriptOptions.DocumentReady))
                {
                    JQuery(page);
                    page.ClientScript.RegisterClientScriptBlock(typeof (Register), key, EmbedDocumentReady(script), true);
                }
                else if (Is(options, ScriptOptions.Include))
                    page.ClientScript.RegisterClientScriptInclude(key, page.Engine().ManagementPaths.ResolveResourceUrl(script));
                else
                    throw new ArgumentException("options");
            }
            else
                throw new ArgumentException("position");
        }
开发者ID:sergheizagaiciuc,项目名称:n2cms,代码行数:33,代码来源:Register.cs


示例3: JavaScript

        /// <summary>Registers a script block on a page.</summary>
        /// <param name="page">The page onto which to added the script.</param>
        /// <param name="script">The script to add.</param>
        /// <param name="position">Where to add the script.</param>
        /// <param name="options">Script registration options.</param>
        public static void JavaScript(this Page page, string script, ScriptPosition position, ScriptOptions options)
        {
            if (page == null) throw new ArgumentNullException("page");

            if (position == ScriptPosition.Header)
            {
                JavaScript(page, script, options);
            }
            else if (position == ScriptPosition.Bottom)
            {
                string key = script.GetHashCode().ToString();
                if (options.Is(ScriptOptions.None))
                    page.ClientScript.RegisterStartupScript(typeof(Register), key, script);
                else if (options.Is(ScriptOptions.ScriptTags))
                    page.ClientScript.RegisterStartupScript(typeof(Register), key, script, true);
                else if (options.Is(ScriptOptions.DocumentReady))
                {
                    page.JQuery();
                    page.ClientScript.RegisterStartupScript(typeof(Register), key, EmbedDocumentReady(script), true);
                }
                else if (options.Is(ScriptOptions.Include))
                    page.ClientScript.RegisterClientScriptInclude(key, Url.ResolveTokens(script));
                else
                    throw new ArgumentException("options");
            }
            else
                throw new ArgumentException("position");
        }
开发者ID:pauldotknopf,项目名称:Noodle,代码行数:33,代码来源:Register.cs


示例4: GenerateJavaScriptOptionsDoesAlwaysQuotingObjecLiteralKeys

        public void GenerateJavaScriptOptionsDoesAlwaysQuotingObjecLiteralKeys()
        {
            var literal = JS.Object(new {name = "Dave", function = "Developer"});

            var without = new ScriptOptions {AlwaysQuoteObjectLiteralKeys = false, PreferredQuoteChar = '"'};
            var with = new ScriptOptions {AlwaysQuoteObjectLiteralKeys = true, PreferredQuoteChar = '"'};

            Assert.AreEqual("{name:\"Dave\",function:\"Developer\"};", literal.ToString(true, without, false));
            Assert.AreEqual("{\"name\":\"Dave\",\"function\":\"Developer\"};", literal.ToString(true, with, false));
        }
开发者ID:DaveVdE,项目名称:adamjsgenerator,代码行数:10,代码来源:GenerateJavaScriptOptionsTests.cs


示例5: GenerateJavaScriptOptionsCanBeSet

        public void GenerateJavaScriptOptionsCanBeSet()
        {
            ScriptOptions options = new ScriptOptions();

            options.PreferredQuoteChar = '\'';

            Assert.AreEqual('\'', options.PreferredQuoteChar);

            Expect.Throw<ArgumentException>(
                "The preferred quote char can only be one of the allowed quote chars.\r\nParameter name: value",
                () => options.PreferredQuoteChar = '@');
        }
开发者ID:DaveVdE,项目名称:adamjsgenerator,代码行数:12,代码来源:GenerateJavaScriptOptionsTests.cs


示例6: RunScript

        private int RunScript(ScriptOptions options, string code, ErrorLogger errorLogger, CancellationToken cancellationToken)
        {
            var globals = new CommandLineScriptGlobals(_console.Out, _objectFormatter);
            globals.Args.AddRange(_compiler.Arguments.ScriptArguments);

            var script = Script.CreateInitialScript<object>(_scriptCompiler, code, options, globals.GetType(), assemblyLoaderOpt: null);
            try
            {
                script.RunAsync(globals, cancellationToken).Wait();

                // TODO: use the return value of the script https://github.com/dotnet/roslyn/issues/5773
                return CommonCompiler.Succeeded;
            }
            catch (CompilationErrorException e)
            {
                _compiler.ReportErrors(e.Diagnostics, _console.Out, errorLogger);
                return CommonCompiler.Failed;
            }
        }
开发者ID:hcn0843,项目名称:roslyn,代码行数:19,代码来源:CommandLineRunner.cs


示例7: Is

 private static bool Is(this ScriptOptions options, ScriptOptions expectedOption)
 {
     return (options & expectedOption) == expectedOption;
 }
开发者ID:jackiezhang926,项目名称:n2cms,代码行数:4,代码来源:Register.cs


示例8: JavaScript

 public ResourcesHelper JavaScript(string script, ScriptOptions options)
 {
     Writer.Write(N2.Resources.Register.JavaScript(ViewData, script, options));
     return this;
 }
开发者ID:Jobu,项目名称:n2cms,代码行数:5,代码来源:ResourcesExtensions.cs


示例9: TryBuildAndRun

        private bool TryBuildAndRun(Script<object> newScript, InteractiveScriptGlobals globals, ref ScriptState<object> state, ref ScriptOptions options, CancellationToken cancellationToken)
        {
            var diagnostics = newScript.Compile(cancellationToken);
            DisplayDiagnostics(diagnostics);
            if (diagnostics.HasAnyErrors())
            {
                return false;
            }

            try
            {
                var task = (state == null) ?
                    newScript.RunAsync(globals, cancellationToken) :
                    newScript.ContinueAsync(state, cancellationToken);

                state = task.GetAwaiter().GetResult();
            }
            catch (FileLoadException e) when (e.InnerException is InteractiveAssemblyLoaderException)
            {
                var oldColor = _console.ForegroundColor;
                try
                {
                    _console.ForegroundColor = ConsoleColor.Red;
                    _console.Out.WriteLine(e.InnerException.Message);
                }
                finally
                {
                    _console.ForegroundColor = oldColor;
                }

                return false;
            }
            catch (Exception e)
            {
                DisplayException(e);
                return false;
            }

            options = UpdateOptions(options, globals);

            return true;
        }
开发者ID:Ryujose,项目名称:roslyn,代码行数:42,代码来源:CommandLineRunner.cs


示例10: JavaScript

		public static string JavaScript(ICollection<string> stateCollection, string script, ScriptOptions options)
		{
			const string scriptFormat = "<script type=\"text/javascript\">//<![CDATA[\n{0}//]]></script>";

			if (IsRegistered(stateCollection, script))
				return null;

			RegisterResource(stateCollection, script);

			if (options == ScriptOptions.Include)
				return JavaScript(stateCollection, script);
			if (options == ScriptOptions.None)
				return script;
			if (options == ScriptOptions.ScriptTags)
				return String.Format(scriptFormat, script);
			if (options == ScriptOptions.DocumentReady)
				return String.Format(scriptFormat, EmbedDocumentReady(script));

			throw new NotSupportedException(options + " not supported");
		}
开发者ID:nicklv,项目名称:n2cms,代码行数:20,代码来源:Register.cs


示例11: JavaScript

		public static void JavaScript(this Page page, string script, ScriptOptions options)
		{
			if (page == null) return;

			if (page.Items[script] == null)
			{
				PlaceHolder holder = GetPlaceHolder(page);

				if (options.Is(ScriptOptions.Include))
				{
					AddScriptInclude(page, script, holder, options.Is(ScriptOptions.Prioritize));
				}
				else if (options.Is(ScriptOptions.None))
				{
					holder.Page.Items[script] = AddString(holder, script, options.Is(ScriptOptions.Prioritize));
				}
				else
				{
					Script scriptHolder = GetScriptHolder(page);
					if (options.Is(ScriptOptions.ScriptTags))
					{
						holder.Page.Items[script] = AddString(scriptHolder, script + Environment.NewLine, Is(options, ScriptOptions.Prioritize));
					}
					else if (options.Is(ScriptOptions.DocumentReady))
					{
						JQuery(page);
						holder.Page.Items[script] = AddString(scriptHolder, EmbedDocumentReady(script) + Environment.NewLine, options.Is(ScriptOptions.Prioritize));
					}
				}
			}
		}
开发者ID:n2cms,项目名称:n2cms,代码行数:31,代码来源:Register.cs


示例12: BuildAndRun

        private void BuildAndRun(Script<object> newScript, InteractiveScriptGlobals globals, ref ScriptState<object> state, ref ScriptOptions options, bool displayResult, CancellationToken cancellationToken)
        {
            var diagnostics = newScript.Compile(cancellationToken);
            DisplayDiagnostics(diagnostics);
            if (diagnostics.HasAnyErrors())
            {
                return;
            }

            var task = (state == null) ?
                newScript.RunAsync(globals, catchException: e => true, cancellationToken: cancellationToken) :
                newScript.RunFromAsync(state, catchException: e => true, cancellationToken: cancellationToken);

            state = task.GetAwaiter().GetResult();
            if (state.Exception != null)
            {
                DisplayException(state.Exception);
            }
            else if (displayResult && newScript.HasReturnValue())
            {
                globals.Print(state.ReturnValue);
            }

            options = UpdateOptions(options, globals);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:25,代码来源:CommandLineRunner.cs


示例13: AddScripts

 private void AddScripts(IEnumerable<string> names, ScriptOptions options)
 {
     if (null != names)
     {
         foreach (var script in names)
         {
             Converter.AddScript(script, options);
         }
     }
 }
开发者ID:thomas13335,项目名称:wpf2html5,代码行数:10,代码来源:ConverterModel.cs


示例14: RunInteractiveLoop

        private void RunInteractiveLoop(ScriptOptions options, CancellationToken cancellationToken)
        {
            var globals = new InteractiveScriptGlobals(_console.Out, _objectFormatter);
            globals.Args.AddRange(_compiler.Arguments.ScriptArguments);

            ScriptState <object> state = null;

            while (true)
            {
                _console.Out.Write("> ");
                var input = new StringBuilder();
                string line;
                bool cancelSubmission = false;

                while (true)
                {
                    line = _console.In.ReadLine();
                    if (line == null)
                    {
                        if (input.Length == 0)
                        {
                            return;
                        }

                        cancelSubmission = true;
                        break;
                    }

                    input.AppendLine(line);

                    var tree = _scriptCompiler.ParseSubmission(SourceText.From(input.ToString()), cancellationToken);
                    if (_scriptCompiler.IsCompleteSubmission(tree))
                    {
                        break;
                    }

                    _console.Out.Write(". ");
                }

                if (cancelSubmission)
                {
                    continue;
                }

                string code = input.ToString();

                Script<object> newScript;
                if (state == null)
                {
                    newScript = Script.CreateInitialScript<object>(_scriptCompiler, code, options, globals.GetType(), assemblyLoaderOpt: null);
                }
                else
                {
                    newScript = state.Script.ContinueWith(code, options);
                }

                var newCompilation = newScript.GetCompilation();

                try
                {
                    newScript.Build(cancellationToken);

                    // display warnings:
                    DisplayDiagnostics(newCompilation.GetDiagnostics(cancellationToken).Where(d => d.Severity == DiagnosticSeverity.Warning));
                }
                catch (CompilationErrorException e)
                {
                    DisplayDiagnostics(e.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error || d.Severity == DiagnosticSeverity.Warning));
                    continue;
                }

                try
                {
                    var task = (state == null) ?
                        newScript.RunAsync(globals, cancellationToken) :
                        newScript.ContinueAsync(state, cancellationToken);

                    state = task.GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    DisplayException(e);
                    continue;
                }

                bool hasValue;
                ITypeSymbol resultType = newCompilation.GetSubmissionResultType(out hasValue);
                if (hasValue)
                {
                    if (resultType != null && resultType.SpecialType == SpecialType.System_Void)
                    {
                        _console.Out.WriteLine(_objectFormatter.VoidDisplayString);
                    }
                    else
                    {
                        globals.Print(state.ReturnValue);
                    }
                }
            }
        }
开发者ID:e42s,项目名称:roslyn,代码行数:100,代码来源:CommandLineRunner.cs


示例15: AddScript

        public void AddScript(string filename, ScriptOptions options)
        {
            switch(options)
            {
                case ScriptOptions.Framework:
                    _frameworkscripts.Add(filename);
                    break;

                case ScriptOptions.Before:
                    _scriptsbefore.Add(filename);
                    break;

                case ScriptOptions.After:
                    _scriptsafter.Add(filename);
                    break;

                default:
                    throw new ArgumentException("invalid script option specified.");
            }
        }
开发者ID:thomas13335,项目名称:wpf2html5,代码行数:20,代码来源:WpfToHtmlConverter.cs


示例16: JavaScript

			public ResourcesHelper JavaScript(string script, ScriptOptions options)
			{
				Writer.Write(N2.Resources.Register.JavaScript(StateCollection, script, options));
				return this;
			}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:5,代码来源:ResourcesExtensions.cs


示例17: CSharpScript

 private CSharpScript(string code, string path, ScriptOptions options, Type globalsType, Type returnType, ScriptBuilder builder, Script previous)
     : base(code, path, options, globalsType, returnType, builder, previous)
 {
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:4,代码来源:CSharpScript.cs


示例18: Create

 internal override Script Create(string code, ScriptOptions options, Type globalsType, Type returnType)
 {
     return CSharpScript.Create(code, options).WithGlobalsType(globalsType).WithReturnType(returnType).WithBuilder(this.Builder);
 }
开发者ID:daking2014,项目名称:roslyn,代码行数:4,代码来源:CSharpScriptEngine.cs


示例19: Make

 internal override Script Make(string code, string path, ScriptOptions options, Type globalsType, Type returnType, ScriptBuilder builder, Script previous)
 {
     return new CSharpScript(code, path, options, globalsType, returnType, builder, previous);
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:4,代码来源:CSharpScript.cs


示例20: RunScript

        private int RunScript(ScriptOptions options, string code, ErrorLogger errorLogger, CancellationToken cancellationToken)
        {
            var globals = new CommandLineScriptGlobals(_console.Out, _objectFormatter);
            globals.Args.AddRange(_compiler.Arguments.ScriptArguments);

            var script = Script.CreateInitialScript<int>(_scriptCompiler, code, options, globals.GetType(), assemblyLoaderOpt: null);
            try
            {
                return script.RunAsync(globals, cancellationToken).Result.ReturnValue;
            }
            catch (CompilationErrorException e)
            {
                _compiler.ReportErrors(e.Diagnostics, _console.Out, errorLogger);
                return CommonCompiler.Failed;
            }
        }
开发者ID:Ryujose,项目名称:roslyn,代码行数:16,代码来源:CommandLineRunner.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ScriptProcessor类代码示例发布时间:2022-05-24
下一篇:
C# ScriptObject类代码示例发布时间: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