Exemplo n.º 1
0
        public override NativeBinding ProvideNativeBinding(IShibaContext context, ShibaExtension value)
        {
            var dataContextPath =
                nameof(context.DataContext);
            var targetPath = value.Value;
            var path       = dataContextPath;

            return(new NativeBinding
            {
                Converter = Singleton <JsonConverter> .Instance,
                ConverterParameter = targetPath,
                Source = context,
                Path = new PropertyPath(path),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
        }
Exemplo n.º 2
0
        public virtual NativeBinding ProvideNativeBinding(IShibaContext context, ShibaExtension value)
        {
            var dataContextPath =
                nameof(context.DataContext);
            var targetPath = value.Value;
            var path       = string.IsNullOrEmpty(targetPath)
                ? dataContextPath
                : $"{dataContextPath}.{targetPath}";

            return(new NativeBinding
            {
                Source = context,
                Path = new PropertyPath(path),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
        }
Exemplo n.º 3
0
        private object Visit(ShibaExtension item, IShibaContext context)
        {
            var executor =
                ShibaApp.Instance.Configuration.ExtensionExecutors.FirstOrDefault(it => it.Name == item.Type);

            if (executor != null)
            {
                var value = executor.ProvideValue(context, item);
                if (string.IsNullOrEmpty(item.ScriptName))
                {
                    return(value);
                }

                var func = new ShibaFunction(item.ScriptName)
                {
                    Parameters = { item }
                };
                if (value is NativeBinding binding)
                {
                    if (binding.Converter != null)
                    {
                        binding.ConverterParameter = new ShibaConverterParameter
                        {
                            InnerConverter = binding.Converter,
                            InnerParameter = binding.ConverterParameter,
                            Function       = func
                        }
                    }
                    ;
                    else
                    {
                        binding.ConverterParameter = func;
                    }
                    binding.Converter = Singleton <SingleBindingFunctionConverter> .Instance;
                    return(binding);
                }

                return(new NativeBinding
                {
                    ConverterParameter =
                        Singleton <SingleBindingShibaFunctionExecutor> .Instance.Execute(func, item),
                    Converter = Singleton <RawDataConverter> .Instance
                });
            }

            throw new NotImplementedException();
        }
Exemplo n.º 4
0
 public object ProvideValue(IShibaContext context, ShibaExtension value)
 {
     return(ProvideNativeBinding(context, value));
 }
Exemplo n.º 5
0
 public object ProvideValue(IShibaContext context, ShibaExtension value)
 {
     return(Application.Current.Resources.ContainsKey(value.Value) ? Application.Current.Resources[value.Value] : null);
 }
Exemplo n.º 6
0
 protected override object GetValueFromDataContext(ShibaExtension binding, object dataContext)
 {
     return(dataContext);
 }
Exemplo n.º 7
0
 protected virtual object GetValueFromDataContext(ShibaExtension extension, object dataContext)
 {
     return(ShibaApp.Instance.Configuration.ExtensionExecutors
            .FirstOrDefault(it => it.Name == extension.Type)?.ProvideValue(null, extension));
 }