/// <summary>
        /// Initializes the view-model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="parentViewModel">
        /// The parent view-model.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// The <paramref name="model"/> parameter is null.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="parentViewModel"/> parameter is null.
        /// </exception>
        public void Initialize(WebMethodCallSettingsEdit model, IServiceCallSettingsViewModel parentViewModel)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            if (parentViewModel == null)
                throw new ArgumentNullException("parentViewModel");

            ParentViewModel = parentViewModel;

            RefreshInternal(model);
        }
 private static void Static(WeakEventListener<WebMethodCallSettingsViewModel, WebMethodCallSettingsEdit, PropertyChangedEventArgs> listener, WebMethodCallSettingsEdit source)
 {
     source.PropertyChanged -= listener.OnEvent;
 }
        /// <summary>
        /// Refreshes the internal.
        /// </summary>
        /// <param name="model">The model.</param>
        private void RefreshInternal(WebMethodCallSettingsEdit model)
        {
            Model = model;
            _selectedMethod = Model.MethodName;

            if (ServiceDescription != null && Model.ServiceDescriptionId != ServiceDescription.Id)
                ServiceDescription = null;

            PopulateMethods();

            if (ServiceDescription != null)
            {
                UpdateInputParameters();
                UpdateOutputParameters();
            }

            UpdateInputHeaderViewModels(false);
            UpdateInputParameterViewModels(false);
            UpdateOutputParameterViewModels(false);
            UpdateOutputHeaderViewModels(false);

            ((IActionCommand)GetServiceDescriptionCommand).RaiseCanExecuteChanged();
            ((IActionCommand)GetMethodsCommand).RaiseCanExecuteChanged();
            ((IActionCommand)EditMethodParametersMappingCommand).RaiseCanExecuteChanged();
            ((IActionCommand)EditMethodResultMappingCommand).RaiseCanExecuteChanged();
            ((IActionCommand)ClearMethodParametersMappingCommand).RaiseCanExecuteChanged();
            ((IActionCommand)ClearMethodResultMappingCommand).RaiseCanExecuteChanged();
        }
        /// <summary>
        /// Edits the <see cref="WebMethodCallSettingsEdit.ResultMapping"/> expression.
        /// </summary>
        /// <param name="parentWindow">
        /// The parent window.
        /// </param>
        /// <param name="method">
        /// The method.
        /// </param>
        /// <param name="process">
        /// The process.
        /// </param>
        /// <param name="callSettings">
        /// The call settings.
        /// </param>
        public void EditExpression(
            ITopLevelWindow parentWindow,
            IWebServiceMethodDescription method,
            IProcessEdit process,
            WebMethodCallSettingsEdit callSettings)
        {
            SaveAction = CreateSaveAction(callSettings);
            RemoveAction = CreateRemoveAction(callSettings);

            ExpressionDesigner.Value.LoadFromExpressionObjects(new List<IExpressionObjectBase>());
            WindowManager.Value.ShowStatus(new Status { IsBusy = true });

            var expressions = new List<IExpressionObjectBase>();
            var newExpressions = new List<IExpressionObjectBase>();

            var syncContext = new NotifyClientAction(
                () =>
                {
                    ExpressionDesigner.Value.LoadFromExpressionObjects(expressions);
                    WindowManager.Value.ShowStatus(new Status());
                });

            syncContext.OperationStarted();

            newExpressions.Add(
                CreateSourceItem(
                    "Soap Headers",
                    Constants.WebMethodCallOutputHeadersExpressionName,
                    10,
                    10,
                    method.OutputParameters.Where(p => p.IsSoapHeader),
                    callSettings.ResultFields));
            newExpressions.Add(
                CreateSourceItem(
                    "Output Parameters",
                    Constants.WebMethodCallOutputParametersExpressionName,
                    160,
                    10,
                    method.OutputParameters.Where(p => !p.IsSoapHeader),
                    callSettings.ResultFields));
            newExpressions.Add(CreateUserInformationItem(CurrentUserInformationItemName, 310, 10));
            newExpressions.Add(CreateDestinationItem(process));

            if (!string.IsNullOrWhiteSpace(callSettings.ResultMapping))
            {
                try
                {
                    var expressionsContainer = Serializer.Deserialize(callSettings.ResultMapping);
                    expressions.AddRange(expressionsContainer.Expressions);
                }
                catch
                {
                    // Do nothing, new expressions will be used.
                }
            }

            UpdateStateList(process);

            UpdateStoredExpressions(expressions, newExpressions, syncContext);

            syncContext.OperationCompleted();
            WindowManager.Value.ShowChildWindow(parentWindow, this);
        }
 private static Action CreateRemoveAction(WebMethodCallSettingsEdit callSettings)
 {
     return () => callSettings.ResultMapping = null;
 }
 private Action CreateSaveAction(WebMethodCallSettingsEdit callSettings)
 {
     return () => callSettings.ResultMapping = GetXml();
 }