/// <summary> /// Fills a Stack with the contents of a particular collection. The items are /// pushed onto the stack in the same order they are read by the enumerator. /// </summary> public PooledStack(IEnumerable <T> enumerable, ClearMode clearMode, ArrayPool <T> customPool) { _pool = customPool ?? ArrayPool <T> .Shared; _clearOnFree = ShouldClear(clearMode); switch (enumerable) { case null: ThrowHelper.ThrowArgumentNullException(ExceptionArgument.enumerable); break; case ICollection <T> collection: if (collection.Count == 0) { _array = Array.Empty <T>(); } else { _array = _pool.Rent(collection.Count); collection.CopyTo(_array, 0); _size = collection.Count; } break; default: using (var list = new PooledList <T>(enumerable)) { _array = _pool.Rent(list.Count); list.Span.CopyTo(_array); _size = list.Count; } break; } }
/// <summary> /// Fills a Stack with the contents of a particular collection. The items are /// pushed onto the stack in the same order they are read by the enumerator. /// </summary> public PooledStack(ReadOnlySpan <T> span, ClearMode clearMode, ArrayPool <T> customPool) { _pool = customPool ?? ArrayPool <T> .Shared; _clearOnFree = ShouldClear(clearMode); _array = _pool.Rent(span.Length); span.CopyTo(_array); _size = span.Length; }
public void ClearLine(ClearMode clearMode) { int clearCode = 48 + (int)clearMode; byte[] buffer = new byte[4] { 27, 91, (byte)clearCode, 75 }; stream.Write(buffer, 0, buffer.Length); }
private static bool ShouldClear(ClearMode mode) { #if NETCOREAPP2_1 return(mode == ClearMode.Always || (mode == ClearMode.Auto && RuntimeHelpers.IsReferenceOrContainsReferences <T>())); #else return(mode != ClearMode.Never); #endif }
/// <summary> /// Creates a Command which clears the given Graph or Graphs depending on the Clear Mode specified /// </summary> /// <param name="graphUri">Graph URI</param> /// <param name="mode">Clear Mode</param> /// <param name="silent">Whether errors should be suppressed</param> public ClearCommand(Uri graphUri, ClearMode mode, bool silent) : base(SparqlUpdateCommandType.Clear) { this._graphUri = graphUri; this._mode = mode; if (this._graphUri == null && this._mode == ClearMode.Graph) this._mode = ClearMode.Default; if (this._mode == ClearMode.Default) this._graphUri = null; this._silent = silent; }
/// <summary> /// Initializes a new instance of the <see cref="PooledQueue{T}"/> class that is empty and has the specified initial capacity. /// </summary> public PooledQueue(int capacity, ClearMode clearMode, ArrayPool <T> customPool) { if (capacity < 0) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); } _pool = customPool ?? ArrayPool <T> .Shared; _array = _pool.Rent(capacity); _clearOnFree = ShouldClear(clearMode); }
/// <summary> /// Initializes a new instance of the <see cref="PooledQueue{T}"/> class that contains elements copied from the specified /// span and has sufficient capacity to accommodate the number of elements copied. /// </summary> public PooledQueue(ReadOnlySpan <T> span, ClearMode clearMode, ArrayPool <T> customPool) { _pool = customPool ?? ArrayPool <T> .Shared; _clearOnFree = ShouldClear(clearMode); _array = _pool.Rent(span.Length); span.CopyTo(_array); _size = span.Length; if (_size != _array.Length) { _tail = _size; } }
/// <summary> /// Determines if the given value represents a valid state of this property. /// </summary> /// <param name="value">The state that should be used.</param> /// <returns>True if the state is valid, otherwise false.</returns> protected override Boolean IsValid(CSSValue value) { ClearMode mode; if (modes.TryGetValue(value, out mode)) { _mode = mode; return(true); } return(false); }
public void Clear(ClearMode clearMode) { if (this._itemSlotViews == null) { return; } for (int i = 0; i < this._itemSlotViews.Count; i++) { this._itemSlotViews[i].Clear(clearMode); } }
public override void Run(bool forced, ClearMode mode) { byte frcd = (forced) ? frcd = 0x03 : frcd = 0x01; byte[] sendbuffer = { NetNo, PcNo, destinationCpu, 0x03, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x01, 0x10, 0x00, 0x00, frcd, 0x00, (byte)mode, 0x00 }; sendbuffer = Concat(PacketHead, sendbuffer); SendBuffer(sendbuffer); }
/// <summary> /// Creates a new DROP command /// </summary> /// <param name="graphUri">URI ofthe Graph to DROP</param> /// <param name="mode">DROP Mode to use</param> /// <param name="silent">Whether the DROP should be done silently</param> public DropCommand(Uri graphUri, ClearMode mode, bool silent) : base(SparqlUpdateCommandType.Drop) { this._graphUri = graphUri; this._mode = mode; if (this._graphUri == null && this._mode == ClearMode.Graph) { this._mode = ClearMode.Default; } if (this._mode == ClearMode.Default) { this._graphUri = null; } this._silent = silent; }
protected override Boolean IsValid(CSSValue value) { ClearMode mode; if (value is CSSIdentifierValue && modes.TryGetValue(((CSSIdentifierValue)value).Value, out mode)) { _mode = mode; } else if (value != CSSValue.Inherit) { return(false); } return(true); }
/// <summary> /// Creates a Command which clears the given Graph or Graphs depending on the Clear Mode specified. /// </summary> /// <param name="graphUri">Graph URI.</param> /// <param name="mode">Clear Mode.</param> /// <param name="silent">Whether errors should be suppressed.</param> public ClearCommand(Uri graphUri, ClearMode mode, bool silent) : base(SparqlUpdateCommandType.Clear) { _graphUri = graphUri; _mode = mode; if (_graphUri == null && _mode == ClearMode.Graph) { _mode = ClearMode.Default; } if (_mode == ClearMode.Default) { _graphUri = null; } _silent = silent; }
/// <summary> /// Creates a Command which performs the specified type of clear /// </summary> /// <param name="mode">Clear Mode</param> public ClearCommand(ClearMode mode) : this(mode, false) { }
public void SetState(ClearMode mode) { _mode = mode; }
/// <summary> /// Creates a Command which performs the specified type of clear /// </summary> /// <param name="mode">Clear Mode</param> /// <param name="silent">Whether errors should be suppressed</param> public ClearCommand(ClearMode mode, bool silent) : this(null, mode, silent) { }
/// <summary> /// Create a stack with the default initial capacity. /// </summary> public PooledStack(ClearMode clearMode) : this(clearMode, ArrayPool <T> .Shared) { }
internal override void Reset() { _mode = ClearMode.None; }
public static MCACommand Clear(ClearMode mode) { return new MCACommand(CommandName.CMD_CLEAR, (byte)mode); }
/// <summary> /// Creates a Command which performs the specified type of clear. /// </summary> /// <param name="mode">Clear Mode.</param> public ClearCommand(ClearMode mode) : this(mode, false) { }
/// <summary> /// Creates a new DROP command /// </summary> /// <param name="graphUri">URI of the Graph to DROP</param> /// <param name="mode">DROP Mode to use</param> public DropCommand(Uri graphUri, ClearMode mode) : this(graphUri, mode, false) { }
/// <summary> /// Initializes a new instance of the <see cref="PooledQueue{T}"/> class that is empty and has the default initial capacity. /// </summary> public PooledQueue(ClearMode clearMode) : this(clearMode, ArrayPool <T> .Shared) { }
/// <summary> /// Initializes a new instance of the <see cref="PooledQueue{T}"/> class that contains elements copied from the specified /// array and has sufficient capacity to accommodate the number of elements copied. /// </summary> public PooledQueue(T[] array, ClearMode clearMode, ArrayPool <T> customPool) : this(array.AsSpan(), clearMode, customPool) { }
/// <summary> /// Initializes a new instance of the <see cref="PooledQueue{T}"/> class that contains elements copied from the specified /// span and has sufficient capacity to accommodate the number of elements copied. /// </summary> public PooledQueue(ReadOnlySpan <T> span, ClearMode clearMode) : this(span, clearMode, ArrayPool <T> .Shared) { }
public abstract void Run(bool forced, ClearMode mode);
/// <summary> /// Initializes a new instance of the <see cref="PooledQueue{T}"/> class that contains elements copied from the specified /// collection and has sufficient capacity to accommodate the number of elements copied. /// </summary> public PooledQueue(IEnumerable <T> enumerable, ClearMode clearMode) : this(enumerable, clearMode, ArrayPool <T> .Shared) { }
private static void TestImport([JetBrains.Annotations.NotNull] string path, bool clearDstFolder, ClearMode cleartablemode, bool verifyRowCount = false) { TestImport(path, out _, out _, cleartablemode, verifyRowCount, out _, clearDstFolder); }
internal CSSClearProperty() : base(PropertyNames.Clear) { _mode = modes["none"]; _inherited = false; }
internal override void Reset() { _mode = Default; }
/// <summary> /// Initializes a new instance of the <see cref="PooledQueue{T}"/> class that is empty and has the default initial capacity. /// </summary> public PooledQueue(ClearMode clearMode, ArrayPool <T> customPool) { _pool = customPool ?? ArrayPool <T> .Shared; _array = Array.Empty <T>(); _clearOnFree = ShouldClear(clearMode); }
/// <summary> /// Creates a Command which performs the specified type of clear. /// </summary> /// <param name="mode">Clear Mode.</param> /// <param name="silent">Whether errors should be suppressed.</param> public ClearCommand(ClearMode mode, bool silent) : this(null, mode, silent) { }
/// <summary> /// Initializes a new instance of the <see cref="PooledQueue{T}"/> class that is empty and has the specified initial capacity. /// </summary> public PooledQueue(int capacity, ClearMode clearMode) : this(capacity, clearMode, ArrayPool <T> .Shared) { }
/// <summary> /// Initializes a new instance of the <see cref="PooledQueue{T}"/> class that contains elements copied from the specified /// array and has sufficient capacity to accommodate the number of elements copied. /// </summary> public PooledQueue(T[] array, ClearMode clearMode) : this(array.AsSpan(), clearMode, ArrayPool <T> .Shared) { }
private static void TestImport([JetBrains.Annotations.NotNull] string srcfilename, [JetBrains.Annotations.NotNull] out Simulator mainsim, [JetBrains.Annotations.NotNull] out DatabaseMerger dbm, ClearMode clearTablesMode, bool checkrowcounts, [JetBrains.Annotations.NotNull] out DatabaseSetup db, bool clearDstFolder) { var acceptedUneven = new List <string> { "tblSettings", "tblOptions", "tblHHTTraits", // this is messed up since it would need a sorting of the householdtraits by subtraits "tblLPGVersion", // settings are not imported "tblHouseholdPlanEntries" //nobody cares about the household plans anymore }; if (clearDstFolder) { CleanTestBase.RunAutomatically(false); } DirectoryInfo di = new DirectoryInfo("."); Logger.Info("Current directory:" + di.FullName); var fis = di.GetFiles(); Logger.Info("Files in this directory:"); foreach (var fileInfo in fis) { Logger.Info(fileInfo.Name); } var fi = FindImportFile(srcfilename); db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()); var oldSim = new Simulator(db.ConnectionString); Dictionary <string, int> srctablerowcounts = null; switch (clearTablesMode) { case ClearMode.ClearTable: { var connectionstrOld = "Data Source=" + fi.FullName; srctablerowcounts = GetTableRowCounts(connectionstrOld); ClearAllTables(db); } break; case ClearMode.DeleteOnlyOneRow: { var connectionstrOld = "Data Source=" + fi.FullName; srctablerowcounts = GetTableRowCounts(connectionstrOld); DeleteOneElementFromAllTables(db); } break; case ClearMode.NoClearing: break; default: throw new ArgumentOutOfRangeException(nameof(clearTablesMode), clearTablesMode, null); } var mainSim = new Simulator(db.ConnectionString); dbm = new DatabaseMerger(mainSim); dbm.RunFindItems(fi.FullName, null); dbm.RunImport(null); foreach (var oldAff in oldSim.Affordances.MyItems) { foreach (var newAff in mainSim.Affordances.MyItems) { if (newAff.Name == oldAff.Name) { foreach (var oldDes in oldAff.AffordanceDesires) { var foundDesire = false; foreach (var newDes in newAff.AffordanceDesires) { if (oldDes.Desire.Name == newDes.Desire.Name) { foundDesire = true; } } if (!foundDesire) { Logger.Info("Missing affordance Desire in " + oldAff.Name + " " + oldDes.Desire.Name); } } } } } foreach (var hhg in oldSim.HouseholdTemplates.It) { Logger.Info("HHG 1:" + hhg.Name + " " + hhg.Entries.Count); } foreach (var hhg in mainSim.HouseholdTemplates.It) { Logger.Info("HHG 2:" + hhg.Name + " " + hhg.Entries.Count); } if (checkrowcounts && srctablerowcounts != null) { var dsttablerowcounts = GetTableRowCounts(db.ConnectionString); var errors = new List <string>(); foreach (var srctablerowcount in srctablerowcounts) { if (!acceptedUneven.Contains(srctablerowcount.Key)) { if (!dsttablerowcounts.ContainsKey(srctablerowcount.Key)) { errors.Add(srctablerowcount.Key + " is missing in the dst"); } if (dsttablerowcounts[srctablerowcount.Key] != srctablerowcount.Value) { errors.Add(srctablerowcount.Key + " is missing rows: dst = " + dsttablerowcounts[srctablerowcount.Key] + " src = " + srctablerowcount.Value); } } } var s = string.Empty; foreach (var error in errors) { Logger.Error(error); s += error + Environment.NewLine; } if (s.Length > 0) { throw new LPGException("Errors happened in " + s); } } mainsim = mainSim; // load again to see if anything gets deleted on loading Logger.Threshold = Severity.Debug; var oldSim2 = new Simulator(db.ConnectionString); foreach (var hhg in oldSim2.HouseholdTemplates.It) { Logger.Info("HHG 3:" + hhg.Name + " " + hhg.Entries.Count); } foreach (var hhg in mainSim.HouseholdTemplates.It) { Logger.Info("HHG 4:" + hhg.Name + " " + hhg.Entries.Count); } if (checkrowcounts) { var dsttablerowcounts = GetTableRowCounts(db.ConnectionString); var errors = new List <string>(); if (srctablerowcounts == null) { throw new LPGException("srctablerowcounts was null"); } foreach (var srctablerowcount in srctablerowcounts) { if (!acceptedUneven.Contains(srctablerowcount.Key)) { if (!dsttablerowcounts.ContainsKey(srctablerowcount.Key)) { errors.Add(srctablerowcount.Key + " is missing in the dst"); } if (dsttablerowcounts[srctablerowcount.Key] != srctablerowcount.Value) { errors.Add(srctablerowcount.Key + " is missing rows: dst = " + dsttablerowcounts[srctablerowcount.Key] + " src = " + srctablerowcount.Value); } } } var s = string.Empty; foreach (var error in errors) { Logger.Error(error); #pragma warning disable CC0039 // Don't concatenate strings in loops s += error + Environment.NewLine; #pragma warning restore CC0039 // Don't concatenate strings in loops } if (s.Length > 0) { throw new LPGException("Errors happened in " + s); } } db.Cleanup(); if (clearDstFolder) { CleanTestBase.RunAutomatically(true); } }