Beispiel #1
0
 private void SetParameter(MethodParameterViewModel data)
 {
     ViewModel.Parameter = data;
 }
Beispiel #2
0
 public MethodParameterReferenceValueViewModel GetCurrentValueForParameter(MethodParameterViewModel parameter)
 {
     return(MethodInputParametersReferenceValues.FirstOrDefault(k => k.RegardingMethodParameter.Name == parameter.Name));
 }
Beispiel #3
0
 public List <MethodParameterReferenceViewModel> GetAvailableParametersForMethodParmaeter(MethodParameterViewModel parameter)
 {
     return(AvailableInputParameterReferences.Where(k => k.MethodParameter.Type == parameter.Type).ToList());
 }
Beispiel #4
0
        private void RegisterCommands()
        {
            AddNewParameterCommand = new RelayCommandHandled((input) =>
            {
                var instance = new MethodParameterViewModel();
                var model    = instance.ToGenericInputModel("Add new parmeter", _typesAttribute.ToArray());
                var window   = new GenericInputFormWindow(model);
                window.ShowDialog();
                if (window.Response == WindowResponse.OK)
                {
                    instance.UpdateDataFromDictionary(window.Values);
                    Parameters.Add(instance);
                    UpdateListToCollection(Parameters, ParametersCollection);
                    _view.RaiseOnModifiedListEvent(Parameters);
                }
            });

            ModifyNewParameterCommand = new RelayCommandHandled((input) =>
            {
                var instance = SelectedParameter;
                var model    = instance.ToGenericInputModel("Modify parmeter", _typesAttribute.ToArray());
                var window   = new GenericInputFormWindow(model);
                window.ShowDialog();
                if (window.Response == WindowResponse.OK)
                {
                    instance.UpdateDataFromDictionary(window.Values);
                    UpdateListToCollection(Parameters, ParametersCollection);
                    _view.RaiseOnModifiedListEvent(Parameters);
                }
            }, (input) => { return(SelectedParameter != null); });

            RemoveParameterCommand = new RelayCommandHandled((input) =>
            {
                RaiseOkCancelDialog("Confirm the remove?", "Remove", () =>
                {
                    Parameters.Remove(SelectedParameter);
                    UpdateListToCollection(Parameters, ParametersCollection);
                });
                _view.RaiseOnModifiedListEvent(Parameters);
            }, (input) => { return(SelectedParameter != null); });

            MoveUpParameterCommand = new RelayCommandHandled((input) =>
            {
                var oldSelectedParameter = SelectedParameter;
                var items  = Parameters;
                Parameters = Parameters.MoveItemUp(SelectedParameter).ToList();
                UpdateListToCollection(Parameters, ParametersCollection);
                SelectedParameter = ParametersCollection.First(k => k.Name == oldSelectedParameter.Name);
                _view.RaiseOnModifiedListEvent(Parameters);
            }, (input) => { return(SelectedParameter != null && SelectedParameter != ParametersCollection.First()); });

            MoveDownParameterCommand = new RelayCommandHandled((input) =>
            {
                var oldSelectedParameter = SelectedParameter;
                var items  = Parameters;
                Parameters = Parameters.MoveItemDown(SelectedParameter).ToList();
                UpdateListToCollection(Parameters, ParametersCollection);
                SelectedParameter = ParametersCollection.First(k => k.Name == oldSelectedParameter.Name);
                _view.RaiseOnModifiedListEvent(Parameters);
            }, (input) => { return(SelectedParameter != null && SelectedParameter != ParametersCollection.Last()); });


            RegisterCommand(AddNewParameterCommand);
            RegisterCommand(ModifyNewParameterCommand);
            RegisterCommand(RemoveParameterCommand);
            RegisterCommand(MoveUpParameterCommand);
            RegisterCommand(MoveDownParameterCommand);
        }
Beispiel #5
0
 private void UpdatedParameter(MethodParameterViewModel data)
 {
     NewReferenceValue.RegardingMethodParameter = data;
 }
Beispiel #6
0
        public static GenericFormModel ToGenericInputModel(this MethodParameterViewModel parameter, string formDescription, OptionSetValue[] options)
        {
            var model = new GenericFormModel(formDescription);

            model.AddAttribute(
                GenericFormInputModel.TypeValue.String,
                nameof(MethodParameterViewModel.Name),
                nameof(MethodParameterViewModel.Name),
                nameof(MethodParameterViewModel.Name),
                true,
                parameter.Name);


            var directionAttr = new GenericFormInputModel()
            {
                DisplayName           = nameof(MethodParameterViewModel.Direction),
                Key                   = nameof(MethodParameterViewModel.Direction),
                Description           = nameof(MethodParameterViewModel.Direction),
                IsMandatory           = true,
                Type                  = GenericFormInputModel.TypeValue.OptionSet,
                OptionSetValueOptions = new List <OptionSetValue>()
                {
                    { new OptionSetValue(MethodParameter.ParameterDirection.Input.ToString(), (int)MethodParameter.ParameterDirection.Input) },
                    { new OptionSetValue(MethodParameter.ParameterDirection.Output.ToString(), (int)MethodParameter.ParameterDirection.Output) }
                }.ToArray(),
                DefaultValue = ((int)parameter.Direction) > 0 ? new OptionSetValue((int)parameter.Direction) : null
            };


            var typeAttr = new GenericFormInputModel()
            {
                DisplayName           = nameof(MethodParameterViewModel.Type),
                Key                   = nameof(MethodParameterViewModel.Type),
                Description           = nameof(MethodParameterViewModel.Type),
                IsMandatory           = true,
                Type                  = GenericFormInputModel.TypeValue.OptionSet,
                OptionSetValueOptions = options,
                DefaultValue          = ((int)parameter.Type) > 0 ? new OptionSetValue((int)parameter.Type) : null
            };

            var enumAttr = new GenericFormInputModel()
            {
                DisplayName           = nameof(MethodParameterViewModel.EnumerableType),
                Key                   = nameof(MethodParameterViewModel.EnumerableType),
                Description           = nameof(MethodParameterViewModel.EnumerableType),
                IsMandatory           = false,
                Type                  = GenericFormInputModel.TypeValue.OptionSet,
                OptionSetValueOptions = options,
                DefaultValue          = ((int)parameter.EnumerableType) > 0 ? new OptionSetValue((int)parameter.EnumerableType) : null
            };


            var dicKeyAttr = new GenericFormInputModel()
            {
                DisplayName           = nameof(MethodParameterViewModel.DictionaryKeyType),
                Key                   = nameof(MethodParameterViewModel.DictionaryKeyType),
                Description           = nameof(MethodParameterViewModel.DictionaryKeyType),
                IsMandatory           = false,
                Type                  = GenericFormInputModel.TypeValue.OptionSet,
                OptionSetValueOptions = options,
                DefaultValue          = ((int)parameter.DictionaryKeyType) > 0 ? new OptionSetValue((int)parameter.DictionaryKeyType) : null
            };


            var dicValueAttr = new GenericFormInputModel()
            {
                DisplayName           = nameof(MethodParameterViewModel.DictionaryValueType),
                Key                   = nameof(MethodParameterViewModel.DictionaryValueType),
                Description           = nameof(MethodParameterViewModel.DictionaryValueType),
                IsMandatory           = false,
                Type                  = GenericFormInputModel.TypeValue.OptionSet,
                OptionSetValueOptions = options,
                DefaultValue          = ((int)parameter.DictionaryValueType) > 0 ? new OptionSetValue((int)parameter.DictionaryValueType) : null
            };

            model.Attributes.Add(directionAttr);
            model.Attributes.Add(typeAttr);
            model.Attributes.Add(enumAttr);
            model.Attributes.Add(dicKeyAttr);
            model.Attributes.Add(dicValueAttr);

            return(model);
        }