public FirebirdGenerator(Processors.Firebird.FirebirdOptions fbOptions) : base(new FirebirdColumn(fbOptions), new FirebirdQuoter(), new EmptyDescriptionGenerator()) { if (fbOptions == null) throw new ArgumentNullException("fbOptions"); FBOptions = fbOptions; truncator = new FirebirdTruncator(FBOptions.TruncateLongNames, FBOptions.PackKeyNames); }
public void Test_Null() { MockProcessor mock = new MockProcessor(); Processors proc = new Processors {new MockProcessor(), new TestProcessor(), new NullProcessor(), mock}; Assert.IsNull(proc.Process("something")); Assert.AreEqual(0, mock.Count); }
public void Test_Mock() { MockProcessor mock = new MockProcessor(); Processors proc = new Processors {mock}; Assert.AreEqual("something", proc.Process("something")); Assert.AreEqual(1, mock.Count); Assert.AreEqual("something", proc.Process("something")); Assert.AreEqual(2, mock.Count); }
public void Test_Test() { TestProcessor test = new TestProcessor(); Processors proc = new Processors {test}; Assert.AreEqual("test", proc.Process("something")); Assert.AreEqual(1, test.Count); Assert.AreEqual("test", proc.Process("something")); Assert.AreEqual(2, test.Count); }
/// <summary> /// Constructor /// </summary> /// <param name="pDocument"></param> /// <param name="pProc"></param> public Tokens(string pDocument, Processors pProc) : this(pProc) { Regex r = new Regex(_TOKEN_PATTERN); Match m = r.Match(pDocument); while (m.Success) { Add(m.Groups["val"].Value); m = m.NextMatch(); } }
/// <summary> /// Write the processor queues to disk /// </summary> /// <param name="peekTickTime">Time of the next tick in the stream</param> /// <param name="step">Period between flushes to disk</param> /// <param name="final">Final push to disk</param> /// <returns></returns> private DateTime WriteToDisk(Processors processors, ManualResetEvent waitForFlush, DateTime peekTickTime, TimeSpan step, bool final = false) { waitForFlush.WaitOne(); waitForFlush.Reset(); Flush(processors, peekTickTime, final); Task.Run(() => { try { foreach (var type in Enum.GetValues(typeof(TickType))) { var tickType = type; var groups = processors.Values.Select(x => x[(int)tickType]).Where(x => x.Queue.Count > 0).GroupBy(process => process.Symbol.Underlying.Value); Parallel.ForEach(groups, group => { string zip = string.Empty; try { var symbol = group.Key; zip = group.First().ZipPath.Replace(".zip", string.Empty); foreach (var processor in group) { var tempFileName = Path.Combine(zip, processor.EntryPath); Directory.CreateDirectory(zip); File.AppendAllText(tempFileName, FileBuilder(processor)); } } catch (Exception err) { Log.Error("AlgoSeekOptionsConverter.WriteToDisk() returned error: " + err.Message + " zip name: " + zip); } }); } } catch (Exception err) { Log.Error("AlgoSeekOptionsConverter.WriteToDisk() returned error: " + err.Message); } waitForFlush.Set(); }); //Pause while writing the final flush. if (final) { waitForFlush.WaitOne(); } return(peekTickTime.RoundDown(step)); }
protected virtual void ExecuteStrategy() { Processors.Initialize(); if (DataSource.Initialize()) { foreach (ProcessItem <T> item in DataSource) { Processors.Execute(item); } } }
private List <IDocumentProcessor> LoadSchemaDrivenDocumentProcessors(DocumentBuildParameters parameter) { using (new LoggerPhaseScope(nameof(LoadSchemaDrivenDocumentProcessors))) { var result = new List <IDocumentProcessor>(); SchemaValidateService.RegisterLicense(parameter.SchemaLicense); using (var resource = parameter?.TemplateManager?.CreateTemplateResource()) { if (resource == null || resource.IsEmpty) { return(result); } var siteHostName = TryGetPublishTargetSiteHostNameFromEnvironment(); var markdigMarkdownService = CreateMarkdigMarkdownService(parameter); foreach (var pair in resource.GetResourceStreams(@"^schemas/.*\.schema\.json")) { var fileName = Path.GetFileName(pair.Key); using (new LoggerFileScope(fileName)) { using var stream = pair.Value; using var sr = new StreamReader(stream); DocumentSchema schema; try { schema = DocumentSchema.Load(sr, fileName.Remove(fileName.Length - ".schema.json".Length)); } catch (Exception e) { Logger.LogError(e.Message); throw; } var sdp = new SchemaDrivenDocumentProcessor( schema, new CompositionContainer(CompositionContainer.DefaultContainer), markdigMarkdownService, new FolderRedirectionManager(parameter.OverwriteFragmentsRedirectionRules), siteHostName); Logger.LogVerbose($"\t{sdp.Name} with build steps ({string.Join(", ", from bs in sdp.BuildSteps orderby bs.BuildOrder select bs.Name)})"); result.Add(sdp); } } } if (result.Count > 0) { Logger.LogInfo($"{result.Count} schema driven document processor plug-in(s) loaded."); Processors = Processors.Union(result); } return(result); } }
public ScreenParameters PrintMenu(Processors.BBCS.ConnectionInfo connection) { param.tag = CCUpdate.Program.WriteMenu(BBCS.EMAIL_JOB_BBCS, "Enter tag", true); string response = CCUpdate.Program.WriteMenu(BBCS.EMAIL_JOB_BBCS, "Enter number of recipients", true); param.recipientCount = int.Parse(response); string screen = CCUpdate.Program.GetMenu(CCUpdate.Program.RUN_BBCS); CCUpdate.Program.WriteScreen(string.Format(screen, connection.Host, connection.User, connection.Password, param.tag, connection.BulkInline())); return param; }
internal override void ReadData(AwesomeReader ar) { Pedals.Clear(); Processors.Clear(); AmpPath = ar.ReadUInt64(); GainLevel = ar.ReadSingle(); BassLevel = ar.ReadSingle(); MidLevel = ar.ReadSingle(); TrebleLevel = ar.ReadSingle(); ReverbLevel = ar.ReadSingle(); VolumeLevel = ar.ReadSingle(); AmpReverb = ar.ReadUInt64(); int pedalCount = ar.ReadInt32(); ar.BaseStream.Position += 4; int processorCount = ar.ReadInt32(); ar.BaseStream.Position += 4; // Reads pedals for (int i = 0; i < pedalCount; i++) { Pedal pedal = new Pedal(); pedal.ModelPath = ar.ReadUInt64(); pedal.Flag1 = ar.ReadBoolean(); pedal.Flag2 = ar.ReadBoolean(); pedal.Flag3 = ar.ReadBoolean(); pedal.Flag4 = ar.ReadBoolean(); pedal.Knob1 = ar.ReadSingle(); pedal.Knob2 = ar.ReadSingle(); pedal.Knob3 = ar.ReadSingle(); Pedals.Add(pedal); } // Reads audio processors for (int i = 0; i < processorCount; i++) { AudioProcessor processor = new AudioProcessor(); processor.ModelPath = ar.ReadUInt64(); processor.Knob1 = ar.ReadSingle(); processor.Knob2 = ar.ReadSingle(); Processors.Add(processor); } }
public ActionResult Edit([Bind(Include = "Id,Name,Price,Delivery,Order,Maker")] Processors processors) { if (ModelState.IsValid) { db.Entry(processors).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Delivery = new SelectList(db.Deliveries, "Id", "date", processors.Delivery); ViewBag.Maker = new SelectList(db.Makers, "Id", "Name", processors.Maker); ViewBag.Order = new SelectList(db.Orders, "Id", "date", processors.Order); return(View(processors)); }
public void Test_Mock() { MockProcessor mock = new MockProcessor(); Processors proc = new Processors { mock }; Assert.AreEqual("something", proc.Process("something")); Assert.AreEqual(1, mock.Count); Assert.AreEqual("something", proc.Process("something")); Assert.AreEqual(2, mock.Count); }
private void OnValueAdded(string key, object value) { if (value is SkinDictionary skinValue) { skinValue.Parent = this; skinValue.Key = key; } if (value is SkinDictionaryProcessor skinProcessor) { Processors.Add(skinProcessor); } }
public void Test_Score() { TokenCollection good = Create(new[] {"ikea", "kitchen", "mouse"}); TokenCollection bad = Create(new[] {"house", "stock", "chicken"}); Processors proc = new Processors(); const string document = "ikea kitchen mouse ikea kitchen mouse ikea kitchen mouse ikea kitchen mouse"; Tokens tokens = new Tokens(document, proc); float score = Analyzer.Score(tokens, good, bad); //Assert.AreEqual(0.0f, score); }
private void RemoveRendererTypes() { // Unregister render processors ComponentTypeAdded -= EntitySystemOnComponentTypeAdded; foreach (var renderProcessors in registeredRenderProcessorTypes) { foreach (var renderProcessorInstance in renderProcessors.Value.Instances) { Processors.Remove(renderProcessorInstance.Value); } } registeredRenderProcessorTypes.Clear(); }
public DocumentBuilder(IEnumerable <Assembly> assemblies = null) { using (new LoggerPhaseScope(PhaseName)) { Logger.LogInfo("Loading plug-in..."); GetContainer(DefaultAssemblies.Union(assemblies ?? new Assembly[0])).SatisfyImports(this); Logger.LogInfo($"{Processors.Count()} plug-in(s) loaded:"); foreach (var processor in Processors) { Logger.LogInfo($"\t{processor.Name} with build steps ({string.Join(", ", from bs in processor.BuildSteps orderby bs.BuildOrder select bs.Name)})"); } } }
public void Test_Test() { TestProcessor test = new TestProcessor(); Processors proc = new Processors { test }; Assert.AreEqual("test", proc.Process("something")); Assert.AreEqual(1, test.Count); Assert.AreEqual("test", proc.Process("something")); Assert.AreEqual(2, test.Count); }
private void OnValueRemoved(string key, object value) { if (value is SkinDictionary skinValue) { skinValue.Parent = null; skinValue.Key = null; } if (value is SkinDictionaryProcessor skinProcessor) { Processors.Remove(skinProcessor); } }
public void Test_Score() { TokenCollection good = Create(new[] { "ikea", "kitchen", "mouse" }); TokenCollection bad = Create(new[] { "house", "stock", "chicken" }); Processors proc = new Processors(); const string document = "ikea kitchen mouse ikea kitchen mouse ikea kitchen mouse ikea kitchen mouse"; Tokens tokens = new Tokens(document, proc); Analyzer a = new Analyzer(); float score = Analyzer.Score(tokens, good, bad); //Assert.AreEqual(0.0f, score); }
public DocumentBuilder(IEnumerable <Assembly> assemblies = null) { Logger.LogVerbose("Loading plug-in..."); var assemblyList = assemblies?.ToList(); _container = GetContainer(assemblyList); _container.SatisfyImports(this); _currentBuildInfo.PluginHash = ComputePluginHash(assemblyList); Logger.LogInfo($"{Processors.Count()} plug-in(s) loaded."); foreach (var processor in Processors) { Logger.LogVerbose($"\t{processor.Name} with build steps ({string.Join(", ", from bs in processor.BuildSteps orderby bs.BuildOrder select bs.Name)})"); } }
public void Run() { foreach (var procKlass in _processors) { var processorType = Type.GetType("Elite.DataCollecting.API.Lib.Processors." + procKlass); var processor = (TextProcessor)Activator .CreateInstance(processorType, new object[] { _hostingEnvironment, _inputText }); Processors.Add(processor); processor.ProcessText(); _inputText = processor.OutputText; } Result = _inputText; }
public ProcessingStatus Run() { Telemetry.TrackEvent("EngineStart", new Dictionary <string, string> { { "Engine", "Migration" } }, new Dictionary <string, double> { { "Processors", Processors.Count }, { "Mappings", FieldMaps.Count } }); Stopwatch engineTimer = Stopwatch.StartNew(); ProcessingStatus ps = ProcessingStatus.Running; Processors.EnsureConfigured(); TypeDefinitionMaps.EnsureConfigured(); GitRepoMaps.EnsureConfigured(); ChangeSetMapps.EnsureConfigured(); FieldMaps.EnsureConfigured(); Log.Information("Beginning run of {ProcessorCount} processors", Processors.Count.ToString()); foreach (IProcessor process in Processors.Items) { Log.Information("Processor: {ProcessorName}", process.Name); Stopwatch processorTimer = Stopwatch.StartNew(); process.Execute(); processorTimer.Stop(); Telemetry.TrackEvent("ProcessorComplete", new Dictionary <string, string> { { "Processor", process.Name }, { "Status", process.Status.ToString() } }, new Dictionary <string, double> { { "ProcessingTime", processorTimer.ElapsedMilliseconds } }); if (process.Status == ProcessingStatus.Failed) { ps = ProcessingStatus.Failed; Log.Error("{Context} The Processor {ProcessorName} entered the failed state...stopping run", process.Name, "MigrationEngine"); break; } } engineTimer.Stop(); Telemetry.TrackEvent("EngineComplete", new Dictionary <string, string> { { "Engine", "Migration" } }, new Dictionary <string, double> { { "EngineTime", engineTimer.ElapsedMilliseconds } }); return(ps); }
/// <summary> /// Returns a Processors enum constant for the named processor type, without /// throwing an exception if the processor is unknown. /// </summary> /// <param name="proc">String containing a processor name</param> /// <returns>Processor enum constant</returns> internal static Processors GetProcessor(string processor) { Processors result = Processors.Undefined; try { result = (Processors)Enum.Parse(typeof(Processors), processor, true); } catch (System.Exception) { } return(result); }
private EntityProcessor CreateRenderProcessor(RegisteredRenderProcessors registeredRenderProcessor, VisibilityGroup visibilityGroup) { // Create var processor = (EntityProcessor)Activator.CreateInstance(registeredRenderProcessor.Type); // Set visibility group ((IEntityComponentRenderProcessor)processor).VisibilityGroup = visibilityGroup; // Add processor Processors.Add(processor); registeredRenderProcessor.Instances.Add(new KeyValuePair <VisibilityGroup, EntityProcessor>(visibilityGroup, processor)); return(processor); }
// GET: Processors/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Processors processors = db.Processors.Find(id); if (processors == null) { return(HttpNotFound()); } return(View(processors)); }
public void RollbackTransaction() { AssertTransaction(); var index = transactionStartIndices.Peek(); if (currentIndex != index) { operations.RemoveRange(currentIndex, GetTransactionEndIndex() - currentIndex); for (; currentIndex > index; currentIndex--) { Processors.Invert(operations[currentIndex - 1]); } } }
public static IActionResult BuildFeed(List <RssEntry> entries, string titleSuffix) { var ch = new XElement("channel", new XElement("title", $"Anilibria — так звучит аниме! [{titleSuffix}]"), new XElement("link", "https://www.anilibria.tv"), new XElement("description", "Неофициальная RSS-лента по сайту Anilibria.tv"), new XElement("language", "ru-ru"), new XElement("copyright", "Все права на контент в этом канале принадлежат сайту Anilibria.tv. Все права на код синхронизатора базы и генератора ленты принадлежат AgentMC."), new XElement("webMaster", "[email protected] (AgentMC)"), new XElement("lastBuildDate", entries[0].Created.ToRssDateTimeString()), new XElement("generator", $"Azure Functions + Azure Sql + a bunch of C# :) version [{Assembly.GetExecutingAssembly().GetName().Version}]"), new XElement("docs", "http://validator.w3.org/feed/docs/rss2.html"), new XElement("ttl", "15"), new XElement("image", new XElement("url", "https://static.anilibria.tv/img/footer.png"), new XElement("title", "Anilibria — Спасибо, что выбираете нас!"), new XElement("link", "https://www.anilibria.tv"))); foreach (var episode in entries) { ch.Add(new XElement("item", new XElement("title", Processors["{maintitle}"](episode)), new XElement("link", Processors["{releaselink}"](episode)), new XElement("guid", new XAttribute("isPermaLink", "false"), GetGlobalizedUid(episode, titleSuffix).ToString()), new XElement("pubDate", episode.Created.ToRssDateTimeString()), new XElement("source", new XAttribute("url", "https://getlibriarss.azurewebsites.net/api/RssOnline"), $"GetLibriaRss - {titleSuffix}"), new XElement("description", BuildDescription(episode)))); } return(new OkObjectResult(new XDocument(new XElement("rss", new XAttribute("version", "2.0"), ch)).ToString()) { Formatters = new FormatterCollection <IOutputFormatter> { new RssMediaFormatter() } }); }
/// <summary> /// Returns an IDisposable LocalWrapper that will render the open tag upon opening, and a close tag upon closing /// </summary> /// <returns>returns a LocalWrapper containing the rendered tag</returns> public LocalWrapper Open() { if (!(IsDisplayed || DebugMode)) { return(new LocalWrapper(null, _context)); } var builder = new TagBuilder(TagName); foreach (var attribute in LocalizedAttributes) { var value = Repository.GetQualified(attribute.Value.Key, attribute.Value.Default); builder.MergeAttribute(attribute.Key, Processors.Aggregate( value.Value.DecodeWithReplacements(Replacements), (val, processor) => processor(val) )); if (!DebugMode) { continue; } builder.MergeAttribute("data-loc-debug", "true"); var key = "data-loc-attribute-" + attribute.Key + "-"; builder.MergeAttribute(key + "part", value.Qualifier.Part.ToString()); builder.MergeAttribute(key + "content", value.Value.Content); } if (DebugMode) { if (LocalizedAttributes.Any()) { var localizations = String.Join(((char)31).ToString(CultureInfo.InvariantCulture), LocalizedAttributes.Select(localization => localization.Key + (char)30 + localization.Value)); builder.MergeAttribute("data-loc-localizations", localizations); } if (Replacements.Any()) { var replacements = String.Join(((char)31).ToString(CultureInfo.InvariantCulture), Replacements.Select(replacement => replacement.Key + (char)30 + replacement.Value)); builder.MergeAttribute("data-loc-replacements", replacements); } } foreach (var attribute in OtherAttributes) { builder.MergeAttribute(attribute.Key, attribute.Value); } return(new LocalWrapper(builder, _context)); }
/// <exception cref="DomainBusConfigurationException">When missing a storage implemementation.</exception> internal void VerifyWeHaveAll() { _hostName.MustNotBeEmpty(); _containerBuilder.MustNotBeNull(ex: new DomainBusConfigurationException("Missing an implementation of IRegisterBusTypesInContainer")); Processors.Verify(); var missing = _storages .Where(kv => kv.Value == null) .Select(d => d.Key).ToArray(); if (!missing.Any()) { return; } throw new DomainBusConfigurationException($"I need an implementation for the following interfaces: '{missing.StringJoin()}'"); }
public Type[] SupportedClasses() { if (ProcessorList.Count > 0) { List <Type> types = new List <Type>(); Processors.ForEach(n => types.AddRange(n.SupportedClasses())); return(types.ToArray()); } else { return(new Type[] { typeof(object) }); } }
// GET: Processors/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Processors processors = db.Processors.Find(id); if (processors == null) { return(HttpNotFound()); } ViewBag.Delivery = new SelectList(db.Deliveries, "Id", "date", processors.Delivery); ViewBag.Maker = new SelectList(db.Makers, "Id", "Name", processors.Maker); ViewBag.Order = new SelectList(db.Orders, "Id", "date", processors.Order); return(View(processors)); }
public void Step(TimeSpan span) { if (isFirstRun) { Processors.ForEach(x => x.Init(Context)); isFirstRun = false; } Context.WorldClock += span; Context.StepStart(); foreach (var item in Processors) { if (item.EnableProcess) { item.Process(Context, span); } } Context.StepEnd(); }
protected virtual void OnLoad() { Input = Window.CreateInput(); GFX.Initialize(); GFX.OnDebugOutput += (source, type, id, severity, message) => //Console.WriteLine($"[GLDebug] [{severity}] {type}/{id}: {message}"); this.Log(severity.ToLogSeverity(), "{0}/{1}: {2}", type, id, message); Processors.Start <Renderer>(); Processors.Start <TextureManager>(); Processors.Start <MeshManager>(); Processors.Start <CameraController>(); var mainCamera = Entities.New(); Set(mainCamera, (Transform)Matrix4x4.Identity); Set(mainCamera, Camera.Default3D); }
private void startClient(Socket s) { var dc = new DaemonClient(this) { Peer = s.RemoteEndPoint }; // [caytchen] TODO: insanse anonymous methods were ported 1:1 from jgit, do properly sometime var t = new Thread( new ThreadStart(delegate { using (NetworkStream stream = new NetworkStream(s)) { try { dc.Execute(new BufferedStream(stream)); } catch (IOException) { } catch (SocketException) { } finally { try { s.Close(); } catch (IOException) { } catch (SocketException) { } } } })); t.Start(); Processors.Add("Git-Daemon-Client " + s.RemoteEndPoint, t); }
public void Undo() { if (!CanUndo()) { return; } bool documentChanged = false; int s = GetTransactionStartIndex(); while (currentIndex > 0 && !documentChanged) { documentChanged |= AnyChangingOperationWithinRange(s, currentIndex); for (; currentIndex > s; currentIndex--) { Processors.Invert(operations[currentIndex - 1]); } s = GetTransactionStartIndex(); } OnChange(); }
private void OnNew() { var defaultPipeline = MessageBox.Show("Do you want create an new pipeline?", "Default Pipeline", MessageBoxButton.YesNo, MessageBoxImage.Question); if (defaultPipeline != MessageBoxResult.Yes) { return; } foreach (var processor in Processors) { processor.Stop(); } Model.Stop(); Processors.Clear(); Pipes.Clear(); Model = new Pipeline(); }
public void PrintScreen(Processors.BBCS.ConnectionInfo connection) { string screen = CCUpdate.Program.GetMenu(CCUpdate.Program.RUN_BBCS); CCUpdate.Program.WriteScreen(string.Format(screen, connection.Host, connection.User, connection.Password, this.param.tag, connection.BulkAdd())); }
public void Test_Empty() { Processors proc = new Processors(); Assert.AreEqual("something", proc.Process("something")); }
public FirebirdGenerator(Processors.Firebird.FirebirdOptions fbOptions) : base(new FirebirdColumn(fbOptions), new FirebirdQuoter(), new GenericEvaluator()) { FBOptions = fbOptions; truncator = new FirebirdTruncator(FBOptions.TruncateLongNames); }