示例#1
0
        public IHttpActionResult PutSetList(int id, SetList setList)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != setList.Id)
            {
                return(BadRequest());
            }

            db.Entry(setList).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SetListExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        private void CreateSets()
        {
            _rummys.HasSecond  = false;
            _rummys.HasWild    = true;
            _rummys.LowNumber  = 3;
            _rummys.HighNumber = 14;
            SetsList           = new CustomBasicList <SetList>();
            SetList firstSet = new SetList();

            firstSet.Description = "1 Set Of 3";
            AddSets(firstSet, true, 3);
            firstSet             = new SetList();
            firstSet.Description = "2 Sets Of 3";
            AddSets(firstSet, false, 3);
            firstSet             = new SetList();
            firstSet.Description = "1 Set Of 4";
            AddSets(firstSet, true, 4);
            firstSet             = new SetList();
            firstSet.Description = "2 Sets Of 4";
            AddSets(firstSet, false, 4);
            firstSet             = new SetList();
            firstSet.Description = "1 Set Of 5";
            AddSets(firstSet, true, 5);
            firstSet             = new SetList();
            firstSet.Description = "2 Sets Of 5";
            AddSets(firstSet, false, 5);
            firstSet             = new SetList();
            firstSet.Description = "1 Set Of 6";
            AddSets(firstSet, true, 6);
            firstSet             = new SetList();
            firstSet.Description = "2 Sets Of 6";
            AddSets(firstSet, false, 6);
        }
        public void TestSubsets()
        {
            SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
            SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

            SetList<int>subt = lista.SubtractSet(listb);
            Assert.IsFalse(subt.IsEqualTo(lista));
            Assert.IsTrue(subt.Contains(5));
            Assert.IsFalse(subt.Contains(10));
            Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

            Assert.IsTrue(subt.IsSubsetOf(lista));
            Assert.IsFalse(subt.IsSupersetOf(lista));

            Assert.IsTrue(lista.IsSupersetOf(subt));
            Assert.IsFalse(lista.IsSubsetOf(subt));
            
            SetList<int> copy = lista.Clone();
            copy.RemoveAll(listb);
            Assert.IsFalse(copy.IsEqualTo(lista));
            Assert.IsTrue(copy.IsEqualTo(subt));

            copy.Add(11);
            Assert.IsFalse(copy.IsEqualTo(lista));

            SetList<int> xor = lista.ExclusiveOrWith(listb);
            Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

            SetList<int> comp = lista.ComplementOf(listb);
            Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
        }
示例#4
0
 public override void Refresh()
 {
     FForm.Cursor = Cursors.WaitCursor;
     try
     {
         CD dat = gridMain.Grid.Value as CD;
         SetStatusCount(0);
         try
         {
             Application.DoEvents();
             if (gridMain != null && gridMain.Grid != null)
             {
                 WaitForm.Start(gridMain.Grid);
             }
             //TreeList.Reload();
             SetList.Load();
         }
         finally
         {
             WaitForm.Stop();
             Application.DoEvents();
         }
         gridMain.Grid.SetDataSource(SetList);
         SetStatusCount(SetList.CountAll, SetList.Count);
         gridMain.Grid.Value = dat;
     }
     finally
     {
         gridMain.Grid.ValueEventDisabled = false;
         FForm.Cursor = Cursors.Default;
     }
 }
示例#5
0
        private void gl_OnGameDoubleClick(object sender, EventArgs e)
        {
            var g = sender as Data.Game;

            _currentSetList = new SetList(g);
            frame1.Navigate(_currentSetList);
        }
 public void TestSetIndex2()
 {
     SetList<string> list = new SetList<string>();
     list.Add("");
     Assert.AreEqual("", list[0]);
     list[0] = "error";
 }
        public void TestCTors()
        {
            SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
            Assert.AreEqual("a,B", String.Join(",", list.ToArray())); 
            
            list = new SetList<string>(2);
            Assert.AreEqual("", String.Join(",", list.ToArray()));
            list.Add("a");
            list.Add("B");
            Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

            list = new SetList<string>(2, StringComparer.Ordinal);
            Assert.AreEqual("", String.Join(",", list.ToArray()));
            list.Add("a");
            list.Add("B");
            Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

            list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
            list.Add("a");
            list.Add("B");
            Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

            list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
            Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

            list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
            Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
        }
示例#8
0
        public void TestBasics()
        {
            SetList <int> list = new SetList <int>();

            Assert.IsFalse(list.IsReadOnly);

            for (int i = 512; i >= 0; i--)
            {
                list.Add(i);
            }

            int offset = 0;

            foreach (int item in list)
            {
                Assert.AreEqual(offset++, item);
            }

            Assert.AreEqual(513, offset);
            Assert.AreEqual(513, list.Count);

            list.Clear();
            list.AddRange(new int[] { 5, 10, 20 });
            list.AddRange(new int[] { });

            Assert.AreEqual(3, list.Count);

            Assert.IsTrue(list.Contains(20));
            Assert.IsTrue(list.Remove(20));

            Assert.IsFalse(list.Contains(20));
            Assert.IsFalse(list.Remove(20));

            Assert.AreEqual(2, list.Count);

            int pos;

            list.Add(10, out pos);
            Assert.AreEqual(1, pos);
            Assert.AreEqual(2, list.Count);

            int[] items = new int[2];
            list.CopyTo(items, 0);
            Assert.AreEqual(5, items[0]);
            Assert.AreEqual(10, items[1]);

            items = list.ToArray();
            Assert.AreEqual(5, items[0]);
            Assert.AreEqual(10, items[1]);

            List <int> tmp = new List <int>();

            foreach (int i in list)
            {
                tmp.Add(i);
            }
            Assert.AreEqual(2, tmp.Count);
            Assert.AreEqual(5, tmp[0]);
            Assert.AreEqual(10, tmp[1]);
        }
示例#9
0
        public void TestICollection()
        {
            SetList <int> list = new SetList <int>();

            list.AddRange(new int[] { 5, 10, 20 });

            ICollection coll = list;

            Assert.IsFalse(coll.IsSynchronized);
            Assert.IsTrue(Object.ReferenceEquals(coll, coll.SyncRoot));

            int[] copy = new int[3];
            coll.CopyTo(copy, 0);
            Assert.AreEqual(5, copy[0]);
            Assert.AreEqual(10, copy[1]);
            Assert.AreEqual(20, copy[2]);

            List <int> tmp = new List <int>();

            foreach (int i in coll)
            {
                tmp.Add(i);
            }
            Assert.AreEqual(3, tmp.Count);
            Assert.AreEqual(5, tmp[0]);
            Assert.AreEqual(10, tmp[1]);
            Assert.AreEqual(20, tmp[2]);
        }
示例#10
0
        private void ResetField()
        {
            if (SingleInfo !.PlayerCategory == EnumPlayerCategory.Self)
            {
                _model !.TempSets !.ClearBoard(); //i think
            }
            DeckRegularDict <TileInfo> tempList = new DeckRegularDict <TileInfo>();

            SaveRoot !.YourTiles.ForEach(thisIndex =>
            {
                var thisTile = _model !.Pool1 !.GetTile(thisIndex);
                tempList.Add(thisTile);
            });
            SingleInfo.MainHandList.ReplaceRange(tempList);
            SaveRoot.TilesFromField.Clear();
            int x = SaveRoot.BeginningList.Count; //the first time, actually load manually.

            _model !.MainSets1 !.SetList.Clear(); //try this way.
            x.Times(y =>
            {
                TileSet set = new TileSet(_command, _rummys);
                _model.MainSets1.CreateNewSet(set);
            });
            _model.MainSets1.LoadSets(SaveRoot.BeginningList);
            _model.MainSets1.RedoSets(); //i think.
            SingleInfo.MainHandList.ForEach(thisCard => thisCard.WhatDraw = EnumDrawType.IsNone);
            if (SingleInfo.PlayerCategory == EnumPlayerCategory.Self)
            {
                SingleInfo.MainHandList.Sort();
            }
        }
示例#11
0
        public ActionResult DeleteConfirmed(int id)
        {
            SetList setList = db.SetLists.Find(id);

            db.SetLists.Remove(setList);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#12
0
        private void RibbonButtonClick1(object sender, RoutedEventArgs e)
        {
            _currentSetList = null;
            var gl = new GameList();

            gl.OnGameClick += gl_OnGameDoubleClick;
            frame1.Navigate(gl);
        }
 public EditSetPage(SetList set)
 {
     _connection = DependencyService.Get <ISQLiteDb>().GetConnection();
     InitializeComponent();
     SetId      = set.Id;
     ExerciseId = set.ExerciseId;
     Date       = set.TimeOfSet;
 }
示例#14
0
        public ActionResult SaveName(string setListName, int setListId)
        {
            SetList setList = db.SetLists.Find(setListId);

            setList.Name = setListName;
            db.SaveChanges();
            return(Json(setList.Name, JsonRequestBehavior.AllowGet));
        }
示例#15
0
        public UnionFind(SetList sets)
        {
            this.Sets  = sets;
            this.Roots = new Vector();

            this.Initialize();
            this.Start();
        }
示例#16
0
        public async Task <SetList> Create(SetList setList)
        {
            // Check if already added?

            _context.SetLists.Add(setList);
            await _context.SaveChangesAsync();

            return(setList);
        }
示例#17
0
        protected void AppendUpdateColumnValue(MemberInfo column, object value)
        {
            InitializeSetList();

            AppendColumn(SetList, column);

            SetList.Append(" = ");

            AppendParameter(SetList, value);
        }
 public ActionResult Edit([Bind(Include = "SetListID,Title")] SetList setList)
 {
     if (ModelState.IsValid)
     {
         db.Entry(setList).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(setList));
 }
示例#19
0
        void TreeChanged(object sender, DatEventArgs e)
        {
            ITreeDat tree = (ITreeDat)e.DatEntity;

            SetList.FilterReset();
            SetList.LoadFilter = new SQLFilter();
            SetList.LoadFilter.AddWhere(new FilterString("Parent_FP", tree.FP.ToString()));
            Refresh();
            gridMain.captList.Caption = Caption + " [ветка '" + tree.Name + "']";
        }
示例#20
0
        public void ValuesSimpleAlias()
        {
            SetList w = new SetList(global::SqlBuilder.Format.MsSQL);

            w.AppendValue("a", "NOW()").AppendValue("b", "100").AppendValue("c", "NULL");
            string result = w.GetSql("t");
            string sql    = "[t].[a]=NOW(), [t].[b]=100, [t].[c]=NULL";

            Assert.AreEqual(sql, result);
        }
示例#21
0
        public void ValuesSimple1()
        {
            SetList w = new SetList(global::SqlBuilder.Format.MsSQL);

            w.Append("a", "b", "c");
            string result = w.GetSql();
            string sql    = "[a]=@a, [b]=@b, [c]=@c";

            Assert.AreEqual(sql, result);
        }
示例#22
0
        public ActionResult MoveUp(int id, int concertId)
        {
            SetList song         = context.SetLists.FirstOrDefault(s => s.SongId == id);
            SetList previousSong = context.SetLists.FirstOrDefault(s => s.Position == song.Position - 1);

            song.Position         = previousSong.Position;
            previousSong.Position = song.Position + 1;
            context.SaveChanges();
            return(RedirectToAction("SetList", new { id = concertId }));
        }
示例#23
0
        public ActionResult Create(int bandId, string setListName)
        {
            SetList setList = new SetList();

            setList.BandId = bandId;
            setList.Name   = setListName;
            db.SetLists.Add(setList);
            db.SaveChanges();
            return(RedirectToAction("Edit", "SetList", new { setListId = setList.SetListId }));
        }
示例#24
0
        protected void ParseSet <R>(Expression <Func <T, R> > property, Expression <Func <T, R> > value)
        {
            InitializeSetList();

            Parse(SetList, property.Body);

            SetList.Append(" = ");

            Parse(SetList, value.Body);
        }
示例#25
0
        protected void TestAll(string path)
        {
            KorgFileReader korgFileReader = new KorgFileReader();

            _pcgMemory = (PcgMemory)korgFileReader.Read(DefaultDirectory + path);

            Debug.Assert(_pcgMemory != null);

            // Test set list generator.
            TestDefaultPatchList();
            TestProgramUsageList();
            TestDefaultCombiContentList();
            TestDefaultFileContentList();

            // Swap program (if there is more than one program).
            IProgramBanks programBanks = _pcgMemory.ProgramBanks;

            if (programBanks != null)
            {
                ProgramBank programBank = (ProgramBank)programBanks[0];

                if (programBank.IsFilled && programBank.IsWritable && (programBank.CountPatches > 1))
                {
                    _pcgMemory.SwapPatch(programBank[0], programBank[1]);
                }
            }

            // Swap combi (if there is more than one combi).
            ICombiBanks combiBanks = _pcgMemory.CombiBanks;

            if (combiBanks != null)
            {
                CombiBank combiBank = (CombiBank)combiBanks[0];
                if (combiBank.IsFilled && combiBank.IsWritable && (combiBank.CountPatches > 1))
                {
                    _pcgMemory.SwapPatch(combiBank[0], combiBank[1]);
                }
            }

            // Swap set list slot.
            ISetLists setLists = _pcgMemory.SetLists;

            if (setLists != null)
            {
                SetList setList0 = (SetList)setLists[0];
                if (setList0.IsFilled && setList0.IsWritable)
                {
                    _pcgMemory.SwapPatch((SetListSlot)(setList0[0]), (SetListSlot)(setList0[1]));
                }
            }

            // Test save.
            _pcgMemory.FileName = "E:\\test.pcg";
            _pcgMemory.SaveFile(false, false);
        }
示例#26
0
        public IHttpActionResult GetSetList(int id)
        {
            SetList setList = db.SetLists.Where(s => s.Id == id && s.UserId == User.Identity.GetUserId()).FirstOrDefault();

            if (setList == null)
            {
                return(NotFound());
            }

            return(Ok(setList));
        }
示例#27
0
        public void Add_NoValuesToArray_ReturnsArrayLength()
        {
            SetList <string> setList = new SetList <string>();
            //Arrange

            //Act
            int value = setList.Counter;

            //Assert
            Assert.AreEqual(0, value);
        }
示例#28
0
        public void ToString_CustomStringListWithNoValues_ReturnsNull()
        {
            SetList <string> listOne = new SetList <string>();

            //Arrange

            //Act
            listOne.ToString();
            //Assert
            Assert.IsNull(listOne.itemSeries[0]);
        }
示例#29
0
        public void ToString_CustomIntListWithNoValues_ReturnsValue()
        {
            SetList <int> listOne = new SetList <int>();
            //Arrange
            string itemResult = "";

            //Act
            itemResult = listOne.ToString();
            //Assert
            Assert.AreEqual("", itemResult);
        }
示例#30
0
        public void subtract_TwoInstancesOfEmptyIntCustomList_ReturnsValueAtIndex()
        {
            SetList <int> listOne = new SetList <int>();
            SetList <int> listTwo = new SetList <int>();
            //Arrange
            //Act
            SetList <int> sumOfList = listOne - listTwo;

            //Assert
            Assert.AreEqual(0, sumOfList.itemSeries[0]);
        }
示例#31
0
        /// <summary>
        /// Derives a new filename that doesn't exist from the provided name, ie. file.txt becomes file.txt.~0001
        /// </summary>
        /// <param name="originalPath">the name of the file</param>
        /// <param name="tempfilePath">[out] the temp file name</param>
        /// <returns>A stream with exclusive write access to the file</returns>
        public static Stream CreateDerivedFile(string originalPath, out string tempfilePath)
        {
            string tempFile = null;
            int tempInt, ordinal = 0;
            int maxAttempt = 10;

            if (!Path.IsPathRooted(originalPath))
                originalPath = Path.GetFullPath(originalPath);

            SetList<String> existingFiles = new SetList<string>(
                Directory.GetFiles(Path.GetDirectoryName(originalPath), Path.GetFileName(originalPath) + ".~????", SearchOption.TopDirectoryOnly)
                );
            if (existingFiles.Count > 0)
            {
                string extension = Path.GetExtension(existingFiles[existingFiles.Count - 1]);
                if (extension.Length == 6 && int.TryParse(extension.Substring(2), NumberStyles.AllowHexSpecifier, null, out tempInt))
                    ordinal = Math.Max(ordinal, tempInt);
            }
            Stream stream = null;
            while (stream == null)
            {
                while (tempFile == null || File.Exists(tempFile))
                    tempFile = String.Format("{0}.~{1:x4}", originalPath, ++ordinal);

                try
                {
                    stream = File.Open(tempFile, FileMode.CreateNew, FileAccess.Write, FileShare.Read);
                }
                catch (System.IO.IOException)
                {
                    if (maxAttempt-- <= 0)
                        throw;
                    tempFile = null;
                    stream = null;
                }
            }

            tempfilePath = tempFile;
            return stream;
        }