public virtual void MergeInto(uint x, uint y, OneBppBitmap sourceBitmap, MergeMode mergeMode) { if (sourceBitmap.ByteDirection != this.ByteDirection) { throw new NotImplementedException("OrInto with different ByteDirections in not implemented yet"); } }
private void MergeLocalFile(CodeFile file) { _mergeMode = MergeMode.Normal; using (var reader = new StreamReader(file.FileName)) { if (_showMergeComments) { _lines.Add(new CodeLine(null, 0, string.Concat("// start of local file ", file.FileName))); } int lineNum = 1; while (!reader.EndOfStream) { var line = new CodeLine(file, lineNum, reader.ReadLine()); MergeLocalLine(line); lineNum++; } if (_showMergeComments) { _lines.Add(new CodeLine(null, 0, string.Concat("// end of local file ", file.FileName))); } } }
/// <summary> /// Объединение списков в указанном порядке /// </summary> /// <param name="simbolsToMarge"></param> /// <param name="mergeMode"></param> /// <returns></returns> public List <QuoteRecord> Merge(List <string> simbolsToMarge, MergeMode mergeMode = MergeMode.OutputMain) { List <QuoteRecord> result; var resourseDate = ((BaseParseFormat)Resourse).QuotesDate.Where(x => simbolsToMarge.Contains(x.Simbol)).ToList(); var outputDate = ((BaseParseFormat)Output).QuotesDate.Where(x => simbolsToMarge.Contains(x.Simbol)).ToList(); switch (mergeMode) { case MergeMode.ResourseMain: result = resourseDate; var exOutput = outputDate.Except(resourseDate, new QouteRecordDateComparer()); result.AddRange(exOutput); break; case MergeMode.OutputMain: result = outputDate; var exResourse = resourseDate.Except(outputDate, new QouteRecordDateComparer()); result.AddRange(exResourse); break; default: throw new ArgumentOutOfRangeException("mergeMode"); } return(result.OrderBy(x => x.Simbol).ThenBy(x => x.Date).ToList()); }
public override void MergeInto(uint x, uint y, OneBppBitmap sourceBitmap, MergeMode mergeMode) { if (sourceBitmap.ByteDirection != ByteDirectionSpec.TopToBottomLsbFirst || sourceBitmap.ByteDirection != ByteDirectionSpec.TopToBottomMsbFirst) { throw new NotImplementedException("MergeInto with different ByteDirections in not implemented yet"); } var from = sourceBitmap as OneBppBitmapWithPages; var fromWidth = x + from.Width < this.Width ? from.Width : from.Width - (this.Width - (x + from.Width)); var yPage = y / 8; var yBits = y % 8; if (yBits != 0) { throw new NotImplementedException("MergeInto with y not on byte boundry not implemented yet"); } bool flipByte = this.ByteDirection != from.ByteDirection; for (int yByte = 0; yByte < from.HeightInBytes; yByte++) { if (yPage + yByte < this.HeightInBytes) { var destinationMemory = this.Buffer.Slice(( int )(this.Width * (yPage + yByte)), ( int )this.Width); var sourceMemory = from.Buffer.Slice(( int )(from.Width * yByte), ( int )fromWidth); OneBppBitmapWithPages.MergeInto(sourceMemory, destinationMemory, mergeMode); } } }
static MergeMode get_patchmode(ref string str) { MergeMode policy = MergeMode.DEFAULT; if (ends_with(ref str, ".overwrite")) { policy = MergeMode.OVERWRITE; } else if (ends_with(ref str, ".append")) { policy = MergeMode.APPEND; } else if (ends_with(ref str, ".merge")) { policy = MergeMode.MERGE; } else if (ends_with(ref str, ".add")) { policy = MergeMode.ADD; } else if (ends_with(ref str, ".multiply")) { policy = MergeMode.MULTIPLY; } return(policy); }
/// <summary> /// Объединение списков в указанном порядке /// </summary> /// <param name="simbolsToMarge"></param> /// <param name="mergeMode"></param> /// <returns></returns> public List<QuoteRecord> Merge(List<string> simbolsToMarge, MergeMode mergeMode = MergeMode.OutputMain) { List<QuoteRecord> result; var resourseDate = ((BaseParseFormat) Resourse).QuotesDate.Where(x => simbolsToMarge.Contains(x.Simbol)).ToList(); var outputDate = ((BaseParseFormat)Output).QuotesDate.Where(x => simbolsToMarge.Contains(x.Simbol)).ToList(); switch (mergeMode) { case MergeMode.ResourseMain: result = resourseDate; var exOutput = outputDate.Except(resourseDate, new QouteRecordDateComparer()); result.AddRange(exOutput); break; case MergeMode.OutputMain: result = outputDate; var exResourse = resourseDate.Except(outputDate, new QouteRecordDateComparer()); result.AddRange(exResourse); break; default: throw new ArgumentOutOfRangeException("mergeMode"); } return result.OrderBy(x => x.Simbol).ThenBy(x => x.Date).ToList(); }
public DbMerge( MergeMode mode, TableDefinition tableDefinition, IConnectionManager connectionManager = null, int batchSize = DbDestination.DefaultBatchSize, Func <T> createItem = null, GroupingDataflowBlockOptions batchOptions = null, ExecutionDataflowBlockOptions batchExecutionOptions = null) { Mode = mode; TableDefinition = tableDefinition ?? throw new ArgumentNullException(nameof(tableDefinition)); tableDefinition.ValidateName(nameof(tableDefinition)); this.createItem = createItem; if (batchOptions is null) { batchOptions = new(); } if (batchExecutionOptions is null) { batchExecutionOptions = new(); } destinationTable = new DbDestination <T>(tableDefinition, null, batchSize: batchSize, batchOptions, batchExecutionOptions); destinationTable.BatchInserted += OnBatchInserted; ConnectionManager = connectionManager; InitInternalFlow(batchOptions, batchExecutionOptions); InitOutputFlow(); }
/// <summary> /// Returns a boolean calculating whether or not the current action is /// </summary> /// <param name="mode"></param> /// <param name="isModelMerge"></param> /// <returns></returns> private static bool IsMergeAllowed(MergeMode mode, MergeAttribute isModelMerge) { // If there is Merged property on it, then abort if (isModelMerge == null) { return(false); } // If the mode is all, then map no matter what if (mode == MergeMode.All) { return(true); } // If we're editing and that's enabled if (mode == MergeMode.Update && (isModelMerge != null && isModelMerge.AllowUpdate)) { return(true); } // If we're creating and that's enabled if (mode == MergeMode.Create && (isModelMerge != null && isModelMerge.AllowCreate)) { return(true); } // Otherwise, we're not allowed return(false); }
public MergePaths( string name, string matchName, MergeMode mergeMode) : base(name, matchName) { Mode = mergeMode; }
private void LastMergeOperationSet(MergeMode mergeMode) { if (_lastMergeOperation != mergeMode) { var stringValue = ToString(mergeMode); _settingProvider.WriteValue(lastMergeOperationKey, stringValue); _lastMergeOperation = mergeMode; } }
public static void Merge <T, TKey>( this ICollection <T> collection, IEnumerable <T> updates, Func <T, TKey> keySelector, Action <T, T> updateFactory, MergeMode mergeMode) where T : class { Merge(collection, updates, keySelector, keySelector, item => item, updateFactory, mergeMode); }
internal SharedDictionaryReader(SharedDictionaryImpl dic, IStructuredReader reader, MergeMode mergeMode) { _dic = dic; _mergeMode = mergeMode; _reader = reader; _errorCollector = new List <ReadElementObjectInfo>(); _currentPluginId = SimpleUniqueId.InvalidId.UniqueId; _currentPluginVersion = null; reader.Current.ObjectReadExData += new EventHandler <ObjectReadExDataEventArgs>(Current_ObjectReadExData); }
internal bool TryRestore( SharedDictionaryImpl dic, MergeMode mergeMode ) { INamedVersionedUniqueId uid = dic.FindPlugin( PluginId ); if( uid != null ) { Restore( dic, mergeMode ); return true; } return false; }
internal void Restore( SharedDictionaryImpl dic, MergeMode mergeMode ) { using( IStructuredReader sr = Bookmark.Restore( dic.ServiceProvider ) ) { using( var r = dic.RegisterReader( sr, mergeMode ) ) { r.ReadPluginsData( Obj ); } } }
internal void Restore(SharedDictionaryImpl dic, MergeMode mergeMode) { using (IStructuredReader sr = Bookmark.Restore(dic.ServiceProvider)) { using (var r = dic.RegisterReader(sr, mergeMode)) { r.ReadPluginsData(Obj); } } }
internal bool TryRestore(SharedDictionaryImpl dic, MergeMode mergeMode) { INamedVersionedUniqueId uid = dic.FindPlugin(PluginId); if (uid != null) { Restore(dic, mergeMode); return(true); } return(false); }
public ISharedDictionaryReader RegisterReader(IStructuredReader reader, MergeMode mergeMode) { if (reader == null) { throw new ArgumentNullException("reader"); } ISharedDictionaryReader rdr = new SharedDictionaryReader(this, reader, mergeMode); reader.ServiceContainer.Add <ISharedDictionaryReader>(rdr, Util.ActionDispose); return(rdr); }
public JObject AsJson() { var options = new JObject { { Constants.FieldList, new JArray(FieldList) } }; if (MergeMode != SyncState.MergeModeOptions.None) { options.Add(Constants.MergeMode, MergeMode.ToString()); } return(options); }
internal void ImportFragments( Dictionary<object, List<SkippedFragment>> source, MergeMode mergeMode ) { foreach( KeyValuePair<object,List<SkippedFragment>> s in source ) { List<SkippedFragment> mine = FindOrCreateFragments( s.Key ); if( mine != null ) { if( mergeMode == MergeMode.None ) { mine.Clear(); foreach( SkippedFragment sF in s.Value ) { // If the imported fragment is for a live plugin, // we must restore it. if( !sF.TryRestore( this, mergeMode ) ) { mine.Add( sF.Clone() ); } } } else { foreach( SkippedFragment sF in s.Value ) { int iMyFragment = IndexOf( mine, sF.PluginId ); if( iMyFragment < 0 ) { // We did not find the fragment here. It may be because the // plugin is alive: if this is the case, we must restore the fragment. if( !sF.TryRestore( this, mergeMode ) ) { mine.Add( sF.Clone() ); } } else { if( mergeMode == MergeMode.ErrorOnDuplicate ) throw new CKException( "Duplicate fragment." ); if( mergeMode == MergeMode.ReplaceExisting ) { mine.RemoveAt( iMyFragment ); mine.Add( sF.Clone() ); } } } } // remove the skippedFragment if the list is empty if( mine.Count == 0 ) _fragments.Remove( s.Key ); } } }
private static string ToString(MergeMode mergeMode) { switch (mergeMode) { case MergeMode.Merge: return(mergeModeMerge); case MergeMode.MergeAndCheckIn: return(mergeModeMergeAndCheckin); default: return("unknown"); } }
private MergeMode GetMergeMode(string mergeLine, MergeMode current, string commentSymbol) { if (mergeLine.Trim().StartsWith(commentSymbol + MergeMacros.MacroBeforeMode)) { return(MergeMode.InsertBefore); } else if (mergeLine.Trim().StartsWith(commentSymbol + MergeMacros.MacroStartGroup)) { if (current == MergeMode.InsertBefore) { insertBefore = true; return(MergeMode.InsertBefore); } else { return(MergeMode.Insert); } } else if (mergeLine.Trim().StartsWith(commentSymbol + MergeMacros.MacroEndGroup)) { return(MergeMode.Context); } else if (mergeLine.Trim().StartsWith(commentSymbol + MergeMacros.MacroStartDocumentation)) { return(MergeMode.Documentation); } else if (mergeLine.Trim().StartsWith(commentSymbol + MergeMacros.MacroEndDocumentation)) { return(MergeMode.Context); } else if (mergeLine.Trim().StartsWith(commentSymbol + MergeMacros.MacroStartDelete)) { return(MergeMode.Remove); } else if (mergeLine.Trim().StartsWith(commentSymbol + MergeMacros.MacroEndDelete)) { return(MergeMode.Context); } else if (mergeLine.Trim().StartsWith(commentSymbol + MergeMacros.MacroStartOptionalContext)) { return(MergeMode.OptionalContext); } else if (mergeLine.Trim().StartsWith(commentSymbol + MergeMacros.MacroEndOptionalContext)) { return(MergeMode.Context); } return(current); }
/// <summary> /// Internal Add fn /// justAdd to skip contains check ~ performance /// </summary> /// <param name="item"></param> /// <param name="mergeMode"></param> /// <param name="notify"></param> /// <param name="justAdd"></param> private void _internalAdd(T item, MergeMode mergeMode, bool notify = true) { lock (_list) { if (!_list.ContainsKey(item.GetChangedKeyValue)) { _list.Add(item.GetId(), item); item.PropertyChanged -= Item_PropertyChanged; item.PropertyChanged += Item_PropertyChanged; if (notify) { OnCollectionChanged( item.IsNew ? NotifyCollectionChangedAction.Add : NotifyCollectionChangedAction.Move, new[] { item }); } } else { switch (mergeMode) { case MergeMode.Empty: break; case MergeMode.Append: throw new CDOException($"Duplicate record with ID {item.GetId()}"); case MergeMode.Merge: var index = IndexOf(item); if (Merge(this[index], item) && notify) { OnCollectionChanged(NotifyCollectionChangedAction.Move, new[] { this[index] }); } break; case MergeMode.Replace: _list[item.GetChangedKeyValue] = item; if (notify) { OnCollectionChanged(NotifyCollectionChangedAction.Replace, new[] { item }); } break; default: throw new ArgumentOutOfRangeException(nameof(mergeMode), mergeMode, null); } } } }
private static MergeMode GetMergeMode(string mergeLine, MergeMode current) { if (mergeLine.Contains(MacroBeforeMode)) { return(MergeMode.InsertBefore); } else if (mergeLine.Contains(MacroStartGroup)) { if (current == MergeMode.InsertBefore) { return(MergeMode.InsertBefore); } else { return(MergeMode.Insert); } } else if (mergeLine.Contains(MacroEndGroup)) { return(MergeMode.Context); } else if (mergeLine.Contains(MacroStartDocumentation)) { return(MergeMode.Documentation); } else if (mergeLine.Contains(MacroEndDocumentation)) { return(MergeMode.Context); } else if (mergeLine.Contains(MacroStartDelete)) { return(MergeMode.Remove); } else if (mergeLine.Contains(MacroEndDelete)) { return(MergeMode.Context); } else if (mergeLine.Contains(MacroStartOptionalContext)) { return(MergeMode.OptionalContext); } else if (mergeLine.Contains(MacroEndOptionalContext)) { return(MergeMode.Context); } return(current); }
public void Import(ISharedDictionary source, MergeMode mergeMode) { SharedDictionaryImpl dicSource = (SharedDictionaryImpl)source; if (dicSource != null && dicSource != this && dicSource._values.Count > 0) { ImportFragments(dicSource._fragments, mergeMode); if (mergeMode == MergeMode.None) { ClearAll(); } foreach (SharedDictionaryEntry s in dicSource._values.Values) { ImportValue(new SharedDictionaryEntry(s.Obj, s.PluginId, s.Key, s.Value), mergeMode); } } }
// PRIVATE /* KEEP IT JUST IN CASE * private void ConsumeItem() * { * if (_inventory.CurrentItem != null) * { * _inventory.SetCount(_inventory.CurrentItemCount - 1); * GrantBoosts(MergeMode.Shield); * } * else if (_lottery.LotteryStarted) * { * _lottery.StopAllCoroutines(); * _lottery.ResetLottery(); * GrantBoosts(MergeMode.SpeedBoost); * } * } */ private void GrantBoosts(MergeMode mode) { ItemMerging itemMergingEvent = ItemMerging.Create(); itemMergingEvent.Entity = entity; switch (mode) { case MergeMode.Shield: itemMergingEvent.Shield = true; break; case MergeMode.SpeedBoost: itemMergingEvent.Shield = false; _boost.CustomBoostFromBoostSettings(_boostSettings); break; } itemMergingEvent.Send(); }
/// <summary> /// Configures cell style. /// </summary> /// <typeparam name="TPropertyRenderer">Property renderer type.</typeparam> /// <param name="propertyRenderer">Property renderer.</param> /// <param name="getCellStyle">Function. Input: CellValue, Result: StyleName.</param> /// <param name="mergeMode">StyleApply mode. Default: Merge.</param> /// <returns>The same renderer instance.</returns> public static TPropertyRenderer ConfigureCellStyle <TPropertyRenderer>( this TPropertyRenderer propertyRenderer, Func <string?, string?> getCellStyle, MergeMode mergeMode = MergeMode.Merge) where TPropertyRenderer : IPropertyRenderer { propertyRenderer.AssertArgumentNotNull(nameof(propertyRenderer)); getCellStyle.AssertArgumentNotNull(nameof(getCellStyle)); if (mergeMode == MergeMode.Set) { propertyRenderer.ConfigureMetadata <ExcelCellMetadata>( metadata => metadata.SetValue(ExcelCellMetadata.ConfigureCell, context => ConfigureCellStyleInternal(context, getCellStyle, mergeMode))); } else { propertyRenderer.ConfigureMetadata <ExcelCellMetadata>(metadata => metadata.WithCombinedConfigure(ExcelCellMetadata.ConfigureCell, context => ConfigureCellStyleInternal(context, getCellStyle, mergeMode))); } return(propertyRenderer);
private void DoMergePdfs(PdfDocument document, IList <string> pdfLocations, MergeMode position) { if (pdfLocations.Count <= 0) { return; } foreach (var file in pdfLocations) { _logger.Trace("Merge document with: " + file); PdfReader reader = new PdfReader(file); var doc = new PdfDocument(reader); var startIndex = position == MergeMode.Prepend ? 1 : document.GetNumberOfPages() + 1; doc.CopyPagesTo(Enumerable.Range(1, doc.GetNumberOfPages()).ToList(), document, startIndex); reader.Close(); doc.Close(); } }
internal void ImportValue(SharedDictionaryEntry entryWithValue, MergeMode mergeMode) { if (mergeMode == MergeMode.None || mergeMode == MergeMode.ReplaceExisting) { this[entryWithValue.Obj, entryWithValue.PluginId, entryWithValue.Key] = entryWithValue.Value; } else if (mergeMode == MergeMode.ErrorOnDuplicate) { Add(entryWithValue); } else if (mergeMode == MergeMode.PreserveExisting) { GetOrSet(entryWithValue.Obj, entryWithValue.PluginId, entryWithValue.Key, entryWithValue.Value); } else if (mergeMode == MergeMode.ReplaceExistingTryMerge) { if (!Merge(entryWithValue)) { this[entryWithValue.Obj, entryWithValue.PluginId, entryWithValue.Key] = entryWithValue.Value; } } }
/// <summary> /// Retrieve the arguments /// </summary> /// <param name="result"></param> /// <returns></returns> protected override string GetProcessArguments(IIntegrationResult result) { ProcessArgumentBuilder buffer = new ProcessArgumentBuilder(); var coverageFile = string.IsNullOrEmpty(CoverageFile) ? "coverage.xml" : CoverageFile; buffer.AppendArgument(RootPath(coverageFile, true)); // Add all the NCover arguments buffer.AppendIf(ClearCoverageFilters, "//ccf"); foreach (var filter in CoverageFilters ?? new CoverageFilter[0]) { buffer.AppendArgument("//cf {0}", filter.ToParamString()); } foreach (var threshold in MinimumThresholds ?? new CoverageThreshold[0]) { buffer.AppendArgument("//mc {0}", threshold.ToParamString()); } buffer.AppendIf(UseMinimumCoverage, "//mcsc"); buffer.AppendIf(XmlReportFilter != NCoverReportFilter.Default, "//rdf {0}", XmlReportFilter.ToString()); foreach (var threshold in SatisfactoryThresholds ?? new CoverageThreshold[0]) { buffer.AppendArgument("//sct {0}", threshold.ToParamString()); } buffer.AppendIf(NumberToReport > 0, "//smf {0}", NumberToReport.ToString(CultureInfo.CurrentCulture)); buffer.AppendIf(!string.IsNullOrEmpty(TrendOutputFile), "//at \"{0}\"", RootPath(TrendOutputFile, false)); buffer.AppendArgument("//bi \"{0}\"", string.IsNullOrEmpty(BuildId) ? result.Label : BuildId); buffer.AppendIf(!string.IsNullOrEmpty(HideElements), "//hi \"{0}\"", HideElements); buffer.AppendIf(!string.IsNullOrEmpty(TrendInputFile), "//lt \"{0}\"", RootPath(TrendInputFile, false)); GenerateReportList(buffer); buffer.AppendIf(!string.IsNullOrEmpty(ProjectName), "//p \"{0}\"", ProjectName); buffer.AppendIf(SortBy != NCoverSortBy.None, "//so \"{0}\"", SortBy.ToString()); buffer.AppendIf(TopUncoveredAmount > 0, "//tu \"{0}\"", TopUncoveredAmount.ToString(CultureInfo.CurrentCulture)); buffer.AppendIf(MergeMode != NCoverMergeMode.Default, "//mfm \"{0}\"", MergeMode.ToString()); buffer.AppendIf(!string.IsNullOrEmpty(MergeFile), "//s \"{0}\"", RootPath(MergeFile, false)); buffer.AppendIf(!string.IsNullOrEmpty(WorkingDirectory), "//w \"{0}\"", RootPath(WorkingDirectory, false)); return(buffer.ToString()); }
internal static Counter Merge(IEnumerable <Counter> counters, MergeMode mergeMode) { var merged = new Counter(); foreach (var counter in counters) { foreach (var counterInfo in counter._counters) { merged.addCounterIfNotExist(counterInfo.Key); switch (mergeMode) { case MergeMode.ADD: merged._counters[counterInfo.Key] += counterInfo.Value; break; default: throw new NotSupportedException(); } } } return(merged); }
/// <summary> /// Merge lexicons. /// </summary> /// <param name="mergedLexicon">Lexicon to be merged to.</param> /// <param name="subLexicon">Lexicon to be merged.</param> /// <param name="mergeMode">MergeMode.</param> private void MergeLexicon(Lexicon mergedLexicon, Lexicon subLexicon, MergeMode mergeMode) { switch (mergeMode) { case MergeMode.KeepAll: MergeLexiconWithKeepAll(mergedLexicon, subLexicon); break; case MergeMode.KeepLastOne: MergeLexiconWithKeepLastOne(mergedLexicon, subLexicon); break; case MergeMode.KeepFirstOne: MergeLexiconWithKeepFirstOne(mergedLexicon, subLexicon); break; default: break; } }
private void MergeLocalFile(CodeFile file) { _mergeMode = MergeMode.Normal; using (var reader = new StreamReader(file.FileName)) { if (_showMergeComments) { _lines.Add(new CodeLine(null, 0, string.Concat("// start of local file ", file.FileName))); } int lineNum = 1; while (!reader.EndOfStream) { var line = new CodeLine(file, lineNum, reader.ReadLine()); MergeLocalLine(line); lineNum++; } if (_showMergeComments) { _lines.Add(new CodeLine(null, 0, string.Concat("// end of local file ", file.FileName))); } } }
/// <summary> /// Merges changes in the source model into the target model, returning a list of the fields changed in the model /// This treats any property with and [Editable(true)] attribute as on a white-list for editing and merging /// </summary> /// <typeparam name="TargetType">The type of the models being handle, source model may be a sub-class</typeparam> /// <param name="targetModel">The model that will have its property values changed by this merge</param> /// <param name="newValuesModel">The model contributing new values to the target model</param> /// <param name="mode">The various merge policies for this method - All (every property), Edit (only properties with Editable(true) OR Historical and flag, Create (only properties with flagged Historical attribute)</param> /// <returns></returns> public static IEnumerable <ModelDelta> MergeProperties <TargetType, NewValueType>(this TargetType targetModel, NewValueType newValuesModel, MergeMode mode = MergeMode.All) where TargetType : class where NewValueType : class { if (newValuesModel == null) { throw new ArgumentNullException(nameof(newValuesModel)); } var deltas = new List <ModelDelta>(); var targetModelType = targetModel.GetType(); var newValuesModelType = newValuesModel.GetType(); var targetModelProperties = targetModelType.GetProperties(); var newValuesModelProperties = newValuesModelType.GetProperties().ToDictionary(p => p.Name); // Iterate through the properties in the type foreach (var targetModelProperty in targetModelProperties) { // If it's not in the new values model, then skip it if (!newValuesModelProperties.ContainsKey(targetModelProperty.Name)) { continue; } // Find if they have an editable or historical attribute on them var isModelMergedAttr = targetModelProperty.GetCustomAttribute <MergeAttribute>(); var isAllowed = IsMergeAllowed(mode, isModelMergedAttr); if (isAllowed) { object deltaType = null; // Optionally use the historical attribute's values if (isModelMergedAttr != null) { deltaType = isModelMergedAttr.DeltaType; } // Pull out the newValues property so we can pass it along var newValuesProperty = newValuesModelProperties[targetModelProperty.Name]; SetNewValueOnModel(targetModel, newValuesModel, deltas, targetModelProperty, newValuesProperty, deltaType, isModelMergedAttr.AllowOnce); } } return(deltas); }
private void ProcessLocalLine(string line) { Match match; switch (_mode) { case MergeMode.Normal: if ((match = _rxReplaceLine.Match(line)).Success) { _mode = MergeMode.ReplaceStart; _replace.Clear(); } else if ((match = _rxInsertLine.Match(line)).Success) { var labelName = line.Substring(match.Index + match.Length).Trim(); _insertLine = GetLabelInsert(labelName); if (_insertLine < 0) throw new FileMergeException(this._currentLocalFileName + ": #label '" + labelName + "' not found"); if (_showMergeComments) { _lines.Insert(_insertLine, "// insert from " + _currentLocalFileName + "(" + _currentLocalLine.ToString() + ")"); BumpLabels(_insertLine, 1); _insertLine += 1; } _mode = MergeMode.Insert; } else { _lines.Add(line); } break; case MergeMode.ReplaceStart: if ((match = _rxWithLine.Match(line)).Success) { if (_replace.Count == 0) throw new FileMergeException(this._currentLocalFileName + ": empty #replace statement"); _replaceLine = FindReplace(); if (_replaceLine < 0) throw new FileMergeException(this._currentLocalFileName + ": #replace at line " + this._currentLocalLine.ToString() + " not found"); _lines.RemoveRange(_replaceLine, _replace.Count); BumpLabels(_replaceLine, -_replace.Count); if (_showMergeComments) { _lines.Insert(_replaceLine, "// replace from " + _currentLocalFileName + "(" + _currentLocalLine.ToString() + ")"); BumpLabels(_replaceLine, 1); _replaceLine += 1; } _replace.Clear(); _mode = MergeMode.ReplaceWith; var remain = line.Substring(match.Index + match.Length); if (!string.IsNullOrWhiteSpace(remain)) _replace.Add(remain); } else { _replace.Add(line); } break; case MergeMode.ReplaceWith: if ((match = _rxEndReplaceLine.Match(line)).Success) { if (_showMergeComments) { _lines.Insert(_replaceLine, "// end of replace"); BumpLabels(_replaceLine, 1); _replaceLine += 1; } _mode = MergeMode.Normal; } else { _lines.Insert(_replaceLine, line); BumpLabels(_replaceLine, 1); _replaceLine += 1; } break; case MergeMode.Insert: if ((match = _rxEndInsertLine.Match(line)).Success) { if (_showMergeComments) { _lines.Insert(_insertLine, "// end of insert"); BumpLabels(_insertLine, 1); } _mode = MergeMode.Normal; } else { _lines.Insert(_insertLine, line); BumpLabels(_insertLine, 1); _insertLine += 1; } break; } }
/// <summary> /// Downloads dependencies of assets marked with the specified labels or addresses. /// </summary> /// <param name="keys">List of keys for the locations.</param> /// <param name="mode">Method for merging the results of key matches. See <see cref="MergeMode"/> for specifics</param> /// <param name="autoReleaseHandle">Automatically releases the handle on completion</param> /// <returns>The AsyncOperationHandle for the dependency load.</returns> public static AsyncOperationHandle DownloadDependenciesAsync(IList <object> keys, MergeMode mode, bool autoReleaseHandle = false) { return(m_Addressables.DownloadDependenciesAsync(keys, mode, autoReleaseHandle)); }
public List<AtomicChange> MergeLines(List<int> selectedIndices, MergeMode mergeMode) { var changeList = new List<AtomicChange>(); // sort so consecutive indices can be recognized selectedIndices.Sort(); // "merge prev" is like "merge next" for previous entry if (mergeMode == MergeMode.Prev) { for (int i = 0; i < selectedIndices.Count; i++) selectedIndices[i] -= 1; } // remove illegal indices selectedIndices.RemoveAll(delegate (int i) { return !IsIndexInRange(i); }); // can't merge zero objects if (selectedIndices.Count <= 0) return changeList; // go through whole list and unify selected int inSelectedIndicesListIndex = 0; int numDeletedRows = 0; // every time a card information is deleted, all the following indices will decrease for (int currentListIndex = 0; currentListIndex <= selectedIndices[selectedIndices.Count - 1]; currentListIndex++) { // skip if line was not selected for merging if (currentListIndex < selectedIndices[inSelectedIndicesListIndex]) { continue; } // get references and indices to current CardInfo and next CardInfo int thisIndex = selectedIndices[inSelectedIndicesListIndex] - numDeletedRows; var thisCardInfo = m_cardInfos[thisIndex]; // can't merge next if this entry is last if (thisIndex == m_cardInfos.Count - 1) break; int nextIndex = selectedIndices[inSelectedIndicesListIndex] - numDeletedRows + 1; var nextCardInfo = m_cardInfos[nextIndex]; inSelectedIndicesListIndex++; // only merge if merging is possible if (!CardInfo.IsMergePossbile(thisCardInfo, nextCardInfo)) continue; nextCardInfo = new CardInfo(thisCardInfo, nextCardInfo); // "next entry" now contains both entries -> save this change m_cardInfos[nextIndex] = nextCardInfo; if (changeList.Count > 0 && changeList.Last().line == currentListIndex) changeList[changeList.Count - 1] = new AtomicChange(currentListIndex, null, ChangeType.LineDelete); else changeList.Add(new AtomicChange(currentListIndex, null, ChangeType.LineDelete)); changeList.Add(new AtomicChange(currentListIndex + 1, nextCardInfo, ChangeType.DataUpdate)); // remove entry that was unified into next m_cardInfos.RemoveAt(thisIndex); numDeletedRows++; } finalizeChangeList(changeList); return changeList; }
private async void MergeExecute(MergeMode? mergeMode) { Logger.Info("Merging start..."); if (!mergeMode.HasValue) return; MergeMode = mergeMode.Value; _settings.LastMergeOperation = mergeMode.Value; switch (mergeMode) { case MergeMode.Merge: await MergeAndCheckInExecute(false); break; case MergeMode.MergeAndCheckIn: await MergeAndCheckInExecute(true); break; } Logger.Info("Merging end"); }
private void MergeLocalLine(CodeLine line) { Match match; switch (_mergeMode) { case MergeMode.Normal: if ((match = line.Match(_rxReplace)).Success) { _mergeMode = MergeMode.ReplaceStart; _replace.Clear(); var trailing = match.Groups[1].Value.Trim(); if (!string.IsNullOrEmpty(trailing)) _replace.Add(trailing); } else if ((match = line.Match(_rxInsert)).Success) { var labelName = match.Groups[1].Value.Trim(); _insertIndex = FindLabel(labelName); if (_insertIndex < 0) { _errors.Add(new CodeError(line, string.Format("Label '{0}' not found.", labelName))); } else { if (_showMergeComments) { _lines.Insert(_insertIndex, new CodeLine(null, 0, string.Format("// insert from {0} ({1})", line.FileName, line.LineNum))); _insertIndex++; } } _mergeMode = MergeMode.Insert; } else { _lines.Add(line); } break; case MergeMode.ReplaceStart: if ((match = line.Match(_rxWith)).Success) { if (_replace.Count == 0) { _errors.Add(new CodeError(line, "Empty #replace statement.")); _insertIndex = -1; } else if ((_insertIndex = FindReplace()) < 0) { _errors.Add(new CodeError(line, "#replace not found.")); } else { _lines.RemoveRange(_insertIndex, _replace.Count); if (_showMergeComments) { _lines.Insert(_insertIndex, new CodeLine(null, 0, string.Format("// replace from {0} ({1})", line.FileName, line.LineNum))); _insertIndex++; } if (!string.IsNullOrWhiteSpace(match.Groups[1].Value)) { _lines.Insert(_insertIndex, new CodeLine(line.File, line.LineNum, match.Groups[1].Value)); } } _mergeMode = MergeMode.ReplaceWith; _replace.Clear(); } else { _replace.Add(line.Text); } break; case MergeMode.ReplaceWith: if ((match = line.Match(_rxEndReplace)).Success) { if (_insertIndex >= 0) { if (_showMergeComments) { _lines.Insert(_insertIndex, new CodeLine(null, 0, "// end of replace")); _insertIndex++; } } _mergeMode = MergeMode.Normal; _insertIndex = -1; if (!String.IsNullOrWhiteSpace(match.Groups[1].Value)) { _lines.Add(new CodeLine(line.File, line.LineNum, match.Groups[1].Value)); } } else { if (_insertIndex >= 0) { _lines.Insert(_insertIndex, line); _insertIndex++; } } break; case MergeMode.Insert: if ((match = line.Match(_rxEndInsert)).Success) { if (_insertIndex >= 0 && _showMergeComments) { _lines.Insert(_insertIndex, new CodeLine(null, 0, "// end of insert")); } _mergeMode = MergeMode.Normal; _insertIndex = -1; } else { if (_insertIndex > 0) { _lines.Insert(_insertIndex, line); _insertIndex++; } } break; } }
/// <summary> /// Extract Domain Lexicon from script. /// </summary> /// <param name="scriptFolder">Script Folder.</param> /// <param name="domainListFile">Domain List File.</param> /// <param name="inMainLex">Input Main Lexicon.</param> /// <param name="defaultPartOfSpeech">Default Part of Speech.</param> /// <param name="mergeMode">Merging Mode for Lexicon.</param> /// <param name="phoneSet">Phone set.</param> /// <param name="attribSchema">Lexical attribute schema.</param> /// <returns>Lexicon.</returns> private Lexicon ExtractDomainLexicon(string scriptFolder, string domainListFile, Lexicon inMainLex, string defaultPartOfSpeech, MergeMode mergeMode, TtsPhoneSet phoneSet, LexicalAttributeSchema attribSchema) { if (attribSchema != null) { if (PosItem.Validate(defaultPartOfSpeech, null, attribSchema).Count > 0) { Log("Default Part of speech {0} is unrecognized according to attribute schema, extraction breaks", defaultPartOfSpeech); return null; } } Lexicon outLex = null; foreach (string domainName in Helper.FileLines(domainListFile)) { string domainFilePath = Path.Combine(scriptFolder, domainName); XmlScriptFile scriptFile = new XmlScriptFile(); scriptFile.Load(domainFilePath); if (outLex != null && outLex.Language != scriptFile.Language) { throw new InvalidDataException(Helper.NeutralFormat( "Found inconsistent language \"{0}\" against previous one \"{1}\" in the file of \"{2}\"", scriptFile.Language.ToString(), outLex.Language.ToString(), domainFilePath)); } Lexicon lexicon = Lexicon.CreateFromXmlScriptFile(scriptFile, defaultPartOfSpeech, inMainLex); if (phoneSet != null && attribSchema != null) { lexicon.Validate(phoneSet, attribSchema); if (lexicon.ErrorSet.Count > 0) { Console.Error.WriteLine("The script file {0} contains {1} errors, skip!", domainFilePath, lexicon.ErrorSet.Count); Log("The script file {0} contains {1} errors:", domainFilePath, lexicon.ErrorSet.Count); foreach (Error error in lexicon.ErrorSet.Errors) { Log(error.ToString()); } // Skip this domain lexicon continue; } } if (outLex == null) { outLex = lexicon; } else { MergeLexicon(outLex, lexicon, mergeMode); } } if (outLex.Items.Count == 0) { Log("The final lexicon is empty."); } return outLex; }
internal static extern IntPtr XmRenderTableAddRenditions( IntPtr oldtable, IntPtr [] renditions, int rendition_count, MergeMode merge_mode);
public List <AtomicChange> MergeLines(List <int> selectedIndices, MergeMode mergeMode) { var changeList = new List <AtomicChange>(); // sort so consecutive indices can be recognized selectedIndices.Sort(); // "merge prev" is like "merge next" for previous entry if (mergeMode == MergeMode.Prev) { for (int i = 0; i < selectedIndices.Count; i++) { selectedIndices[i] -= 1; } } // remove illegal indices selectedIndices.RemoveAll(delegate(int i) { return(!IsIndexInRange(i)); }); // can't merge zero objects if (selectedIndices.Count <= 0) { return(changeList); } // go through whole list and unify selected int inSelectedIndicesListIndex = 0; int numDeletedRows = 0; // every time a card information is deleted, all the following indices will decrease for (int currentListIndex = 0; currentListIndex <= selectedIndices[selectedIndices.Count - 1]; currentListIndex++) { // skip if line was not selected for merging if (currentListIndex < selectedIndices[inSelectedIndicesListIndex]) { continue; } // get references and indices to current CardInfo and next CardInfo int thisIndex = selectedIndices[inSelectedIndicesListIndex] - numDeletedRows; var thisCardInfo = m_cardInfos[thisIndex]; // can't merge next if this entry is last if (thisIndex == m_cardInfos.Count - 1) { break; } int nextIndex = selectedIndices[inSelectedIndicesListIndex] - numDeletedRows + 1; var nextCardInfo = m_cardInfos[nextIndex]; inSelectedIndicesListIndex++; // only merge if merging is possible if (!CardInfo.IsMergePossbile(thisCardInfo, nextCardInfo)) { continue; } nextCardInfo = new CardInfo(thisCardInfo, nextCardInfo); // "next entry" now contains both entries -> save this change m_cardInfos[nextIndex] = nextCardInfo; if (changeList.Count > 0 && changeList.Last().line == currentListIndex) { changeList[changeList.Count - 1] = new AtomicChange(currentListIndex, null, ChangeType.LineDelete); } else { changeList.Add(new AtomicChange(currentListIndex, null, ChangeType.LineDelete)); } changeList.Add(new AtomicChange(currentListIndex + 1, nextCardInfo, ChangeType.DataUpdate)); // remove entry that was unified into next m_cardInfos.RemoveAt(thisIndex); numDeletedRows++; } finalizeChangeList(changeList); return(changeList); }
protected MergeMode MergeChoiceGUI(string label, MergeMode mm) { return (MergeMode)EditorGUILayout.EnumPopup(label, mm); }
private void LastMergeOperationSet(MergeMode mergeMode) { if (_lastMergeOperation != mergeMode) { var stringValue = ToString(mergeMode); _settingProvider.WriteValue(lastMergeOperationKey, stringValue); _lastMergeOperation = mergeMode; } }
private static string ToString(MergeMode mergeMode) { switch (mergeMode) { case MergeMode.Merge: return mergeModeMerge; case MergeMode.MergeAndCheckIn: return mergeModeMergeAndCheckin; default: return "unknown"; } }
public MergeResult Merge(IEnumerable <string> source, IEnumerable <string> merge) { _result = source.ToList(); var documentationEndIndex = merge.SafeIndexOf(merge.FirstOrDefault(m => m.Contains(MergeMacros.MacroEndDocumentation)), 0); var diffTrivia = FindDiffLeadingTrivia(source, merge, documentationEndIndex); foreach (var mergeLine in merge) { // try to find context line if (mergeMode == MergeMode.Context || mergeMode == MergeMode.OptionalContext || mergeMode == MergeMode.Remove) { if (LineHasInlineAdditions(mergeLine)) { _currentContextLineIndex = FindAndModifyContextLine(mergeLine, diffTrivia); } else { _currentContextLineIndex = FindContextLine(mergeLine, diffTrivia); } } // if line is found, add buffer if any if (_currentContextLineIndex > -1) { var linesAdded = TryAddBufferContent(); var linesRemoved = TryRemoveBufferContent(); _lastContextLineIndex = _currentContextLineIndex + linesAdded - linesRemoved; CleanBuffers(); } // get new merge direction or add to buffer if (IsMergeDirection(mergeLine)) { mergeMode = GetMergeMode(mergeLine, mergeMode, _codeStyleProvider?.CommentSymbol); } else { switch (mergeMode) { case MergeMode.InsertBefore: case MergeMode.Insert: _insertionBuffer.Add(mergeLine.WithLeadingTrivia(diffTrivia)); break; case MergeMode.Remove: _removalBuffer.Add(mergeLine.WithLeadingTrivia(diffTrivia)); break; case MergeMode.Context: if (mergeLine == string.Empty) { _insertionBuffer.Add(mergeLine); } else if (_currentContextLineIndex == -1) { return(new MergeResult() { Success = false, ErrorLine = mergeLine, Result = source, }); } break; } } } // Add remaining buffers before finishing TryAddBufferContent(); TryRemoveBufferContent(); return(new MergeResult() { Success = true, ErrorLine = string.Empty, Result = _result, }); }
private void LastMergeOperationSet(MergeMode mergeMode) { if (_lastMergeOperation != mergeMode) { var stringValue = ToString(mergeMode); _vsSettingsProvider.SetString(collectionKey, lastMergeOperationKey, stringValue); _lastMergeOperation = mergeMode; } }