Exemple #1
0
        private void SetEvent(object instance, object value)
        {
            if (mPropertyDescriptor != null)
            {
                object oldValue = base.Value;

                mPropertyDescriptor.SetValue(instance, value);

                SetVariableLogic.Self.PropertyValueChanged(RootVariableName, oldValue);
            }
            else
            {
                mStateSave.SetValue(mVariableName, value);
            }
            // set the value
        }
        private void HandleCustomSet(object instance, object value)
        {
            if (mPropertyDescriptor != null)
            {
                object oldValue = base.Value;

                mPropertyDescriptor.SetValue(instance, value);

                string name = RootVariableName;

                bool handledByExposedVariable = false;

                // This might be a tunneled variable, and we want to react to the
                // change using the underlying variable if so:
                if (instance is ElementSave)
                {
                    var elementSave = instance as ElementSave;
                    var variable    = elementSave.DefaultState.Variables
                                      .FirstOrDefault(item => item.ExposedAsName == RootVariableName);
                    if (variable != null)
                    {
                        var sourceObjectName = variable.SourceObject;

                        name = variable.Name;
                        var instanceInElement = elementSave.Instances
                                                .FirstOrDefault(item => item.Name == sourceObjectName);

                        if (instanceInElement != null)
                        {
                            handledByExposedVariable = true;
                            SetVariableLogic.Self.ReactToPropertyValueChanged(variable.GetRootName(), oldValue, elementSave, instanceInElement, true);
                        }
                    }
                }

                if (!handledByExposedVariable)
                {
                    SetVariableLogic.Self.PropertyValueChanged(name, oldValue);
                }
            }
            else
            {
                mStateSave.SetValue(mVariableName, value);
            }
            // set the value
        }