Exemple #1
0
        internal void Confirm(
            string?correlatingMessageId,
            AttributeSet set,
            TrackedAttribute tracked,
            ApplicationMessageType type, Node toOriginalSource)
        {
            switch (type)
            {
            case ApplicationMessageType.AddAttribute:
                var confirmAdd = ConfirmAttribute.From(correlatingMessageId, toOriginalSource, set, tracked, ApplicationMessageType.ConfirmAddAttribute);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, confirmAdd.ToPayload()), toOriginalSource.Collected);
                _application.InformAttributeAdded(set.Name !, tracked.Attribute?.Name);
                break;

            case ApplicationMessageType.RemoveAttribute:
                var confirmRemove = ConfirmAttribute.From(correlatingMessageId, toOriginalSource, set, tracked, ApplicationMessageType.ConfirmRemoveAttribute);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, confirmRemove.ToPayload()), toOriginalSource.Collected);
                _application.InformAttributeRemoved(set.Name !, tracked.Attribute?.Name);
                break;

            case ApplicationMessageType.ReplaceAttribute:
                var confirmReplace = ConfirmAttribute.From(correlatingMessageId, toOriginalSource, set, tracked, ApplicationMessageType.ConfirmReplaceAttribute);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, confirmReplace.ToPayload()), toOriginalSource.Collected);
                _application.InformAttributeReplaced(set.Name !, tracked.Attribute?.Name);
                break;

            default:
                throw new InvalidOperationException("Cannot confirm unknown ApplicationMessageType.");
            }
        }
        public void TestConfirmRemoveAttribute()
        {
            var inboundStreamInterest =
                TestWorld.ActorFor <IInboundStreamInterest>(
                    () => new AttributesAgentActor(_localNode, Application, _outboundStream.Actor, Config, _interest));

            var confirm = new ConfirmAttribute("123", _localNode, _set, _tracked, ApplicationMessageType.ConfirmRemoveAttribute);

            inboundStreamInterest.Actor.HandleInboundStreamMessage(AddressType.Op, RawMessageFor(_localNodeId, _localNode.Name, confirm));
            Assert.Equal(_set.Name, _interest.AttributeSetName);
            Assert.Equal(_tracked.Attribute.Name, _interest.AttributeName);
            Assert.Equal(confirm.Type, _interest.Type);
            Assert.Equal(1, _interest.Confirmed);
        }
Exemple #3
0
        void ListValue(object sender, EventArgs e)
        {
            GridItem     g      = propertyGrid2.SelectedGridItem;
            object       val    = g.Value;
            GridItem     parent = g.Parent;
            PropertyInfo pi     = parent.Value.GetType().GetProperty(g.PropertyDescriptor.Name);

            if (parent == null)
            {
                return;
            }
            IParentBase pval = parent.Value as IParentBase;

            if (pval == null)
            {
                return;
            }
            IParentList plist = pval.Parent as IParentList;

            if (plist == null)
            {
                return;
            }
            ConfirmAttribute cf = Attribute.GetCustomAttribute(pi, typeof(ConfirmAttribute)) as ConfirmAttribute;
            //if (cf != null)
            //{
            //    if (MessageBox.Show("Подтвердите изменения", "Внимание", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            //        return;
            //}
            int count = plist.ListCount();

            for (int i = 0; i < count; i++)
            {
                object lval = plist.GetItem(i);
                pi.SetValue(lval, val, null);
            }
            propertyGrid2.Refresh();
            if (OnRefresh != null)
            {
                OnRefresh();
            }
        }
Exemple #4
0
        private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            PropertyDescriptor pd = e.ChangedItem.PropertyDescriptor;
            Type             tc   = pd.ComponentType;
            Type             tp   = pd.PropertyType;
            PropertyInfo     pi   = tc.GetProperty(pd.Name);
            ConfirmAttribute cf   = Attribute.GetCustomAttribute(pi, typeof(ConfirmAttribute)) as ConfirmAttribute;

            //if (cf != null)
            //{
            //    if (MessageBox.Show("Подтвердите изменения", "Внимание", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            //    {
            //        e.ChangedItem.PropertyDescriptor.SetValue(propertyGrid1.SelectedObject, e.OldValue);
            //        propertyGrid1.Refresh();
            //        return;
            //    }
            //}
            if (OnValueChanged != null)
            {
                OnValueChanged(propertyGrid1.SelectedObject);
            }
        }