Ejemplo n.º 1
0
        void Handle_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            TypeProblem _currentTag = e.Item as TypeProblem;

            ((ListView)sender).SelectedItem = null;
            Navigation.PushAsync(new DescribeProblemPage(_currentTag));
        }
Ejemplo n.º 2
0
        void Handle_PickProblem(object sender, SelectionChangedEventArgs e)
        {
            TypeProblem tmp = e.CurrentSelection.FirstOrDefault() as TypeProblem;

            if (cv1.SelectedItem != null || cv2.SelectedItem != null || cv3.SelectedItem != null || cv4.SelectedItem != null || cv5.SelectedItem != null)
            {
                Navigation.PushAsync(new DescribeProblemPage(tmp));
            }
        }
 public DescribeProblemPage(TypeProblem tmp)
 {
     _typeproblem = tmp;
     TagID        = tmp.TagID;
     TitleText    = tmp.Pcategory;
     InitializeComponent();
     IsLoading      = false;
     BindingContext = this;
 }
Ejemplo n.º 4
0
        private static void CacheTypes()
        {
            var baseType = typeof(Instance);

            var asm = baseType.Assembly;

            foreach (var type in asm.GetTypes().Where(x => baseType.IsAssignableFrom(x) && !x.IsAbstract))
            {
                TypeProblem     problem = TypeProblem.NoProblem;
                Func <Instance> creator = null;

                if (type.IsAbstract)
                {
                    problem = TypeProblem.NotCreatable;
                }
                else if (typeof(Service).IsAssignableFrom(type))
                {
                    problem = TypeProblem.IsAService;
                }
                else if (type.GetConstructor(Type.EmptyTypes) == null)
                {
                    problem = TypeProblem.RequiresParameters;
                }
                else if (type.GetCustomAttributes(typeof(UncreatableAttribute), false).Any())
                {
                    problem = TypeProblem.NotCreatable;
                }

                if (problem == TypeProblem.NoProblem)
                {
                    var constructor = type.GetConstructor(Type.EmptyTypes);
                    Debug.Assert(constructor != null, "constructor != null");
                    creator =
                        Expression.Lambda <Func <Instance> >(Expression.New(constructor))
                        .Compile();
                }

                var item = new TypeCacheItem(type, creator)
                {
                    Problem = problem
                };

                _typeCache.TryAdd(type.Name, item);
            }
        }
Ejemplo n.º 5
0
        internal IList <TypeProblem> GetzhTagList()
        {
            //建立数据库连接
            MySqlConnection conn = new MySqlConnection(connStr);

            try
            {   //建立连接,打开数据库
                conn.Open();
                string sqlstr =
                    "SELECT * FROM Tags";
                MySqlCommand    cmd    = new MySqlCommand(sqlstr, conn);
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    int    TagID     = reader.GetInt32(0);
                    string Pcategory = reader.GetString(3);
                    string ImageUrl  = reader.GetString(2);

                    TypeProblem tmp = new TypeProblem()
                    {
                        TagID     = TagID,
                        Pcategory = Pcategory,
                        ImageUrl  = ImageUrl
                    };
                    tagInfoList.Add(tmp);
                }
                return(tagInfoList);
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
                return(tagInfoList);
            }
            finally
            {
                conn.Close();   //关闭连接
            }
        }
 public DescribeProblemPage(TypeProblem tmp)
 {
     _typeproblem = tmp;
     InitializeComponent();
 }