コード例 #1
0
        public void Can_execute_attribute_changing()
        {
            var entity = new MsGenerated.Account
            {
                Id          = Guid.NewGuid(),
                CreditLimit = new Money(200m)
            };

            var txEntity = new TransactionContextEntity <MsGenerated.Account>(entity);

            Entity senderEntity           = null;
            AttributeChangingEventArgs ev = null;
            Money value = null;

            txEntity.AttributeChanging += (sender, e) =>
            {
                senderEntity = (Entity)sender;
                ev           = e;
                value        = ((Entity)sender).GetAttributeValue <Money>(e.AttributeName);
            };

            txEntity.Entity.CreditLimit = new Money(450m);

            Assert.Equal(entity, senderEntity);
            Assert.Equal("CreditLimit", ev.PropertyName);
            Assert.Equal("creditlimit", ev.AttributeName);
            Assert.Equal(200m, value.Value);
        }
コード例 #2
0
        public void Can_execute_attribute_changing()
        {
            var entity = new Entity("entity")
            {
                Id = Guid.NewGuid(),
                ["xts_attribute"] = new Money(200m)
            };

            var txEntity = new TransactionContextEntity <Entity>(entity);

            Entity senderEntity           = null;
            AttributeChangingEventArgs ev = null;
            Money value = null;

            txEntity.AttributeChanging += (sender, e) =>
            {
                senderEntity = (Entity)sender;
                ev           = e;
                value        = ((Entity)sender).GetAttributeValue <Money>(e.AttributeName);
            };

            txEntity["xts_attribute"] = new Money(450m);

            Assert.Equal(entity, senderEntity);
            Assert.Null(ev.PropertyName);
            Assert.Equal("xts_attribute", ev.AttributeName);
            Assert.Equal(200m, value.Value);
        }
コード例 #3
0
        private static void RemoveFormattedValue(object entity, AttributeChangingEventArgs e)
        {
            var source = (Entity)entity;

            source.FormattedValues.Remove(e.AttributeName);
        }
コード例 #4
0
 internal void FireEvent(MapNode node, AttributeChangingEventArgs args)
 {
     AttributeChanging(node, args);
 }