Esempio n. 1
0
        protected override void ProcessRecord()
        {
            if (InputObject == null)
            {
                return;
            }

            try
            {
                // new document or none yet
                var document = DocumentInput.NewDocumentWithId(NewId, Id, InputObject, SessionState);

                document = Actor.ToBsonDocument(document, InputObject, new DocumentInput(SessionState, Convert), _Selectors);

                if (Update)
                {
                    WriteResult(TargetCollection.Save(document, WriteConcern, Result));
                }
                else
                {
                    WriteResult(TargetCollection.Insert(document, WriteConcern, Result));
                }
            }
            catch (ArgumentException ex)
            {
                WriteError(DocumentInput.NewErrorRecordBsonValue(ex, InputObject));
            }
            catch (MongoException ex)
            {
                WriteException(ex, InputObject);
            }
        }
        private void ItemParameterChanged(object sender, EventArgs e)
        {
            if (TargetCollection == null || targetCollection.Count < 1 ||
                Index < 0 || Index >= targetCollection.Count)
            {
                return;
            }

            MASM_FormattingItem updatedValues = TargetCollection[Index];

            updatedValues.enable         = EnableToggle.Checked;
            updatedValues.prefix         = PrefixField.Text;
            updatedValues.postfix        = PostfixField.Text;
            updatedValues.property       = PropertyField.Text;
            updatedValues.mode           = ModeField.ToEnum(MASM_FormattingItem.ItemMode.Property);
            updatedValues.operationValue = ParseFloat(ValueField.Text);
            updatedValues.operationType  = OperationField.ToEnum(MASM_FormattingItem.OperationType.None);
            updatedValues.targetData     = TargetField.ToEnum(MASM_FormattingItem.TargetData.PropertyValue);
            updatedValues.roundMode      = RoundField.ToEnum(MASM_FormattingItem.RoundingType.None);
            updatedValues.modulo         = ModuloToggle.Checked;
            updatedValues.outFormat      = OutFormatField.Text;

            if (TargetCollection[Index] != updatedValues)
            {
                TargetCollection[Index] = updatedValues;
            }

            if (sender == CopyButton)
            {
                TargetCollection.Insert(index + 1, TargetCollection[Index]);
            }

            if (sender == MoveUpButton && index - 1 > -1)
            {
                TargetCollection.Move(index, index - 1);
            }

            if (sender == MoveDownButton && index + 1 < TargetCollection.Count)
            {
                TargetCollection.Move(index, index + 1);
            }

            if (sender == RemoveButton &&
                MessageBox.Show("Are you sure to delete item " + index + "?",
                                "Confirm Delete!", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                TargetCollection.RemoveAt(index);
                return;
            }
        }
 /// <see cref="ICollectionChangedEventSource{TSourceItem,TCollectionItem}.InsertItem"/>
 public override void InsertItem(int index, TTarget item)
 {
     TargetCollection?.Insert(index, item);
 }