Пример #1
0
        protected object ExtractProperty(ReactStylesDiffMap props)
        {
            if (props.IsNull(Name) && s_defaultValues.TryGetValue(PropertyType, out var defaultFunc))
            {
                return(defaultFunc(_attribute));
            }

            return(props.GetProperty(Name)?
                   .ToObject(PropertyType));
        }
Пример #2
0
        public static T GetProperty <T>(this ReactStylesDiffMap props, string name)
        {
            var property = props.GetProperty(name, typeof(T));

            if (property == null)
            {
                throw new Exception("ReactStylesDiffMapExtensions GetProperty error, property is null");
            }
            return((T)property);
        }
Пример #3
0
        /// <summary>
        /// Checks if the property key is layout-only.
        /// </summary>
        /// <param name="props">The prop collection.</param>
        /// <param name="prop">The prop name.</param>
        /// <returns>
        /// <b>true</b> if the property is layout-only, <b>false</b> otherwise.
        /// </returns>
        public static bool IsLayoutOnly(ReactStylesDiffMap props, string prop)
        {
            if (s_layoutOnlyProperties.Contains(prop))
            {
                return(true);
            }
            else if (PointerEvents == prop)
            {
                var value = props.GetProperty(prop).Value <string>();
                return(value == "auto" || value == "box-none");
            }

            return(false);
        }
Пример #4
0
        protected object ExtractProperty(ReactStylesDiffMap props)
        {
            if (props.IsNull(Name) && s_defaultValues.TryGetValue(PropertyType, out var defaultFunc))
            {
                return(defaultFunc(_attribute));
            }

            var prop = props.GetProperty(Name)?
                       .ToObject(PropertyType);

            if (prop == null && PropertyType.GetTypeInfo().IsValueType)
            {
                return(Activator.CreateInstance(PropertyType));
            }

            return(prop);
        }
Пример #5
0
        protected object ExtractProperty(ReactStylesDiffMap props)
        {
            var defaultFunc = default(Func <ReactPropBaseAttribute, object>);

            if (props.IsNull(Name) && s_defaultValues.TryGetValue(PropertyType, out defaultFunc))
            {
                return(defaultFunc(_attribute));
            }
            try
            {
                return(props.GetProperty(Name)?
                       .ToObject(PropertyType));
            }
            catch (Exception ex)
            {
                Log.Error(ReactConstants.Tag, $"ExtractProperty failed, Name is {Method.Name}, PropertyType is {PropertyType}");
                throw ex;
            }
        }
Пример #6
0
        private bool IsLayoutOnlyAndCollapsible(ReactStylesDiffMap props)
        {
            if (props == null)
            {
                return(true);
            }

            if (props.ContainsKey(ViewProps.Collapsible) && !props.GetProperty <bool>(ViewProps.Collapsible))
            {
                return(false);
            }

            foreach (var key in props.Keys)
            {
                if (!ViewProps.IsLayoutOnly(props, key))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #7
0
 public static T GetProperty <T>(this ReactStylesDiffMap props, string name)
 {
     return((T)props.GetProperty(name, typeof(T)));
 }
Пример #8
0
 public static object GetProperty(this ReactStylesDiffMap props, string name, Type type)
 {
     return(props.GetProperty(name).ToObject(type));
 }
        private bool IsLayoutOnlyAndCollapsible(ReactStylesDiffMap props)
        {
            if (props == null)
            {
                return true;
            }

            if (props.ContainsKey(ViewProps.Collapsible) && !props.GetProperty<bool>(ViewProps.Collapsible))
            {
                return false;
            }

            foreach (var key in props.Keys)
            {
                if (!ViewProps.IsLayoutOnly(key))
                {
                    return false;
                }
            }

            return true;
        }