Esempio n. 1
0
        private async Task ExecuteFunction(ObjectProxy instance, MethodInfo method, string methodName)
        {
            var parameters           = method.GetParameters();
            var parameterValueStores = parameters
                                       .Select(p => new SelfcontainedValueStore
            {
                Identifier = p.GetCustomAttribute <TitleAttribute>()?.Title ?? ObjectDisplay.Nicely(p),
                Value      =
                    ((p.Attributes & ParameterAttributes.HasDefault) == ParameterAttributes.HasDefault) ? p.DefaultValue
                                                : p.ParameterType == typeof(DateTime) ? (object)DateTime.Today
                                                : null,
                ValueType  = p.ParameterType,
                CustomView = p.GetCustomAttribute <CustomViewAttribute>()?.ResourceKey,
            }).ToList <IValueStore>();

            var parameterValueStoresWithoutObservableCollections = parameterValueStores
                                                                   .Where(vs => IsObservableCollection(vs.ValueType) == false)
                                                                   .ToList();

            var propertiesViewModels = PropertiesViewModels.Of(parameterValueStoresWithoutObservableCollections, _Objects);

            if (parameterValueStoresWithoutObservableCollections.Any())
            {
                MethodInvocationTitle        = methodName;
                MethodInvocationParameters   = propertiesViewModels;
                MethodInvocationContinuation = new Command(async() => await InvokeMethod(instance, method, parameterValueStores));
                ShowMethodInvocationDialog(parameterValueStoresWithoutObservableCollections);
            }
            else
            {
                await InvokeMethod(instance, method, parameterValueStores);
            }
        }
Esempio n. 2
0
        protected override void OnSelectedMasterItem(object o)
        {
            var selectedObject = o as ObjectProxy;

            if (selectedObject != null)
            {
                var type = selectedObject.ProxiedObject.GetType();
                Properties = PropertiesViewModels.Of(PropertyValueStore.ForPropertiesOf(type, selectedObject, InvokeChangedEvents), _Objects);

                var methods   = type.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
                var functions = GetFunctions(selectedObject, methods);

                DetailCommands.Clear();
                foreach (var function in functions)
                {
                    DetailCommands.Add(new ActionViewModel
                    {
                        Label  = function.Item1,
                        Icon   = function.Item2,
                        Action = function.Item3
                    });
                }
            }
            else
            {
                Properties = new List <IPropertyViewModel>();
                DetailCommands.Clear();
            }

            System.Diagnostics.Debug.WriteLine("Properties.Count: " + Properties.Count);
            Changed(() => Properties);
        }