예제 #1
0
        public async Task <ActionResult <CList> > PostCList(CList cList)
        {
            _context.CList.Add(cList);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCList", new { id = cList.Id }, cList));
        }
예제 #2
0
        public static void FromFile(out CList <T> list, string fileName)
        {
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream(fileName, FileMode.Open, FileAccess.Read);

            list = (CList <T>)formatter.Deserialize(stream);
        }
예제 #3
0
        public async Task <IActionResult> PutCList(int id, CList cList)
        {
            if (id != cList.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cList).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CListExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #4
0
        public void SubtractTwoListsInstance_Returns_Expected_Capacity_5()
        {
            // arrange
            CList <int> List1 = new CList <int>()
            {
                10, 20, 30
            };
            CList <int> List2 = new CList <int>()
            {
                30, 20, 60
            };
            CList <int> expected = new CList <int>()
            {
                10, 60
            };
            CList <int> actual         = new CList <int>();
            int         Capacity       = 5;
            int         expectedResult = Capacity;

            // act
            actual = List1 - List2;

            // assert
            Assert.AreEqual(expectedResult, actual.Capacity);
        }
예제 #5
0
        public void ZipTwoListsInstance_Returns_Expected_Capacity_5()
        {
            // arrange
            CList <int> List1 = new CList <int>()
            {
                1, 3, 5
            };
            CList <int> List2 = new CList <int>()
            {
                2, 4, 6
            };
            CList <int> expected = new CList <int>()
            {
                1, 2, 3, 4, 5, 6
            };
            CList <int> actual         = new CList <int>();
            int         Capacity       = 8;
            int         expectedResult = Capacity;

            // act
            // actual.zip(List1, List2)

            // assert
            Assert.AreEqual(expectedResult, actual.Capacity);
        }
예제 #6
0
        public void SubtractListsInstance_Returns_Expected_Count_2()
        {
            // arrange
            CList <int> List1 = new CList <int>()
            {
                10, 20, 30
            };
            CList <int> List2 = new CList <int>()
            {
                30, 20, 60
            };
            CList <int> expected = new CList <int>()
            {
                10, 60
            };
            CList <int> actual         = new CList <int>();
            int         Count          = 2;
            int         expectedResult = Count;

            // act
            actual = List1 - List2;

            // assert
            Assert.AreEqual(expectedResult, actual.Count);
        }
예제 #7
0
        public void AddTwoListsInstance_Returns_Expected_Capacity_8()
        {
            // arrange
            CList <int> List1 = new CList <int>()
            {
                10, 20, 30
            };
            CList <int> List2 = new CList <int>()
            {
                40, 50, 60
            };
            CList <int> expected = new CList <int>()
            {
                10, 20, 30, 40, 50, 60
            };
            CList <int> actual         = new CList <int>();
            int         Capacity       = 8;
            int         expectedResult = Capacity;

            // act
            actual = List1 + List2;

            // assert
            Assert.AreEqual(expectedResult, actual.Capacity);
        }
예제 #8
0
        //

        public void RemoveValue_Return_Expected_Count_8()
        {
            int count          = 8;
            int ExpectedResult = count;
            //Arrange
            CList <int> customList = new CList <int>();
            int         value1     = 10;
            int         value2     = 20;
            int         value3     = 30;
            int         value4     = 40;
            int         value5     = 50;
            int         value6     = 60;
            int         value7     = 70;
            int         value8     = 80;
            int         value9     = 90;


            //Act
            customList.Add(value1);
            customList.Add(value2);
            customList.Add(value3);
            customList.Add(value4);
            customList.Add(value5);
            customList.Add(value6);
            customList.Add(value7);
            customList.Add(value8);
            customList.Add(value9);

            customList.Remove(value2);


            //Assert
            Assert.AreEqual(ExpectedResult, customList.Count);
        }
예제 #9
0
        public void IterableTestMethod()
        {
            //arrange
            CList <int> storedValues = new CList <int>();
            int         counter;

            counter = 0;

            storedValues.Add(1);
            storedValues.Add(2);
            storedValues.Add(3);
            storedValues.Add(4);
            storedValues.Add(5);
            storedValues.Add(6);
            storedValues.Add(7);
            storedValues.Add(8);
            storedValues.Add(9);
            storedValues.Add(0);

            //act
            foreach (int number in storedValues)
            {
                counter = counter + number;
            }

            //assert
            Assert.AreEqual(45, counter);
        }
예제 #10
0
        public void Reduce2Lists_PositiveTest_Same1List()
        {
            //arrange
            CList <int> list1 = new CList <int> {
            };
            CList <int> list2 = new CList <int> {
            };
            int new1Int       = 1;
            int new2Int       = 2;
            int new3Int       = 3;
            int new4Int       = 4;
            int new5Int       = 5;
            int new6Int       = 6;

            list1.Add(new1Int);
            list1.Add(new2Int);
            list1.Add(new3Int);
            list2.Add(new4Int);
            list2.Add(new5Int);
            list2.Add(new6Int);
            //act
            string      test1String = list1.ToString();
            string      test2String = list2.ToString();
            CList <int> list3       = list1 - list2;
            string      test3String = list3.ToString();

            //assert
            Assert.AreEqual(test3String, test1String);
        }
예제 #11
0
        /// <summary>
        /// 过滤查找
        /// </summary>
        public void FilterSearch()
        {
            String sText = m_searchTextBox.Text.ToUpper();

            m_grid.BeginUpdate();
            m_grid.ClearRows();
            int row = 0;
            CList <GSecurity> securities = SecurityService.FilterCode(sText);

            if (securities != null)
            {
                int rowCount = securities.size();
                for (int i = 0; i < rowCount; i++)
                {
                    GSecurity security = securities.get(i);
                    GridRow   gridRow  = new GridRow();
                    m_grid.AddRow(gridRow);
                    gridRow.AddCell(0, new GridStringCell(security.m_code));
                    gridRow.AddCell(1, new GridStringCell(security.m_name));
                    row++;
                }
            }
            securities.Dispose();
            m_grid.EndUpdate();
        }
예제 #12
0
        public void StoreListTestMethod()
        {
            //arrange
            CList <CList <string> > storeValueList = new CList <CList <string> >();

            CList <string> stringList = new CList <string>();

            stringList.Add("this");
            stringList.Add("is");
            stringList.Add("a");
            stringList.Add("test");

            CList <string> stringOfNumbers = new CList <string>();

            stringOfNumbers.Add("1");
            stringOfNumbers.Add("2");
            stringOfNumbers.Add("3");
            stringOfNumbers.Add("4");

            //act
            storeValueList.Add(stringList);
            storeValueList.Add(stringOfNumbers);

            //assert
            Assert.AreSame(stringList, storeValueList[0]);
            Assert.AreSame(stringOfNumbers, storeValueList[1]);
        }
예제 #13
0
    public static CList Cons(CList l, CList r)
    {
	CList newlist = new CList(l);
	for(int i = 0; i < r.Count; i++)
	    newlist.la.Add(r.la[i]);
	return newlist;
    }
예제 #14
0
        public void Reduce2ListsWIthInt_PositiveTest_Different1List()
        {
            //arrange
            CList <string> list1 = new CList <string> {
            };
            CList <string> list2 = new CList <string> {
            };
            string new1String    = "1";
            string new2String    = "2";
            string new3String    = "3";
            string new4String    = "4";
            string new5String    = "5";
            string new6String    = "6";

            list1.Add(new1String);
            list1.Add(new2String);
            list1.Add(new3String);
            list2.Add(new4String);
            list2.Add(new5String);
            list2.Add(new6String);
            //act
            string         test1Int = list1.ToString();
            string         test2Int = list2.ToString();
            CList <string> list3    = list1 - list2;
            string         test3Int = list3.ToString();

            //assert
            Assert.AreEqual(test3Int, test1Int);
        }
예제 #15
0
        public void StoreValueTestMethod()
        {
            //arrange
            CList <int> storeValueList = new CList <int>();

            //act
            storeValueList.Add(9);
            storeValueList.Add(8);
            storeValueList.Add(7);
            storeValueList.Add(6);
            storeValueList.Add(5);
            storeValueList.Add(4);
            storeValueList.Add(3);
            storeValueList.Add(2);
            storeValueList.Add(1);
            storeValueList.Add(0);
            //assert
            Assert.AreEqual(9, storeValueList[0]);
            Assert.AreEqual(8, storeValueList[1]);
            Assert.AreEqual(7, storeValueList[2]);
            Assert.AreEqual(6, storeValueList[3]);
            Assert.AreEqual(5, storeValueList[4]);
            Assert.AreEqual(4, storeValueList[5]);
            Assert.AreEqual(3, storeValueList[6]);
            Assert.AreEqual(2, storeValueList[7]);
            Assert.AreEqual(1, storeValueList[8]);
            Assert.AreEqual(0, storeValueList[9]);
        }
    public static CList ToList(int Val)
    {
        CList c = new CList();

        c.la.Add(Convert.ToString(Val));
        return(c);
    }
예제 #17
0
        public void Zip2Lines_PositiveZip_CorrectCount()
        {
            //arrange
            CList <int> list1 = new CList <int> {
            };
            CList <int> list2 = new CList <int> {
            };
            int new1Int       = 1;
            int new2Int       = 2;
            int new3Int       = 3;
            int new4Int       = 4;
            int new5Int       = 5;
            int new6Int       = 6;

            list1.Add(new1Int);
            list1.Add(new2Int);
            list1.Add(new3Int);
            list2.Add(new4Int);
            list2.Add(new5Int);
            list2.Add(new6Int);
            //act
            CList <int> list3      = list1.Zip(list2);
            string      testString = list3.ToString();

            //assert
            Assert.AreEqual(list3.Count, 6);
        }
예제 #18
0
 public Command(CList com, byte[] data)
 {
     this.controlCRC = CRC(data);
     this.idCommand  = com;
     this.length     = data.Length;
     this.data       = data;
 }
예제 #19
0
        public void PlusOperatorTestMethod()
        {
            //arrange
            CList <int> storedValues     = new CList <int>();
            CList <int> additionalValues = new CList <int>();
            CList <int> combinedValues   = new CList <int>();
            CList <int> testValues       = new CList <int>();

            storedValues.Add(0);
            storedValues.Add(1);
            storedValues.Add(2);

            additionalValues.Add(3);
            additionalValues.Add(4);
            additionalValues.Add(5);

            testValues.Add(0);
            testValues.Add(1);
            testValues.Add(2);
            testValues.Add(3);
            testValues.Add(4);
            testValues.Add(5);

            //act

            combinedValues = storedValues + additionalValues;

            //assert
            Assert.AreEqual(testValues[0], combinedValues[0]);
            Assert.AreEqual(testValues[5], combinedValues[5]);
            Assert.AreEqual(testValues[9], combinedValues[9]);
            Assert.AreEqual(testValues.count, combinedValues.count);
            Assert.AreEqual(testValues.capacity, testValues.capacity);
        }
예제 #20
0
        /// <summary>
        /// 加载证券
        /// </summary>
        private void Load()
        {
            //预创建内存
            m_securities.set_capacity(200);
            for (int i = 0; i < 200; i++)
            {
                CList <Security> list = new CList <Security>();
                m_securities.push_back(list);
            }
            int securitiesSize = m_securitiesCache.Count;

            int[] capacities = new int[1000];
            for (int i = 0; i < securitiesSize; i++)
            {
                Security security = m_securitiesCache[i];
                capacities[security.m_type] = capacities[security.m_type] + 1;
            }
            for (int i = 0; i < 200; i++)
            {
                CList <Security> list = m_securities.get(i);
                list.set_capacity(capacities[i]);
            }
            for (int i = 0; i < securitiesSize; i++)
            {
                Security security = m_securitiesCache[i];
                m_securities.get(security.m_type).push_back(security);
                m_securitiesMap[security.m_code.ToUpper()] = security;
            }
            m_securitiesCache.Clear();
            m_loaded   = true;
            capacities = null;
            System.GC.Collect();
        }
예제 #21
0
        public void Zip2Lines_PositiveZip_CorrectStringOrder()
        {
            //arrange
            CList <string> list1 = new CList <string> {
            };
            CList <string> list2 = new CList <string> {
            };
            string new1String    = "1";
            string new2String    = "2";
            string new3String    = "3";
            string new4String    = "4";
            string new5String    = "5";
            string new6String    = "6";

            list1.Add(new1String);
            list1.Add(new2String);
            list1.Add(new3String);
            list2.Add(new4String);
            list2.Add(new5String);
            list2.Add(new6String);
            //act
            CList <string> list3      = list1.Zip(list2);
            string         testString = list3.ToString();

            //assert
            Assert.AreEqual("142536", testString);
        }
예제 #22
0
        static void Main(String[] args)
        {
            CList <CTest> l = new CList <CTest>();

            l.Add(new CTest());
            l.Add(new CTest());
            l.Add(new CTest());
            l.Remove(2);
            l.Remove(1);

            var i = l.Add(new CTest());
            var v = i.Index;



            l.AddAt(1, new CTest());
            l.AddAt(2, new CTest());
            l.AddAt(0, new CTest());
            l.Remove(1);
            var i0 = l.Get(0);


            var i1 = l.Get(1);

            if (i1)
            {
                Console.WriteLine("i1");
            }

            var i2 = l.Get(2);
            var i3 = l.Get(3);

            Console.WriteLine("end");
        }
예제 #23
0
        public void ListToStringTestMethod()
        {
            //arrange
            CList <CList <string> > storedList    = new CList <CList <string> >();
            CList <string>          storedInts    = new CList <string>();
            CList <string>          storedStrings = new CList <string>();
            string testString;
            string resultString;

            storedInts.Add("1");
            storedInts.Add("2");
            storedInts.Add("3");
            storedInts.Add("4");
            storedInts.Add("5");

            storedStrings.Add("This");
            storedStrings.Add("Is");
            storedStrings.Add("A");
            storedStrings.Add("Test");
            storedStrings.Add(".");

            storedList.Add(storedInts);
            storedList.Add(storedStrings);

            testString = "1,2,3,4,5,This,Is,A,Test,.";

            //act
            resultString = storedList.ToString();
            //assert
            Assert.AreEqual(testString, resultString);
        }
        public async CTask Do()
        {
            Console.WriteLine("TRAVEL AGENT - Workflow Initialized");
            var compensatingActions = new CList <Func <CTask> >();

            try
            {
                var reservationId = await BankConnection.ReserveFunds(1_000, "1234-1234-1234-1234");

                compensatingActions.Add(() => BankConnection.CancelReservation(reservationId));
                var carBookingId = await AirlineConnection.Book("Mazda 2 Sport");

                compensatingActions.Add(() => AirlineConnection.CancelBooking(carBookingId));
                var hotelBookingId = await HotelConnection.Book("Hotel Dangleterre Suite");

                compensatingActions.Add(() => HotelConnection.CancelBooking(hotelBookingId));
                await BankConnection.DeductFunds(reservationId);
            }
            catch (Exception)
            {
                compensatingActions.ForEach(a => a());
                throw;
            }

            Console.WriteLine("TRAVEL AGENT - Workflow completed!");
        }
예제 #25
0
    public static void Main()
    {
        var list2 = new CList <int>();

        list2.Add(1000);
        list2.Add(2000);
        Console.WriteLine(list2.ToString());
    }
예제 #26
0
		public static bool ReadVariables(string FileName, Circuit owner)
		{
			Dictionary<string,double> CList;
			string[] words,keys;
			string line = "";
			char[] delimiterChars = { ' ', ',', '\t' };
			double val = 0;
			
			
			if(owner == null)
				CList = Program.Globals;
			else
				CList = ((composite)owner).Locals;
		
			Console.WriteLine("\n   Reading variables from {0}:", FileName);
			StreamReader reader = new StreamReader(FileName);
            if (!StringReader.FindString("<variables>", reader)){
                Console.WriteLine("WARNING! Variable list is missing.");
				reader.Dispose();
                return true;
            }
			
			while ((line = reader.ReadLine()) != null){
				line = line.Trim();
                words = StringReader.TrimWords(line.Split(delimiterChars));//read the type and the name
				
				#region "check for empty/terminator lines"
                if (line.StartsWith("<end>")) //finish at the end of group
                    break;
                if (line.StartsWith("#") || line.Length == 0 || words.Length == 0 ) //ignore empty lines/comments/timer
                    continue;
				#endregion
			
				#region "parse the line"
				for(int i=0;i<words.Length;i++){
					keys = StringReader.TrimWords(words[i].Split('=')); //divide the string,
					if(keys.Length != 2){
						Console.WriteLine("ERROR! Expected varible=value pair.");
						return false;
					}
					//now we have a pair of strings... the second must be a number!
					if(!double.TryParse(keys[1], out val)){
						Console.WriteLine("ERROR! Value of variable {0} is not a number.",keys[0]);
						return false;
					}
					//now check if the variable was already declared
					if(CList.ContainsKey(keys[0])){
						Console.WriteLine("ERROR! Variable {0} was already declared.",keys[0]);
						return false;
					}
					
					CList.Add(keys[0],val);	
				}
				#endregion
			}
				
			return true;
		}
예제 #27
0
 /// <summary>
 /// 过滤证券数据
 /// </summary>
 /// <param name="key">关键字</param>
 /// <param name="securities">证券数据列表</param>
 /// <returns>状态</returns>
 public bool FilterSecurities(String key, CList <Security> securities)
 {
     if (!m_loaded)
     {
         return(false);
     }
     Find(key, 10, securities);
     return(true);
 }
예제 #28
0
 public CharacterList(PacketIn packet)
 {
     packet.Seek( 6, System.IO.SeekOrigin.Current );
     nCount = packet.ReadInt16();
     nList = new CList[nCount];
     for ( int i = 0; i < nCount; i++ ) {
         nList[i] = new CList( packet );
     }
 }
예제 #29
0
    public static CList Cdr(CList l)
    {
	if (l.la.Count == 0)
	    return new CList();
	
	CList newlist = new CList(l);
	newlist.la.RemoveRange(0, 1);
	return newlist;
    }
        public void AddAndRemoveNonReferencingElementsFromCList()
        {
            var storage = new InMemoryStorageEngine();
            var os      = ObjectStore2.New(storage);

            var cList = new CList <string>();

            cList.Add("hello");
            cList.Add("world");
            cList.Add("from here");

            os.Roots.Entangle(cList);
            os.Persist();

            os    = ObjectStore2.Load(storage);
            cList = os.Roots.Find <CList <string> >();
            cList.Count.ShouldBe(3);
            cList[0].ShouldBe("hello");
            cList[1].ShouldBe("world");
            cList[2].ShouldBe("from here");

            cList.Remove(0);

            os.Persist();

            os    = ObjectStore2.Load(storage);
            cList = os.Roots.Find <CList <string> >();
            cList.Count.ShouldBe(2);
            cList[0].ShouldBe("world");
            cList[1].ShouldBe("from here");
            cList.Remove(1);

            os.Persist();

            os    = ObjectStore2.Load(storage);
            cList = os.Roots.Find <CList <string> >();
            cList.Count.ShouldBe(1);
            cList[0].ShouldBe("world");
            cList.Add("hello");

            os.Persist();

            os    = ObjectStore2.Load(storage);
            cList = os.Roots.Find <CList <string> >();
            cList.Count.ShouldBe(2);
            cList[0].ShouldBe("world");
            cList[1].ShouldBe("hello");

            cList.Remove(0);
            cList.Remove(0);

            os.Persist();

            os    = ObjectStore2.Load(storage);
            cList = os.Roots.Find <CList <string> >();
            cList.Count.ShouldBe(0);
        }
        public void InsertAndRemoveAgainAndAgain()
        {
            var l = new CList <int>();

            for (var i = 0; i < 50; i++)
            {
                l.Add(i);
            }
        }
예제 #32
0
        public void TestListCtor()
        {
            CList <int> l1 = new CList <int>();

            for (int i = 1; i <= 10; i++)
            {
                l1.Append(i);
            }
            Assert.AreEqual(l1.Length, 10);
        }
    public static CList Cons(CList l, CList r)
    {
        CList newlist = new CList(l);

        for (int i = 0; i < r.Count; i++)
        {
            newlist.la.Add(r.la[i]);
        }
        return(newlist);
    }
예제 #34
0
    public static CList Car(CList l)
    {
	if (l.la.Count == 0)
	    return new CList();
	if (l.la[0] is CList)
	    return (CList)l.la[0];
	CList newlist = new CList();
	newlist.Add(l.la[0]);
	return newlist;
    }
예제 #35
0
    private static CList InitMultiple(String str, ref int index)
    {
	CList newList = new CList();
	//String tempstr = str.SubString(1);
	//tempstr = str.SubString(0, str.Length - 1);
	String temp = null;
	bool InState = false;
	index++;
	
	while (index < str.Length){
	    if(Char.IsWhiteSpace(str[index])){
		if (InState){
		    newList.Add(temp);
		    temp = null;
		}
		index++;
		InState = false;
	    }
	    else if(str[index] == '('){
		newList.Add(InitMultiple(str, ref index));
	    }
	    else if(str[index] == ')'){
		if(InState)
		    newList.Add(temp);
		index++;
		return newList;
	    }
	    else{
		InState = true;
		temp = temp + str[index];
		index++;
	    }
	}
	Console.WriteLine("IlFormed Parens");
	return null;
    }
예제 #36
0
    public static CList Init(String item)
    {
	CList newlist = new CList();
	int index = 0;

	if (item.CompareTo(String.Empty) == 0)
	    return newlist;                 //Empty CList is NIL
	if(item[0] == '('){
	    return InitMultiple(item, ref index);
	}
	else
	    newlist.Add(item);

	return newlist;
    }
예제 #37
0
    public static void Print(CList item)
    {
	if (item.Count == 0){
	    Console.Write("NIL");
	    return;
	}
	
	if(item.Count > 1){
	    Console.Write("(");
	    for (int i = 0; i < item.Count; i++){
		if (item.la[i] is CList)
		    Print((CList)item.la[i]);
		else
		    Console.Write((String)item.la[i]);
		if (i < item.Count - 1)
		    Console.Write(" ");
	    }
	    Console.Write(")");
	}
	else{
	    if(item.la[0] is CList)
		Print((CList)item.la[0]);
	    else
		Console.Write((String)item.la[0]);
	}
     
    }
예제 #38
0
    public static CList Subst(CList r, CList f, CList exp)
    {
	String rstr = (String)r.la[0];
	String fstr = (String)f.la[0];
	
	for (int i = 0; i < exp.la.Count; i++){
	    if (exp.la[i] is CList){
		exp.la[i] = Subst(r, f, (CList)exp.la[i]);
	    }
	    else if (exp.la[i] is String)
		if(((String)exp.la[i]).CompareTo(fstr) == 0){
		    exp.la[i] = rstr;
		}
	}
	return exp;
    }
예제 #39
0
    public static bool IsNull(CList value)
    {
	return (value.Count == 0);
    }
예제 #40
0
    public static bool IsAtom(CList value)
    {
	return (value.Count == 1);
    }
예제 #41
0
    public CList(CList l)
    {
	la = new ArrayList(l.la);
    }
예제 #42
0
    public static CList ToList(int Val)
    {
	CList c = new CList();
	c.la.Add(Convert.ToString(Val));
	return c;
    }
예제 #43
0
    public static int ToInt(CList l)
    {
	if (l.la.Count == 0)
	    Console.WriteLine("Somethings wrong");
	
	if (l.la[0] is String){
	    try {
		return Convert.ToInt32((String)l.la[0]);
	    }
	    catch(FormatException ){
		return 0;
	    }
	}
	else{
	    Console.WriteLine("Runtime Error 1: Cannot Convert to Int");
	    return 0;
	}
    }