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


C# System.Collections.Generic.Dictionary.Clear方法代码示例

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


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

示例1: ObtenerItemsMenu

 private void ObtenerItemsMenu()
 {
   string s1 = GetSecurityConnectionString();
   System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(s1);
   Menues_ = new System.Collections.Generic.Dictionary<string, IntelliTrack.Client.Application.Menues.MenuItem>();
   try
   {
     sqlConnection.Open();
     string s2 = "select * from sf_menu(NULL, " + NroSistema + ", '" + UserName + "') ORDER BY MEN_POSICION";
     System.Data.SqlClient.SqlDataAdapter sqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter(s2, sqlConnection);
     System.Data.DataSet dataSet = new System.Data.DataSet();
     sqlDataAdapter.Fill(dataSet);
     System.Collections.Generic.Dictionary<string, IntelliTrack.Client.Application.Menues.MenuItem> dictionary = new System.Collections.Generic.Dictionary<string, IntelliTrack.Client.Application.Menues.MenuItem>();
     foreach (System.Data.DataRow dataRow in dataSet.Tables[0].Rows)
     {
       IntelliTrack.Client.Application.Menues.MenuItem menuItem = new IntelliTrack.Client.Application.Menues.MenuItem(dataRow);
       dictionary[dataRow["MEN_NUMERO"].ToString()] = menuItem;
     }
     Menues_ = dictionary;
   }
   catch (System.Data.SqlClient.SqlException e)
   {
     System.Windows.Forms.MessageBox.Show("Error de conexion a la base de datos.", "Error", System.Windows.Forms.MessageBoxButtons.OK);
     IntelliTrack.Client.Application.Logging.logError.Error("Error al intentar acceder a la base de datos de seguridad", e);
   }
   catch (System.Exception)
   {
     Menues_.Clear();
   }
   finally
   {
     sqlConnection.Close();
   }
 }
开发者ID:diegowald,项目名称:intellitrack,代码行数:34,代码来源:ValidacionSeguridad.cs

示例2: ObtenerItemsMenu

  private void ObtenerItemsMenu()
  {
    try
    {
      string strConnection = GetSecurityConnectionString();
      System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(strConnection);
      conn.Open();

      string cmd = "select * from sf_menu(NULL, " + NroSistema + ", '" + UserName + "')";
      System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd, conn);

      System.Data.DataSet ds = new System.Data.DataSet();
      da.Fill(ds);

      System.Collections.Generic.Dictionary<string, string> menues = new System.Collections.Generic.Dictionary<string, string>();
      foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
      {
        menues[dr["MEN_POSICION"].ToString()] = dr["MEN_ID"].ToString();
      }
      Menues_ = menues;
    }
    catch (Exception)
    {
      Menues_.Clear();
    }
  }
开发者ID:diegowald,项目名称:intellitrack,代码行数:26,代码来源:ValidacionSeguridad.cs

示例3: HyperlinkRelationshipTest

        public void HyperlinkRelationshipTest()
        {
            using (var stream = new System.IO.MemoryStream(TestFileStreams.May_12_04, false))
            {
                using (WordprocessingDocument testDocument = WordprocessingDocument.Open(stream, false))
                {
                    OpenXmlValidator validator = new OpenXmlValidator();
                    var errors = validator.Validate(testDocument);
                    Assert.Equal(0, errors.Count());

                    var mainPart = testDocument.MainDocumentPart;

                    Assert.Equal(0, mainPart.ExternalRelationships.Count());
                    Assert.Equal(71, mainPart.HyperlinkRelationships.Count());

                    var rid15 = mainPart.GetReferenceRelationship("rId15");
                    Assert.Equal("rId15", rid15.Id);
                    Assert.Equal(new System.Uri("#_THIS_WEEK_IN", System.UriKind.Relative), rid15.Uri);
                    Assert.False(rid15.IsExternal);

                    var rid18 = mainPart.GetReferenceRelationship("rId18");
                    Assert.Equal("rId18", rid18.Id);
                    Assert.Equal(new System.Uri("http://www.iaswresearch.org/"), rid18.Uri);
                    Assert.True(rid18.IsExternal);
                }
            }

            using (System.IO.Stream stream = new System.IO.MemoryStream())
            {
                using (var testDocument = WordprocessingDocument.Create(stream, WordprocessingDocumentType.Document))
                {
                    var mainPart = testDocument.AddMainDocumentPart();
                    var paragraph = new DocumentFormat.OpenXml.Wordprocessing.Paragraph(new Body());
                    mainPart.Document = new Document(new Body(paragraph));
                    mainPart.Document.Save();

                    var newUri = new System.Uri("#New", System.UriKind.Relative);
                    var ridnew = mainPart.AddHyperlinkRelationship(newUri, false);
                    var newRel = mainPart.PackagePart.GetRelationship(ridnew.Id);
                    Assert.Equal(System.IO.Packaging.TargetMode.Internal, newRel.TargetMode);
                    Assert.Equal(ridnew.Id, newRel.Id);
                    Assert.Equal(newUri, newRel.TargetUri);
                    Assert.Equal(HyperlinkRelationship.RelationshipTypeConst, newRel.RelationshipType);

                    mainPart.DeleteReferenceRelationship(ridnew);
                    Assert.Equal(0, mainPart.HyperlinkRelationships.Count());

                    newUri = new System.Uri("http://microsoft.com", System.UriKind.Absolute);
                    ridnew = mainPart.AddHyperlinkRelationship(newUri, true, ridnew.Id);
                    newRel = mainPart.PackagePart.GetRelationship(ridnew.Id);
                    Assert.Equal(System.IO.Packaging.TargetMode.External, newRel.TargetMode);
                    Assert.Equal(ridnew.Id, newRel.Id);
                    Assert.Equal(newUri, newRel.TargetUri);
                    Assert.Equal(HyperlinkRelationship.RelationshipTypeConst, newRel.RelationshipType);

                }

                // Test the OpenXmlPartContainer.AddSubPartFromOtherPackage().
                // The method should import all hyperlink relationships.
                stream.Seek(0, System.IO.SeekOrigin.Begin);
                using (var testDocument = WordprocessingDocument.Create(stream, WordprocessingDocumentType.Document))
                {
                    using (var sourcestream = new System.IO.MemoryStream(TestFileStreams.May_12_04, false))
                    {
                        using (WordprocessingDocument sourceDocument = WordprocessingDocument.Open(sourcestream, false))
                        {
                            var parts = new System.Collections.Generic.Dictionary<OpenXmlPart, bool>();
                            sourceDocument.MainDocumentPart.FindAllReachableParts(parts);
                            var partCounts = parts.Count;

                            var hyperlinksBefore = sourceDocument.MainDocumentPart.HyperlinkRelationships.ToArray();
                            var externalRelsBefore = sourceDocument.MainDocumentPart.ExternalRelationships.ToArray();

                            testDocument.AddPart(sourceDocument.MainDocumentPart);
                            parts.Clear();
                            testDocument.MainDocumentPart.FindAllReachableParts(parts);

                            // all parts under the main document part should be imported.
                            Assert.Equal(partCounts, parts.Count);

                            var hyperlinksAfter = testDocument.MainDocumentPart.HyperlinkRelationships.ToArray();
                            var externalRelsAfter = testDocument.MainDocumentPart.ExternalRelationships.ToArray();

                            // all hyperlink relationships should be imported.
                            Assert.Equal(hyperlinksBefore.Length, hyperlinksAfter.Length);
                            for (int i = 0; i < hyperlinksBefore.Length; i++)
                            {
                                Assert.Equal(hyperlinksBefore[i].Id, hyperlinksAfter[i].Id);
                                Assert.Equal(hyperlinksBefore[i].IsExternal, hyperlinksAfter[i].IsExternal);
                                Assert.Equal(hyperlinksBefore[i].Uri, hyperlinksAfter[i].Uri);
                            }

                            // all external relationships should be improted.
                            Assert.Equal(externalRelsBefore.Length, externalRelsAfter.Length);
                        }
                    }
                }
            }
        }
开发者ID:eriawan,项目名称:Open-XML-SDK,代码行数:99,代码来源:OpenXmlPartTest.cs


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