/// <summary>
 /// Creates the parameter view model.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="baseType">
 /// The base type.
 /// </param>
 /// <param name="parentViewModel">
 /// The parent view model.
 /// </param>
 /// <returns>
 /// The parameter view-model.
 /// </returns>
 public IWebMethodCallParameterViewModel CreateParameterViewModel(
     IWebMethodCallParameter model,
     IWebServiceTypeDescription baseType,
     IWebMethodCallSettingsViewModel parentViewModel)
 {
     return new WebMethodCallParameterViewModel(model, baseType, parentViewModel, this, PopupFactory);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="WebMethodCallParameterViewModel"/> class.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="baseType">
        /// The base type.
        /// </param>
        /// <param name="parentViewModel">
        /// The parent view model.
        /// </param>
        /// <param name="parameterViewModelFactory">
        /// The parameter view model factory.
        /// </param>
        /// <param name="popupFactory">
        /// The popup factory.
        /// </param>
        public WebMethodCallParameterViewModel(
            IWebMethodCallParameter model,
            IWebServiceTypeDescription baseType,
            IWebMethodCallSettingsViewModel parentViewModel,
            IWebMethodCallParameterViewModelFactory parameterViewModelFactory,
            PopupFactory popupFactory)
        {
            if (model == null)
                throw new ArgumentNullException("model");

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

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

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

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

            ParentViewModel = parentViewModel;
            ParameterViewModelFactory = parameterViewModelFactory;
            PopupFactory = popupFactory;
            RefreshInternal(model, baseType);
        }
        /// <summary>
        /// Refreshes the internal.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="baseType">
        /// The base type.
        /// </param>
        private void RefreshInternal(IWebMethodCallParameter model, IWebServiceTypeDescription baseType)
        {
            Model = model;
            Name = model.Name;
            
            _isNull = model.IsNull;
            _itemCountIsSpecified = model.ArrayItemCount.HasValue;
            _itemCount = model.ArrayItemCount ?? 0;
            RaisePropertyChanged(() => IsNull);
            RaisePropertyChanged(() => IsNullable);
            RaisePropertyChanged(() => ItemCountIsSpecified);
            RaisePropertyChanged(() => ItemCount);

            BaseType = baseType;
            UpdateAvailableTypes();

            UpdateChildren(false);
        }
 private static void Static(WeakEventListener<WebMethodCallParameterViewModel, IWebMethodCallParameter, PropertyChangedEventArgs> listener, IWebMethodCallParameter source)
 {
     source.PropertyChanged -= listener.OnEvent;
 }
        /// <summary>
        /// Refreshes the specified model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="baseType">
        /// The base type.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// The <paramref name="model"/> parameter is null.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="baseType"/> parameter is null.
        /// </exception>
        public void Refresh(IWebMethodCallParameter model, IWebServiceTypeDescription baseType)
        {
            if (model == null)
                throw new ArgumentNullException("model");

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

            RefreshInternal(model, baseType);
        }