Beispiel #1
0
        protected virtual TNativeView Map(ShibaView view, IShibaContext context)
        {
            var target = CreateNativeView(context);

            if (view.DefaultValue != null && DefaultPropertyMap != null && HasDefaultProperty)
            {
                SetValue(context, view.DefaultValue, DefaultPropertyMap, target);
            }

            foreach (var property in view.Properties)
            {
                var propertyCache = _propertyCache.Value.LastOrDefault(it => it.Name == property.Name);
                if (propertyCache != null)
                {
                    SetValue(context, property.Value, propertyCache, target);
                }
                else
                {
                    var eventCache = _eventCache.Value.LastOrDefault(it => it.Name == property.Name);
                    if (eventCache != null && property.Value is string name)
                    {
                        eventCache.Setter.Invoke(target, name, context);
                    }
                }
            }

            return(target);
        }
Beispiel #2
0
        public static DataTemplate ToDataTemplate(this ShibaView view)
        {
            throw new NotImplementedException();
            //var layoutString = view.ToString();
            //var templateString =
            //    $"<DataTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><views:{typeof(ShibaHost).Name} xmlns:views=\"using:{typeof(ShibaHost).Namespace}\" DataContext=\"{{Binding}}\" Layout={JsonConvert.SerializeObject(layoutString)}/></DataTemplate>";
            //var template = XamlReader.Load(templateString) as DataTemplate;

            //return template;
        }
Beispiel #3
0
 object IViewMapper.Map(ShibaView view, IShibaContext context)
 {
     return(Map(view, context));
 }