private void addExecute() { for (int x = 0; x < Quantity; x++) { TECEquipment equipment = null; if (AsReference && underlyingTemplate != null) { equipment = templates.EquipmentSynchronizer.NewItem(underlyingTemplate); } else if (underlyingTemplate != null) { if (templates != null) { equipment = new TECEquipment(underlyingTemplate, ssSynchronizer: templates.SubScopeSynchronizer); } else { equipment = new TECEquipment(underlyingTemplate); } } else { equipment = new TECEquipment(ToAdd); } equipment.CopyPropertiesFromScope(ToAdd); add(equipment); if (ConnectVM != null && ConnectVM.Connect) { ConnectVM.ExecuteConnection(equipment.SubScope); } Added?.Invoke(equipment); } }
private void TryAddToCache(IEnumerable <Security> securities) { if (securities == null) { throw new ArgumentNullException(nameof(securities)); } var newSecurities = new List <Security>(); foreach (var security in securities) { var nativeId = security.ExtensionInfo == null ? default(TNativeId) : CreateNativeId(security); if (nativeId == null) { return; } bool isNew; _cacheByNativeId.SafeAdd(nativeId, key => security, out isNew); if (isNew) { newSecurities.Add(security); } } Added?.Invoke(newSecurities); }
/// <summary> /// Добавление предмета в хранилище. /// </summary> /// <param name="prop"> Целевой предмет. </param> public void Add(IProp prop) { switch (prop) { case Resource resource: // запоминаем предыдущее состояния для событий var oldProp = (Resource)CalcActualItems()?.SingleOrDefault(x => x.Scheme == prop.Scheme); TransferResource(resource, PropAdded, PropRemoved); // Выброс событий var currentProp = CalcActualItems()?.SingleOrDefault(x => x.Scheme == prop.Scheme); if (oldProp == null) { Added?.Invoke(this, new PropStoreEventArgs(currentProp)); } else { Changed?.Invoke(this, new PropStoreEventArgs(currentProp)); } break; case Equipment _: case Concept _: TransferNoCount(prop, PropRemoved, PropAdded); Added?.Invoke(this, new PropStoreEventArgs(prop)); break; } }
private void OnCollectionChanged(object s, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case Add: foreach (T item in e.NewItems) { if (!Value.Add(item)) { throw new InvalidOperationException( $"The ObservableCollection<{typeof(T).Name}> is being tracked as a Set. " + "Sets do not allow duplicate values. " + $"A value {item} is already present in the collection"); } Added?.Invoke(item); } break; case Remove: foreach (T item in e.OldItems) { if (!Value.Remove(item)) { throw new Exception("WTF!?"); } Removed?.Invoke(item); } break; default: throw new InvalidOperationException( $"The ObservableCollection<{typeof(T).Name}> is being tracked as a Set. " + $"{e.Action} operation is not supported!"); } }
public override T Add(T sipAsset) { try { if (sipAsset == null) { throw new ArgumentException("The " + sipAsset.GetType().ToString() + " cannot be empty for Add."); } else if (Get(a => a.Id == sipAsset.Id) != null) { throw new ArgumentException("SIP Asset with id " + sipAsset.Id.ToString() + " already exists."); } Guid id = sipAsset.Id; lock (m_sipAssets) { m_sipAssets.Add(id, sipAsset); } WriteSIPAssetXML(); Added?.Invoke(sipAsset); return(Get(id)); } catch (Exception excp) { logger.Error("Exception SIPAssetXMLPersistor Add (for " + typeof(T).Name + "). " + excp.Message); throw; } }
public void AddReferenced <TRefernces>(TRefernces entity) where TRefernces : TEntity, IEntity <TRefernces> { if (entity.Reference == null) { throw new EntitiesException("Entity not added to entity group"); } // Add entity var reference = GetReference(); reference.Index = entities.Count; references.SetAt(reference.Index, reference); entities.SetAt(reference.Index, entity); Added?.Invoke(entities.Buffer[reference.Index]); // Connect to parent reference.IsChild = true; var linkedReference = (LinkedReference)entity.Reference; while (linkedReference.Child != null) { linkedReference = linkedReference.Child; } linkedReference.Child = reference; }
public void Add(T element) { _list.Add(element); Added.Invoke(this, new AddedEventArgs <T> { Element = element }); }
private static void AddAsync(int progid) { lock (DbUpdateLock) { using (SQLiteCommand command = new SQLiteCommand("insert into subscriptions (progid) values (@progid)", FetchDbConn())) { command.Parameters.Add(new SQLiteParameter("@progid", progid)); try { command.ExecuteNonQuery(); } catch (SQLiteException sqliteExp) { if (sqliteExp.ErrorCode == SQLiteErrorCode.Constraint) { // Already added while this was waiting in the threadpool return; } throw; } } } Added?.Invoke(progid); RaiseUpdated(progid); }
public void Add(T data) { if (data == null) { throw new System.ArgumentException("Parameter cannot be null", "data"); } else { Node <T> node = new Node <T>(data); if (head == null) { head = node; tail = node; tail.Next = head; } else { node.Next = head; tail.Next = node; tail = node; } count++; Added?.Invoke(sender: this, e: new AddToCollection <T>(data, message: $"{data} was added")); } }
private void AddCore(DownloadLink link) { var tokeSource = new CancellationTokenSource(); var tasks = link.Downloader.EmitTasks(link.Request, tokeSource.Token); var downloadTask = new DownloadTask(tasks, tokeSource.Token); var box = new DownloadBox(downloadTask, link) { TokenSource = tokeSource }; box.Canceled += Box_Canceled; downloadTask.MovedNext += (a, b) => { MovedNext?.Invoke(this, a, b); }; downloadTask.Seeked += (a, b) => { Seeked?.Invoke(this, a, b); }; downloadTask.Done += async w => { await RemoveAsync(box.Address); Done?.Invoke(this, box); }; downloadMap.Add(link.Request.Entity.ComicUrl, box); downloadManager.Add(downloadTask); Added?.Invoke(this, box); }
private void HandleChange(string oldDirectoryName, string newDirectoryName) { var wasRepository = WasRepository(oldDirectoryName, out var oldRepository); var isRepository = IsRepository(newDirectoryName, out var newRepository); var isNameChanged = !string.Equals(oldDirectoryName, newDirectoryName, StringComparison.OrdinalIgnoreCase); if (wasRepository && isRepository) { if (isNameChanged) { _repositories.Remove(oldDirectoryName); _repositories[newRepository.Name] = newRepository; Renamed?.Invoke(oldRepository, newRepository); } } else if (wasRepository) { _repositories.Remove(oldDirectoryName); Removed?.Invoke(oldRepository); } else if (isRepository) { _repositories[newRepository.Name] = newRepository; Added?.Invoke(newRepository); } }
public void Add(NotificationLog notificationLog) { m_logger.Info($"{notificationLog}"); m_repository.Add(notificationLog); Added?.Invoke(notificationLog); }
public virtual void InvokeAddedEvent(BackupObject obj) { if (Added != null) { Added.Invoke(obj); } }
public void AddEquip(string m) { if (ObjEquip == 0) { equipments = new string[1]; } else { string[] tmpEquip = new string[ObjEquip]; for (int i = 0; i < ObjEquip; i++) { tmpEquip[i] = equipments[i]; } equipments = new string[ObjEquip + 1]; for (int i = 0; i < ObjEquip; i++) { equipments[i] = tmpEquip[i]; } } equipments[ObjEquip] = m; ObjEquip += 1; Console.ForegroundColor = ConsoleColor.DarkRed; Added?.Invoke($"You add new equipment: {m}."); Console.ResetColor(); }
/// <summary> /// Try add native security identifier to storage. /// </summary> /// <param name="name">Storage name.</param> /// <param name="securityId">Security identifier.</param> /// <param name="nativeId">Native (internal) trading system security id.</param> /// <param name="isPersistable">Save the identifier as a permanent.</param> /// <returns><see langword="true"/> if native identifier was added. Otherwise, <see langword="false" />.</returns> public bool TryAdd(string name, SecurityId securityId, object nativeId, bool isPersistable) { if (name.IsEmpty()) { throw new ArgumentNullException(nameof(name)); } if (nativeId == null) { throw new ArgumentNullException(nameof(nativeId)); } lock (_sync) { var nativeIds = _nativeIds.SafeAdd(name); var added = nativeIds.TryAdd(securityId, nativeId); if (!added) { return(false); } } if (isPersistable) { Save(name, securityId, nativeId); } Added?.Invoke(name, securityId, nativeId); return(true); }
public void Add(ChatLog chatLog) { m_logger.Info($"{chatLog}"); m_repository.Add(chatLog); Added?.Invoke(chatLog); }
public void Add(TItem item) { if (this.Node.CompareTo(item) > 0) { if (this.LeftTree == null) { this.LeftTree = new BinaryTree <TItem>(item); Added?.Invoke(this, new AddToBinaryTreeEventArgs <TItem>(item, $"{item} added to left tree")); } else { this.LeftTree.Add(item); Added?.Invoke(this, new AddToBinaryTreeEventArgs <TItem>(item, $"{item} added to left tree")); } } else { if (this.RightTree == null) { this.RightTree = new BinaryTree <TItem>(item); Added?.Invoke(this, new AddToBinaryTreeEventArgs <TItem>(item, $"{item} added to right tree")); } else { this.RightTree.Add(item); Added?.Invoke(this, new AddToBinaryTreeEventArgs <TItem>(item, $"{item} added to right tree")); } } }
private void OnAdd() { if (Added != null) { Added.Invoke(this, EventArgs.Empty); } }
private void addExecute() { for (int x = 0; x < Quantity; x++) { if (parent is TECBid bid) { TECTypical typical = new TECTypical(toAdd, bid); bid.Systems.Add(typical); typical.AddInstance(); Added?.Invoke(typical); } else if (parent is TECTemplates) { TECSystem system = null; if (underlyingTemplate != null) { system = new TECSystem(underlyingTemplate, synchronizers: new Tuple <TemplateSynchronizer <TECEquipment>, TemplateSynchronizer <TECSubScope> >(templates.EquipmentSynchronizer, templates.SubScopeSynchronizer)); system.CopyPropertiesFromScope(ToAdd); } else { system = ToAdd; } parent.Templates.SystemTemplates.Add(system); Added?.Invoke(system); } } }
private void OnAdded(T item) { if (!_dontRaiseEvents) { Added?.Invoke(item); } }
public bool Insert(T _item, T _index) //вставляет элемент перед определенным элементом { Node <T> current = first; while (current != null) { if (Equals(current.item, _index)) { break; } current = current.next; } Node <T> new_item = new Node <T>(_item); if (current == null) { return(false); } new_item.next = current; new_item.prev = current.prev; if (current.prev != null) { current.prev.next = new_item; } current.prev = new_item; if (new_item.prev == null) { first = new_item; } Count++; Added?.Invoke(_item); return(true); }
public void Add(TKey key, TValue value) { OnAdd(key, value); Added?.Invoke(key, value); m_addedHandler?.Invoke(key, value); }
public new void Add(T item) { var castedItem = item as DummyModel; base.Add(item); Added?.Invoke(this, new CollectionEventArgs($"Item with name {castedItem.Name} has been added into collection")); }
public async Task AddAsync(TKey key, TValue value) { await OnAddAsync(key, value); Added?.Invoke(key, value); m_addedHandler?.Invoke(key, value); }
private void addExecute() { for (int x = 0; x < Quantity; x++) { TECSubScope subScope = null; if (underlyingTemplate != null) { subScope = AsReference ? templates.SubScopeSynchronizer.NewItem(underlyingTemplate) : new TECSubScope(underlyingTemplate); subScope.CopyPropertiesFromScope(ToAdd); foreach (IEndDevice device in ToAdd.Devices.Where(item => !originalDevices.Contains(item))) { subScope.AddDevice(device); } foreach (TECPoint point in ToAdd.Points.Where(item => !originalPoints.Contains(item))) { subScope.AddPoint(point); } } else { subScope = new TECSubScope(ToAdd); } add(subScope); if (ConnectVM != null && ConnectVM.Connect) { ConnectVM.ExecuteConnection(subScope); } Added?.Invoke(subScope); } }
public void Add(T item) { try { if (CountInArray == 100) { throw new Exception("слышь? Хватит уже"); } if (First == null) { First = new NodeForMyCollection <T>(item); Last = First; CountInArray++; Added?.Invoke("добавилось"); } else { Last = new NodeForMyCollection <T>(item, Last); CountInArray++; Added("добавилось"); } } catch (Exception e) { Console.WriteLine(e.Message); } }
public virtual T Add(T asset) { Added?.Invoke(asset); throw new NotImplementedException("Method " + MethodBase.GetCurrentMethod().Name + " in " + MethodBase.GetCurrentMethod().DeclaringType .ToString() + " not implemented."); }
public bool Insert(T item, T index) { Node current = FindNode(index); Node node = new Node(item); if (current == null) { return(false); } node.Next = current; node.Prev = current.Prev; if (current.Prev != null) { current.Prev.Next = node; } current.Prev = node; if (node.Prev == null) { First = node; } Count++; Added?.Invoke(item); return(true); }
private void DeviceWatcher_Added(DeviceWatcher sender, DeviceInformation args) { System.Diagnostics.Debug.WriteLine("BLEWATCHER_ADDED:: Name:" + args.Name + " Address:" + RXBluetoothUtils.GetAddressStringFromDeviceId(args.Id)); RXBluetoothDevice device = (BluetoothManager as BluetoothManager).GetBluetoothDeviceFromDeviceInformation(args); Added?.Invoke(this, device); }
private KVID5Panel Add(string code, float x, float y, float z, string type, int?iR, int?oV, int?oF, string blockBA, string connectorType, Action <Cell> cellClickHandler) { var removeButton = RemoveButton.Factory.Create(_removeButtonPrefab, _removes.transform, RemoveButton_Clicked); var codeCell = Cell.Factory.CreateUnique(_cellPrefab, code, _codes, cellClickHandler); var xCell = Cell.Factory.Create(_cellPrefab, x, _xs, cellClickHandler); var yCell = Cell.Factory.Create(_cellPrefab, y, _ys, cellClickHandler); var zCell = Cell.Factory.Create(_cellPrefab, z, _zs, cellClickHandler); var tCell = Cell.Factory.Create(_cellPrefab, type, false, _types, cellClickHandler, "И", "П", "У"); var irCell = Cell.Factory.Create(_cellPrefab, iR, _innerResists, cellClickHandler); var ovCell = Cell.Factory.Create(_cellPrefab, oV, _operatingVoltages, cellClickHandler); var ofCell = Cell.Factory.Create(_cellPrefab, oF, _operatingFrequensies, cellClickHandler); var ctCell = Cell.Factory.Create(_cellPrefab, connectorType, true, _connectorTypes, cellClickHandler); // reference cells var list = TableDataManager.Instance.KVID2Data.Select(d => d.tabName ?? "-").ToList(); var bbaCell = ReferenceCell.Factory.Create(_referenceCellPrefab, list, blockBA, _blockBAs); var panel = new KVID5Panel(removeButton, codeCell, xCell, yCell, zCell, tCell, irCell, ovCell, ofCell, bbaCell, ctCell); _kvid5Panels.Add(panel); removeButton.Panel = panel; AddPanelToColumns(panel); Added.Invoke(panel); return(panel); }