本文整理汇总了C#中System.Collections.SortedList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.Add方法的具体用法?C# SortedList.Add怎么用?C# SortedList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.SortedList
的用法示例。
在下文中一共展示了SortedList.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GatherNamespaceToRender
private void GatherNamespaceToRender(string nsPrefix, SortedList nsListToRender, Hashtable nsLocallyDeclared)
{
int num;
foreach (object obj2 in nsListToRender.GetKeyList())
{
if (Utils.HasNamespacePrefix((XmlAttribute) obj2, nsPrefix))
{
return;
}
}
XmlAttribute a = (XmlAttribute) nsLocallyDeclared[nsPrefix];
XmlAttribute nearestRenderedNamespaceWithMatchingPrefix = base.GetNearestRenderedNamespaceWithMatchingPrefix(nsPrefix, out num);
if (a != null)
{
if (Utils.IsNonRedundantNamespaceDecl(a, nearestRenderedNamespaceWithMatchingPrefix))
{
nsLocallyDeclared.Remove(nsPrefix);
nsListToRender.Add(a, null);
}
}
else
{
int num2;
XmlAttribute nearestUnrenderedNamespaceWithMatchingPrefix = base.GetNearestUnrenderedNamespaceWithMatchingPrefix(nsPrefix, out num2);
if (((nearestUnrenderedNamespaceWithMatchingPrefix != null) && (num2 > num)) && Utils.IsNonRedundantNamespaceDecl(nearestUnrenderedNamespaceWithMatchingPrefix, nearestRenderedNamespaceWithMatchingPrefix))
{
nsListToRender.Add(nearestUnrenderedNamespaceWithMatchingPrefix, null);
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:ExcAncestralNamespaceContextManager.cs
示例2: Main
static void Main(string[] args)
{
// Here we define the Hashtable obect and initialize it
Hashtable countryCodes = new Hashtable();
countryCodes.Add("358", "Finland");
countryCodes.Add("1", "Canada");
countryCodes.Add("254", "Kenya");
// Here we print the full content of the Hashtable
foreach (string code in countryCodes.Keys)
Console.WriteLine(code + " --> " + countryCodes[code]);
// Here we print all values in the Hastable
Console.WriteLine("Values in the hash table: ");
foreach (string value in countryCodes.Values)
Console.WriteLine(value);
SortedList countryAbbr = new SortedList();
countryAbbr.Add("FI", "Finland");
countryAbbr.Add("NL", "Netherlands");
countryAbbr.Add("IR", "Iran");
countryAbbr.Add("CA", "Canada");
Console.WriteLine("Country with abbreviation NL in sorted list: " + countryAbbr["NL"]);
Console.WriteLine("Third value in the sorted list: " + countryAbbr.GetByIndex(2));
// Here we print the full content of the SortedList
Console.WriteLine("The contnet of the sorted list: ");
foreach (string abbr in countryAbbr.Keys)
Console.WriteLine(abbr + " --> " + countryAbbr[abbr]);
// Here we print all values in the Hastable
Console.WriteLine("Values in the SortedList: ");
foreach (string abbr in countryAbbr.Values)
Console.WriteLine(abbr);
}
示例3: Main
static void Main(string[] args)
{
SortedList sl = new SortedList();
sl.Add("Stack", "Represents a LIFO collection of objects.");
sl.Add("Queue", "Represents a FIFO collection of objects.");
sl.Add("SortedList", "Represents a collection of key/value pairs.");
foreach (DictionaryEntry de in sl)
{
Console.WriteLine("{0,12}: {1}", de.Key, de.Value);
}
Console.WriteLine("\n" + sl["Queue"]);
Console.WriteLine(sl.GetByIndex(1));
Console.WriteLine("\nName Value Collection:");
NameValueCollection nvc = new NameValueCollection();
nvc.Add("Stack", "Represents a LIFO collection of objects.");
nvc.Add("Stack", "A pile of pancakes.");
nvc.Add("Queue", "Represents a FIFO collection of objects.");
nvc.Add("Queue", "In England, a line.");
nvc.Add("SortedList", "Represents a collection of key/value pairs.");
foreach (string s in nvc.GetValues(0))
Console.WriteLine(s);
foreach (string s in nvc.GetValues("Queue"))
Console.WriteLine(s);
}
示例4: JavascriptAsGenericSortedListTestOptionsTest
public void JavascriptAsGenericSortedListTestOptionsTest()
{
IDictionary<string, string> options = new SortedList<string, string>();
options.Add("key1","option1");
options.Add("key2","option2");
Assert.AreEqual("{key1:option1, key2:option2}",AbstractHelper.JavascriptOptions(options));
}
示例5: btnSave_Click
void btnSave_Click(object sender, EventArgs e)
{
SortedList sl = new SortedList();
Qry = "delete from Unit_master where UnitGroupName='" + cboUnitType.Text + "'";
sl.Add(sl.Count + 1, Qry);
for (int i = 0; i < dgvInfo.Rows.Count - 1; i++)
{
Qry = "INSERT INTO [dbo].[Unit_Master] " +
" ([UnitGroupName]" +
" ,[UnitID]" +
" ,[UnitName]" +
" ,[RelativeFactor]" +
" ,[IsBaseUOM]" +
" ,[AddedBy]" +
" ,[DateAdded])" +
" VALUES " +
" ('" + cboUnitType.Text + "'," +
"'" + dgvInfo.Rows[i].Cells[0].Value.ToString() + "'," +
"'" + dgvInfo.Rows[i].Cells[1].Value.ToString() + "'," +
"" + dgvInfo.Rows[i].Cells[2].Value.ToString() + "," +
"'" + Convert.ToBoolean(dgvInfo.Rows[i].Cells[3].Value) + "'," +
"'" + LoginSession.UserID + "',getdate())";
sl.Add(sl.Count + 1, Qry);
}
DbUtility.ExecuteQuery(sl, "");
MessageBox.Show("Saved");
}
示例6: StateSites
public StateSites(State mdoState)
{
this.name = mdoState.Name;
this.abbr = mdoState.Abbr;
SortedList lst = new SortedList();
foreach (DictionaryEntry de in mdoState.Sites)
{
Site s = (Site)de.Value;
if (s.ChildSites != null)
{
for (int i = 0; i < s.ChildSites.Length; i++)
{
lst.Add(s.ChildSites[i].Name, s.ChildSites[i]);
}
}
Site clone = new Site();
clone.Id = s.Id;
clone.Name = s.Name;
clone.State = s.State;
clone.City = s.City;
clone.DisplayName = s.DisplayName;
clone.ParentSiteId = s.ParentSiteId;
clone.RegionId = s.RegionId;
lst.Add(clone.Name, clone);
}
this.sites = new SiteArray(lst);
}
示例7: Button
public Button()
{
this.m_bNoScalingOnSetRect = true;
Name = "Button";
this.MouseActive = true;
m_plStateSprites = new SortedList();
Frame spFrame = new Frame();
spFrame.Parent = this;
spFrame.Member = new MemberSpriteBitmap("Button2Up");
spFrame.Ink = RasterOps.ROPs.BgTransparent;
spFrame.Member.ColorKey = Color.FromArgb(0,0,0);
spFrame.Rect = new ERectangleF(0,0,50,50);
m_plStateSprites.Add(Sprite.MouseEventType.Leave, (Sprite)spFrame);
spFrame = new Frame();
spFrame.Parent = this;
spFrame.Member = new MemberSpriteBitmap("Button2Down");
spFrame.Ink = RasterOps.ROPs.BgTransparent;
spFrame.Member.ColorKey = Color.FromArgb(0,0,0);
spFrame.Rect = new ERectangleF(0,0,50,50);
m_plStateSprites.Add(Sprite.MouseEventType.Enter, (Sprite)spFrame);
for (int i = 0; i < m_plStateSprites.Count; i++)
{
((Sprite)m_plStateSprites.GetByIndex(i)).Visible = false;
}
((Sprite)m_plStateSprites[MouseEventType.Leave]).Visible = true;
}
示例8: GetCountries
public static SortedList GetCountries(bool insertEmpty)
{
SortedList countries = new SortedList();
if (insertEmpty)
countries.Add("", "Please select one...");
foreach (String country in _countries)
countries.Add(country, country);
return countries;
}
示例9: GetStates
public static SortedList GetStates(bool insertEmpty)
{
SortedList states = new SortedList();
if (insertEmpty)
states.Add("", "Please select one...");
foreach (String state in _states)
states.Add(state, state);
return states;
}
示例10: CanTestContentsOfSortedList
public void CanTestContentsOfSortedList()
{
object item = "xyz";
SortedList list = new SortedList();
list.Add("a", 123);
list.Add("b", item);
list.Add("c", "abc");
Assert.That(list.Values, new CollectionContainsConstraint(item));
Assert.That(list.Keys, new CollectionContainsConstraint("b"));
}
示例11: SortedList
public void SortedList()
{
var list = new SortedList();
list.Add(5, "Matteo");
list.Add(4, DateTime.UtcNow);
list.Add(1, "Pierangeli");
var firstPosition = list.GetKey(0);
Assert.That(list[firstPosition], Is.EqualTo("Pierangeli"));
}
示例12: TestCtorDefault
public void TestCtorDefault()
{
StringBuilder sblMsg = new StringBuilder(99);
SortedList sl2 = null;
StringBuilder sbl3 = new StringBuilder(99);
StringBuilder sbl4 = new StringBuilder(99);
StringBuilder sblWork1 = new StringBuilder(99);
//
// Constructor: Create a default SortedList
//
sl2 = new SortedList();
// Verify that the SortedList is not null.
Assert.NotNull(sl2);
// Verify that the SortedList is empty.
Assert.Equal(0, sl2.Count);
//
// Constructor: few more tests
//
sl2 = new SortedList();
var k0 = new CtorTestClass("cde");
var k1 = new CtorTestClass("abc");
var k2 = new CtorTestClass("bcd");
sl2.Add(k0, null);
sl2.Add(k1, null);
sl2.Add(k2, null);
// Verify that the SortedList is not null.
Assert.NotNull(sl2);
// Verify that the SortedList Count is right.
Assert.Equal(3, sl2.Count);
// Verify that the SortedList actually sorted the hashtable.
Assert.Equal(2, sl2.IndexOfKey(k0));
Assert.Equal(0, sl2.IndexOfKey(k1));
Assert.Equal(1, sl2.IndexOfKey(k2));
// Verify that the SortedList contains the right keys.
Assert.True(((CtorTestClass)sl2.GetKey(0)).GetString().Equals("abc"));
Assert.True(((CtorTestClass)sl2.GetKey(1)).GetString().Equals("bcd"));
Assert.True(((CtorTestClass)sl2.GetKey(2)).GetString().Equals("cde"));
}
示例13: CreateHashtableWithStrings
public static HashTestClass CreateHashtableWithStrings()
{
SortedList list = new SortedList();
list.Add("1", "a");
list.Add("2", "b");
list.Add("3", "c");
HashTestClass hash = new HashTestClass();
hash.ElementHash = list;
return hash;
}
示例14: CreateHashtableWithElements
public static HashTestClass CreateHashtableWithElements()
{
SortedList list = new SortedList();
list.Add("1", ElementTestClass.Create("1"));
list.Add("2", ElementTestClass.Create("2"));
list.Add("3", ElementTestClass.Create("3"));
HashTestClass hash = new HashTestClass();
hash.ElementHash = list;
return hash;
}
示例15: Login
public LoginInfo Login(string UserName, string Password, string Client_identifier = "", string Language = "zh-cn")
{
LoginInfo LI = new LoginInfo();
ClientToken = Client_identifier;
try
{
HttpWebRequest auth = (HttpWebRequest)WebRequest.Create(RouteAuthenticate);
auth.Method = "POST";
AuthenticationRequest ag = new AuthenticationRequest(UserName, Password);
DataContractJsonSerializer agJsonSerialiaer = new DataContractJsonSerializer(typeof(AuthenticationRequest));
MemoryStream agJsonStream = new MemoryStream();
agJsonSerialiaer.WriteObject(agJsonStream, ag);
agJsonStream.Position = 0;
string logindata = (new StreamReader(agJsonStream)).ReadToEnd();
byte[] postdata = Encoding.UTF8.GetBytes(logindata);
auth.ContentLength = postdata.LongLength;
Stream poststream = auth.GetRequestStream();
poststream.Write(postdata, 0, postdata.Length);
poststream.Close();
HttpWebResponse authans = (HttpWebResponse)auth.GetResponse();
DataContractJsonSerializer ResponseJsonSerializer = new DataContractJsonSerializer(typeof(AuthenticationResponse));
StreamReader ResponseStream = new StreamReader(authans.GetResponseStream());
string ResponseJson = ResponseStream.ReadToEnd();
MemoryStream ResponseJsonStream = new MemoryStream(Encoding.UTF8.GetBytes(ResponseJson));
ResponseJsonStream.Position = 0;
AuthenticationResponse Response = ResponseJsonSerializer.ReadObject(ResponseJsonStream) as AuthenticationResponse;
if (Response.getClientToken() != NewLogin.ClientToken)
{
LI.Suc = false;
LI.Errinfo = "客户端标识和服务器返回不符,这是个不常见的错误,就算是正版启动器这里也没做任何处理,只是报了这么个错。";
return LI;
}
LI.Suc = true;
LI.UN = Response.getSelectedProfile().getName();
LI.Client_identifier = NewLogin.ClientToken;
DataContractSerializer OtherInfoSerializer = new DataContractSerializer(typeof(SortedList));
SortedList OtherInfoList = new SortedList();
OtherInfoList.Add("${auth_uuid}",Response.getSelectedProfile().getId());
OtherInfoList.Add("${auth_access_token}", Response.getAccessToken());
MemoryStream OtherInfoStream = new MemoryStream();
OtherInfoSerializer.WriteObject(OtherInfoStream, OtherInfoList);
OtherInfoStream.Position = 0;
LI.OtherInfo = (new StreamReader(OtherInfoStream)).ReadToEnd();
return LI;
}
catch (TimeoutException ex)
{
LI.Suc = false;
LI.Errinfo = ex.Message;
return LI;
}
}