示例#1
0
            public void AdicionarUsuario(Usuarios usuario)

            {//Adiciono o meu usuario a minha lista
                object ListaDeUsuario = null;

                ListaDeUsuario.Add(usuario);
            }
示例#2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     pnlDatos.Enabled = true;
     pctPhoto.Image   = null;
     coachBindingSource.Add(new Coach());
     coachBindingSource.MoveLast();
     txtFirstName.Focus();
 }
示例#3
0
 public Snake(Point tail, int lenght, Direction direction)
 {
     for (int i = 0; i < lenght; i++)
     {
         Point p = new Point(tail);
         p.Move(i, direction);
         pList.Add(p);
     }
 }
示例#4
0
        public static List <Setup> Load(string csvDataFilePath)
        {
            List <Setup> crimeStatsList = new List <Setup>();

            try
            {
                using (var reader = new StreamReader(csvDataFilePath))
                {
                    int lineNumber = 0;
                    while (!reader.EndOfStream)
                    {
                        var line = reader.ReadLine();
                        lineNumber++;
                        if (lineNumber == 1)
                        {
                            continue;
                        }

                        var values = line.Split(',');

                        if (values.Length != NumItemsInRow)
                        {
                            throw new Exception($"Row {lineNumber} contains {values.Length} values. It should contain {NumItemsInRow}.");
                        }
                        try
                        {
                            String name   = string(values[0]);
                            String artist = string(values[1]);
                            String album  = string(values[2]);
                            String genre  = string(values[3]);
                            int    size   = Int32.Parse(values[4]);
                            int    time   = Int32.Parse(values[5]);
                            int    year   = Int32.Parse(values[6]);
                            int    plays  = Int32.Parse(values[7]);

                            Setup  setup     = new Setup(name, artist, album, genre, size, time, year, plays);
                            object setupList = null;
                            setupList.Add(setup);
                        }
                        catch (FormatException e)
                        {
                            throw new Exception($"Row {lineNumber} contains invalid data. ({e.Message})");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception($"Unable to open {csvDataFilePath} ({e.Message}).");
            }

            return(crimeStatsList);
        }
        void ResetMenu()
        {
            ClearAllSubmenus();

            var menuEntryList = new object[0].ToList(MenuEntryType);

            foreach (var category in SettingCollection.Categories)
            {
                var submenu = MenuEntry.Create(category.Name, () => CreateMenuForCategory(category));

                submenu.AsDynamic().Description     = category.Description;
                submenu.AsDynamic().IsCenterAligned = false;

                menuEntryList.Add(submenu.AsTimeSpinnerMenuEntry());
            }

            menuEntryList.Add(CreateDefaultsMenu(SettingCollection.Categories, false));

            ((object)Dynamic._primaryMenuCollection).AsDynamic()._entries = menuEntryList;
            ((object)Dynamic._selectedMenuCollection).AsDynamic().SetSelectedIndex(0);
        }
示例#6
0
        static void Main()
        {
            var anon = GetAnonymous().FromPrototype(new { FirstName = "", LastName = "" });

            Console.WriteLine(anon.FirstName);

            var list = new object[0].Select(o => new { FirstName = "", LastName = "" }).ToList();

            list.Add(anon);

            foreach (var o in list)
            {
                Console.WriteLine(o);
            }
        }
示例#7
0
    public static List <object> ListarAnonimo()
    {
        var lista = new object[] {
            new {
                Nome    = "",
                Idade   = 0,
                Salario = 0.0m
            }
        }.ToList();

        lista.Clear();
        lista.Add(new {
            Nome    = "Gato",
            Idade   = 25,
            Salario = 3000000.0m
        });
        return(lista);
    }
示例#8
0
        public static void CopyCurrentCharaOverlayByController(ChaControl sourceChaCtrl, ChaControl targetChaCtrl, bool[] isChecked)
        {
            MonoBehaviour sourceController = sourceChaCtrl.GetComponents <MonoBehaviour>().FirstOrDefault(x => Equals(x.GetType().Name, "CharaOverlaysBasedOnCoordinateController"));
            MonoBehaviour targetController = targetChaCtrl.GetComponents <MonoBehaviour>().FirstOrDefault(x => Equals(x.GetType().Name, "CharaOverlaysBasedOnCoordinateController"));

            object sourceOverlays = sourceController.GetProperty("CurrentOverlay").ToDictionaryWithoutType();
            object targetOverlays = targetController.GetProperty("CurrentOverlay").ToDictionaryWithoutType();

            object result = sourceOverlays.ToDictionaryWithoutType();   //Clone it to use the structure

            result.RemoveAll(x => true);

            _ = sourceOverlays.ForEach((x) => {
                DictionaryEntry d = (DictionaryEntry)x;
                int checkCase     = -1;
                switch (Convert.ToInt32(d.Key))
                {
                case 1:
                case 3:
                    checkCase = 2;
                    break;

                case 2:
                case 4:
                    checkCase = 1;
                    break;

                case 5:
                case 6:
                    checkCase = 0;
                    break;

                case 0:
                    break;

                default:
                    Logger.LogWarning("Cast failed while reading overlays from KK_COBOC!");
                    break;
                }
                if (checkCase >= 0 && checkCase < isChecked.Length)
                {
                    if (isChecked[checkCase])
                    {
                        result.Add(d.Key, ((byte[])d.Value).Clone());
                    }
                    else if (targetOverlays.TryGetValue(d.Key, out object val))
                    {
                        result.Add(d.Key, ((byte[])val).Clone());
                    }
                    else
                    {
                        result.Add(d.Key, new byte[] { });
                    }
                }
            });

            if (targetController.SetProperty("CurrentOverlay", result))
            {
                //單眼
                if (isChecked[0])
                {
                    int[] sourceIris = (int[])sourceController.GetField("IrisDisplaySide");
                    int[] targetIris = (int[])targetController.GetField("IrisDisplaySide");
                    int   sourceType = sourceChaCtrl.fileStatus.coordinateType;
                    int   targetType = targetChaCtrl.fileStatus.coordinateType;
                    if (sourceIris.Length > sourceType && targetIris.Length > targetType)
                    {
                        targetIris[targetType] = sourceIris[sourceType];
                    }
                    targetController.SetField("IrisDisplaySide", targetIris);
                }
                targetController.Invoke("OverwriteOverlay");
                Logger.LogDebug($"Copy Current CharaOverlay {sourceChaCtrl.fileParam.fullname} -> {targetChaCtrl.fileParam.fullname}: {isChecked[0]} {isChecked[1]} {isChecked[2]}");
            }
        }
示例#9
0
        public void Add_NullAddTwo_ReturnTwo()
        {
            object nullValue = null;

            Assert.AreEqual(2, nullValue.Add(2));
        }
示例#10
0
        public bool PlayableByCard(int p1CardNo1, int p1CardNo2, int p1CardNo3,
                                   string p1CardSymbol1, string p1CardSymbol2, string p1CardSymbol3,
                                   int p2CardNo1, int p2CardNo2, int p2CardNo3,
                                   string p2CardSymbol1, string p2CardSymbol2, string p2CardSymbol3)
        {
            var SymbolList = new List <string> {
                PokdengInfo.Symbol.Club, PokdengInfo.Symbol.Diamond, PokdengInfo.Symbol.Heart, PokdengInfo.Symbol.Spade
            };

            var p1SymbolList = new List <string> {
                p1CardSymbol1, p1CardSymbol2, p1CardSymbol3
            };
            var p2SymbolList = new List <string> {
                p2CardSymbol1, p2CardSymbol2, p2CardSymbol3
            };

            var NoSymbol = string.IsNullOrEmpty(p1SymbolList[0]) || string.IsNullOrEmpty(p1SymbolList[1]) ||
                           string.IsNullOrEmpty(p2SymbolList[0]) || string.IsNullOrEmpty(p2SymbolList[1]);

            if (NoSymbol)
            {
                return(false);
            }

            var IsCorrectSymbol = SymbolList.Any(it => p1SymbolList.Contains(it)) && SymbolList.Any(it => p2SymbolList.Contains(it));

            if (!IsCorrectSymbol)
            {
                return(false);
            }

            var p1CardNoList = new List <int> {
                p1CardNo1, p1CardNo2, p1CardNo3
            };
            var p2CardNoList = new List <int> {
                p2CardNo1, p2CardNo2, p2CardNo3
            };

            var HasCorrectCardNO = (p1CardNoList[0] >= 1 && p1CardNoList[0] <= 13) || (p1CardNoList[1] >= 1 && p1CardNoList[1] <= 13) ||
                                   (p2CardNoList[0] >= 1 && p2CardNoList[0] <= 13) || (p2CardNoList[1] >= 1 && p2CardNoList[1] <= 13);

            if (!HasCorrectCardNO)
            {
                return(false);
            }

            var cardInList = new object[] { }.ToList();
            var allCardNo     = p1CardNoList.Concat(p2CardNoList).ToList();
            var allCardSymbol = p1SymbolList.Concat(p2SymbolList).ToList();

            for (int i = 0; i < 6; i++)
            {
                var card = new { CardNo = allCardNo[i], Symbol = allCardSymbol[i] };
                if (allCardNo[i] != 0 && !string.IsNullOrEmpty(allCardSymbol[i]))
                {
                    if (!cardInList.Contains(card))
                    {
                        cardInList.Add(card);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (allCardNo[i] != 0 && string.IsNullOrEmpty(allCardSymbol[i]))
                {
                    return(false);
                }
                else if (allCardNo[i] == 0 && !string.IsNullOrEmpty(allCardSymbol[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
 public ActionResult seeAuthority()
 {
     //if (System.Web.HttpContext.Current.Session["login"] != null) return Redirect("/login");
     //if (int.Parse(((Dictionary<string, string>)Session["user_all"])["wc_identify"]) < 1) return Json(new { msg = "error", more = "Insufficient permissions" });
     //Response.Headers.Set("Access-Control-Allow-Origin", "*");//仅供跨域测试使用
     if (Request.Form["target"] == null)
     {
         return(Json(new { msg = "error", more = "parameter error" }));
     }
     if (Request.Form["target"].ToString() == "getdata")
     {
         if (Request.Form["status"] == null)
         {
             return(Json(new { msg = "error", more = "parameter error" }));
         }
         var cz = new Dictionary <string, object>();
         int cl;
         if (!int.TryParse(Request.Form["status"].ToString(), out cl))
         {
             return(Json(new { msg = "error", more = "parameter error" }));
         }
         cz.Add("status", cl);
         if (Request.Form["yeshu"] != null && (!int.TryParse(Request.Form["yeshu"].ToString(), out cl) || cl < 0))
         {
             return(Json(new { msg = "error", more = "parameter error" }));
         }
         if (Request.Form["yeshu"] == null)
         {
             cl = 0;
         }
         cz.Add("yeshu", cl * 15);
         cz.Add("zongshu", (cl + 1) * 15);
         var z = mi.wc.data_search_self("select id,wc_name,building_name,room_name,apply_time,apply_for_time,start_time,end_time,organization,reason,status from(select top (@zongshu) wc_recoder.id,wc_name,building_name,room_name,apply_time,apply_for_time,start_time,end_time,organization,reason,status,ROW_NUMBER() over (order by wc_recoder.id)n from wc_recoder left join wc_building on wc_recoder.room_id=wc_building.id left join wc_user_all on wc_recoder.applyer_id=wc_user_all.id where status=@status)kco where n>@yeshu order by n", cz);
         if (z == null)
         {
             return(Json(new { detail = new { num = "0" } }));
         }
         var qc = mi.wc.data_search_self("select COUNT(id) as num from wc_recoder where status=@status", cz);
         var iop = new object[] { }.ToList();
         foreach (var c in z)
         {
             iop.Add(new
             {
                 id             = c.Value["id"],
                 name           = c.Value["wc_name"],
                 building_name  = c.Value["building_name"],
                 room_name      = c.Value["room_name"],
                 apply_time     = DateTime.Parse(c.Value["apply_time"]).ToString("yyyy-MM-dd HH:mm:ss"),
                 apply_for_time = DateTime.Parse(c.Value["apply_for_time"]).ToString("yyyy-MM-dd"),
                 start_time     = c.Value["start_time"],
                 end_time       = c.Value["end_time"],
                 organization   = c.Value["organization"],
                 reason         = c.Value["reason"],
                 status         = c.Value["status"]
             });
         }
         var deti = new { num = qc[0]["num"] };
         var ddl  = new { detail = deti, data = iop.ToArray() };
         return(Json(ddl));
     }
     if (Request.Form["target"] == "updata")
     {
         if (Request.Form["status"] == null)
         {
             return(Json(new { msg = "error", more = "parameter error" }));
         }
         int cl;
         Dictionary <string, object> a = new Dictionary <string, object>();
         if (Request.Form["id"] == null)
         {
             return(Json(new { msg = "error", more = "parameter error" }));
         }
         if (!int.TryParse(Request.Form["id"].ToString(), out cl))
         {
             return(Json(new { msg = "error", more = "parameter error" }));
         }
         a.Add("id", cl);
         if (!int.TryParse(Request.Form["status"].ToString(), out cl))
         {
             return(Json(new { msg = "error", more = "parameter error" }));
         }
         if (cl == -1)
         {
             var c = mi.wc.data_search_self("select wc_recoder.id,wc_building.building_name,wc_building.room_name,wc_name,wc_recoder.apply_time,wc_recoder.apply_for_time,wc_recoder.start_time,ck.end_time,wc_recoder.reason,wc_recoder.organization,wc_recoder.status from wc_recoder,(select * from wc_recoder as cl where id=@id)ck left join wc_user_all on ck.applyer_id=wc_user_all.id left join wc_building on ck.room_id=wc_building.id where wc_recoder.status=0 and wc_recoder.apply_for_time=ck.apply_for_time  and not (wc_recoder.id=ck.id) and (case when wc_recoder.start_time>ck.start_time then wc_recoder.start_time else ck.start_time end)<(case when wc_recoder.end_time<ck.end_time then wc_recoder.end_time else ck.end_time end)", a);
             if (c != null)
             {
                 var iop = new object[] { }.ToList();
                 foreach (var ik in c)
                 {
                     iop.Add(new
                     {
                         id             = ik.Value["id"],
                         name           = ik.Value["wc_name"],
                         building_name  = ik.Value["building_name"],
                         room_name      = ik.Value["room_name"],
                         apply_time     = DateTime.Parse(ik.Value["apply_time"]).ToString("yyyy-MM-dd HH:mm:ss"),
                         apply_for_time = DateTime.Parse(ik.Value["apply_for_time"]).ToString("yyyy-MM-dd"),
                         start_time     = ik.Value["start_time"],
                         end_time       = ik.Value["end_time"],
                         organization   = ik.Value["organization"],
                         reason         = ik.Value["reason"],
                         status         = ik.Value["status"]
                     });
                 }
                 if (Request.Form["confirm"] != null && Request.Form["confirm"].ToString() == "1")
                 {
                     string k = "";
                     foreach (var d in iop.ToArray())
                     {
                         if (k == "")
                         {
                             k = d.GetType().GetProperty("id").GetValue(d, null).ToString();
                             continue;
                         }
                         ;
                         k = k + "," + d.GetType().GetProperty("id").GetValue(d, null).ToString();
                     }
                     var cp = new int[] { -1, 0, 1, 2 };
                     if (!test.isIn(cp, cl))
                     {
                         return(Json(new { msg = "error", more = "parameter error" }));
                     }
                     a.Add("verifier_id", 2);
                     mi.wc.data_change_self("update wc_recoder set status = 1,reply_time=GETDATE(),verifier_id=@verifier_id where id in (" + k + ")", a);
                     a.Add("status", Request.Form["status"].ToString());
                     //a.Add("verifier_id",Session["id"]) 由于测试没有这个东西所以先不管
                     mi.wc.data_change_self("update wc_recoder set status = @status,reply_time=GETDATE(),verifier_id=@verifier_id where id=@id", a);
                     return(Json(new { msg = "success" }));
                 }
                 return(Json(new { msg = "error", more = "conflict recoder", data = iop.ToArray() }));
             }
         }//设置为已通过,检查是否有冲突
         var z = new int[] { -1, 0, 1, 2 };
         if (!test.isIn(z, cl))
         {
             return(Json(new { msg = "error", more = "parameter error" }));
         }
         a.Add("status", Request.Form["status"].ToString());
         a.Add("verifier_id", 2);
         //a.Add("verifier_id",Session["id"]) 由于测试没有这个东西所以先不管
         mi.wc.data_change_self("update wc_recoder set status = @status,reply_time=GETDATE(),verifier_id=@verifier_id where id=@id", a);
         return(Json(new { msg = "success" }));
     }
     if (Request.Form["target"] == "num")
     {
         int cl;
         if (Request.Form["status"] == null || !int.TryParse(Request.Form["status"].ToString(), out cl) || !test.isIn(new int[] { -1, 0, 1, 2 }, cl))
         {
             return(Json(new { msg = "error", more = "parameter error" }));
         }
         Dictionary <string, object> a = new Dictionary <string, object>();
         a.Add("status", cl);
         var p = mi.wc.data_search_self("select isnull(count(status),0) as count from wc_recoder where  status=@status", a);
         return(Json(new { num = p[0]["count"] }));
     }
     return(Json(new { msg = "error", more = "parameter error" }));
 }