コード例 #1
0
        public void Navigate(string name, Intent intent, params string[] parameters)
        {
            var topVc = TopViewController;
            var navVc = topVc.NavigationController;

            if (!Maps.ContainsKey(name))
            {
                throw new KeyNotFoundException(name);
            }
            var  type      = Maps [name];
            bool isPush    = false;
            bool isPresent = false;
            Tuple <MethodInfo, object> convert = null;

            foreach (var item in parameters)
            {
                isPush    |= _toPush == item;
                isPresent |= _toPresent == item;
                convert    = Converts.FirstOrDefault(x => x.Key == item).Value;
            }
            var view = Create(type, intent) as UIViewController;

            if (convert != null)
            {
                view = CreateByConvert <UIViewController> (convert, view);
            }
            if (view == null)
            {
                throw new TypeInitializationException(type.FullName, new Exception("does not initialize"));
            }
            if (intent != null)
            {
                if (isPush && navVc != null)
                {
                    navVc.PushViewController(view, UseAnimated);
                    return;
                }
                if (isPresent)
                {
                    topVc.PresentViewController(view, UseAnimated, null);
                    return;
                }
            }
            if (navVc != null)
            {
                if (navVc.GetType() == view.GetType())
                {
                    throw new ArgumentException("The navigation controller does not push to the navigation controller");
                }
                navVc.PushViewController(view, UseAnimated);
            }
            else
            {
                topVc.PresentViewController(view, UseAnimated, null);
            }
        }
コード例 #2
0
        public virtual T CellConvert(T item, string header, Cell cell)
        {
            Type type = typeof(T);

            string propertyName = header;
            string value        = ReadCellValue(cell);

            if (_viewConfigure != null)
            {
                var descriptor = _viewConfigure.GetViewPortDescriptors(true).FirstOrDefault(m => m.DisplayName == header);
                if (descriptor != null)
                {
                    propertyName = descriptor.Name;
                    var dropdown = descriptor as DropDownListDescriptor;
                    if (dropdown != null)
                    {
                        foreach (var op in dropdown.OptionItems)
                        {
                            if (op.Value == value)
                            {
                                value = op.Key;
                            }
                        }
                    }
                }
            }
            var property = _entryProperites.FirstOrDefault(m => m.Name == propertyName);

            if (property != null && value != null)
            {
                var    convert        = Converts.FirstOrDefault(m => m.SupportType == property.PropertyType);
                object convertedValue = null;
                if (convert != null)
                {
                    convertedValue = convert.Convert(value);
                }
                else
                {
                    convertedValue = ClassAction.ValueConvert(property, value);
                }
                property.SetValue(item, convertedValue);
            }

            return(item);
        }