private List <string> GetCompositeScriptData(ScriptMode scriptMode, string culture) { List <string> data = new List <string>(); var previousCulture = CultureInfo.CurrentUICulture; var previousScriptMode = _scriptManager.ScriptMode; try { if (!String.IsNullOrEmpty(culture)) { Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(culture); } _scriptManager.ScriptMode = scriptMode; foreach (var reference in _references) { var openReference = new OpenScriptReference(reference); data.Add(openReference.GetUrl(_scriptManager)); } } finally { if (previousCulture != CultureInfo.CurrentUICulture) { Thread.CurrentThread.CurrentUICulture = previousCulture; } if (previousScriptMode != _scriptManager.ScriptMode) { _scriptManager.ScriptMode = previousScriptMode; } } return(data); }
string GetScript(string code, ScriptMode mode = ScriptMode.Create, DbDialect dialect = DbDialect.SqlServer, bool print = true) { var model = PersistentModel.Compile(code); if (!model.IsValid) { Assert.Fail("invalid model"); } var sb = new StringBuilder(); foreach (var w in model.GetWriters(dialect, mode)) { w.NoComment = true; var str = w.ToString(); if (!string.IsNullOrWhiteSpace(str)) { sb.AppendLine(str); } } var result = sb.ToString(); if (print) { Console.WriteLine(result.Replace("\"", "\"\"")); } return(result.Trim()); }
public void SequenceWriter(string name, int start, int step, DbDialect dialect,ScriptMode mode, string test){ var pt = new PersistentClass{Name = name, Schema = "dbo"}; var sq = new Sequence(); sq.Setup(null,pt,null,null); var wr = new SequenceWriter(sq) { NoComment = true, NoDelimiter = true, Mode = mode, Dialect = dialect }; ; Assert.AreEqual(test,wr.ToString().Trim()); }
public ScriptReference(string name, string path, ScriptMode mode, string[] dependencies, string version) { _name = name; _path = path; _mode = mode; _dependencies = dependencies; _version = version; }
/// <summary> /// Возваращает все скрипты для указанной позиции и языка в генерации /// </summary> /// <param name="dialect"></param> /// <param name="mode"></param> /// <param name="position"></param> /// <returns></returns> public IEnumerable <SqlScript> GetScripts(DbDialect dialect, ScriptMode mode, ScriptPosition position) { if (GenerationOptions.Supports(SqlObjectType.Script)) { return(ExtendedScripts.SelectMany(_ => _.GetRealScripts(dialect, position, mode))); } return(new SqlScript[] {}); }
public void Compress(string wavFile, string outFile, int qualityPreset, bool deleteOrigin, ScriptMode scriptMode) { filesList.Enqueue(new compressTask { WavFileName = wavFile, OutFileName = outFile, QuelityPreset = qualityPreset, DeleteOrigin = deleteOrigin }); _scriptMode = scriptMode; }
public static ScriptMode GetScriptModeFromWebConfig(ISite site) { ScriptMode mode = ScriptMode.Release; GlobalConfig config = GetCooliteSection(site); if (config != null) { mode = config.ScriptMode; } return(mode); }
public void SchemaWriter(string schemaname, ScriptMode mode, DbDialect dialect, string test) { var schema = new Schema { Name = schemaname }; var writer = new SchemaWriter(schema) { Mode = mode, Dialect = dialect, NoComment = true, NoDelimiter = true }; Assert.AreEqual(test, writer.ToString().Trim()); }
public void LateFKGenerator(DbDialect dialect, ScriptMode mode, string test) { var model = PersistentModel.Compile(CircularModel); var cref = model["slave"]["master"]; var crefwr = new LateForeignKeyWriter(cref) { NoDelimiter = true, NoComment = true, Dialect = dialect, Mode = mode }; var result = crefwr.ToString().Trim(); Console.WriteLine(result); Assert.AreEqual(test, result); }
string GetDigest(string code,ScriptMode mode =ScriptMode.Create, DbDialect dialect = DbDialect.SqlServer){ var model = PersistentModel.Compile(code); if(!model.IsValid)Assert.Fail("invalid model"); var sb = new StringBuilder(); foreach (var w in model.GetWriters(dialect,mode)){ var str = w.GetDigest(); if (!string.IsNullOrWhiteSpace(str)){ sb.AppendLine(str); } } var result = sb.ToString(); Console.WriteLine(result.Replace("\"","\"\"")); return result.Trim(); }
/// <summary> /// Возвращает реальные скрипты н /// </summary> /// <param name="dialect"></param> /// <param name="position"></param> /// <param name="mode"></param> /// <returns></returns> public IEnumerable<SqlScript> GetRealScripts(DbDialect dialect, ScriptPosition position, ScriptMode mode){ if (0 == SubScripts.Count){ if (DbDialect == DbDialect.Ansi || dialect == DbDialect){ if (Mode == mode){ if (Position == position){ yield return this; } } } } else{ foreach (SqlScript subScript in SubScripts){ foreach (SqlScript rs in subScript.GetRealScripts(dialect, position, mode)){ yield return rs; } } } }
/// <summary> /// </summary> /// <param name="dialect"></param> /// <param name="mode"></param> /// <returns></returns> public string GetDigest(DbDialect dialect, ScriptMode mode) { var sb = new StringBuilder(); foreach (SqlCommandWriter sw in GetWriters(dialect, mode)) { if (null == sw) { continue; } string subresult = sw.GetDigest(); if (!string.IsNullOrWhiteSpace(subresult)) { sb.AppendLine(subresult); } } return(sb.ToString()); }
/// <summary> /// Parses a script with the specified content and path. /// </summary> /// <param name="scriptContent">Content of the script.</param> /// <param name="scriptPath">The script path.</param> /// <param name="parsingMode">The parsing mode.</param> /// <returns> /// The parsed script or null of an error occured /// </returns> /// <exception cref="System.ArgumentNullException">if <paramref name="scriptContent" /> or <paramref name="scriptPath" /> is null</exception> /// <remarks> /// If there are any parsing errors, the errors will be logged to the <see cref="Log" /> and <see cref="HasErrors" /> will be set to <c>true</c>. /// </remarks> public ScriptInstance ParseScript(string scriptContent, UPath scriptPath, ScriptMode parsingMode) { if (scriptContent == null) { throw new ArgumentNullException(nameof(scriptContent)); } if (scriptPath == null) { throw new ArgumentNullException(nameof(scriptPath)); } IFrontMatter frontmatter = null; TextPosition startPosition = default; if (parsingMode == ScriptMode.FrontMatterAndContent && scriptContent.Length > 3) { var span = scriptContent.AsSpan(); foreach (var parser in FrontMatterParsers) { if (parser.CanHandle(span)) { frontmatter = parser.TryParse(scriptContent, (string)scriptPath, out startPosition); break; } } parsingMode = ScriptMode.Default; } // Load parse the template var template = Template.Parse(scriptContent, scriptPath.FullName, null, new LexerOptions() { StartPosition = startPosition, Mode = parsingMode }); // If we have any errors, log them and set the errors flag on this instance if (template.HasErrors) { LogScriptMessages(template.Messages); } return(new ScriptInstance(template.HasErrors, (string)scriptPath, frontmatter, template.Page)); }
/// <summary> /// 运行客户端JavaScript脚本 /// </summary> /// <param name="ctrl">放置脚本的控件</param> /// <param name="code">JavaScript代码</param> /// <param name="mode">执行模式</param> public static void RunScript(System.Web.UI.Control ctrl, string code, ScriptMode mode) { if (mode == ScriptMode.BeforeLoad) { ctrl.Page.ClientScript.RegisterClientScriptBlock(ctrl.GetType(), "jsBlock", code, true); } else if (mode == ScriptMode.AfterLoad) { System.Web.UI.HtmlControls.HtmlGenericControl hgc = new System.Web.UI.HtmlControls.HtmlGenericControl(); hgc.TagName = "div"; hgc.InnerHtml = "<script type=\"text/javascript\">"; hgc.InnerHtml += code; hgc.InnerHtml += "</script>"; ctrl.Controls.Add(hgc); } else { System.Web.UI.ScriptManager.RegisterClientScriptBlock(ctrl, ctrl.GetType(), "jsBlock", code, true); } }
public static void AddScriptReference(this AjaxHelper ajaxHelper, string scriptName, ScriptMode scriptMode) { ScriptModel scriptModel = GetScriptModel(ajaxHelper); if (String.IsNullOrEmpty(scriptName)) { throw new ArgumentNullException("scriptName"); } ScriptSharpSection configSection = ScriptSharpSection.GetSettings(); ScriptElement scriptElement = configSection.Scripts.GetElement(scriptName, scriptModel.ScriptFlavor); string actualFlavor = String.Empty; int flavorIndex = scriptElement.Name.IndexOf('.'); if (flavorIndex > 0) { actualFlavor = scriptElement.Name.Substring(flavorIndex + 1); } ScriptReference scriptReference = new ScriptReference(scriptName, scriptElement.Url, scriptMode, scriptElement.GetDependencyList(), scriptElement.Version + actualFlavor); scriptModel.AddScriptReference(scriptReference); }
private List<string> GetCompositeScriptData(ScriptMode scriptMode, string culture) { List<string> data = new List<string>(); var previousCulture = CultureInfo.CurrentUICulture; var previousScriptMode = _scriptManager.ScriptMode; try { if (!String.IsNullOrEmpty(culture)) { Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(culture); } _scriptManager.ScriptMode = scriptMode; foreach (var reference in _references) { var openReference = new OpenScriptReference(reference); data.Add(openReference.GetUrl(_scriptManager)); } } finally { if (previousCulture != CultureInfo.CurrentUICulture) { Thread.CurrentThread.CurrentUICulture = previousCulture; } if (previousScriptMode != _scriptManager.ScriptMode) { _scriptManager.ScriptMode = previousScriptMode; } } return data; }
/// <summary> /// Получить последовательность генерации /// </summary> /// <returns></returns> public IEnumerable <SqlCommandWriter> GetWriters(DbDialect dialect, ScriptMode mode) { if (mode == ScriptMode.Create && !GenerationOptions.GenerateCreateScript) { yield break; } if (mode == ScriptMode.Drop && !GenerationOptions.GenerateDropScript) { yield break; } if (!GenerationOptions.IncludeDialect.HasFlag(dialect)) { yield break; } var factory = new SqlCommandWriterFactory { Mode = mode, Dialect = dialect, Model = this }; IEnumerable <object> objset = mode == ScriptMode.Create ? GetCreateOrderedWriters(dialect) : GetDropWriters(dialect); foreach (SqlCommandWriter w in factory.Get(objset)) { yield return(w); } }
public Script(string name, ScriptMode mode, params string[] sqls) { Name = name; Mode = mode; Sqls = sqls; }
public static string GetInfoScript(Massive m, ScriptMode mode) { //определяем расширения string ext = Path.GetExtension(m.infilepath).ToLower(); AudioStream instream = (m.inaudiostreams.Count > 0) ? (AudioStream)m.inaudiostreams[m.inaudiostream] : new AudioStream(); //начинаем писать скрипт string script = ""; // загружаем доп функции script += "Import(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\functions\\AudioFunctions.avs\")" + Environment.NewLine; script += "Import(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\functions\\VideoFunctions.avs\")" + Environment.NewLine; //загружаем необходимые плагины импорта if (m.vdecoder == Decoders.AVCSource) script += "LoadPlugin(\"" + Calculate.StartupPath + "\\apps\\DGAVCDec\\DGAVCDecode.dll\")" + Environment.NewLine; else if (m.vdecoder == Decoders.MPEG2Source) script += "LoadPlugin(\"" + Calculate.StartupPath + "\\apps\\DGMPGDec\\DGDecode.dll\")" + Environment.NewLine; else if (m.vdecoder == Decoders.DGSource) script += "LoadPlugin(\"" + m.dgdecnv_path + "DGDecodeNV.dll\")" + Environment.NewLine; else if (m.vdecoder == Decoders.DirectShowSource2) script += "LoadPlugin(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\avss.dll\")" + Environment.NewLine; else if (m.vdecoder == Decoders.RawSource) script += "LoadPlugin(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\rawsource.dll\")" + Environment.NewLine; else if (m.vdecoder == Decoders.QTInput) script += "LoadPlugin(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\QTSource.dll\")" + Environment.NewLine; if (m.vdecoder == Decoders.FFmpegSource2 || instream.decoder == Decoders.FFAudioSource) { script += "LoadPlugin(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\FFMS2.dll\")" + Environment.NewLine; script += "Import(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\FFMS2.avsi\")" + Environment.NewLine; } if (m.vdecoder == Decoders.LSMASHVideoSource || instream.decoder == Decoders.LSMASHAudioSource || m.vdecoder == Decoders.LWLibavVideoSource || instream.decoder == Decoders.LWLibavAudioSource) { script += "LoadPlugin(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\LSMASHSource.dll\")" + Environment.NewLine; } if (instream.decoder == Decoders.NicAC3Source || instream.decoder == Decoders.NicMPG123Source || instream.decoder == Decoders.NicDTSSource || instream.decoder == Decoders.RaWavSource) script += "LoadPlugin(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\NicAudio.dll\")" + Environment.NewLine; else if (instream.decoder == Decoders.bassAudioSource) script += "LoadPlugin(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\bass\\bassAudio.dll\")" + Environment.NewLine; if (mode == ScriptMode.Autocrop) script += "LoadPlugin(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\AutoCrop.dll\")" + Environment.NewLine; if (mode == ScriptMode.Interlace) script += "LoadPlugin(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\TIVTC.dll\")" + Environment.NewLine; if (instream.channelconverter != AudioOptions.ChannelConverters.KeepOriginalChannels) script += "LoadPlugin(\"" + Calculate.StartupPath + "\\dlls\\AviSynth\\plugins\\soxfilter.dll\")" + Environment.NewLine; script += Environment.NewLine; //прописываем импорт видео //принудительная установка fps string fps = ""; if ((m.vdecoder == Decoders.DirectShowSource || m.vdecoder == Decoders.DirectShowSource2) && !string.IsNullOrEmpty(m.inframerate)) fps = ", fps=" + m.inframerate; //принудительная конвертация частоты string convertfps = ""; if (m.vdecoder == Decoders.DirectShowSource && m.isconvertfps && Settings.DSS_ConvertFPS) convertfps = ", convertfps=true"; //Настройки DSS2 string dss2 = ""; if (m.vdecoder == Decoders.DirectShowSource2) { int dss2_temp_val = 0; dss2 = (((dss2_temp_val = Settings.DSS2_SubsMode) > 0) ? ", subsm=" + dss2_temp_val : "") + (((dss2_temp_val = Settings.DSS2_Preroll) > 0) ? ", preroll=" + dss2_temp_val : "") + ((Settings.DSS2_LAVSplitter) ? ", lavs=\"" + Settings.DSS2_LAVS_Settings + "\"" : "") + ((Settings.DSS2_LAVDecoder) ? ", lavd=\"" + Settings.DSS2_LAVV_Settings + "\"" : "") + ((Settings.DSS2_FlipV) ? ", flipv=true" : "") + ((Settings.DSS2_FlipH) ? ", fliph=true" : ""); } //выбор аудио трека string audio = ""; if (m.vdecoder == Decoders.DirectShowSource && (mode == ScriptMode.VCrop || mode == ScriptMode.Autocrop || mode == ScriptMode.Interlace || instream.audiopath != null || !Settings.DSS_Enable_Audio || !Settings.EnableAudio || ext == ".grf")) audio = ", audio=false"; else if (m.vdecoder == Decoders.AVISource && (mode == ScriptMode.VCrop || mode == ScriptMode.Autocrop || mode == ScriptMode.Interlace || instream.audiopath != null || !Settings.EnableAudio)) audio = ", audio=false"; else if (m.vdecoder == Decoders.FFmpegSource2 && m.inaudiostreams.Count > 0 && instream.audiopath == null && Settings.FFMS_Enable_Audio && Settings.EnableAudio && mode != ScriptMode.VCrop && mode != ScriptMode.Autocrop && mode != ScriptMode.Interlace) audio = ", atrack=" + (instream.ff_order) + ", adjustdelay=-3"; //ипортируем видео string invideostring = ""; if (m.vdecoder == Decoders.BlankClip) { invideostring = m.vdecoder.ToString() + "(length=" + m.inframes + ", width=128, height=96, fps=" + ((!string.IsNullOrEmpty(m.inframerate) ? m.inframerate : "25.000")) + ", pixel_type=\"YV12\", audio_rate=0)"; } else if (ext == ".d2v") { int n = 0; foreach (string file in m.infileslist) { n++; invideostring += m.vdecoder.ToString() + "(\"" + file + "\", cpu=0, info=3)"; if (n < m.infileslist.Length) invideostring += "++"; } } else if (ext == ".dga" || ext == ".dgi") { int n = 0; foreach (string file in m.infileslist) { n++; invideostring += m.vdecoder.ToString() + "(\"" + file + "\")"; if (n < m.infileslist.Length) invideostring += "++"; } } else if (ext != ".d2v" && m.vdecoder == Decoders.MPEG2Source) { invideostring = m.vdecoder.ToString() + "(\"" + m.indexfile + "\", cpu=0, info=3)"; } else if (ext != ".dgi" && m.vdecoder == Decoders.DGSource) { invideostring = m.vdecoder.ToString() + "(\"" + m.indexfile + "\", fieldop=" + (m.IsForcedFilm ? "1" : "0") + ")"; ; } else { int n = 0; foreach (string file in m.infileslist) { //Изменения под декодеры string cache_path = ""; string assume_fps = ""; if (m.vdecoder == Decoders.FFmpegSource2) { //Стоит-ли повторяться? :) assume_fps = (!string.IsNullOrEmpty(m.inframerate) && Settings.FFMS_AssumeFPS) ? ".AssumeFPS(" + m.inframerate + ")" : ""; cache_path = ", rffmode=0" + ((Settings.FFMS_Threads > 0) ? ", threads=" + Settings.FFMS_Threads : "") + ((m.ffms_indexintemp) ? ", cachefile=\"" + Settings.TempPath + "\\" + Path.GetFileName(file) + ".ffindex\"" : ""); } else if (m.vdecoder == Decoders.LSMASHVideoSource) { //LSMASHVideoSource(string source, int track = 0, int threads = 0, int seek_mode = 0, int seek_threshold = 10, bool dr = false, //int fpsnum = 0, int fpsden = 1, bool stacked = false, string format = "") assume_fps = (!string.IsNullOrEmpty(m.inframerate) && Settings.LSMASH_AssumeFPS) ? ".AssumeFPS(" + m.inframerate + ")" : ""; cache_path = ", track=0" + ((Settings.LSMASH_Threads > 0) ? ", threads=" + Settings.LSMASH_Threads : "") + ", dr=false" + (!string.IsNullOrEmpty(m.disable_hacked_vout) ? ", format=\"" + m.disable_hacked_vout + "\", stacked=true" : ""); } else if (m.vdecoder == Decoders.LWLibavVideoSource) { //LWLibavVideoSource(string source, int stream_index = -1, int threads = 0, bool cache = true, int seek_mode = 0, int seek_threshold = 10, //bool dr = false, int fpsnum = 0, int fpsden = 1, bool repeat = false, int dominance = 0, bool stacked = false, string format = "") assume_fps = (!string.IsNullOrEmpty(m.inframerate) && Settings.LSMASH_AssumeFPS) ? ".AssumeFPS(" + m.inframerate + ")" : ""; cache_path = ", stream_index=-1" + ((Settings.LSMASH_Threads > 0) ? ", threads=" + Settings.LSMASH_Threads : "") + ", cache=true, dr=false" + (!string.IsNullOrEmpty(m.disable_hacked_vout) ? ", format=\"" + m.disable_hacked_vout + "\", stacked=true" : ""); } n += 1; invideostring += m.vdecoder.ToString() + "(\"" + file + "\"" + audio + fps + convertfps + dss2 + cache_path + ")" + assume_fps; if (n < m.infileslist.Length) invideostring += "++"; } } //импорт звука и объединение if (m.inaudiostreams.Count > 0 && mode != ScriptMode.VCrop && mode != ScriptMode.Autocrop && mode != ScriptMode.Interlace) { if (instream.audiopath != null) //Извлеченные или внешние треки { //прописываем импорт видео script += "video = " + invideostring + Environment.NewLine; //пришиваем звук string ffindex = ""; string inaudiostring = ""; string no_video = (instream.decoder == Decoders.DirectShowSource) ? ", video=false" : ""; string nicaudio = (instream.decoder == Decoders.NicAC3Source && Settings.NicAC3_DRC || instream.decoder == Decoders.NicDTSSource && Settings.NicDTS_DRC) ? ", drc=1" : (instream.decoder == Decoders.RaWavSource) ? ", 0" : ""; //0 - это дефолт, но его забыли выставить в старых версиях RaWavSource //LSMASHAudioSource(string source, int "track"(0), bool "skip_priming"(true), string "layout"("")) //LWLibavAudioSource(string source, int "stream_index"(-1), bool "cache"(true), bool "av_sync"(false), string "layout"("")) string lsmash = (instream.decoder == Decoders.LSMASHAudioSource) ? ", track=0, skip_priming=true" : (instream.decoder == Decoders.LWLibavAudioSource) ? ", stream_index=-1, cache=true, av_sync=false" : ""; if (instream.audiofiles != null && instream.audiofiles.Length > 0) { int n = 0; foreach (string file in instream.audiofiles) { n++; ffindex += "FFIndex(" + "\"" + file + "\")\r\n"; inaudiostring += instream.decoder.ToString() + "(\"" + file + "\"" + no_video + nicaudio + lsmash + ")"; if (n < instream.audiofiles.Length) inaudiostring += "++"; } } else { ffindex += "FFIndex(" + "\"" + instream.audiopath + "\")\r\n"; inaudiostring += instream.decoder.ToString() + "(\"" + instream.audiopath + "\"" + no_video + nicaudio + lsmash + ")"; } //объединение if (instream.decoder == Decoders.FFAudioSource) script += ffindex; script += "audio = " + inaudiostring + Environment.NewLine; script += "AudioDub(video, audio)" + Environment.NewLine; } else if ((m.vdecoder == Decoders.LSMASHVideoSource || m.vdecoder == Decoders.LWLibavVideoSource) && Settings.EnableAudio && Settings.LSMASH_Enable_Audio) //Декодирование напрямую из исходника { //прописываем импорт видео script += "video = " + invideostring + Environment.NewLine; //пришиваем звук string inaudiostring = ""; string decoder = (m.vdecoder == Decoders.LSMASHVideoSource) ? Decoders.LSMASHAudioSource.ToString() : Decoders.LWLibavAudioSource.ToString(); //LSMASHAudioSource(string source, int "track"(0), bool "skip_priming"(true), string "layout"("")) //LWLibavAudioSource(string source, int "stream_index"(-1), bool "cache"(true), bool "av_sync"(false), string "layout"("")) string lsmash = (m.vdecoder == Decoders.LSMASHVideoSource) ? (", track=" + (instream.mi_order + 1) + ", skip_priming=true") : (", stream_index=" + instream.ff_order + ", cache=true, av_sync=false"); int n = 0; foreach (string file in m.infileslist) { n += 1; inaudiostring += decoder + "(\"" + file + "\"" + lsmash + ")"; if (n < m.infileslist.Length) inaudiostring += "++"; } //объединение script += "audio = " + inaudiostring + Environment.NewLine; script += "AudioDub(video, audio)" + Environment.NewLine; } else { //прописываем импорт всего клипа script += invideostring + Environment.NewLine; } } else { //прописываем импорт всего клипа script += invideostring + Environment.NewLine; } if (mode == ScriptMode.FastPreview || mode == ScriptMode.Normalize) { //блок обработки звука if (m.outaudiostreams.Count > 0) { AudioStream outstream = (AudioStream)m.outaudiostreams[m.outaudiostream]; //задержка if (outstream.delay != 0) script += "DelayAudio(" + Calculate.ConvertDoubleToPointString(Convert.ToDouble(outstream.delay) / 1000) + ")" + Environment.NewLine; //меняем канальность if (instream.channelconverter != AudioOptions.ChannelConverters.KeepOriginalChannels) script += instream.channelconverter.ToString() + "()" + Environment.NewLine; //меняем битность if (instream.bits != outstream.bits) script += "ConvertAudioTo16bit()" + Environment.NewLine; //прописываем смену частоты if (instream.samplerate != outstream.samplerate && outstream.samplerate != null) script += m.sampleratemodifer + "(" + outstream.samplerate + ")" + Environment.NewLine; //нормализация звука if (mode != ScriptMode.Normalize && instream.gain != "0.0") script += "AmplifydB(" + instream.gain + ")" + Environment.NewLine; } } //автокроп if (mode == ScriptMode.Autocrop) { //Flip if (m.flipv || m.fliph) { script += Environment.NewLine; if (m.flipv) script += "FlipVertical()" + Environment.NewLine; if (m.fliph) script += "FlipHorizontal()" + Environment.NewLine; script += Environment.NewLine; } script += "ConvertToYV12()" + Environment.NewLine + Environment.NewLine; script += "FrameEvaluate(last, \"AutoCrop(mode=4, wMultOf=4, hMultOf=4, samples=1, samplestartframe=current_frame, " + "sampleendframe=current_frame, threshold=" + Settings.AutocropSensivity + ")\")" + Environment.NewLine; } if (mode == ScriptMode.VCrop) { //Flip if (m.flipv) script += "FlipVertical()" + Environment.NewLine; if (m.fliph) script += "FlipHorizontal()" + Environment.NewLine; } if (mode == ScriptMode.Interlace) { script += "Crop(0, 0, -0, -Height() % 4)\r\nConvertToYV12()" + Environment.NewLine; } return script; }
protected ScriptReferenceBase() { this.NotifyScriptLoaded = true; this.ScriptMode = ScriptMode.Auto; }
public ScriptContext(SourceText code, string workingDirectory, IEnumerable <string> args, string filePath = null, OptimizationLevel optimizationLevel = OptimizationLevel.Debug, ScriptMode scriptMode = ScriptMode.Script, string[] packageSources = null) { Code = code; WorkingDirectory = workingDirectory; Args = new ReadOnlyCollection <string>(args != null ? args.ToArray() : Array.Empty <string>()); FilePath = filePath; OptimizationLevel = optimizationLevel; ScriptMode = filePath != null ? ScriptMode.Script : scriptMode; PackageSources = packageSources ?? Array.Empty <string>(); }
private List<string> GetCompositeScriptData(ScriptMode scriptMode) { return GetCompositeScriptData(scriptMode, null); }
public void SchemaWriter(string schemaname, ScriptMode mode, DbDialect dialect, string test){ var schema = new Schema{Name = schemaname}; var writer = new SchemaWriter(schema){Mode = mode, Dialect = dialect,NoComment=true,NoDelimiter=true}; Assert.AreEqual(test,writer.ToString().Trim()); }
private void RenderScriptTag(TextWriter writer, string path, string name, string[] dependencies, ScriptMode mode, string storage, string script) { writer.Write("<script type=\"text/script\""); if (String.IsNullOrEmpty(path) == false) { writer.Write(" data-src=\""); writer.Write(path); writer.Write("\""); } if (String.IsNullOrEmpty(name) == false) { writer.Write(" data-name=\""); writer.Write(name); writer.Write("\""); } if (dependencies != null) { writer.Write(" data-requires=\""); for (int i = 0; i < dependencies.Length; i++) { writer.Write(dependencies[i]); if (i != dependencies.Length - 1) { writer.Write(","); } } writer.Write("\""); } if (storage != null) { writer.Write(" data-store=\""); writer.Write(storage); writer.Write("\""); } if (mode != ScriptMode.Startup) { writer.Write(" data-mode=\""); if (mode == ScriptMode.Deferred) { writer.Write("deferred"); } else { Debug.Assert(mode == ScriptMode.OnDemand); writer.Write("ondemand"); } writer.Write("\""); } if (String.IsNullOrEmpty(script)) { writer.WriteLine("></script>"); } else { writer.WriteLine(">"); writer.Write(script); writer.WriteLine("</script>"); } }
private IEnumerable<object> GetCreateOrderedWriters(DbDialect dialect, ScriptMode mode = ScriptMode.Create){ foreach (SqlScript script in GetScripts(dialect, mode, ScriptPosition.Before)){ yield return script; } foreach (FileGroup fg in DatabaseSqlObjects.OfType<FileGroup>()){ yield return fg; } foreach (Schema schema in DatabaseSqlObjects.OfType<Schema>()){ yield return schema; } foreach (Sequence sequence in Tables.SelectMany(_ => _.SqlObjects.OfType<Sequence>())){ yield return sequence; } foreach (PartitionDefinition part in Tables.SelectMany(_ => _.SqlObjects.OfType<PartitionDefinition>())){ yield return part; } foreach (SqlScript script in GetScripts(dialect, mode, ScriptPosition.BeforeTables)){ yield return script; } foreach (PersistentClass cls in Tables){ yield return cls; } foreach (Field circularRef in Tables.SelectMany(_ => _.Fields.Values.Where(__ => __.GetIsCircular()))){ yield return circularRef; } foreach (SqlScript script in GetScripts(dialect, mode, ScriptPosition.AfterTables)){ yield return script; } foreach (SqlFunction function in Tables.SelectMany(_ => _.SqlObjects.OfType<SqlFunction>())){ if(function.Dialect==DbDialect.None||function.Dialect==dialect||function.Dialect==DbDialect.Ansi) yield return function; } foreach (SqlView view in Tables.SelectMany(_ => _.SqlObjects.OfType<SqlView>())){ if (view.Dialect == DbDialect.None || view.Dialect == dialect || view.Dialect == DbDialect.Ansi) yield return view; } foreach (SqlTrigger trigger in Tables.SelectMany(_ => _.SqlObjects.OfType<SqlTrigger>())){ if (trigger.Dialect == DbDialect.None || trigger.Dialect == dialect || trigger.Dialect == DbDialect.Ansi) yield return trigger; } foreach (SqlScript script in Tables.SelectMany(_ => _.SqlObjects.OfType<SqlScript>())) { if (script.Dialect == DbDialect.None || script.Dialect == dialect || script.Dialect == DbDialect.Ansi) yield return script; } foreach (SqlScript script in GetScripts(dialect, mode, ScriptPosition.After)){ yield return script; } }
/// <summary> /// </summary> /// <param name="dialect"></param> /// <param name="mode"></param> /// <returns></returns> public string GetDigest(DbDialect dialect, ScriptMode mode){ var sb = new StringBuilder(); foreach (SqlCommandWriter sw in GetWriters(dialect, mode)){ if (null == sw) continue; string subresult = sw.GetDigest(); if (!string.IsNullOrWhiteSpace(subresult)){ sb.AppendLine(subresult); } } return sb.ToString(); }
protected internal override string GetUrl(ScriptManager scriptManager, bool zip) { bool isDebuggingEnabled = !scriptManager.DeploymentSectionRetail && ((ScriptMode == ScriptMode.Debug) || (((ScriptMode == ScriptMode.Inherit) || (ScriptMode == ScriptMode.Auto)) && (scriptManager.IsDebuggingEnabled))); if (!String.IsNullOrEmpty(Path)) { string path = Path; if (isDebuggingEnabled) { path = GetDebugPath(path); } if (scriptManager.EnableScriptLocalization && (ResourceUICultures != null) && (ResourceUICultures.Length != 0)) { CultureInfo currentCulture = CultureInfo.CurrentUICulture; string cultureName = null; bool found = false; while (!currentCulture.Equals(CultureInfo.InvariantCulture)) { cultureName = currentCulture.ToString(); foreach (string uiCulture in ResourceUICultures) { if (String.Equals(cultureName, uiCulture.Trim(), StringComparison.OrdinalIgnoreCase)) { found = true; break; } } if (found) { break; } currentCulture = currentCulture.Parent; } if (found) { path = (path.Substring(0, path.Length - 2) + cultureName + ".js"); } } // ResolveClientUrl is appropriate here because the path is consumed by the page it was declared within return(ClientUrlResolver.ResolveClientUrl(path)); } List <Tuple <Assembly, List <Tuple <string, CultureInfo> > > > resources = new List <Tuple <Assembly, List <Tuple <string, CultureInfo> > > >(); Tuple <Assembly, List <Tuple <string, CultureInfo> > > resourceList = null; foreach (ScriptReference reference in Scripts) { if ((scriptManager.AjaxFrameworkMode == AjaxFrameworkMode.Explicit) && reference.IsAjaxFrameworkScript(scriptManager) && reference.EffectiveResourceName.StartsWith("MicrosoftAjax.", StringComparison.Ordinal)) { continue; } bool hasPath = !String.IsNullOrEmpty(reference.EffectivePath); #pragma warning disable 618 // ScriptPath is obsolete but still functional bool hasScriptPath = (!String.IsNullOrEmpty(scriptManager.ScriptPath) && !reference.IgnoreScriptPath); #pragma warning restore 618 // cacheAssembly will be null if ScriptPath is set, but we still need the resource assembly in that case Assembly resourceAssembly = null; string resourceName = null; Assembly cacheAssembly = null; ScriptMode effectiveScriptModeForReference = reference.EffectiveScriptMode; bool isDebuggingEnabledForReference = (effectiveScriptModeForReference == ScriptMode.Inherit) ? isDebuggingEnabled : (effectiveScriptModeForReference == ScriptMode.Debug); if (!hasPath) { resourceAssembly = reference.GetAssembly(scriptManager); resourceName = reference.EffectiveResourceName; reference.DetermineResourceNameAndAssembly(scriptManager, isDebuggingEnabledForReference, ref resourceName, ref resourceAssembly); if ((resourceAssembly != scriptManager.AjaxFrameworkAssembly) && (resourceAssembly != AssemblyCache.SystemWebExtensions) && AssemblyCache.IsAjaxFrameworkAssembly(resourceAssembly)) { // if it is coming from an assembly that is not the current ajax script assembly, make sure the assembly // is not meant to be an ajax script assembly. // it isnt an AjaxFrameworkScript but it might be from an assembly that is meant to // be an ajax script assembly, in which case we should throw an error. throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, AtlasWeb.ScriptReference_ResourceRequiresAjaxAssembly, resourceName, resourceAssembly)); } if (!hasScriptPath) { // The resource requested in the composite url will only contain the assembly name if it // will ultimately come from the assembly -- if ScriptPath is set, it doesn't. // We do still need to know the resource assembly in that case though, hence the separate // assembly variables. cacheAssembly = resourceAssembly; } } CultureInfo culture = reference.DetermineCulture(scriptManager); if ((resourceList == null) || (resourceList.Item1 != cacheAssembly)) { resourceList = new Tuple <Assembly, List <Tuple <string, CultureInfo> > >( cacheAssembly, new List <Tuple <string, CultureInfo> >()); resources.Add(resourceList); } if (hasPath || hasScriptPath) { if (hasPath) { if (String.IsNullOrEmpty(reference.Path)) { // the Path is coming from a script mapping, so its debug path applies resourceName = reference.GetPath(scriptManager, reference.EffectivePath, reference.ScriptInfo.DebugPath, isDebuggingEnabledForReference); } else { // path explicitly set, even if a mapping has a DebugPath it does not apply resourceName = reference.GetPath(scriptManager, reference.Path, null, isDebuggingEnabledForReference); } } else { #pragma warning disable 618 // ScriptPath is obsolete but still functional resourceName = ScriptReference.GetScriptPath(resourceName, resourceAssembly, culture, scriptManager.ScriptPath); #pragma warning restore 618 } // ResolveClientUrl not appropriate here because the handler that will serve the response is not // in the same directory as the page that is generating the url. Instead, an absolute url is needed // as with ResolveUrl(). However, ResolveUrl() would prepend the entire application root name. For // example, ~/foo.js would be /TheApplicationRoot/foo.js. If there are many path based scripts the // app root would be repeated many times, which for deep apps or long named apps could cause the url // to reach the maximum 2048 characters very quickly. So, the path is combined with the control's // AppRelativeTemplateSourceDirectory manually, so that ~/foo.js remains ~/foo.js, and foo/bar.js // becomes ~/templatesource/foo/bar.js. Absolute paths can remain as is. The ScriptResourceHandler will // resolve the ~/ with the app root using VirtualPathUtility.ToAbsolute(). if (UrlPath.IsRelativeUrl(resourceName) && !UrlPath.IsAppRelativePath(resourceName)) { resourceName = UrlPath.Combine(ClientUrlResolver.AppRelativeTemplateSourceDirectory, resourceName); } } resourceList.Item2.Add(new Tuple <string, CultureInfo>(resourceName, culture)); } return(ScriptResourceHandler.GetScriptResourceUrl(resources, zip)); }
public IEnumerable <RuntimeDependency> GetDependencies(string targetDirectory, ScriptMode scriptMode, string[] packagesSources, string code = null) { var pathToProjectFile = scriptMode == ScriptMode.Script ? _scriptProjectProvider.CreateProject(targetDirectory, _scriptEnvironment.TargetFramework, true) : _scriptProjectProvider.CreateProjectForRepl(code, Path.Combine(targetDirectory, scriptMode.ToString()), ScriptEnvironment.Default.TargetFramework); return(GetDependenciesInternal(pathToProjectFile, packagesSources)); }
public IEnumerable <RuntimeDependency> GetDependencies(string targetDirectory, ScriptMode scriptMode, string code = null) { var pathToProjectFile = scriptMode == ScriptMode.Script ? _scriptProjectProvider.CreateProject(targetDirectory, RuntimeHelper.TargetFramework, true) : _scriptProjectProvider.CreateProjectForRepl(code, Path.Combine(targetDirectory, scriptMode.ToString()), RuntimeHelper.TargetFramework); return(GetDependenciesInternal(pathToProjectFile)); }
public void LateFKGenerator(DbDialect dialect, ScriptMode mode,string test){ var model = PersistentModel.Compile(CircularModel); var cref = model["slave"]["master"]; var crefwr = new LateForeignKeyWriter(cref){NoDelimiter = true, NoComment = true, Dialect = dialect,Mode = mode}; var result = crefwr.ToString().Trim(); Console.WriteLine(result); Assert.AreEqual(test, result); }
public void SequenceWriter(string name, int start, int step, DbDialect dialect, ScriptMode mode, string test) { var pt = new PersistentClass { Name = name, Schema = "dbo" }; var sq = new Sequence(); sq.Setup(null, pt, null, null); var wr = new SequenceWriter(sq) { NoComment = true, NoDelimiter = true, Mode = mode, Dialect = dialect };; Assert.AreEqual(test, wr.ToString().Trim()); }
public ScriptPage Run() { Messages = new List <LogMessage>(); HasErrors = false; _blockLevel = 0; _isExpressionDepthLimitReached = false; Blocks.Clear(); ScriptPage page = Open <ScriptPage>(); ScriptMode parsingMode = CurrentParsingMode; switch (parsingMode) { case ScriptMode.FrontMatterAndContent: case ScriptMode.FrontMatterOnly: if (Current.Type != TokenType.FrontMatterMarker) { LogError(string.Format(RS.FrontMatterMarkerMissing, CurrentParsingMode, _lexer.Options.FrontMatterMarker, Current.GetText(_lexer.Text))); return(null); } _inFrontMatter = true; _inCodeSection = true; // Skip the frontmatter marker NextToken(); // Parse the front matter page.FrontMatter = ParseBlockStatement(null); // We should not be in a frontmatter after parsing the statements if (_inFrontMatter) { LogError(string.Format(RS.EndOfFrontMatterNotFound, _lexer.Options.FrontMatterMarker)); } if (parsingMode == ScriptMode.FrontMatterOnly) { return(page); } break; case ScriptMode.ScriptOnly: _inCodeSection = true; break; } page.Body = ParseBlockStatement(null); if (page.FrontMatter != null) { FixRawStatementAfterFrontMatter(page); } if (_lexer.HasErrors) { foreach (LogMessage lexerError in _lexer.Errors) { Log(lexerError); } } return(!HasErrors ? page : null); }
protected ScriptReferenceBase () { this.NotifyScriptLoaded = true; this.ScriptMode = ScriptMode.Auto; }
/// <summary> /// /// </summary> /// <param name="scriptMode"></param> /// <returns></returns> public MvcResourceManagerBuilder ScriptMode(ScriptMode scriptMode) { this.config.ScriptMode = scriptMode; this.mgr.ScriptMode = scriptMode; return this; }
public IEnumerable <RuntimeDependency> GetDependenciesForCode(string targetDirectory, ScriptMode scriptMode, string[] packageSources, string code = null) { var projectFileInfo = _scriptProjectProvider.CreateProjectForRepl(code, Path.Combine(targetDirectory, scriptMode.ToString()), ScriptEnvironment.Default.TargetFramework); _restorer.Restore(projectFileInfo, packageSources); var pathToAssetsFile = Path.Combine(Path.GetDirectoryName(projectFileInfo.Path), "obj", "project.assets.json"); return(GetDependenciesInternal(pathToAssetsFile)); }
/// <summary> /// Возваращает все скрипты для указанной позиции и языка в генерации /// </summary> /// <param name="dialect"></param> /// <param name="mode"></param> /// <param name="position"></param> /// <returns></returns> public IEnumerable<SqlScript> GetScripts(DbDialect dialect, ScriptMode mode, ScriptPosition position){ if (GenerationOptions.Supports(SqlObjectType.Script)){ return ExtendedScripts.SelectMany(_ => _.GetRealScripts(dialect, position, mode)); } return new SqlScript[]{}; }
public void ReadScript(string ScriptPath, ref ScriptStep _Step) { _Step.Define_Text = string.Empty; _Step.StepCounts = 0; _Step.m_Step = new List <ScriptMode>(); string[] ScriptLine = File.ReadAllLines(ScriptPath); //读取每行 Match match; Regex ScriptDefine = new Regex("^Define\\(\"(.+)\"\\);"); //描述字符 Regex ScriptShow = new Regex("^Show\\(\"(.+)\"\\);"); //显示字符 Regex ScriptOpenExcel = new Regex("^OpenExcel\\(\\);"); //打开Excel Regex ScriptOpenWorkSheet = new Regex("^OpenWorkSheet\\((.+),\"(.+)\"\\);"); //打开工作页 Regex ScriptCloseExcel = new Regex("^CloseExcel\\(\\);"); //关闭Excel Regex ScriptCloseWorkSheet = new Regex("^CloseWorkSheet\\(\\);"); //关闭工作页 Regex ScriptCheckItem = new Regex("^CheckItem\\((.+),(.+),(.+),\"(.+)\",\"(.+)\"\\);"); //打开工作页 Regex ScriptCheckNRC = new Regex("^CheckNRC\\((.+),(.+),\"(.+)\",\"(.+)\",\"(.+)\",\"(.+)\"\\);"); //打开工作页 Regex ScriptCheckDTC = new Regex("^CheckDTCCodeHex\\((.+),(.+),(.+)\\);"); //检查DTC for (int i = 0; i < ScriptLine.Length; ++i) //获取有效的行数,确定步骤数目 { if (ScriptLine[i] != string.Empty) { if (ScriptLine[i].Substring(0, 2) == "//") { //跳过注释行 continue; } else if (ScriptDefine.IsMatch(ScriptLine[i])) { match = ScriptDefine.Match(ScriptLine[i]); if (match.Groups[1].Value != "#NULL") { _Step.Define_Text = _Step.Define_Text + match.Groups[1].Value + "\r\n"; } else { _Step.Define_Text = _Step.Define_Text + "\r\n"; } continue; } else if (ScriptCheckItem.IsMatch(ScriptLine[i])) { ScriptMode _Buffer = new ScriptMode(); match = ScriptCheckItem.Match(ScriptLine[i]); _Buffer.ScriptType = 6; _Buffer.Position_Y = Convert.ToInt32(match.Groups[1].Value); _Buffer.Position_X = Convert.ToInt32(match.Groups[2].Value); _Buffer.CaculatorSymbol = match.Groups[3].Value; _Buffer.StringCheck = match.Groups[4].Value; _Buffer.StringBuffer = match.Groups[5].Value; _Step.m_Step.Add(_Buffer); _Step.StepCounts++; continue; } else if (ScriptShow.IsMatch(ScriptLine[i])) { ScriptMode _Buffer = new ScriptMode(); match = ScriptShow.Match(ScriptLine[i]); _Buffer.ScriptType = 5; _Buffer.StringBuffer = match.Groups[1].Value; _Step.m_Step.Add(_Buffer); _Step.StepCounts++; continue; } else if (ScriptOpenExcel.IsMatch(ScriptLine[i])) { ScriptMode _Buffer = new ScriptMode(); match = ScriptOpenExcel.Match(ScriptLine[i]); _Buffer.ScriptType = 1; _Step.m_Step.Add(_Buffer); _Step.StepCounts++; continue; } else if (ScriptOpenWorkSheet.IsMatch(ScriptLine[i])) { ScriptMode _Buffer = new ScriptMode(); match = ScriptOpenWorkSheet.Match(ScriptLine[i]); _Buffer.ScriptType = 2; _Buffer.Position_X = Convert.ToInt32(match.Groups[1].Value); _Buffer.StringBuffer = match.Groups[2].Value; _Step.m_Step.Add(_Buffer); _Step.StepCounts++; continue; } else if (ScriptCheckNRC.IsMatch(ScriptLine[i])) { ScriptMode _Buffer = new ScriptMode(); match = ScriptCheckNRC.Match(ScriptLine[i]); _Buffer.ScriptType = 7; _Buffer.Position_Y = Convert.ToInt32(match.Groups[1].Value); _Buffer.Position_X = Convert.ToInt32(match.Groups[2].Value); _Buffer.StringBuffer = match.Groups[3].Value; //支持NRC _Buffer.StringCheck = match.Groups[4].Value; //不支持NRC _Buffer.M_NRC_Des = match.Groups[5].Value; _Buffer.U_NRC_Des = match.Groups[6].Value; _Step.m_Step.Add(_Buffer); _Step.StepCounts++; continue; } else if (ScriptCheckDTC.IsMatch(ScriptLine[i])) { ScriptMode _Buffer = new ScriptMode(); match = ScriptCheckDTC.Match(ScriptLine[i]); _Buffer.ScriptType = 8; _Buffer.Position_Y = Convert.ToInt32(match.Groups[2].Value); _Buffer.Position_X = Convert.ToInt32(match.Groups[1].Value); _Buffer.DTC_Count = Convert.ToInt32(match.Groups[3].Value); _Step.m_Step.Add(_Buffer); _Step.StepCounts++; continue; } else { continue; } } } m_Edit_Process.AppendText(_Step.Define_Text); }
/// <summary> /// Получить последовательность генерации /// </summary> /// <returns></returns> public IEnumerable<SqlCommandWriter> GetWriters(DbDialect dialect, ScriptMode mode){ if (mode == ScriptMode.Create && !GenerationOptions.GenerateCreateScript) yield break; if (mode == ScriptMode.Drop && !GenerationOptions.GenerateDropScript) yield break; if (!GenerationOptions.IncludeDialect.HasFlag(dialect)) yield break; var factory = new SqlCommandWriterFactory{Mode = mode, Dialect = dialect, Model = this}; IEnumerable<object> objset = mode == ScriptMode.Create ? GetCreateOrderedWriters(dialect) : GetDropWriters(dialect); foreach (SqlCommandWriter w in factory.Get(objset)){ yield return w; } }
public ScriptContext(SourceText code, string workingDirectory, IEnumerable <string> args, string filePath = null, bool debugMode = false, ScriptMode scriptMode = ScriptMode.Script) { Code = code; WorkingDirectory = workingDirectory; Args = new ReadOnlyCollection <string>(args.ToArray()); FilePath = filePath; DebugMode = debugMode; ScriptMode = filePath != null ? ScriptMode.Script : scriptMode; }
/** * this function is called in GameControl. Thus, GameFlow is not in charge of * calling process itself, only updates the pointer. When GameControl sees a change * in pointer, this function is invoked. */ private IEnumerator processCurrentLineCoroutine() //current being where the pointer is { if (data[0, pointer] != "") //check if story done (if yes move on to actual game play) { if (data[0, pointer].Equals("SPECIAL")) //this will only happen to the ending SPECIAL tags /* customEvents is in charge of calling levelScript, which is * in charge of using certain SPECIAL blocks (with specific index) * * e.g. levelscript.levelScriptEvent(3) calls a coroutine which uses SPECIAL block 5 and SPECIAL block 6 */ { int ln; int.TryParse(data[1, pointer], out ln); if (ln != 0) { setPointer(ln); } else { Debug.LogError("SPECIAL block end didn't specify goto line number"); } yield break; //breaks out of the coroutine } if (currMode == ScriptMode.DLG) { gameControl.dialogue.disableDialogueBox(); //if transitioning from dlg to others } currMode = (ScriptMode)System.Enum.Parse(typeof(ScriptMode), data[0, pointer]); ///////////the actual changing of mode if (currMode == ScriptMode.DLG) { gameControl.dialogue.enableDialogueBox(); if (gameControl) { gameControl.hideAllIcons(); gameControl.bgManager.setBackgroundsActive(false); //pause } } else if (currMode == ScriptMode.IVS) { if (gameControl) { gameControl.showAllIcons(); } if (player) { player.setNavigationMode(Player.NavMode.TOUCH); } } else if (currMode == ScriptMode.GAME) { if (gameControl) { gameControl.showAllIcons(); } if (player) { player.setNavigationMode(Player.NavMode.ACCL); } } if (currMode != ScriptMode.GAME) { try { GameObject go = gameControl.player.transform.Find("Aim(Clone)").gameObject; if (go != null) { Destroy(go); gameControl.player.GetComponent <Animator>().SetBool("aiming", false); } } catch {} //supress error here } // print("Mode changed to " + currMode + " at line "+pointer); } switch (currMode) { case ScriptMode.DLG: //still in dialogue mode gameControl.dialogue.displayOneLine(data[1, pointer], data[2, pointer], data[3, pointer], data[4, pointer], data[5, pointer], data[7, pointer], data[8, pointer], data[9, pointer], data[10, pointer]); // break; case ScriptMode.GAME: Global.scaleRatio = (int)GameObject.FindWithTag("Player").transform.localScale.x; if (data[1, pointer].Equals("99")) { //special customized event int indexCE; int.TryParse(data[2, pointer], out indexCE); //for now we assume there's at most 6 parameters to a custom event string[] parameters = new string[7]; for (int p = 0; p < 7; p++) { parameters[p] = data[p + 3, pointer]; } customEvents.customEvent(indexCE, parameters); } else //spawn wave { string[] waves = data[1, pointer].Split(','); string[] enemies = data[2, pointer].Split(','); string[] waveWaits = data[3, pointer].Split(','); string[] spawnInterval = data[4, pointer].Split(','); string[] spawnNumber = data[5, pointer].Split(','); string[] colorModes = data[6, pointer].Split(','); string[] colorModeWeights = data[7, pointer].Split(','); //bool loop = data[6, pointer].Equals("TRUE"); List <(PaintballBehavior.ColorMode, float)> tempList = new List <(PaintballBehavior.ColorMode, float)>(); for (int i = 0; i < colorModes.Length; i++) { string cm = colorModes[i], cw = colorModeWeights[i]; Enum.TryParse(cm, true, out PaintballBehavior.ColorMode col); float.TryParse(cw, out float colW); tempList.Add((col, colW)); } PaintballBehavior.standards = tempList; int[] wv, em, wvwt, spnm; float[] intv; wv = System.Array.ConvertAll <string, int>(waves, int.Parse); em = System.Array.ConvertAll <string, int>(enemies, int.Parse); wvwt = System.Array.ConvertAll <string, int>(waveWaits, int.Parse); intv = System.Array.ConvertAll <string, float>(spawnInterval, float.Parse); spnm = System.Array.ConvertAll <string, int>(spawnNumber, int.Parse); gameControl.startEnemyWaves(wv, em, wvwt, intv, spnm); } break; case ScriptMode.IVS: //ivs related actions encountered in csv files int indexIVS = -1; int.TryParse(data[1, pointer], out indexIVS); switch (indexIVS) { case 0: //setup interactables //the current version of code requires all setup be done in one line b/c assignment of string[] //TODO will make previous interactables invalid TODO might need to allow for setting up interactables in other scenes //through metadata... and the actual assigning of gameControl's interactables should be during location setup string[] IDs = data[2, pointer].Split(','); string[] linez = data[3, pointer].Split(','); int[] lines = new int[linez.Length]; GameObject[] ivsGOs = new GameObject[linez.Length]; for (int l = 0; l < linez.Length; l++) { if (!int.TryParse(linez[l], out lines[l])) { Debug.LogError("parse line number failed in IVS"); } ivsGOs[l] = customEvents.findByIdentifier(IDs[l]); //getting the ivs gameobject by id ivsInteractable ivs = ivsGOs[l].AddComponent <ivsInteractable>(); ivs.setindexInArray(l); ivs.setIvsGoToLine(lines[l]); } gameControl.interactables = ivsGOs; break; case 1: //conditional looping for investigate //NOTE: only break after condition is fulfilled, pointer will increment outside the switch statement int varType; int.TryParse(data[2, pointer], out varType); string varName = data[3, pointer]; string varValueS = data[4, pointer]; int goalValueI = -10000; bool goalValueB = false; string goalValueS = null; switch (varType) { case 0: bool.TryParse(varValueS, out goalValueB); break; case 1: int.TryParse(varValueS, out goalValueI); break; case 2: goalValueS = varValueS; break; } yield return(new WaitUntil(() => { //loops until condition meets switch (varType) { case 0: if (!Global.boolVariables.ContainsKey(varName)) { //var not created yet return false; } bool bValue = Global.boolVariables[varName]; return (bValue == goalValueB); case 1: if (!Global.intVariables.ContainsKey(varName)) { //var not created yet return false; } int iValue = Global.intVariables[varName]; return (iValue == goalValueI); case 2: if (!Global.stringVariables.ContainsKey(varName)) { //var not created yet return false; } string sValue = Global.stringVariables[varName]; return (sValue.Equals(goalValueS)); default: Debug.Log("unclear variable type for ivs"); return false; } //end switch statement })); break; default: Debug.Log("error in IVS: " + data[1, pointer] + " not a valid number"); break; } incrementPointer(); //this is b/c gameControl can not increment pointer in IVS mode, has to happen here break; case ScriptMode.END: print("level ended!"); break; default: break; }//end switch processLineInstance = null; //resetting the reference now that it's done }
private bool TryParseStatement(ScriptStatement parent, out ScriptStatement statement, out bool hasEnd) { hasEnd = false; bool nextStatement = true; statement = null; if (HasErrors) { return(false); } continueParsing: switch (Current.Type) { case TokenType.Eof: // Early exit nextStatement = false; break; case TokenType.Raw: statement = ParseRawStatement(); break; case TokenType.CodeEnter: if (_inCodeSection) { LogError("Unexpected token while already in a code block"); } _inCodeSection = true; NextToken(); goto continueParsing; case TokenType.FrontMatterMarker: if (_inFrontMatter) { _inFrontMatter = false; _inCodeSection = false; // When we expect to parse only the front matter, don't try to tokenize the following text // Keep the current token as the code exit of the front matter if (CurrentParsingMode != ScriptMode.FrontMatterOnly) { NextToken(); } if (CurrentParsingMode == ScriptMode.FrontMatterAndContent || CurrentParsingMode == ScriptMode.FrontMatterOnly) { // Once the FrontMatter has been parsed, we can switch to default parsing mode. CurrentParsingMode = ScriptMode.Default; nextStatement = false; } } else { LogError($"Unexpected frontmatter marker `{_lexer.Options.FrontMatterMarker}` while not inside a frontmatter"); NextToken(); } break; case TokenType.CodeExit: if (!_inCodeSection) { LogError("Unexpected code block exit '}}' while no code block enter '{{' has been found"); } else if (CurrentParsingMode == ScriptMode.ScriptOnly) { LogError("Unexpected code clock exit '}}' while parsing in script only mode. '}}' is not allowed."); } _inCodeSection = false; NextToken(); goto continueParsing; default: if (_inCodeSection) { switch (Current.Type) { case TokenType.NewLine: case TokenType.SemiColon: NextToken(); goto continueParsing; case TokenType.Identifier: case TokenType.IdentifierSpecial: var identifier = GetAsText(Current); switch (identifier) { case "end": hasEnd = true; nextStatement = false; NextToken(); break; case "wrap": statement = ParseWrapStatement(); break; case "if": statement = ParseIfStatement(); break; case "else": var parentCondition = parent as ScriptConditionStatement; if (parentCondition == null) { nextStatement = false; // unit test: 201-if-else-error3.txt LogError("A else condition must be preceded by another if/else condition"); } else { var nextCondition = ParseElseStatement(); parentCondition.Else = nextCondition; hasEnd = true; } break; case "for": if (PeekToken().Type == TokenType.Dot) { statement = ParseExpressionStatement(); } else { statement = ParseForStatement(); } break; case "with": statement = ParseWithStatement(); break; case "import": statement = ParseImportStatement(); break; case "readonly": statement = ParseReadOnlyStatement(); break; case "while": if (PeekToken().Type == TokenType.Dot) { statement = ParseExpressionStatement(); } else { statement = ParseWhileStatement(); } break; case "break": statement = Open <ScriptBreakStatement>(); NextToken(); Close(statement); // This has to be done at execution time, because of the wrap statement //if (!IsInLoop()) //{ // LogError(statement, "Unexpected statement outside of a loop"); //} ExpectEndOfStatement(statement); break; case "continue": statement = Open <ScriptContinueStatement>(); NextToken(); Close(statement); // This has to be done at execution time, because of the wrap statement //if (!IsInLoop()) //{ // LogError(statement, "Unexpected statement outside of a loop"); //} ExpectEndOfStatement(statement); break; case "func": statement = ParseFunctionStatement(false); break; case "ret": statement = ParseReturnStatement(); break; case "capture": statement = ParseCaptureStatement(); break; default: // Otherwise it is an expression statement statement = ParseExpressionStatement(); break; } break; default: if (StartAsExpression()) { statement = ParseExpressionStatement(); } else { nextStatement = false; LogError($"Unexpected token {Current.Type}"); } break; } } else { nextStatement = false; LogError($"Unexpected token {Current.Type} while not in a code block {{ ... }}"); // LOG an ERROR. Don't expect any other tokens outside a code section } break; } return(nextStatement); }
/// <summary> /// /// </summary> /// <param name="scriptMode"></param> /// <returns></returns> public MvcResourceManagerBuilder ScriptMode(ScriptMode scriptMode) { this.config.ScriptMode = scriptMode; this.mgr.ScriptMode = scriptMode; return(this); }
/// <summary> /// Возвращает реальные скрипты н /// </summary> /// <param name="dialect"></param> /// <param name="position"></param> /// <param name="mode"></param> /// <returns></returns> public IEnumerable <SqlScript> GetRealScripts(DbDialect dialect, ScriptPosition position, ScriptMode mode) { if (0 == SubScripts.Count) { if (DbDialect == DbDialect.Ansi || dialect == DbDialect) { if (Mode == mode) { if (Position == position) { yield return(this); } } } } else { foreach (SqlScript subScript in SubScripts) { foreach (SqlScript rs in subScript.GetRealScripts(dialect, position, mode)) { yield return(rs); } } } }
public ScriptInfo(string tableName, string filter, ScriptMode scriptMode) { Name = Regex.Replace(tableName, @"(\[)|([\.\]])|(.*?\.)|(\.)", "", RegexOptions.IgnoreCase); Filter = filter; ScriptMode = scriptMode; }
private IEnumerable <object> GetCreateOrderedWriters(DbDialect dialect, ScriptMode mode = ScriptMode.Create) { foreach (SqlScript script in GetScripts(dialect, mode, ScriptPosition.Before)) { yield return(script); } foreach (FileGroup fg in DatabaseSqlObjects.OfType <FileGroup>()) { yield return(fg); } foreach (Schema schema in DatabaseSqlObjects.OfType <Schema>()) { yield return(schema); } foreach (Sequence sequence in Tables.SelectMany(_ => _.SqlObjects.OfType <Sequence>())) { yield return(sequence); } foreach (PartitionDefinition part in Tables.SelectMany(_ => _.SqlObjects.OfType <PartitionDefinition>())) { yield return(part); } foreach (SqlScript script in GetScripts(dialect, mode, ScriptPosition.BeforeTables)) { yield return(script); } foreach (PersistentClass cls in Tables) { yield return(cls); } foreach (Field circularRef in Tables.SelectMany(_ => _.Fields.Values.Where(__ => __.GetIsCircular()))) { yield return(circularRef); } foreach (SqlScript script in GetScripts(dialect, mode, ScriptPosition.AfterTables)) { yield return(script); } foreach (SqlFunction function in Tables.SelectMany(_ => _.SqlObjects.OfType <SqlFunction>())) { if (function.Dialect == DbDialect.None || function.Dialect == dialect || function.Dialect == DbDialect.Ansi) { yield return(function); } } foreach (SqlView view in Tables.SelectMany(_ => _.SqlObjects.OfType <SqlView>())) { if (view.Dialect == DbDialect.None || view.Dialect == dialect || view.Dialect == DbDialect.Ansi) { yield return(view); } } foreach (SqlTrigger trigger in Tables.SelectMany(_ => _.SqlObjects.OfType <SqlTrigger>())) { if (trigger.Dialect == DbDialect.None || trigger.Dialect == dialect || trigger.Dialect == DbDialect.Ansi) { yield return(trigger); } } foreach (SqlScript script in Tables.SelectMany(_ => _.SqlObjects.OfType <SqlScript>())) { if (script.Dialect == DbDialect.None || script.Dialect == dialect || script.Dialect == DbDialect.Ansi) { yield return(script); } } foreach (SqlScript script in GetScripts(dialect, mode, ScriptPosition.After)) { yield return(script); } }
/// <summary> /// 运行客户端JavaScript脚本 /// </summary> /// <param name="ctrl">放置脚本的控件</param> /// <param name="code">JavaScript代码</param> /// <param name="mode">执行模式</param> public static void RunScript(System.Web.UI.Control ctrl, string code,ScriptMode mode) { if (mode == ScriptMode.BeforeLoad) { ctrl.Page.ClientScript.RegisterClientScriptBlock(ctrl.GetType(), "jsBlock", code, true); } else if (mode == ScriptMode.AfterLoad) { System.Web.UI.HtmlControls.HtmlGenericControl hgc = new System.Web.UI.HtmlControls.HtmlGenericControl(); hgc.TagName = "div"; hgc.InnerHtml = "<script type=\"text/javascript\">"; hgc.InnerHtml += code; hgc.InnerHtml += "</script>"; ctrl.Controls.Add(hgc); } else { System.Web.UI.ScriptManager.RegisterClientScriptBlock(ctrl, ctrl.GetType(), "jsBlock", code, true); } }