本文整理汇总了C#中StringCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# StringCollection.Add方法的具体用法?C# StringCollection.Add怎么用?C# StringCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringCollection
的用法示例。
在下文中一共展示了StringCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildList
private static StringCollection BuildList()
{
StringCollection list = new StringCollection();
list.Add("ABC");
list.Add("DEF");
list.Add("GHI");
return list;
}
示例2: Main
static int Main (string [] args)
{
if (args.Length != 1) {
Console.WriteLine ("Please specify action.");
return 1;
}
switch (args [0]) {
case "clear":
Settings.Default.Name = null;
Settings.Default.FirstNames = null;
Settings.Default.Address = null;
Settings.Default.Save ();
break;
case "delete":
Configuration config = ConfigurationManager.OpenExeConfiguration (
ConfigurationUserLevel.PerUserRoamingAndLocal);
File.Delete (config.FilePath);
break;
case "write":
StringCollection firstNames = new StringCollection ();
firstNames.Add ("Miguel");
firstNames.Add ("Atsushi");
firstNames.Add ("Gonzalo");
Settings.Default.Address = new Address ("Whatever", 50);
Settings.Default.FirstNames = firstNames;
Settings.Default.Name = "Mono";
Settings.Default.Save ();
break;
case "read1":
Assert.IsNotNull (Settings.Default.Address, "#1");
Assert.AreEqual (50, Settings.Default.Address.HouseNumber, "#2");
Assert.AreEqual ("Whatever", Settings.Default.Address.Street, "#3");
Assert.IsNotNull (Settings.Default.FirstNames, "#4");
Assert.AreEqual (3, Settings.Default.FirstNames.Count, "#5");
Assert.AreEqual ("Miguel", Settings.Default.FirstNames [0], "#6");
Assert.AreEqual ("Atsushi", Settings.Default.FirstNames [1], "#7");
Assert.AreEqual ("Gonzalo", Settings.Default.FirstNames [2], "#8");
Assert.AreEqual ("Mono", Settings.Default.Name, "#9");
break;
case "read2":
Assert.AreEqual (string.Empty, Settings.Default.Name, "#1");
Assert.IsNull (Settings.Default.FirstNames, "#2");
Assert.IsNull (Settings.Default.Address, "#3");
break;
case "read3":
Assert.IsNull (Settings.Default.Name, "#1");
Assert.IsNull (Settings.Default.FirstNames, "#2");
Assert.IsNull (Settings.Default.Address, "#3");
break;
default:
Console.WriteLine ("Unsupported action '{0}'.", args [0]);
return 2;
}
return 0;
}
示例3: GetTargetIds
public StringCollection GetTargetIds(string parameterValues)
{
StringCollection ids = new StringCollection();
try
{
Configuration.LayerFunctionRow layerFunction = GetLayerFunctionRows().First(o => o.FunctionName == "targetparams");
using (OleDbCommand command = layerFunction.GetDatabaseCommand())
{
string[] p = parameterValues.Split(',');
for (int i = 0; i < command.Parameters.Count - 1; ++i)
{
command.Parameters[i].Value = p[i];
}
command.Parameters[command.Parameters.Count - 1].Value = AppUser.GetRole();
using (OleDbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
ids.Add(reader.GetValue(0).ToString());
}
}
}
}
catch { }
return ids;
}
示例4: BCCAgentIndicator
private void BCCAgentIndicator()
{
try
{
StringCollection serviceList = new StringCollection();
serviceList.Add(ConfigurationManager.AppSettings["BCCAgentName"].ToString());
if (serviceList != null && serviceList.Count > 0)
{
BCCOperator bccOperator = new BCCOperator();
DataTable dtService = bccOperator.GetServiceStatus(serviceList);
if (dtService != null && dtService.Rows != null && dtService.Rows.Count > 0)
{
string agent = "BCC Agent";
agentName.Text = agent;
agentStatus.Status = dtService.Rows[0][1].ToString();
agentStatus.ToolTip = dtService.Rows[0][1].ToString();
agentName.ToolTip = agent + " - " + dtService.Rows[0][1].ToString();
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.Write(ex.Message + ex.StackTrace, "Controls_AgentIndicator");
}
}
示例5: GetProductSearchResults
public void GetProductSearchResults()
{
this.apiContext.Timeout = 360000;
GetProductSearchResultsCall api = new GetProductSearchResultsCall(this.apiContext);
ProductSearchType ps = new ProductSearchType();
//ps.AttributeSetID = 1785;// Cell phones
ps.MaxChildrenPerFamily = 20; ps.MaxChildrenPerFamilySpecified = true;
ps.AvailableItemsOnly = false; ps.AvailableItemsOnlySpecified = true;
ps.QueryKeywords = "Nokia";
StringCollection ids = new StringCollection();
ids.Add("1785");
ps.CharacteristicSetIDs = ids;
// Pagination
PaginationType pt = new PaginationType();
pt.EntriesPerPage = 50; pt.EntriesPerPageSpecified = true;
pt.PageNumber = 1; pt.PageNumberSpecified = true;
ps.Pagination = pt;
ProductSearchTypeCollection pstc = new ProductSearchTypeCollection();
pstc.Add(ps);
// Make API call.
ProductSearchResultTypeCollection results = api.GetProductSearchResults(pstc);
Assert.IsNotNull(results);
Assert.IsTrue(results.Count > 0);
TestData.ProductSearchResults = results;
Assert.IsNotNull(TestData.ProductSearchResults);
Assert.IsTrue(TestData.ProductSearchResults.Count > 0);
}
示例6: GetOrderTransactions
public void GetOrderTransactions()
{
//
GetOrderTransactionsCall api = new GetOrderTransactionsCall(
this.apiContext);
StringCollection idArray = new StringCollection();
api.OrderIDArrayList = idArray;
idArray.Add("1111111111");
//ItemTransactionIDTypeCollection tIdArray = new ItemTransactionIDTypeCollection();
//api.ItemTransactionIDArrayList = tIdArray;
//ItemTransactionIDType tId = new ItemTransactionIDType();
//tIdArray.Add(tId);
//String itemId = "2222222222";
//tId.ItemID = itemId;
//tId.TransactionID = "test transaction id";
// Make API call.
ApiException gotException = null;
try {
OrderTypeCollection orders = api.GetOrderTransactions(idArray);
} catch (ApiException ex) {
gotException = ex;
}
Assert.IsNull(gotException);
}
示例7: RelistItemFull
public void RelistItemFull()
{
Assert.IsNotNull(TestData.EndedItem2);
TestData.EndedItem2.ApplicationData="this is new appilcation data which is specified by "+DateTime.Now.ToShortDateString();
RelistItemCall rviCall = new RelistItemCall(this.apiContext);
ItemType item = TestData.EndedItem2;
item.CategoryMappingAllowed=true;
item.CategoryMappingAllowed=true;
rviCall.Item=item;
StringCollection fields =new StringCollection();
String field="Item.ApplicationData";
fields.Add(field);
rviCall.DeletedFieldList=fields;
rviCall.Execute();
//check whether the call is success.
Assert.IsTrue(rviCall.AbstractResponse.Ack==AckCodeType.Success || rviCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!");
Assert.IsNotNull(rviCall.FeeList,"the Fees is null");
/*
foreach(FeeType fee in rviCall.FeeList)
{
isTherePropertyNull=ReflectHelper.IsProperteValueNotNull(fee,out nullPropertyNums,out nullPropertyNames);
Assert.IsTrue(isTherePropertyNull,"there are" +nullPropertyNums.ToString()+ " properties value is null. (" +nullPropertyNames+ ")");
}*/
Assert.IsNotNull(rviCall.ItemID,"the ItemID is null");
Assert.IsNotNull(rviCall.StartTime ,"the StartTime is null");
//Assert.IsTrue(false,"NewItem:"+TestData.NewItem.ItemID+";EndedItem:"+TestData.EndedItem.ItemID+";NewItem2:"+TestData.NewItem2.ItemID+";EndedItem2:"+TestData.EndedItem2.ItemID);
}
示例8: RelativePathTo
/// <summary>
/// Creates a relative path from one file or folder to another.
/// </summary>
/// <param name="fromDirectory">Contains the directory that defines the start of the relative path.</param>
/// <param name="toPath">Contains the path that defines the endpoint of the relative path.</param>
/// <returns>The relative path from the start directory to the end path.</returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException"></exception>
public static string RelativePathTo(string fromDirectory, string toPath)
{
if(fromDirectory == null)
throw new ArgumentNullException("fromDirectory");
if(toPath == null)
throw new ArgumentNullException("fromDirectory");
if(System.IO.Path.IsPathRooted(fromDirectory) && System.IO.Path.IsPathRooted(toPath))
{
if(string.Compare(System.IO.Path.GetPathRoot(fromDirectory),
System.IO.Path.GetPathRoot(toPath), true) != 0)
{
throw new ArgumentException(
string.Format("The paths '{0} and '{1}' have different path roots.",
fromDirectory, toPath));
}
}
StringCollection relativePath = new StringCollection();
string[] fromDirectories = fromDirectory.Split(System.IO.Path.DirectorySeparatorChar);
string[] toDirectories = toPath.Split(System.IO.Path.DirectorySeparatorChar);
int length = Math.Min(fromDirectories.Length, toDirectories.Length);
int lastCommonRoot = -1;
// find common root
for(int x = 0; x < length; x++)
{
if(string.Compare(fromDirectories[x], toDirectories[x], true) != 0)
break;
lastCommonRoot = x;
}
if(lastCommonRoot == -1)
{
throw new ArgumentException(
string.Format("The paths '{0} and '{1}' do not have a common prefix path.",
fromDirectory, toPath));
}
// add relative folders in from path
for(int x = lastCommonRoot + 1; x < fromDirectories.Length; x++)
if(fromDirectories[x].Length > 0)
relativePath.Add("..");
// add to folders to path
for(int x = lastCommonRoot + 1; x < toDirectories.Length; x++)
relativePath.Add(toDirectories[x]);
// create relative path
string[] relativeParts = new string[relativePath.Count];
relativePath.CopyTo(relativeParts, 0);
string newPath = string.Join(System.IO.Path.DirectorySeparatorChar.ToString(), relativeParts);
return newPath;
}
示例9: GetAllAssembly
private static void GetAllAssembly(Assembly assembly, StringCollection stringCollection)
{
string location = assembly.Location;
if (!stringCollection.Contains(location))
{
stringCollection.Add(location);
}
}
示例10: GetSingleItemSpecific
private NameValueListType GetSingleItemSpecific(string key, string value)
{
NameValueListType nv1 = new NameValueListType();
nv1.Name = key;
StringCollection nv1Col = new StringCollection();
nv1Col.Add(value);
nv1.Value = nv1Col;
return nv1;
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Configuration config = AppContext.GetConfiguration();
if (Request.QueryString["check"] != null)
{
string status = "unknown";
switch (Request.QueryString["check"].ToLower())
{
case "app":
status = AppSettings.AppIsAvailable ? "up" : "down";
break;
case "appmessage":
status = AppSettings.AppStatusMessage;
break;
case "mapservices":
StringCollection serviceStatus = new StringCollection();
foreach (Configuration.MapTabRow mapTab in config.MapTab)
{
bool isAvailable = AppContext.GetDataFrame(mapTab.MapTabID).Service.IsAvailable;
serviceStatus.Add(mapTab.MapTabID + ": " + (isAvailable ? "up" : "down"));
}
status = serviceStatus.Join("; ");
break;
}
Response.Write(status);
Response.End();
}
labMessage.Text = AppSettings.AppStatusMessage;
if (AppSettings.AppIsAvailable)
{
DataTable table = config.MapTab.Copy();
table.Columns.Add("Status", typeof(string));
foreach (DataRow row in table.Rows)
{
CommonDataFrame dataFrame = AppContext.GetDataFrame(row["MapTabID"].ToString());
row["Status"] = dataFrame.Service.IsAvailable ? "up" : "down";
}
grdMapServices.DataSource = table;
grdMapServices.DataBind();
grdMapServices.Visible = true;
}
}
示例12: getCatList
private void getCatList(int number,ref StringCollection catList,out CategoryTypeCollection categories)
{
bool isSuccess;
string message;
catList.Clear();
//get a leaf category
isSuccess=CategoryHelper.GetCISSupportLeafCategory(number,out categories,this.apiContext,out message);
Assert.IsTrue(isSuccess,message);
for(int i=0;i<number;i++)
{
//add to catList
catList.Add(categories[i].CategoryID);
}
}
示例13: Main
static void Main(string[] args)
{
if (args.Length != 2)
Environment.Exit(1);
string ip = args[0];
string hostname = args[1];
try {
String hosts = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\drivers\etc\hosts");
string[] lines = File.ReadAllLines(hosts);
StringCollection linesToSave = new StringCollection();
foreach (string l in lines) {
if (!l.Contains(hostname) && !l.Contains(ip)) {
linesToSave.Add(l);
}
}
if (!".".Equals(ip))
linesToSave.Add(ip + "\t" + hostname);
lines = new String[linesToSave.Count];
linesToSave.CopyTo(lines, 0);
File.WriteAllLines(hosts, lines);
} catch (Exception e) {
Console.WriteLine("{0}", e);
}
}
示例14: GetNames
} //AddName()
public StringCollection GetNames() {
// Assert FileIOPermission, caller may not have it!
new FileIOPermission(PermissionState.Unrestricted).Assert();
FileStream fs = new FileStream("names.txt", FileMode.Open,FileAccess.ReadWrite);
StreamReader sr = new StreamReader(fs);
StringCollection sc = new StringCollection();
string s = sr.ReadLine();
while (s != null) {
sc.Add(s);
s = sr.ReadLine();
} //while
fs.Close();
return sc;
} //GetNames()
示例15: Put
public void Put([FromBody]List<SelectOption> pingServices, string action = "")
{
var sc = new StringCollection();
try
{
foreach (var item in pingServices)
{
sc.Add(item.OptionValue);
}
BlogService.SavePingServices(sc);
}
catch (System.Exception)
{
throw new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
}
}