Example #1
0
 // We write variables below, but these should be local variables for each method.
 public void WriteVariables()
 {
     IDictionaryEnumerator e = strings.GetEnumerator();
     e.Reset();
     while (e.MoveNext())
     {
         Indent();
         String var = (String)e.Key;
         stream.WriteLine("String " + var + " = null;");
     }
     e = variables.GetEnumerator();
     e.Reset();
     while (e.MoveNext())
     {
         Indent();
         String var = (String)e.Key;
         stream.WriteLine("?? " + var + " = ??;");
     }
     e = arrays.GetEnumerator();
     e.Reset();
     while (e.MoveNext())
     {
         Indent();
         String var = (String)e.Key;
         stream.WriteLine("??[] " + var + " = new ??[??];");
     }
     e = arrays_2d.GetEnumerator();
     e.Reset();
     while (e.MoveNext())
     {
         Indent();
         String var = (String)e.Key;
         stream.WriteLine("??[][] " + var + " = new ??[??][??];");
     }
 }
Example #2
0
        public static void GetEnumerator_IDictionaryEnumerator_Invalid()
        {
            MyDictionary          dictBase   = CreateDictionary(100);
            IDictionaryEnumerator enumerator = dictBase.GetEnumerator();

            // Index < 0
            Assert.Throws <InvalidOperationException>(() => enumerator.Current);
            Assert.Throws <InvalidOperationException>(() => enumerator.Entry);
            Assert.Throws <InvalidOperationException>(() => enumerator.Key);
            Assert.Throws <InvalidOperationException>(() => enumerator.Value);

            // Index > dictionary.Count
            while (enumerator.MoveNext())
            {
                ;
            }
            Assert.False(enumerator.MoveNext());
            Assert.Throws <InvalidOperationException>(() => enumerator.Current);
            Assert.Throws <InvalidOperationException>(() => enumerator.Entry);
            Assert.Throws <InvalidOperationException>(() => enumerator.Key);
            Assert.Throws <InvalidOperationException>(() => enumerator.Value);

            // Current throws after resetting
            enumerator.Reset();
            Assert.True(enumerator.MoveNext());

            enumerator.Reset();
            Assert.Throws <InvalidOperationException>(() => enumerator.Current);
            Assert.Throws <InvalidOperationException>(() => enumerator.Entry);
            Assert.Throws <InvalidOperationException>(() => enumerator.Key);
            Assert.Throws <InvalidOperationException>(() => enumerator.Value);
        }
Example #3
0
        public static void GetEnumeratorTest(ListDictionary ld, KeyValuePair <string, string>[] data)
        {
            bool repeat = true;
            IDictionaryEnumerator enumerator = ld.GetEnumerator();

            Assert.NotNull(enumerator);
            while (repeat)
            {
                Assert.Throws <InvalidOperationException>(() => enumerator.Current);
                foreach (KeyValuePair <string, string> element in data)
                {
                    Assert.True(enumerator.MoveNext());
                    DictionaryEntry entry = (DictionaryEntry)enumerator.Current;
                    Assert.Equal(entry, enumerator.Current);
                    Assert.Equal(element.Key, entry.Key);
                    Assert.Equal(element.Value, entry.Value);
                    Assert.Equal(element.Key, enumerator.Key);
                    Assert.Equal(element.Value, enumerator.Value);
                }
                Assert.False(enumerator.MoveNext());
                Assert.Throws <InvalidOperationException>(() => enumerator.Current);
                Assert.False(enumerator.MoveNext());

                enumerator.Reset();
                enumerator.Reset();
                repeat = false;
            }
        }
Example #4
0
        /// <summary>
        /// Serializes the specified o.
        /// </summary>
        /// <param name="o">The o.</param>
        /// <param name="sb">The sb.</param>
        public override void Serialize(object o, StringBuilder sb)
        {
            IDictionary dic = o as IDictionary;

            if (dic == null)
            {
                throw new NotSupportedException();
            }

            Type t = o.GetType();
            IDictionaryEnumerator enumerable = dic.GetEnumerator();

            enumerable.Reset();
            bool b = true;

            sb.Append("{");
            sb.Append("\"keys\":[");

            while (enumerable.MoveNext())
            {
                if (b)
                {
                    b = false;
                }
                else
                {
                    sb.Append(",");
                }

                sb.Append(JavaScriptSerializer.Serialize(enumerable.Key));
            }
            sb.Append("],\"values\":[");

            enumerable.Reset();
            b = true;
            while (enumerable.MoveNext())
            {
                if (b)
                {
                    b = false;
                }
                else
                {
                    sb.Append(",");
                }

                sb.Append(JavaScriptSerializer.Serialize(enumerable.Value));
            }
            sb.Append("],\"__type\":");
            JavaScriptUtil.QuoteString(t.AssemblyQualifiedName, sb);
            sb.Append("}");
        }
        public void IDictionary_NonGeneric_IDictionaryEnumerator_Reset_BeforeIteration_Support(int count)
        {
            IDictionaryEnumerator enumerator = NonGenericIDictionaryFactory(count).GetEnumerator();

            if (ResetImplemented)
            {
                enumerator.Reset();
            }
            else
            {
                Assert.Throws <NotSupportedException>(() => enumerator.Reset());
            }
        }
Example #6
0
        public void testPofWriterWriteUniformDictionaryWithNulls()
        {
            var col1 = new Hashtable();
            var col2 = new Hashtable();

            col1.Add((Int16)0, "A");
            col1.Add((Int16)1, "Z");
            col1.Add((Int16)2, "7");
            col1.Add((Int16)3, null);

            col2.Add(5, 32);
            col2.Add(10, Int32.MinValue);
            col2.Add(15, Int32.MaxValue);
            col2.Add(20, null);

            initPOFWriter();
            pofwriter.WriteDictionary(0, col1, typeof(Int16), typeof(String));
            pofwriter.WriteDictionary(0, col2, typeof(Int32), typeof(Int32));
            pofwriter.WriteDate(0, new DateTime(2006, 8, 8));

            initPOFReader();
            IDictionary rcol1 = pofreader.ReadDictionary(0, new Hashtable(3));
            IDictionary rcol2 = pofreader.ReadDictionary(0, new Hashtable(3));

            // compare col1 with result 1
            IDictionaryEnumerator denum = col1.GetEnumerator();

            denum.Reset();
            foreach (DictionaryEntry entryr in rcol1)
            {
                denum.MoveNext();
                DictionaryEntry entry = denum.Entry;
                Assert.AreEqual(entryr.Key, entry.Key);
                Assert.AreEqual(entryr.Value, entry.Value);
            }

            // compare col2 with result 2
            denum = col2.GetEnumerator();
            denum.Reset();
            foreach (DictionaryEntry entryr in rcol2)
            {
                denum.MoveNext();
                DictionaryEntry entry = denum.Entry;
                Assert.AreEqual(entryr.Key, entry.Key);
                Assert.AreEqual(entryr.Value, entry.Value);
            }

            pofreader.ReadDictionary(0, null);
        }
Example #7
0
        protected void gvClients_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            dsData = Session["ClientData"] as DataSet;
            ASPxGridView gridView = sender as ASPxGridView;
            DataRow      row      = dsData.Tables[0].NewRow();
            Random       rd       = new Random();

            e.NewValues["CaseDescriptionId"] = rd.Next();
            e.NewValues["CreatedBy"]         = Master.LoggedUser.UserId.Value;


            IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator();

            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                if (enumerator.Key.ToString() != "Count")
                {
                    row[enumerator.Key.ToString()] = enumerator.Value == null ? DBNull.Value : enumerator.Value;
                }
            }
            gridView.CancelEdit();
            e.Cancel = true;

            dsData.Tables[0].Rows.Add(row);
            Session["ClientData"] = dsData;
        }
        void SaveDesktopItemsCache()
        {
            Log <DesktopItemService> .Debug("Saving desktop item cache '{0}'.", DockyDesktopFileCacheFile);

            try {
                using (StreamWriter writer = new StreamWriter(DockyDesktopFileCacheFile, false)) {
                    foreach (DesktopItem item in RegisteredItems)
                    {
                        writer.WriteLine("[{0}]", item.Path);
                        IDictionaryEnumerator enumerator = item.Values.GetEnumerator();
                        enumerator.Reset();
                        while (enumerator.MoveNext())
                        {
                            writer.WriteLine("{0}={1}", enumerator.Key, enumerator.Value);
                        }
                        writer.WriteLine("");
                    }
                    writer.Close();
                }
            } catch (Exception e) {
                Log <DesktopItemService> .Error("Error saving desktop item cache: {0}", e.Message);

                Log <DesktopItemService> .Error(e.StackTrace);
            }
        }
Example #9
0
        protected void gvRatePlan_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            dsData = Session[Constants.SESSION_ROOMRATEPLAN] as DataSet;
            ASPxGridView gridView = sender as ASPxGridView;
            DataRow      row      = dsData.Tables[0].NewRow();
            Random       rd       = new Random();

            e.NewValues["RoomRatePlanId"] = rd.Next();
            e.NewValues["CreatedUser"]    = SessionHandler.LoggedUser.UsersId;
            e.NewValues["RoomId"]         = cmbRooms.Value;

            IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator();

            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                if (enumerator.Key.ToString() != "Count")
                {
                    row[enumerator.Key.ToString()] = enumerator.Value == null ? DBNull.Value : enumerator.Value;
                }
            }
            gridView.CancelEdit();
            e.Cancel = true;

            dsData.Tables[0].Rows.Add(row);

            if (new RoomRatePlanDAO().InsertUpdateDelete(dsData))
            {
                this.LoadRoomRatePlan();
            }
        }
    static void Main()
    {
        // Create a hash table.
        Hashtable ht = new Hashtable();

        // Add elements to the table.
        ht.Add("Tom", "555–3456");
        ht.Add("Mary", "555–9876");
        ht.Add("Todd", "555–3452");
        ht.Add("Ken", "555–7756");

        // Demonstrate enumerator.
        IDictionaryEnumerator etr = ht.GetEnumerator();

        Console.WriteLine("Display info using Entry.");
        while (etr.MoveNext())
        {
            Console.WriteLine(etr.Entry.Key + ": " + etr.Entry.Value);
        }
        Console.WriteLine();

        Console.WriteLine("Display info using Key and Value directly.");
        etr.Reset();
        while (etr.MoveNext())
        {
            Console.WriteLine(etr.Key + ": " + etr.Value);
        }
    }
Example #11
0
        public void RetrieveStatistics_GetEnumerator_Success()
        {
            IDictionary d = new SqlConnection().RetrieveStatistics();

            IDictionaryEnumerator e = d.GetEnumerator();

            Assert.NotNull(e);
            Assert.NotSame(e, d.GetEnumerator());

            for (int i = 0; i < 2; i++)
            {
                Assert.Throws <InvalidOperationException>(() => e.Current);

                foreach (string ignored in s_retrieveStatisticsKeys)
                {
                    Assert.True(e.MoveNext());

                    Assert.NotNull(e.Current);
                    Assert.NotNull(e.Entry.Key);
                    Assert.NotNull(e.Entry.Value);

                    Assert.Equal(e.Current, e.Entry);
                    Assert.Same(e.Key, e.Entry.Key);
                    Assert.Same(e.Value, e.Entry.Value);
                }

                Assert.False(e.MoveNext());
                Assert.False(e.MoveNext());
                Assert.False(e.MoveNext());

                Assert.Throws <InvalidOperationException>(() => e.Current);

                e.Reset();
            }
        }
    public static void Main()
    {
        // Create a hash table.
        Hashtable ht = new Hashtable();

        // Add elements to the table
        ht.Add("A", "3");
        ht.Add("B", "9");
        ht.Add("C", "3");
        ht.Add("D", "7");

        // Demonstrate enumerator
        IDictionaryEnumerator etr = ht.GetEnumerator();

        Console.WriteLine("Display info using Entry.");
        while (etr.MoveNext())
        {
            Console.WriteLine(etr.Entry.Key + ": " +
                              etr.Entry.Value);
        }

        Console.WriteLine();

        Console.WriteLine("Display info using Key and Value directly.");
        etr.Reset();
        while (etr.MoveNext())
        {
            Console.WriteLine(etr.Key + ": " +
                              etr.Value);
        }
    }
Example #13
0
        //SERIALIZACAO: A classe XMLSerializer irá usar este metodo para pegar um item para serializar no xml.
        public DictionaryEntry this[int index]
        {
            get
            {
                if (_enumerator == null)  // lazy
                {
                    _enumerator = _hashTable.GetEnumerator();
                }

                // Acessar um item cuja a posicao seja anterior a ultima recebida é anormal,
                // pois o XMLSerializaer irá chamar este metodo varias vezes, passando o indice
                // de forma crescente.
                // Mas, caso isso aconteça, então é necessario chamar o Reset() do enumerator
                // pois ele trabalha 'forward-only'.
                if (index < _position)
                {
                    _enumerator.Reset();
                    _position = -1;
                }

                while (_position < index)
                {
                    _enumerator.MoveNext();
                    _position++;
                }
                return(_enumerator.Entry);
            }
        }
        public void RemoveJoin(String fromTable, String joinTable, String type)
        {
            String key = fromTable + " " + type + " " + joinTable;

            Dictionary <String, String> tempDictionary = new Dictionary <String, String>(onDictionary);
            IDictionaryEnumerator       enumerator     = tempDictionary.GetEnumerator();

            enumerator.Reset();

            if (!(fromTable.Equals("") || joinTable.Equals("") || type.Equals("")))
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Key.ToString().Contains(key))
                    {
                        onDictionary.Remove(enumerator.Key.ToString());
                    }
                }

                joinDictionary.Remove(key);
            }
            else
            {
                throw new Exception("Missing Required Field");
            }
        }
Example #15
0
        private void btnDeleteNew_Click(object sender, EventArgs e)
        {
            if (ControlTreeNew.AllNodesCount == 0)
            {
                return;
            }

            if (XtraMessageBox.Show("Bạn có chắc bạn muốn xóa các hàng đã chọn trong cây mới?", "Xác nhận xóa", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                ControlTreeNew.LockReloadNodes();

                try
                {
                    Hashtable             sel   = GetNodesNewForDeleting();
                    IDictionaryEnumerator nodes = sel.GetEnumerator();
                    nodes.Reset();

                    while (nodes.MoveNext())
                    {
                        ControlTreeNew.DeleteNode((DevExpress.XtraTreeList.Nodes.TreeListNode)nodes.Value);
                    }
                }
                finally
                {
                    ControlTreeNew.UnlockReloadNodes();
                }
            }
        }
Example #16
0
        internal Array TableToArray(object luaParamValue, Type paramArrayType)
        {
            Array paramArray;

            if (luaParamValue is LuaTable)
            {
                LuaTable table = (LuaTable)luaParamValue;
                IDictionaryEnumerator tableEnumerator = table.GetEnumerator();
                tableEnumerator.Reset();
                paramArray = Array.CreateInstance(paramArrayType, table.Values.Count);

                int paramArrayIndex = 0;

                while (tableEnumerator.MoveNext())
                {
                    object o = tableEnumerator.Value;
                    if (paramArrayType == typeof(object))
                    {
                        if (o != null && o.GetType() == typeof(double) && IsInteger((double)o))
                        {
                            o = Convert.ToInt32((double)o);
                        }
                    }
                    paramArray.SetValue(Convert.ChangeType(o, paramArrayType), paramArrayIndex);
                    paramArrayIndex++;
                }
            }
            else
            {
                paramArray = Array.CreateInstance(paramArrayType, 1);
                paramArray.SetValue(luaParamValue, 0);
            }

            return(paramArray);
        }
        public String GetOnClause(String join)
        {
            IDictionaryEnumerator enumerator = onDictionary.GetEnumerator();
            String onClause = "";

            enumerator.Reset();

            while (enumerator.MoveNext())
            {
                if (enumerator.Key.ToString().Contains(join))
                {
                    onClause = "ON " + enumerator.Value;

                    while (enumerator.MoveNext())
                    {
                        if (enumerator.Key.ToString().Contains(join))
                        {
                            if (enumerator.Value.ToString().StartsWith("OR "))
                            {
                                onClause = onClause + Environment.NewLine + enumerator.Value;
                            }
                            else
                            {
                                onClause = onClause + Environment.NewLine + "AND " + enumerator.Value;
                            }
                        }
                    }
                }
            }

            return(onClause);
        }
Example #18
0
        public String GetFromClause()
        {
            String fromClause = joinBuilder.GetStatement();

            if (fromClause.Equals(""))
            {
                IDictionaryEnumerator enumerator = fromDictionary.GetEnumerator();

                enumerator.Reset();

                if (enumerator.MoveNext())
                {
                    fromClause = "FROM " + enumerator.Value;

                    while (enumerator.MoveNext())
                    {
                        fromClause = fromClause + "," + Environment.NewLine + enumerator.Value;
                    }

                    fromClause = fromClause + Environment.NewLine;
                }
            }

            return(fromClause);
        }
Example #19
0
        public String GetWhereClause()
        {
            IDictionaryEnumerator enumerator = whereDictionary.GetEnumerator();
            String whereClause = "";

            enumerator.Reset();

            if (enumerator.MoveNext())
            {
                whereClause = "WHERE " + enumerator.Value;

                while (enumerator.MoveNext())
                {
                    if (enumerator.Value.ToString().StartsWith("OR "))
                    {
                        whereClause = whereClause + Environment.NewLine + enumerator.Value;
                    }
                    else
                    {
                        whereClause = whereClause + Environment.NewLine + "AND " + enumerator.Value;
                    }
                }
                whereClause = whereClause + Environment.NewLine;
            }

            return(whereClause);
        }
Example #20
0
        protected void gvDirtyRooms_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            DataSet      dsDirtyRooms = Session[Constants.SESSION_DIRTYROOMS] as DataSet;
            ASPxGridView gridView     = sender as ASPxGridView;
            DataTable    dataTable    = dsDirtyRooms.Tables[0];
            DataRow      row          = dataTable.Rows.Find(e.Keys[0]);

            e.NewValues["UpdatedUser"] = Master.LoggedUser.UsersId;
            IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator();

            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                row[enumerator.Key.ToString()] = enumerator.Value == null ? DBNull.Value : enumerator.Value;
            }

            gridView.CancelEdit();
            e.Cancel = true;

            if (new GeneralManagement.RoomDAO().DashboardUpdateDirtyRooms(dsDirtyRooms))
            {
                System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Success + "')", true);
                LoadDirtyRooms();
            }
            else
            {
                System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Unsuccess + "')", true);
            }
        }
Example #21
0
        public void RemoveStandardJoin(String selection, String key)
        {
            Dictionary <String, String> tempDictionary = new Dictionary <String, String>(whereDictionary);
            IDictionaryEnumerator       enumerator     = tempDictionary.GetEnumerator();

            enumerator.Reset();

            if (!key.Equals(""))
            {
                while (enumerator.MoveNext())
                {
                    string field = enumerator.Key.ToString().Remove(enumerator.Key.ToString().Length - 1, 1);
                    if (field.Equals(key))
                    {
                        whereDictionary.Remove(enumerator.Key.ToString());
                    }
                }
            }
            else if (!selection.Equals(""))
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Key.ToString().Contains(selection))
                    {
                        whereDictionary.Remove(enumerator.Key.ToString());
                    }
                }
            }
            else
            {
                throw new Exception("Missing Required Field");
            }
        }
Example #22
0
 void IEnumerator.Reset()
 {
     if (_enumerator != null)
     {
         _enumerator.Reset();
     }
 }
Example #23
0
        protected void gvArrivals_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            dsData = Session[Constants.SESSION_ARRIVALS] as DataSet;
            ASPxGridView gridView  = sender as ASPxGridView;
            DataTable    dataTable = dsData.Tables[0];
            DataRow      row       = dataTable.Rows.Find(e.Keys[0]);

            e.NewValues["UpdatedUser"] = Master.LoggedUser.UsersId;
            IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator();

            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                row[enumerator.Key.ToString()] = enumerator.Value == null ? DBNull.Value : enumerator.Value;
            }

            gridView.CancelEdit();
            e.Cancel = true;

            if (new ReservationManagement.ReservationRoom().UpdateDashboardArrivalsDepartures(dsData))
            {
                System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Success + "')", true);
                if (dtpArrivalFromDate.Value != null && dtpArrivalToDate.Value != null)
                {
                    LoadArrivals(dtpArrivalFromDate.Date, dtpArrivalToDate.Date);
                }
            }
            else
            {
                System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Unsuccess + "')", true);
            }
        }
        public void IDictionary_NonGeneric_IDictionaryEnumerator_Current_FromStartToFinish(int count)
        {
            IDictionaryEnumerator enumerator = NonGenericIDictionaryFactory(count).GetEnumerator();

            for (int i = 0; i < 2; i++)
            {
                int counter = 0;
                while (enumerator.MoveNext())
                {
                    object          current = enumerator.Current;
                    object          key     = enumerator.Key;
                    object          value   = enumerator.Value;
                    DictionaryEntry entry   = enumerator.Entry;
                    Assert.Equal(current, entry);
                    Assert.Equal(key, entry.Key);
                    Assert.Equal(value, entry.Value);
                    counter++;
                }
                Assert.Equal(count, counter);
                if (!ResetImplemented)
                {
                    break;
                }
                enumerator.Reset();
            }
        }
Example #25
0
        protected virtual void ReadResources()
        {
            if (resources_read)
            {
                return;
            }

            if (Reader == null)
            {
                throw new ObjectDisposedException("ResourceSet is closed.");
            }
            lock (Table) {
                if (resources_read)
                {
                    return;
                }

                IDictionaryEnumerator i = Reader.GetEnumerator();
                i.Reset();
                while (i.MoveNext())
                {
                    Table.Add(i.Key, i.Value);
                }
                resources_read = true;
            }
        }
Example #26
0
        internal Array TableToArray(object luaParamValue, Type paramArrayType)
        {
            Array array;

            if (luaParamValue is LuaTable)
            {
                LuaTable luaTable = (LuaTable)luaParamValue;
                IDictionaryEnumerator enumerator = luaTable.GetEnumerator();
                enumerator.Reset();
                array = Array.CreateInstance(paramArrayType, luaTable.Values.get_Count());
                int num = 0;
                while (enumerator.MoveNext())
                {
                    object obj = enumerator.get_Value();
                    if (paramArrayType == typeof(object) && obj != null && obj.GetType() == typeof(double) && MetaFunctions.IsInteger((double)obj))
                    {
                        obj = Convert.ToInt32((double)obj);
                    }
                    array.SetValue(Convert.ChangeType(obj, paramArrayType), num);
                    num++;
                }
            }
            else
            {
                array = Array.CreateInstance(paramArrayType, 1);
                array.SetValue(luaParamValue, 0);
            }
            return(array);
        }
Example #27
0
        protected void gvBedTypes_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            dsData = Session[Constants.SESSION_BEDTYPES] as DataSet;
            ASPxGridView gridView  = sender as ASPxGridView;
            DataTable    dataTable = dsData.Tables[0];
            DataRow      row       = dataTable.Rows.Find(e.Keys[0]);

            e.NewValues["StatusId"]    = (int)Enums.HBMStatus.Modify;
            e.NewValues["UpdatedUser"] = SessionHandler.LoggedUser.UsersId;
            IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator();

            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                row[enumerator.Key.ToString()] = enumerator.Value == null ? DBNull.Value : enumerator.Value;
            }

            gridView.CancelEdit();
            e.Cancel = true;

            bedType.BedTypeId   = Convert.ToInt32(e.Keys["BedTypeId"].ToString());
            bedType.BedTypeName = e.NewValues["BedTypeName"].ToString();

            if (!bedType.IsDuplicateTypeName())
            {
                if (bedType.Save(dsData))
                {
                    this.LoadBedTypes();
                }
            }
            else
            {
                throw new System.Exception(Messages.Duplicate_record);
            }
        }
Example #28
0
        protected DataRow GetRow(DataTable LocObject, IDictionaryEnumerator enumerator, int Keys)
        {
            DataTable dataTable = new DataTable();

            if (LocObject != null)
            {
                dataTable = LocObject;
            }
            else
            {
                dataTable.Columns.Add("Name");
            }
            DataRow DRRow = null;

            if (Keys == 0)
            {
                DRRow = dataTable.NewRow();
            }

            else
            {
                DRRow = dataTable.Rows.Find(Keys);
            }

            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                DRRow[enumerator.Key.ToString()] = (enumerator.Value == null ? "False" : enumerator.Value);
            }
            return(DRRow);
        }
Example #29
0
            private bool UpdateMonoSpaced()
            {
                bool flag1 = this.isMonoSpaced;
                int  num1  = this.fontHeight;

                this.isMonoSpaced = false;
                this.fontHeight   = 0;
                if (this.fontInfo != null)
                {
                    this.isMonoSpaced = this.fontInfo.IsMonoSpaced;
                    int num2 = this.fontInfo.FontMetrics.AveCharWidth;
                    IDictionaryEnumerator enumerator1 = this.stylesTable.GetEnumerator();
                    enumerator1.Reset();
                    while (enumerator1.MoveNext())
                    {
                        if (this.isMonoSpaced && (((TextPainter.FontInfo)enumerator1.Value).FontMetrics.AveCharWidth != num2))
                        {
                            this.isMonoSpaced = false;
                        }
                        this.fontHeight = Math.Max(this.fontHeight, ((TextPainter.FontInfo)enumerator1.Value).FontMetrics.Height);
                    }
                }
                if (flag1 == this.isMonoSpaced)
                {
                    return(num1 != this.fontHeight);
                }
                return(true);
            }
Example #30
0
        public String GetHavingClause()
        {
            IDictionaryEnumerator enumerator = havingDictionary.GetEnumerator();
            String havingClause = "";

            enumerator.Reset();

            if (enumerator.MoveNext())
            {
                havingClause = "HAVING " + enumerator.Value;

                while (enumerator.MoveNext())
                {
                    if (enumerator.Value.ToString().StartsWith("OR "))
                    {
                        havingClause = havingClause + Environment.NewLine + enumerator.Value;
                    }
                    else
                    {
                        havingClause = havingClause + Environment.NewLine + "AND " + enumerator.Value;
                    }
                }

                havingClause = havingClause + Environment.NewLine;
            }
            return(havingClause);
        }
Example #31
0
        private string createTransTable(IDictionaryEnumerator translist)
        {
            translist.Reset();
            string res = "";
            while (translist.MoveNext())
            {
                Translation trans = (Translation) translist.Value;
                res += "<tr>\n\t\t\t<td></td><td colspan=\"3\" bgcolor=\"dddddd\">" + trans.ToString() + "</td></tr>\n\t\t";
                res += "<tr>\n\t\t\t<td colspan=\"4\" style=\"padding:10px;\" bgcolor=\"#f4f4f4\">" +
                    this.cleanText(trans.Text, this.checkBox1.Checked) + "</td></tr>\n\t\t";

            }
            return res;
        }
        public static unoidl.com.sun.star.uno.XComponentContext defaultBootstrap_InitialComponentContext(
            string iniFile,
            IDictionaryEnumerator bootstrapParameters)
        {
            if (bootstrapParameters != null)
            {
            bootstrapParameters.Reset();
            while (bootstrapParameters.MoveNext())
            {
                string key = (string)bootstrapParameters.Key;
                string value = (string)bootstrapParameters.Value;

                native_bootstrap_set(key, key.Length, value, value.Length);
            }
            }

            System.Console.WriteLine("Bootstrap with ini " + iniFile);
            // bootstrap native uno
            IntPtr context;
            if (iniFile == null)
            {
            context = native_defaultBootstrap_InitialComponentContext();
            }
            else
            {
            context = native_defaultBootstrap_InitialComponentContext(iniFile, iniFile.Length);
            }

            return (unoidl.com.sun.star.uno.XComponentContext)ExtractObject(context);
        }
Example #33
0
        private void CompareDictionaryIgnoreOrder(string breadCrumb, IDictionaryEnumerator enumerator1,
            IDictionaryEnumerator enumerator2)
        {
            var loopedBack = false;
            var needLoopBack = false;
            var enumerator1Index = -1;
            var enumerator2Index = 0;
            int? limit = null;

            //if object2 holds more items than object1 we need to track, and then show diffs of the remaining
            //items
            var needTrackingOfObject2 = IsBigger(enumerator1, enumerator2);
            var foundObject2Items = new List<int>();

            while (enumerator1.MoveNext())
            {
                enumerator1Index++;

                //currentCrumb = AddBreadCrumb(breadCrumb, info.Name, string.Empty, i);
                var found = false;

                // expect order, but don't assume it.  this improves performance
                // where the collections are ordered in sync (wittingly, or un-), but
                // the logic is a bit different than the above index compare,

                var movedNext = enumerator2.MoveNext();

                if (!movedNext)
                {
                    enumerator2.Reset();
                    movedNext = enumerator2.MoveNext();
                    enumerator2Index = 0;
                }

                string currentBreadCrumb = breadCrumb;

                while (movedNext)
                {
                    var clone = Clone();
                    clone.Differences = new List<Difference>();

                    currentBreadCrumb = AddBreadCrumb(breadCrumb, "Current", string.Empty, enumerator1Index);

                    if (HasMatchingSpecEntry(enumerator1.Key))
                    {
                        if (clone.MatchObjects(enumerator1.Key, enumerator2.Key, ref breadCrumb))
                        {
                            found = true;
                            Compare(enumerator1.Key, enumerator2.Key, breadCrumb);
                            foundObject2Items.Add(enumerator2Index);
                            break;
                        }
                    }
                    else
                    {
                        clone.Compare(enumerator1.Key, enumerator2.Key, currentBreadCrumb);
                    }

                    if (clone.Differences.Count == 0)
                    {
                        clone.Compare(enumerator1.Value, enumerator2.Value, currentBreadCrumb);

                        if (clone.Differences.Count == 0)
                        {
                            found = true;

                            foundObject2Items.Add(enumerator2Index);

                            break;
                        }
                    }

                    movedNext = enumerator2.MoveNext();
                    enumerator2Index++;

                    if (enumerator2Index == limit)
                        break;

                    if (!movedNext && needLoopBack && !loopedBack)
                    {
                        enumerator2.Reset();
                        limit = enumerator2Index;
                        enumerator2Index = 0;
                        movedNext = enumerator2.MoveNext();
                        loopedBack = true;
                    }
                }

                if (!found)
                {
                    Difference difference = new Difference
                    {
                        ExpectedName = ExpectedName,
                        ActualName = ActualName,
                        PropertyName = currentBreadCrumb,
                        Object1Value = NiceString(enumerator1.Key),
                        Object2Value = "(null)",
                        ChildPropertyName = "Item",
                        Object1 = new WeakReference(enumerator1),
                        Object2 = null
                    };

                    AddDifference(difference);
                }

                if (Differences.Count >= MaxDifferences)
                    return;

                needLoopBack = true;
            }

            enumerator2.Reset();

            if (needTrackingOfObject2)
            {
                var j = 0;

                while (enumerator2.MoveNext())
                {
                    if (!foundObject2Items.Contains(j))
                    {
                        object objectValue2 = enumerator2.Key;
                        var matchingEntry = GetMatchingSpecEntry(objectValue2);
                        var currentCrumb = AddBreadCrumb(breadCrumb, string.Empty, (null == matchingEntry) ? string.Empty : GetMatchPhrase(objectValue2), j);

                        Compare(null, objectValue2, currentCrumb);

                        if (Differences.Count >= MaxDifferences)
                            return;
                    }

                    j++;
                }
            }
        }
Example #34
0
		public void Reset ()
		{
			hashEnum = hash.GetEnumerator ();
			hashEnum.Reset ();
		}