/// <summary>
        /// Refreshes the view-model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="field">
        /// The field.
        /// </param>
        public void Refresh(IWebMethodCallResultField model, IWebServiceTypeFieldDescription field)
        {
            if (field == null)
                throw new ArgumentNullException("field");

            Name = field.Name;
            DeclaringType = field.DeclaringType;
            BaseType = field.FieldType;
            Model = model;

            UpdateChildren(false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WebMethodCallResultViewModel"/> class.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="field">
        /// The field.
        /// </param>
        /// <param name="parentNode">
        /// The parent node.
        /// </param>
        /// <param name="popupFactory">
        /// The popup factory.
        /// </param>
        /// <param name="selectChildTypeFieldsViewModel">
        /// The select child type fields view model.
        /// </param>
        /// <param name="resultViewModelFactory">
        /// The result view model factory.
        /// </param>
        /// <param name="resultFieldFactory">
        /// The result field factory.
        /// </param>
        public WebMethodCallResultViewModel(
            IWebMethodCallResultField model,
            IWebServiceTypeFieldDescription field,
            IWebMethodCallResultViewModel parentNode,
            PopupFactory popupFactory,
            ISelectChildTypeFieldsViewModel selectChildTypeFieldsViewModel,
            IWebMethodCallResultViewModelFactory resultViewModelFactory,
            IWebMethodCallResultFieldFactory resultFieldFactory)
        {
            if (field == null)
                throw new ArgumentNullException("field");

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

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

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

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

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

            _model = model;
            _name = field.Name;
            _baseType = field.FieldType;
            _declaringType = field.DeclaringType;
            _parentNode = parentNode;
            PopupFactory = popupFactory;
            SelectChildTypeFieldsViewModel = selectChildTypeFieldsViewModel;
            ResultViewModelFactory = resultViewModelFactory;
            ResultFieldFactory = resultFieldFactory;
        }
        /// <summary>
        /// Refreshes the view-model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="parameter">
        /// The parameter.
        /// </param>
        public void Refresh(IWebMethodCallResultField model, IWebServiceMethodParameterDescription parameter)
        {
            if (parameter == null)
                throw new ArgumentNullException("parameter");

            Name = parameter.Name;
            DeclaringType = null;
            BaseType = parameter.ParameterType;
            Model = model;

            UpdateChildren(false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WebMethodCallResultViewModel"/> class.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="parameter">
        /// The parameter.
        /// </param>
        /// <param name="parentSettings">
        /// The parent settings.
        /// </param>
        /// <param name="popupFactory">
        /// The popup factory.
        /// </param>
        /// <param name="selectChildTypeFieldsViewModel">
        /// The select child type fields view model.
        /// </param>
        /// <param name="resultViewModelFactory">
        /// The result view model factory.
        /// </param>
        /// <param name="resultFieldFactory">
        /// The result field factory.
        /// </param>
        public WebMethodCallResultViewModel(
            IWebMethodCallResultField model,
            IWebServiceMethodParameterDescription parameter,
            IWebMethodCallSettingsViewModel parentSettings,
            PopupFactory popupFactory,
            ISelectChildTypeFieldsViewModel selectChildTypeFieldsViewModel,
            IWebMethodCallResultViewModelFactory resultViewModelFactory,
            IWebMethodCallResultFieldFactory resultFieldFactory)
        {
            if (parameter == null)
                throw new ArgumentNullException("parameter");

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

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

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

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

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

            _model = model;
            _name = parameter.Name;
            _baseType = parameter.ParameterType;
            _parentSettings = parentSettings;
            PopupFactory = popupFactory;
            SelectChildTypeFieldsViewModel = selectChildTypeFieldsViewModel;
            ResultViewModelFactory = resultViewModelFactory;
            ResultFieldFactory = resultFieldFactory;
        }
 /// <summary>
 /// Creates a <see cref="IWebMethodCallResultViewModel"/>.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="parameter">
 /// The parameter.
 /// </param>
 /// <param name="parentSettings">
 /// The parent settings.
 /// </param>
 /// <returns>
 /// The <see cref="IWebMethodCallResultViewModel"/>.
 /// </returns>
 public IWebMethodCallResultViewModel CreateViewModel(
     IWebMethodCallResultField model,
     IWebServiceMethodParameterDescription parameter,
     IWebMethodCallSettingsViewModel parentSettings)
 {
     return new WebMethodCallResultViewModel(model, parameter, parentSettings, PopupFactory, SelectChildTypeFieldsViewModel, this, ResultFieldFactory);
 }
 /// <summary>
 /// Create a <see cref="IWebMethodCallResultViewModel"/>.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="field">
 /// The field.
 /// </param>
 /// <param name="parentNode">
 /// The parent node.
 /// </param>
 /// <returns>
 /// The <see cref="IWebMethodCallResultViewModel"/>.
 /// </returns>
 public IWebMethodCallResultViewModel CreateViewModel(
     IWebMethodCallResultField model,
     IWebServiceTypeFieldDescription field,
     IWebMethodCallResultViewModel parentNode)
 {
     return new WebMethodCallResultViewModel(model, field, parentNode, PopupFactory, SelectChildTypeFieldsViewModel, this, ResultFieldFactory);
 }
        private SourceField CreateSourceField(
            IWebServiceTypeFieldDescription field,
            IWebMethodCallResultField resultField,
            ExpressionObjectBase owner)
        {
            var dataType = GetNodeDataType(field.FieldType);
            var retriever = GetSubfieldsRetriever(field.FieldType, resultField != null ? resultField.Fields : null);
            var name = field.Name;
            var fullName = field.Name;

            if (!field.DeclaringType.IsArray)
            {
                name = field.DeclaringType.DisplayName + "." + name;
                fullName = field.DeclaringType.Name + Constants.WebMethodCallResultDeclaringTypeSeparator + fullName;
            }
            
            var result = new SourceField(owner)
                         {
                             DataType = dataType,
                             Name = name,
                             ConnectorOut = { DataType = dataType, Name = name },
                             InnerName = fullName,
                             SystemName = fullName,
                             SubfieldsRetriever = retriever,
                             SetName = SourceFieldSetNames.IntegrationWebMethodCallResultItem
                         };

            return result;
        }
        private SourceField CreateSourceField(
            IWebServiceMethodParameterDescription parameter,
            IWebMethodCallResultField resultField,
            ExpressionObjectBase owner)
        {
            var dataType = GetNodeDataType(parameter.ParameterType);
            var retriever = GetSubfieldsRetriever(parameter.ParameterType, resultField != null ? resultField.Fields : null);
            var result = new SourceField(owner)
                         {
                             DataType = dataType,
                             Name = parameter.Name,
                             ConnectorOut = { DataType = dataType, Name = parameter.Name },
                             InnerName = parameter.Name,
                             SystemName = parameter.Name,
                             SubfieldsRetriever = retriever,
                             SetName = SourceFieldSetNames.IntegrationWebMethodCallResultItem
                         };

            return result;
        }