public RegisterJob() { _scope = ContainerConfig.Configure().BeginLifetimeScope(); _cs = _scope.Resolve <CopySource>(); _idb = _scope.Resolve <InitializeDatabase>(); _iwh = _scope.Resolve <InitializeWebHost>(); _iws = _scope.Resolve <InitializeWindowService>(); _us = _scope.Resolve <UninstallJob>(); }
/// <summary> /// Helper to clear any in progress copy-paste /// </summary> public void CancelCopy() { if (copySource != null && currentCharacteristic == copySource.Characteristic) { copySource.Obj.CopyImage.color = Color.white; } copySource = null; SetPasteMode(false); }
public CopyActivity(CopySource source, CopySink sink, CopyTranslator translator = null) : this() { Ensure.IsNotNull(source, "source"); Ensure.IsNotNull(sink, "sink"); this.Source = source; this.Sink = sink; this.Translator = translator; }
public CopySource ToSdkObject() { var copySource = new CopySource() { SourceRetryCount = this.SourceRetryCount, SourceRetryWait = this.SourceRetryWait, MaxConcurrentConnections = this.MaxConcurrentConnections }; this.AdditionalProperties?.ForEach(item => copySource.Add(item.Key, item.Value)); return(copySource); }
/// <summary> /// Set the row as the source for a copy-paste operation /// </summary> /// <param name="row">UI row that was clicked on</param> private void SetCopySource(DifficultyRow row) { // If we copied from the current characteristic remove the highlight if (copySource != null && currentCharacteristic == copySource.Characteristic) { copySource.Obj.CopyImage.color = Color.white; } // Clicking twice on the same source removes it if (copySource != null && copySource.Obj == row && currentCharacteristic == copySource.Characteristic) { CancelCopy(); return; } copySource = new CopySource(diffs[row.Name], currentCharacteristic, row); SetPasteMode(true); row.CopyImage.color = copyColor; }
string ITextPasteHandler.FormatPlainText(int insertionOffset, string text, byte[] copyData) { if (document.Editor.Options.IndentStyle == IndentStyle.None || document.Editor.Options.IndentStyle == IndentStyle.Auto) { return(text); } if (copyData != null && copyData.Length == 1) { CopySource src = (CopySource)copyData [0]; switch (src) { case CopySource.VerbatimString: text = ConvertFromVerbatimString(text); break; case CopySource.StringLiteral: text = ConvertFromString(text); break; } } stateTracker.UpdateEngine(insertionOffset); var engine = stateTracker.Engine.Clone() as CSharpIndentEngine; var result = new StringBuilder(); if (engine.IsInsideStringLiteral) { return(ConvertToStringLiteral(text)); } if (engine.IsInsideVerbatimString) { return(ConvertToVerbatimLiteral(text)); } bool inNewLine = false; foreach (var ch in text) { if (!engine.IsInsideOrdinaryCommentOrString) { if (inNewLine && (ch == ' ' || ch == '\t')) { engine.Push(ch); continue; } } if (inNewLine && ch != '\n' && ch != '\r') { if (!engine.IsInsideOrdinaryCommentOrString) { if (ch != '#') { engine.Push(ch); } result.Append(engine.ThisLineIndent); if (ch == '#') { engine.Push(ch); } } inNewLine = false; } else { engine.Push(ch); } result.Append(ch); if (ch == '\n' || ch == '\r') { inNewLine = true; } } return(result.ToString()); }
byte[] ITextPasteHandler.GetCopyData(TextSegment segment) { stateTracker.UpdateEngine(segment.Offset); if (stateTracker.Engine.IsInsideStringLiteral) { return new [] { (byte)CopySource.StringLiteral } } ; if (stateTracker.Engine.IsInsideVerbatimString) { return new [] { (byte)CopySource.VerbatimString } } ; return(null); } string ITextPasteHandler.FormatPlainText(int insertionOffset, string text, byte[] copyData) { if (document.Editor.Options.IndentStyle == IndentStyle.None || document.Editor.Options.IndentStyle == IndentStyle.Auto) { return(text); } if (copyData != null && copyData.Length == 1) { CopySource src = (CopySource)copyData [0]; switch (src) { case CopySource.VerbatimString: text = text.Replace("\"\"", "\""); break; case CopySource.StringLiteral: StringBuilder sb = new StringBuilder(); for (int i = 0; i < text.Length; i++) { switch (text [i]) { case '\\': i++; switch (text [i]) { case '\\': sb.Append('\\'); break; case 'r': sb.Append('\r'); break; case 'n': sb.Append('\n'); break; case 't': sb.Append('\t'); break; } break; default: sb.Append(text [i]); break; } } text = sb.ToString(); break; } } stateTracker.UpdateEngine(insertionOffset); var engine = stateTracker.Engine.Clone() as CSharpIndentEngine; StringBuilder result = new StringBuilder(); if (engine.IsInsideStringLiteral) { foreach (var ch in text) { switch (ch) { case '\t': result.Append("\\t"); break; case '"': result.Append("\\\""); break; case '\n': result.Append("\\n"); break; case '\r': result.Append("\\r"); break; case '\\': result.Append("\\\\"); break; default: result.Append(ch); break; } } return(result.ToString()); } if (engine.IsInsideVerbatimString) { foreach (var ch in text) { switch (ch) { case '"': result.Append("\"\""); break; default: result.Append(ch); break; } } return(result.ToString()); } bool inNewLine = false; foreach (var ch in text) { if (!engine.IsInsideOrdinaryCommentOrString) { if (inNewLine && (ch == ' ' || ch == '\t')) { engine.Push(ch); continue; } } if (inNewLine && ch != '\n' && ch != '\r') { if (!engine.IsInsideOrdinaryCommentOrString) { if (ch != '#') { engine.Push(ch); } result.Append(engine.ThisLineIndent); if (ch == '#') { engine.Push(ch); } } inNewLine = false; } else { engine.Push(ch); } result.Append(ch); if (ch == '\n' || ch == '\r') { inNewLine = true; } } return(result.ToString()); } #endregion #region Sharing the tracker void InitTracker() { stateTracker = new DocumentStateTracker <CSharpIndentEngine> (new CSharpIndentEngine(Policy, TextStylePolicy), textEditorData); }
/// <summary> /// Resolves the copy operations /// </summary> /// <param name="operation">The <see cref="Operation"/></param> private void ResolveCopy(Operation operation) { if (!operation.OperationKind.IsCopyOperation()) { return; } var options = new CopyInfoOptions { CopyKind = CopyKind.Deep, KeepOwner = operation.OperationKind == OperationKind.Copy || operation.OperationKind == OperationKind.CopyKeepValues, KeepValues = operation.OperationKind == OperationKind.CopyKeepValues || operation.OperationKind == OperationKind.CopyKeepValuesChangeOwner }; var sourcepoco = operation.OriginalThing.QuerySourceThing(); var sourceIteration = sourcepoco.GetContainerOfType <Iteration>(); var source = new CopySource { Thing = new CopyReference { Iid = operation.OriginalThing.Iid, ClassKind = operation.OriginalThing.ClassKind }, TopContainer = new CopyReference { Iid = sourcepoco.TopContainer.Iid, ClassKind = sourcepoco.TopContainer.ClassKind }, IterationId = sourceIteration?.Iid }; var poco = operation.ModifiedThing.QuerySourceThing(); if (poco.Container == null) { throw new InvalidOperationException("The container cannot be null."); } var targetIteration = poco.GetContainerOfType <Iteration>(); var target = new CopyTarget { Container = new CopyReference { Iid = poco.Container.Iid, ClassKind = poco.Container.ClassKind }, TopContainer = new CopyReference { Iid = poco.TopContainer.Iid, ClassKind = poco.TopContainer.ClassKind }, IterationId = targetIteration?.Iid }; var copyInfo = new CopyInfo { Source = source, Target = target, Options = options }; if (targetIteration != null) { var participation = this.session.OpenIterations.FirstOrDefault(x => x.Key.Iid == targetIteration.Iid).Value; copyInfo.ActiveOwner = participation.Item1?.Iid ?? Guid.Empty; } this.Copy.Add(copyInfo); }