当前位置: 首页>>代码示例>>C#>>正文


C# Hashtable.Clear方法代码示例

本文整理汇总了C#中Hashtable.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.Clear方法的具体用法?C# Hashtable.Clear怎么用?C# Hashtable.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hashtable的用法示例。


在下文中一共展示了Hashtable.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCameraMove

    public void OnCameraMove()
    {
        //StopAllCoroutines();

        Hashtable hash = new Hashtable();
        hash.Add("position", TargetPos);
        hash.Add("time", MovingSec);
        hash.Add("easetype", iTween.EaseType.easeInOutExpo);
        iTween.MoveTo(gameObject, hash);

        hash.Clear();
        hash.Add("rotation", TargetAngle);
        hash.Add("time", MovingSec);
        hash.Add("easetype", iTween.EaseType.easeInOutExpo);
        iTween.RotateTo(gameObject, hash);

        hash.Clear();
        hash.Add("from", CameraObject.orthographicSize);
        hash.Add("to", TargetSize);
        hash.Add("time", MovingSec);
        hash.Add("onupdate", "SizeUpdate");
        hash.Add("easetype", iTween.EaseType.easeInOutExpo);
        iTween.ValueTo(gameObject, hash);

    }
开发者ID:jwvg0425,项目名称:Hmmo,代码行数:25,代码来源:CameraScript.cs

示例2: MoveLeftRight

    /// <summary>
    /// 从左到右移动
    /// </summary>
    /// <param name="time">Time.</param>
    protected override IEnumerator MoveLeftRight()
    {
        //Vector3 pos1 = new Vector3 (go.transform.position.x, go.transform.position.y + 0.3f, go.transform.position.z);
        Hashtable args = new Hashtable ();

        Transform layer3 = GetTransform (gameObject.transform, "layer3");
        GameObject go = layer3.gameObject;

        Vector3 origin2 = go.transform.position;
        Vector3 pos2 = new Vector3 (go.transform.position.x - 0.3f, go.transform.position.y, go.transform.position.z);

        args.Clear ();
        args.Add ("time", 1.5f);
        args.Add ("position", pos2);
        args.Add ("easetype", "linear");
        iTween.MoveTo (go, args);

        yield return new WaitForSeconds (1.5f);
        //Vector3 pos1 = new Vector3 (go.transform.position.x - 0.5f, go.transform.position.y, go.transform.position.z);

        args.Clear ();

        args.Add ("time", 1.5f);
        args.Add ("position", origin2);
        args.Add ("easetype", "linear");

        iTween.MoveTo (go, args);

        yield return new WaitForSeconds (1.5f);
        Vector3 pos1 = new Vector3 (go.transform.position.x + 0.3f, go.transform.position.y, go.transform.position.z);

        args.Clear ();

        args.Add ("time", 1.5f);
        args.Add ("position", pos1);
        args.Add ("easetype", "linear");

        iTween.MoveTo (go, args);

        yield return new WaitForSeconds (1.5f);

        args.Clear ();

        args.Add ("time", 1.5f);
        args.Add ("position", origin2);
        args.Add ("easetype", "linear");

        iTween.MoveTo (go, args);

        yield return new WaitForSeconds (1.5f);

        Move2();
    }
开发者ID:goddie,项目名称:u3dGameFramework,代码行数:57,代码来源:BackgroundSky.cs

示例3: TestClearBasic

        public void TestClearBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);
            Hashtable ht1 = null;
            string s1 = null;
            string s2 = null;

            int i = 0;
            ht1 = new Hashtable(); //default constructor
            ht1.Clear();

            Assert.Equal(0, ht1.Count);

            // add 100 key-val pairs
            ht1 = new Hashtable();

            for (i = 0; i < 100; i++)
            {
                sblMsg = new StringBuilder(99);
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg = new StringBuilder(99);
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                ht1.Add(s1, s2);
            }

            Assert.Equal(100, ht1.Count);
            ht1.Clear();

            Assert.Equal(0, ht1.Count);

            //[]we will make a token call for some important methods to make sure that this is indeed clear
            s1 = "key_0";
            Assert.False(ht1.ContainsKey(s1));

            s1 = "val_0";
            Assert.False(ht1.ContainsValue(s1));

            //[]repeated clears of the HT. Nothing should happen		

            for (i = 0; i < 100; i++)
            {
                ht1.Clear();

                Assert.Equal(0, ht1.Count);
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:52,代码来源:ClearTests.cs

示例4: ImageButtonGiant_Click

    protected void ImageButtonGiant_Click(object sender, ImageClickEventArgs e)
    {
        Hashtable ht = new Hashtable();
        string where = "";

        foreach (GridViewRow row in GridView1.Rows)
        {
            ht.Clear();
            ht.Add("HasDuty_UserManage", ((CheckBox)row.FindControl("chkUserManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_RoleManage", ((CheckBox)row.FindControl("chkUserManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_Role", ((CheckBox)row.FindControl("chkUserManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_CourseManage", ((CheckBox)row.FindControl("chkCourseManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_PaperSetup", ((CheckBox)row.FindControl("chkPaperSetup")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_PaperLists", ((CheckBox)row.FindControl("chkPaperSetup")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_UserPaperList", ((CheckBox)row.FindControl("chkUserPaperList")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_UserScore", ((CheckBox)row.FindControl("chkUserPaperList")).Checked == true ? 1 : 0);

            ht.Add("HasDuty_SingleSelectManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_MultiSelectManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_FillBlankManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_JudgeManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_QuestionManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);

            where = " Where RoleId=" + row.Cells[0].Text;
            Role.Update(ht, where);
        }
        Page.RegisterStartupScript("", "<script>alert('授权成功!');</script>");
    }
开发者ID:zhouhao,项目名称:OnlineExamSystem,代码行数:28,代码来源:RoleManage.aspx.cs

示例5: TestCtorDictionarySingle

        public void TestCtorDictionarySingle()
        {
            // No exception
            var hash = new Hashtable(new Hashtable(), 1f);
            // No exception
            hash = new Hashtable(new Hashtable(new Hashtable(new Hashtable(new Hashtable(new Hashtable()), 1f), 1f), 1f), 1f);

            // []test to see if elements really get copied from old dictionary to new hashtable
            Hashtable tempHash = new Hashtable();
            // this for assumes that MinValue is a negative!
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                tempHash.Add(i, i);
            }

            hash = new Hashtable(tempHash, 1f);

            // make sure that new hashtable has the elements in it that old hashtable had
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                Assert.True(hash.ContainsKey(i));
                Assert.True(hash.ContainsValue(i));
            }

            //[]make sure that there are no connections with the old and the new hashtable
            tempHash.Clear();
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                Assert.True(hash.ContainsKey(i));
                Assert.True(hash.ContainsValue(i));
            }
        }
开发者ID:sky7sea,项目名称:corefx,代码行数:32,代码来源:CtorTests.cs

示例6: ImageButtonGiant_Click

 protected void ImageButtonGiant_Click(object sender, ImageClickEventArgs e)
 {
     //����һ����ϣ��ht
     Hashtable ht = new Hashtable();
     string where = "";
     //Ӧ��foreachѭ��GridView�ؼ��е�CheckBox�ؼ�
     foreach (GridViewRow row in GV.Rows)
     {
         //������¹�ϣ���е�����
         ht.Clear();
         //Ӧ��FindControl��������GridView�ؼ���CheckBox�ؼ�,���ж��Ƿ�ѡ�������û�Ȩ��
         ht.Add("HasDuty_DepartmentManage", ((CheckBox)row.FindControl("chkDepartmentManage")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_UserManage", ((CheckBox)row.FindControl("chkUserManage")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_RoleManage", ((CheckBox)row.FindControl("chkUserManage")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_Role", ((CheckBox)row.FindControl("chkUserManage")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_CourseManage", ((CheckBox)row.FindControl("chkCourseManage")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_PaperSetup", ((CheckBox)row.FindControl("chkPaperSetup")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_PaperLists", ((CheckBox)row.FindControl("chkPaperSetup")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_UserPaperList", ((CheckBox)row.FindControl("chkUserPaperList")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_UserScore", ((CheckBox)row.FindControl("chkUserPaperList")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_SingleSelectManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_MultiSelectManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_FillBlankManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_JudgeManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
         ht.Add("HasDuty_QuestionManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
         //����һ����ѯ���������
         where = " Where RoleId=" + row.Cells[0].Text;
         //����Rolemr�������е�Update�����޸Ľ�ɫȨ����Ϣ
         Rolemr.Update(ht, where);
     }
 }
开发者ID:kinggod,项目名称:21SourceCode,代码行数:31,代码来源:RoleManage.aspx.cs

示例7: Main

	public static void Main (string [] args)
	{
		Hashtable ht = new Hashtable ();
		Assembly asm = Assembly.GetAssembly (typeof (test));
		foreach (Type t in asm.GetTypes ()) {
			ht.Clear ();
			foreach (FieldInfo fi in t.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
				ht.Add (fi.Name, fi);
		}
	}
开发者ID:nobled,项目名称:mono,代码行数:10,代码来源:test-iter-18.cs

示例8: yt

    public static SortedDictionary<int, string> yt(string targetUri)
    {
        CookieContainer cc = new CookieContainer();
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(targetUri);
        req.CookieContainer = cc;
        req.Timeout = 5000;
        req.GetResponse().Close();
        req = (HttpWebRequest)WebRequest.Create("http://www.youtube.com/get_video_info?video_id=" + Regex.Match(targetUri, "(?<=v=)[\\w-]+").Value);
        req.CookieContainer = cc;
        string _info = null;
        System.Net.WebResponse res = req.GetResponse();
        System.IO.StreamReader sr = new System.IO.StreamReader(res.GetResponseStream());
        _info = sr.ReadToEnd();
        sr.Close();
        res.Close();
        Hashtable info = new Hashtable();
        Dictionary<string, string> _tmp = new Dictionary<string, string>();
        SortedDictionary<int, string> fmtmap = new SortedDictionary<int, string>();

        foreach (string item in _info.Split('&'))
        {
            info.Add(item.Split('=')[0], Uri.UnescapeDataString(item.Split('=')[1]));
        }
        if (Convert.ToString(info["status"]) == "fail")
        {
            throw new UnauthorizedAccessException();
        }
        foreach (string item in Convert.ToString(info["url_encoded_fmt_stream_map"]).Split(','))
        {
            foreach (string a in item.Split('&'))
            {
                _tmp.Add(a.Split('=')[0], Uri.UnescapeDataString(a.Split('=')[1]));
            }
            fmtmap.Add(Convert.ToInt32(_tmp["itag"]), (_tmp["url"]) + "&signature=");
            _tmp.Clear();
        }

        req = (HttpWebRequest)WebRequest.Create("http://www.youtube.com/get_video_info?video_id=" + Regex.Match(targetUri, "(?<=v=)\\w+").Value + "&t=" + Convert.ToString(info["token"]));
        req.CookieContainer = cc;
        req.Timeout = 1500;
        req.GetResponse().Close();

        fmtmap[-2] = Convert.ToString(info["title"]);
        fmtmap[-1] = cc.GetCookieHeader(new Uri("http://www.youtube.com"));
        info.Clear();
        return fmtmap;
    }
开发者ID:kazuki0824,项目名称:Breeze-Mono,代码行数:47,代码来源:kk_movdl_csharp.cs

示例9: btn_Save_Click

    protected void btn_Save_Click(object sender, EventArgs e)
    {
        #region
        Int32 iResult = 0;

        try
        {
            if (dtMultiSaveClassAndItem.Rows.Count > 0)
            {
                Hashtable htTemp = new Hashtable();
                Hashtable htParams = new Hashtable();

                htTemp.Clear();
                htTemp.Add("ChanNo", SLP_StoreChain1.Text.Trim());
                htTemp.Add("Store", SLP_Store1.Text.Trim());
                htTemp.Add("StartDate", SLP_SLPDate2.Text.Trim());
                htTemp.Add("EndDate", SLP_SLPDate3.Text.Trim());

                if (CheckSpecTypeAndValue() && CheckDetailDataIsNotNull() && CheckPATTERNSPECCanAdd(htTemp) )
                {
                    #region
                    DataTable dtForUpdate = dtDetailData;//.GetChanges(DataRowState.Added);

                    ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB);
                    string strCode = "";

                    strErrMsgAfterChecked = "";//清空暫存錯誤訊息

                    for (Int32 i = 0; i <= dtMultiSaveClassAndItem.Rows.Count - 1; i++)
                    {
                        #region Master

                        htTemp.Clear();
                        htTemp.Add("ChanNo", SLP_StoreChain1.Text.Trim());
                        htTemp.Add("Store", SLP_Store1.Text.Trim());
                        htTemp.Add("ROOT_NO", dtMultiSaveClassAndItem.Rows[i]["ROOT_NO"].ToString().Trim());
                        htTemp.Add("PMA", dtMultiSaveClassAndItem.Rows[i]["PMA"].ToString().Trim());

                        if (dtMultiSaveClassAndItem.Rows[i]["PATTERN"].ToString().Trim() == "")
                        {
                            htTemp.Add("PATTERN_NO", null);
                        }
                        else
                        {
                            htTemp.Add("PATTERN_NO", dtMultiSaveClassAndItem.Rows[i]["PATTERN"].ToString().Trim());
                        }

                        if (CheckPATTERNSPECExist(htTemp))
                        {
                            strCode = string.Format("{0}_{1}_{2}_{3}_{4}",
                            SLP_StoreChain1.Text.Trim(), SLP_Store1.Text.Trim(),
                            dtMultiSaveClassAndItem.Rows[i]["ROOT_NO"].ToString().Trim(),
                            dtMultiSaveClassAndItem.Rows[i]["PMA"].ToString().Trim(),
                            dtMultiSaveClassAndItem.Rows[i]["PATTERN"].ToString().Trim());

                            htParams.Clear();
                            htParams.Add("CODE", strCode);
                            htParams.Add("UserID", Session["UID"].ToString());
                            htParams.Add("ChanNO", SLP_StoreChain1.Text.Trim());
                            htParams.Add("STORE", SLP_Store1.Text.Trim());
                            htParams.Add("ROOT_NO", dtMultiSaveClassAndItem.Rows[i]["ROOT_NO"].ToString().Trim());
                            htParams.Add("PMA", dtMultiSaveClassAndItem.Rows[i]["PMA"].ToString().Trim());
                            htParams.Add("PATTERN_NO", dtMultiSaveClassAndItem.Rows[i]["PATTERN"].ToString().Trim());
                            htParams.Add("SPEC_TYPE", getSpecTypeChecked());
                            htParams.Add("SPEC_QTY", SLP_Number1.Text.Trim());
                            htParams.Add("S_START_DATE", SLP_SLPDate2.Text.Trim());
                            htParams.Add("S_END_DATE", SLP_SLPDate3.Text.Trim());
                            htParams.Add("REASON", strReason.Trim());

                            iResult = BCO.CreateMasterAndDetail(htParams, dtForUpdate, null);
                        }
                        #endregion
                    }

                    if (strErrMsgAfterChecked != "")
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", strErrMsgAfterChecked), true);
                    }

                    if (iResult == 0)
                    {
                        throw new Exception("新增0筆資料!");
                    }
                    else
                    {
                        if (dtForUpdate != null)
                            dtForUpdate.AcceptChanges();

                        dtDetailData = dtForUpdate;
                        dtForDetailDeleted.Clear();
                        ScriptManager.RegisterStartupScript(UpdatePanel2, this.GetType(), "ClientScript", string.Format("alert('新增完成');location.replace('ALO081.aspx?Code=ALO08&ChanNo={0}&Store={1}');", SLP_StoreChain1.Text, SLP_Store1.Text), true);
                    }
                    #endregion
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(UpdatePanel2, this.GetType(), "ClientScript", "alert('請先加入商品');", true);
            }
        }
//.........这里部分代码省略.........
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:101,代码来源:ALO082.aspx.cs

示例10: btn_CopyDetail_Click

    protected void btn_CopyDetail_Click(object sender, EventArgs e)
    {
        #region

        ALOModel.MaintainPatternSpec BCO = new ALOModel.MaintainPatternSpec(ConnectionDB);

        Hashtable htParams = new Hashtable();
        htParams.Clear();
        htParams.Add("ChanNo", SLP_StoreChain1.Text.Trim());
        htParams.Add("STORE", SLP_Store1.Text.Trim());

        DataTable dtDetl = BCO.QueryLastPATTERNSPECDetail(htParams);



        if (dtDetl != null && dtDetl.Rows.Count > 0)
        {
            dtDetailData = dtDetl;
            gv_Detail.DataSource = dtDetl;
            gv_Detail.DataBind();
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", "alert('此門市無前筆有效明細設定資訊,請手動新增');", true);
        }




        #endregion
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:31,代码来源:ALO082.aspx.cs

示例11: TestAddClearRepeatedly

        public void TestAddClearRepeatedly()
        {
            int inLoops0 = 2;
            int inLoops1 = 2;

            var ht2 = new Hashtable();
            for (int aa = 0; aa < inLoops0; aa++)
            {
                for (int bb = 0; bb < inLoops1; bb++)
                {
                    ht2.Add("KEY: aa==" + aa + " ,bb==" + bb, "VALUE: aa==" + aa + " ,bb==" + bb);
                }

                Assert.Equal(inLoops1, ht2.Count);
                ht2.Clear();
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:17,代码来源:AddTests.cs

示例12: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        Save += btnOK_Click;

        var user = MembershipContext.AuthenticatedUser;

        // Check permissions for Forms application
        if (!user.IsAuthorizedPerUIElement("cms.form", "Form"))
        {
            RedirectToUIElementAccessDenied("cms.form", "Form");
        }

        // Check 'ReadData' permission
        if (!user.IsAuthorizedPerResource("cms.form", "ReadData", SiteInfoProvider.GetSiteName(FormInfo.FormSiteID)))
        {
            RedirectToAccessDenied("cms.form", "ReadData");
        }

        // Check authorized roles for this form
        if (!FormInfo.IsFormAllowedForUser(MembershipContext.AuthenticatedUser.UserName, SiteContext.CurrentSiteName))
        {
            RedirectToAccessDenied(GetString("Bizforms.FormNotAllowedForUserRoles"));
        }

        List<String> columnNames = null;
        DataClassInfo dci = null;
        Hashtable reportFields = new Hashtable();
        FormInfo fi = null;

        // Initialize controls
        PageTitle.TitleText = GetString("BizForm_Edit_Data_SelectFields.Title");
        CurrentMaster.DisplayActionsPanel = true;

        HeaderActions.AddAction(new HeaderAction
        {
            Text = GetString("UniSelector.SelectAll"),
            OnClientClick = "ChangeFields(true); return false;",
            ButtonStyle = ButtonStyle.Default,
        });

        HeaderActions.AddAction(new HeaderAction
        {
            Text = GetString("UniSelector.DeselectAll"),
            OnClientClick = "ChangeFields(false); return false;",
            ButtonStyle = ButtonStyle.Default,
        });

        if (!RequestHelper.IsPostBack())
        {

            if (FormInfo != null)
            {
                // Get dataclass info
                dci = DataClassInfoProvider.GetDataClassInfo(FormInfo.FormClassID);

                if (dci != null)
                {
                    // Get columns names
                    fi = FormHelper.GetFormInfo(dci.ClassName, false);

                    columnNames = fi.GetColumnNames(false);
                }

                // Get report fields
                if (String.IsNullOrEmpty(FormInfo.FormReportFields))
                {
                    reportFields = LoadReportFields(columnNames);
                }
                else
                {
                    reportFields.Clear();

                    foreach (string field in FormInfo.FormReportFields.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                if (columnNames != null)
                {
                    FormFieldInfo ffi = null;
                    ListItem item = null;

                    MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + FormInfo.ClassName);

                    foreach (string name in columnNames)
                    {
                        ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        item = new ListItem(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(GetFieldCaption(ffi, name, resolver))), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
//.........这里部分代码省略.........
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:101,代码来源:BizForm_Edit_Data_SelectFields.aspx.cs

示例13: TestGetCountBasic

        public void TestGetCountBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);

            Hashtable ht1 = null;

            string s1 = null;
            string s2 = null;

            int i = 0;

            // Set - null val, should pass

            ht1 = new Hashtable(); //default constructor
            ht1["first key"] = null;
            Assert.Equal(1, ht1.Count);

            //[]  vanila
            ht1 = new Hashtable(); //default constructor
            ht1["first key"] = "first value";
            Assert.Equal(1, ht1.Count);

            //   Set again with a diff value
            ht1["first key"] = "second value";

            // now, size should still be one
            Assert.Equal(1, ht1.Count);

            //[]  Testcase:  add 50 key-val pairs and check the size
            ht1 = new Hashtable();
            for (i = 0; i < 100; i++)
            {
                sblMsg = new StringBuilder(99);
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg = new StringBuilder(99);
                sblMsg.Append("old_val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                ht1.Add(s1, s2);

                Assert.Equal(i + 1, ht1.Count);
            }

            //
            //[]  Testcase:  now set 100 key-val pairs, this includes the first 50 pairs that
            // just added, their values must be changed to the new values set
            //
            for (i = 0; i < 100; i++)
            {
                sblMsg = new StringBuilder(99);
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg = new StringBuilder(99);
                sblMsg.Append("new_val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                ht1[s1] = s2;
            }

            Assert.Equal(100, ht1.Count);

            //
            //[] Remove a key and then check size
            //
            sblMsg = new StringBuilder(99);
            sblMsg.Append("key_50");
            s1 = sblMsg.ToString();

            ht1.Remove(s1); //removes "Key_50"
            Assert.Equal(99, ht1.Count);

            //
            //[] clear everything and check the size
            //
            ht1.Clear();
            Assert.Equal(0, ht1.Count);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:84,代码来源:PropertyCountTests.cs

示例14: LoadList

    private void LoadList()
    {
        string sSelect = "SELECT Clinic.Name AS ClinicName, [" + TableName + "].ClientID";
        string sInnerjoin = "\n INNER JOIN Clinic ON [" + TableName + "].ClientID = Clinic.Id";
        string sWhere = "\n WHERE Clinic.Id =" + ddlClinic.SelectedValue + " ";
        string sSQL = string.Empty;
        string sListFields = string.Empty;
        List<SqlParameter> parames = new List<SqlParameter>();
        Hashtable hashParames = new Hashtable();
        int i = -1;

        if (searchConditions != null && !string.IsNullOrEmpty(TableName) && TableName.Length > 0)
        {
            var conditionTables = new Hashtable();
            conditionTables.Add("Clinic", "Clinic");
            foreach (SearchExpander seardcondition in searchConditions)
            {
                i++;
                object requesCondition = Request[GetIDControl(seardcondition.ColumnName, seardcondition.Refference, seardcondition.DisplayRefferenceColumn)];
                SqlParameter param = null;
                if (seardcondition.Type == null) sSelect += ", [" + TableName + "]." + seardcondition.ColumnName;
                if (seardcondition.Refference != null)
                {
                    string BeetwenRefTableName = WebCore.GetTableName(seardcondition.Type);
                    string RefTableName = WebCore.GetTableName(seardcondition.Refference);
                    //Add column to sellect
                    sSelect += ", [" + RefTableName + "]." + seardcondition.DisplayRefferenceColumn + " as " + RefTableName + seardcondition.DisplayRefferenceColumn;

                    //===========================================================================
                    //Join table has column refference
                    if (!conditionTables.ContainsKey(RefTableName))
                    {
                        if (seardcondition.Type == null)
                        {
                            sInnerjoin += "\n LEFT OUTER JOIN [" + RefTableName + "] ON [" + RefTableName + "]." + seardcondition.RefferenceColumn + " = [" + TableName + "]." + seardcondition.ColumnName;
                            conditionTables.Add(RefTableName, RefTableName);
                        }
                        else
                        {
                            sInnerjoin += "\n LEFT OUTER JOIN [" + RefTableName + "] ON [" + RefTableName + "]." + seardcondition.RefferenceColumn + " = [" + BeetwenRefTableName + "]." + seardcondition.ColumnName;
                            conditionTables.Add(RefTableName, RefTableName);
                        }
                    }

                    //===========================================================================
                    // Where if search something in search textbox
                    if (requesCondition != null && requesCondition.ToString() != string.Empty)
                    {
                        //Where condition
                        sWhere += " AND  [" + RefTableName + "]." + seardcondition.DisplayRefferenceColumn + " LIKE '%' + @" + RefTableName + seardcondition.DisplayRefferenceColumn + " + '%' ";
                        //Param
                        param = new SqlParameter("@" + RefTableName + seardcondition.DisplayRefferenceColumn, requesCondition ?? string.Empty);
                        if (!hashParames.ContainsKey(param.ParameterName)) { parames.Add(param); hashParames.Add(param.ParameterName, param.ParameterName); }
                    }
                }
                //Check condition
                else if (requesCondition != null && requesCondition.ToString() != string.Empty)
                {
                    // Select like when search in string type
                    if (seardcondition.PKType == typeof(string))
                    {
                        sWhere += " AND " + TableName + ".[" + seardcondition.ColumnName + "] LIKE '%' + @" + seardcondition.ColumnName + " + '%' ";
                        sSQL += " AND " + TableName + ".[" + seardcondition.ColumnName + "] LIKE '%' + @" + seardcondition.ColumnName + " + '%' ";
                        param = new SqlParameter("@" + seardcondition.ColumnName, requesCondition ?? string.Empty);
                    }
                    //Select validate value
                    else
                    {
                        sWhere += " AND " + TableName + ".[" + seardcondition.ColumnName + "] = @" + seardcondition.ColumnName + " ";
                        sSQL += " AND " + TableName + ".[" + seardcondition.ColumnName + "] = @" + seardcondition.ColumnName + " ";
                        param = new SqlParameter("@" + seardcondition.ColumnName, requesCondition ?? DBNull.Value);
                    }
                    if (!hashParames.ContainsKey(param.ParameterName)) { parames.Add(param); hashParames.Add(param.ParameterName, param.ParameterName); }
                }
            }
            // Check with client ID
            if (!string.IsNullOrEmpty(ClientID)) sWhere += " AND [" + TableName + "].ClientId=" + ClientID;
            if (!string.IsNullOrEmpty(Id)) sWhere += " AND [" + TableName + "].Id=" + Id;
            hashParames.Clear();
            hashParames = null;

            //Check group by
            if (this.GroupBy != null)
            {
                sWhere += " AND [" + TableName + "]." + this.GroupBy.ColumnName;
                if (this.GroupBy.PKType == typeof(DateTime))
                {
                    sWhere += " between @" + this.GroupBy.ColumnName + " AND @" + this.GroupBy.ColumnName + "2";
                    DateTime selectDate = DateTime.Today;
                    DateTime.TryParseExact(txtGroupBy.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out selectDate);
                    SqlParameter param1 = new SqlParameter("@" + this.GroupBy.ColumnName, selectDate);
                    SqlParameter param2 = new SqlParameter("@" + this.GroupBy.ColumnName + "2", selectDate.AddDays(1));
                    parames.Add(param1);
                    parames.Add(param2);
                }
            }

            // Group all querry
            sSelect += " FROM [" + TableName + "]";
            sSQL = sSelect + sInnerjoin + sWhere;
//.........这里部分代码省略.........
开发者ID:kiemhieu,项目名称:medicine-website,代码行数:101,代码来源:UserControlBase.ascx.cs

示例15: TestGetKeys


//.........这里部分代码省略.........
            for (i = 0; i < 100; i++)
            {
                sblMsg = new StringBuilder(99);
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg = new StringBuilder(99);
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                ht1.Add(s1, s2);
            }

            //
            // test Get to make sure the key-vals are accessible
            //
            for (i = 0; i < ht1.Count; i++)
            {
                sblMsg = new StringBuilder(99);
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg = new StringBuilder(99);
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                s3 = (string)ht1[s1];

                Assert.Equal(s3, s2);
            }

            //
            // []  now GetKeys and make sure every key is obtained
            //  NOTE: the keys obtained may not necessarily be in any order
            //
            int temp = ht1.Count;
            objArr = new object[temp];

            ht1.Keys.CopyTo(objArr, 0);
            Assert.Equal(objArr.Length, ht1.Count);

            for (i = 0; i < objArr.Length; i++)
            {
                Assert.True(ht1.ContainsKey(objArr[i].ToString()));
            }

            // [] We test other methods in the Collection to make sure that they work!!
            icol1 = ht1.Keys;
            ienm1 = icol1.GetEnumerator();
            iCount = 0;
            while (ienm1.MoveNext())
            {
                iCount++;
                Assert.True(ht1.ContainsKey(ienm1.Current));
            }

            Assert.Equal(iCount, ht1.Count);
            Assert.Equal(icol1.Count, ht1.Count);
            Assert.False(icol1.IsSynchronized);
            Assert.Equal(icol1.SyncRoot, ht1.SyncRoot);

            Assert.Throws<ArgumentException>( () => 
            {
                object[,] mdObjArray = new object[ht1.Keys.Count, ht1.Keys.Count];
                ht1.Keys.CopyTo(mdObjArray, 0);
            });

            //[] The ICollection is alive - i.e. whatever changes we do to the Underlying HT is reflected in the collection
            sblMsg = new StringBuilder();
            sblMsg.Append("key_");
            sblMsg.Append(0);
            s1 = sblMsg.ToString();

            ht1.Remove(s1);
            ienm1 = icol1.GetEnumerator();
            iCount = 0;
            while (ienm1.MoveNext())
            {
                s3 = (string)ienm1.Current;
                Assert.NotEqual(s1, s3);
            }

            Assert.Equal(icol1.Count, ht1.Count);
            //[] we will clear the HT and make sure that the Keys are kaput
            ht1.Clear();
            Assert.Equal(0, icol1.Count);

            iCount = 0;
            ienm1 = icol1.GetEnumerator();
            while (ienm1.MoveNext())
            {
                iCount++;
            }

            Assert.Equal(0, iCount);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:101,代码来源:PropertyKeysTests.cs


注:本文中的Hashtable.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。