public void Suggest(object newValue)
        {
            if (newValue == null && !CanBeAssignedNull(this.Type))
            {
                throw(new AttributeAssignmentException("Attribute of type " + this.Type
                                                       + " can not be assigned from provided value" + newValue + " of type " + newValue.GetType()));
            }
            try
            {
                var convertedValue = convertValueToAttributeType(newValue);
                if (World.Instance.ContainsEntity(ParentComponent.ContainingEntity.Guid))
                {
                    var proposedChange =
                        new ProposeAttributeChangeEventArgs(ParentComponent.ContainingEntity,
                                                            ParentComponent.Name,
                                                            Definition.Name,
                                                            convertedValue);

                    ParentComponent.ContainingEntity.PublishAttributeChangeSuggestion(proposedChange);
                }
                else
                {
                    Set(convertedValue);
                }
            }
            catch
            {
                throw new AttributeAssignmentException("Attribute of type " + this.Type
                                                       + " can not be assigned from provided value" + newValue + " of type " + newValue.GetType());
            }
        }
示例#2
0
 internal void PublishAttributeChangeSuggestion(ProposeAttributeChangeEventArgs e)
 {
     if (this.ProposedAttributeChange != null)
     {
         this.ProposedAttributeChange(this, e);
     }
     else
     {
         // if ProposedAttributeChange is null, then Service Bus is uninitialized and we fall back onto normal
         // change propagation, i.e. via ChangedAttribute event.
         e.Entity[e.ComponentName][e.AttributeName].Set(e.Value);
     }
 }
示例#3
0
 internal void PublishAttributeChangeSuggestion(ProposeAttributeChangeEventArgs e)
 {
     if (this.ProposedAttributeChange != null)
     {
         this.ProposedAttributeChange(this, e);
     }
     else
     {
         // if ProposedAttributeChange is null, then Service Bus is uninitialized and we fall back onto normal
         // change propagation, i.e. via ChangedAttribute event.
         e.Entity[e.ComponentName][e.AttributeName].Set(e.Value);
     }
 }
        private void HandleTransformation(object sender, ProposeAttributeChangeEventArgs transform)
        {
            Dictionary<string, Dictionary<string, object>> initialAccumulation = new Dictionary<string, Dictionary<string, object>>();
            Dictionary<string, object> initialAttributeUpdates = new Dictionary<string, object>();
            initialAttributeUpdates.Add(transform.AttributeName, transform.Value);
            initialAccumulation.Add(transform.ComponentName, initialAttributeUpdates);

            AccumulatedAttributeTransform initialTransform = new AccumulatedAttributeTransform(transform.Entity, initialAccumulation);

            string topic = transform.ComponentName + "." + transform.AttributeName;
            if (topicSubscriptions.ContainsKey(topic) && topicSubscriptions[topic].Count > 0)
            {
                InvokeTopicHandlers(topic, initialTransform);
            }
            else
            {
                CloseComputation(initialTransform);
            }
        }