static bool CanUseQueryCorrelationInitializer(ModelItem activity)
 {
     bool result = true;
     if (null != activity)
     {
         if (activity.IsAssignableFrom<Receive>() || activity.IsAssignableFrom<Send>())
         {
             ModelItem serializationOption;
             activity.TryGetPropertyValue(out serializationOption, "SerializerOption");
             result = SerializerOption.XmlSerializer != (SerializerOption)serializationOption.GetCurrentValue();
         }
         else if (activity.IsAssignableFrom<SendReply>() || activity.IsAssignableFrom<ReceiveReply>())
         {
             ModelItem request;
             activity.TryGetPropertyValue(out request, "Request");
             result = CanUseQueryCorrelationInitializer(request);
         }
     }
     return result;
 }
        void OnItemSelectedCore(ModelItem primarySelection)
        {
            //update variable scope - but ignore selection changes made by selecting variables.
            if (null == primarySelection || !primarySelection.IsAssignableFrom<DesignTimeVariable>())
            {
                ModelItem element = VariableHelper.GetVariableScopeElement(primarySelection);
                ModelItemCollection newVariableScope = VariableHelper.GetVariableCollection(element);
                if (this.CurrentVariableScope != newVariableScope)
                {
                    this.CurrentVariableScope = newVariableScope;
                }
                else
                {
                    bool selectedVariableIsInSelection = false;
                    Selection selection = this.Context.Items.GetValue<Selection>();

                    DesignTimeVariable selectedVariable = this.variableDataGrid.SelectedItem as DesignTimeVariable;
                    if (selectedVariable != null)
                    {
                        foreach (ModelItem item in selection.SelectedObjects)
                        {
                            if (object.ReferenceEquals(selectedVariable, item.GetCurrentValue()))
                            {
                                selectedVariableIsInSelection = true;
                            }
                        }
                    }

                    if (!selectedVariableIsInSelection)
                    {
                        this.variableDataGrid.SelectedItem = null;
                    }
                }
            }
        }