public void Test_ObservableCollection_Enumerator()
 {
     var list = new ObservableCollection<int>() { 4, 5, 6 };
     Assert.NotNull(list.GetEnumerator());
     var enumerable = list as IEnumerable;
     Assert.NotNull(enumerable);
     Assert.NotNull(enumerable.GetEnumerator());
 }
        public static void GetEnumeratorTest()
        {
            Guid[] anArray = { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            ObservableCollection<Guid> col = new ObservableCollection<Guid>((IEnumerable<Guid>)anArray);

            int i = 0;
            IEnumerator<Guid> e;
            for (e = col.GetEnumerator(); e.MoveNext(); ++i)
            {
                Assert.Equal(anArray[i], e.Current);
            }
            Assert.Equal(col.Count, i);
            e.Dispose();
        }
Exemple #3
0
        public bool SendJournalList()
        {
            lock (this)
            {
                try
                {

                    var l1 = JournalData.OrderBy(st => st.ID).ToList();
                    ObservableCollection<JournalContentData> d = new ObservableCollection<JournalContentData>(l1);
                    IEnumerator clientEnumerator = d.GetEnumerator();
                    StringBuilder str = new StringBuilder();
                    int count = 0;
                    while (clientEnumerator.MoveNext())
                    {
                        JournalContentData entry = (JournalContentData)clientEnumerator.Current;
                        if (entry.ID > 0)
                        {
                            str.Append(entry.ID + "-" + entry.ModifyDate + "-" + entry.Date + ";");
                            count++;
                            if (count == 10)
                            {
                                ResponsePacket pck = new OETS.Shared.ResponsePacket(Client.Instance.User, "SSocketServer",
                                    new Smc(Smc.ServiceProviderEnum.TripleDES).Encrypt(str.ToString()));
                                Client.Instance.SendCommand(Client.Instance.ServerIp, OpcoDes.CMSG_GETTING_JOURNAL, pck.GetType().FullName, pck);
                                count = 0;
                                str.Remove(0, str.Length);
                            }
                        }
                    }
                    if (str.Length >= 0)
                    {
                        ResponsePacket pck = new ResponsePacket(Client.Instance.User, "SSocketServer",
                                    new Smc(Smc.ServiceProviderEnum.TripleDES).Encrypt(str.ToString()));
                        Client.Instance.SendCommand(Client.Instance.ServerIp, OpcoDes.CMSG_GETTING_JOURNAL, pck.GetType().FullName, pck);
                        count = 0;
                        str.Remove(0, str.Length);
                    }
                    Trace.Write("[OETS.Client] [SendJournalList] All sended!");
                    return true;
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.Message);
                    return false;
                }
            }
        }
Exemple #4
0
 public bool SendJournalIds()
 {
     var l1 = JournalData.OrderBy(st => st.ID).ToList();
     ObservableCollection<JournalContentData> d = new ObservableCollection<JournalContentData>(l1);
     IEnumerator clientEnumerator = d.GetEnumerator();
     StringBuilder str = new StringBuilder();
     while (clientEnumerator.MoveNext())
     {
         //DictionaryEntry data = (DictionaryEntry)clientEnumerator.Current;
         JournalContentData entry = (JournalContentData)clientEnumerator.Current;
         if (entry.ID > 0)
             str.Append(entry.ID + ";");
     }
     if (str.Length >= 0)
     {
         ResponsePacket pck = new ResponsePacket(Client.Instance.User, "SSocketServer",
                     new Smc(Smc.ServiceProviderEnum.TripleDES).Encrypt(str.ToString()));
         Client.Instance.SendCommand(Client.Instance.ServerIp, OpcoDes.CMSG_GETTING_JOURNAL_2,
             pck.GetType().FullName, pck);
     }
     Trace.Write("[OETS.Client] [SendJournalIds] All sended!");
     return true;
 }
Exemple #5
0
 public String GetJournalEntriesIds()
 {
     var l1 = JournalData.OrderBy(st => st.ID).ToList();
     ObservableCollection<JournalContentData> d = new ObservableCollection<JournalContentData>(l1);
     IEnumerator jeEnumerator = d.GetEnumerator();
     StringBuilder str = new StringBuilder();
     while (jeEnumerator.MoveNext())
     {
         JournalContentData entry = (JournalContentData)jeEnumerator.Current;
         if (entry.ID > 0)
             str.Append(entry.ID + "-" + entry.ModifyDate + "-" + entry.Date + ";");
     }
     return str.ToString();
 }