Esempio n. 1
0
        internal CommonFunctionBehavior(IElementCreationContext context, Parameters parameters, string text, IElement parent)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            _owner      = context.Owner;
            _parameters = parameters;
            _text       = text;
            _parent     = parent;

            _labelView = new CallFunctionView()
            {
                DataContext = this
            };

            if (string.IsNullOrWhiteSpace(context.Data))
            {
                _model = new CallFunctionData();
            }
            else
            {
                _model = JsonConvert.DeserializeObject <CallFunctionData>(context.Data);

                var functionService = context.Owner.GetService <IFunctionService>();

                if (functionService == null)
                {
                    MessageBox.Show("No function service was provided.");
                    return;
                }

                //Get the function
                SelectFunction(functionService.GetFunction(_model.FunctionId));
            }

            _actions = new IElementAction[]
            {
                new ElementAction("Select function...", SelectFunction),
                new ElementAction("Go to definition...", GoToDefinition, CanGoToDefinition),
            };
        }
Esempio n. 2
0
        internal CommonFunctionBehavior(IElementCreationContext context, Parameters parameters, string text, IElement parent)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));
            if (parameters == null) throw new ArgumentNullException(nameof(parameters));
            if (parent == null) throw new ArgumentNullException(nameof(parent));

            _owner = context.Owner;
            _parameters = parameters;
            _text = text;
            _parent = parent;

            _labelView = new CallFunctionView()
            {
                DataContext = this
            };

            if (string.IsNullOrWhiteSpace(context.Data))
            {
                _model = new CallFunctionData();
            }
            else
            {
                _model = JsonConvert.DeserializeObject<CallFunctionData>(context.Data);

                var functionService = context.Owner.GetService<IFunctionService>();

                if (functionService == null)
                {
                    MessageBox.Show("No function service was provided.");
                    return;
                }

                //Get the function
                SelectFunction(functionService.GetFunction(_model.FunctionId));
            }

            _actions = new IElementAction[]
            {
                new ElementAction("Select function...", SelectFunction)
            };
        }