本文整理汇总了C#中System.Collections.Specialized.StringCollection.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Specialized.StringCollection.AddRange方法的具体用法?C# System.Collections.Specialized.StringCollection.AddRange怎么用?C# System.Collections.Specialized.StringCollection.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.StringCollection
的用法示例。
在下文中一共展示了System.Collections.Specialized.StringCollection.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnDownload_Click
private void btnDownload_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtLinks.Text))
{
var strCol = new System.Collections.Specialized.StringCollection();
strCol.AddRange(txtLinks.Text.Split('\r'));
var videoList = VKontakteApiWrapper.Instance.VideoGetByIds(Utils.StringUtils.GetUserAndObjectIDFromUrl(strCol));
this.Close();
DownloadVideo wind = new DownloadVideo(videoList);
wind.Owner = App.Current.MainWindow;
wind.Show();
}
}
示例2: miVidImport_Click
private void miVidImport_Click(object sender, RoutedEventArgs e)
{
// Configure open file dialog box
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.Filter = "Yuv-Videos (.yuv)|*.yuv|All files (*.*)|*.*"; // Filter files by extension
dlg.Multiselect = true;
// Show open file dialog box
Nullable<bool> result = dlg.ShowDialog();
// Process open file dialog box results
if (result == true)
{
System.Collections.Specialized.StringCollection sc = new System.Collections.Specialized.StringCollection();
sc.AddRange(dlg.FileNames);
// Open document
this.vM_ProjectExplorer.importVideos(sc);
}
}
示例3: InnerSetup
/// <summary>
/// Inner method used to implement the setup operation.
/// </summary>
protected void InnerSetup(Config config)
{
// if needed, clear the prior state.
if (setupPerformed)
Clear();
// record the given configuration
this.config = config;
excludedFileSet = new System.Collections.Specialized.StringCollection();
excludedFileSet.AddRange(config.excludeFileNamesSet.ToArray());
string dirPath = config.dirPath;
// try to add a DirectoryEntryInfo record for each of the files that are in the directory
try
{
DirectoryEntryInfo basePathInfo = new DirectoryEntryInfo(dirPath);
if (basePathInfo.Exists)
{
if (basePathInfo.IsFile)
throw new SetupFailureException(Utils.Fcns.CheckedFormat("target path '{0}' does not specify a directory.", dirPath));
}
else
{
if (config.createDirectoryIfNeeded)
System.IO.Directory.CreateDirectory(dirPath);
else
throw new SetupFailureException(Utils.Fcns.CheckedFormat("target path '{0}' does not exist.", dirPath));
}
// directory exists or has been created - now scan it and record each of the entries that are found therein
DirectoryInfo dirInfo = new DirectoryInfo(dirPath);
FileSystemInfo [] directoryFSIArray = dirInfo.GetFileSystemInfos();
foreach (FileSystemInfo fsi in directoryFSIArray)
{
string path = fsi.FullName;
string name = fsi.Name;
if (!excludedFileSet.Contains(name) && !excludedFileSet.Contains(path))
AddDirEntry(path, true);
}
if (numBadDirEntries != 0)
logger.Error.Emit("Setup Failure: There are bad directory entries in dir '{0}'", dirPath);
}
catch (SetupFailureException sfe)
{
SetSetupFaultCode(sfe.Message);
}
catch (System.Exception ex)
{
SetSetupFaultCode(Utils.Fcns.CheckedFormat("Setup Failure: encountered unexpected exception '{0}' while processing dir '{1}'", ex.Message, dirPath));
}
if (!SetupFailed)
{
// perform an additional set of tests
if (string.IsNullOrEmpty(config.fileNamePrefix) || string.IsNullOrEmpty(config.fileNameSuffix))
SetSetupFaultCode("Setup Failure: Invalid file name fields in configuration");
else if (config.advanceRules.fileAgeLimitInSec < 0.0)
SetSetupFaultCode("Setup Failure: Config: advanceRules.fileAgeLimitInSec is negative");
else if (config.purgeRules.dirNumFilesLimit > 0 && config.purgeRules.dirNumFilesLimit < ConfigPurgeNumFilesMinValue)
SetSetupFaultCode("Setup Failure: Config: purgeRules.dirNumFilesLimit is too small");
else if (config.purgeRules.dirNumFilesLimit > 0 && config.purgeRules.dirNumFilesLimit > ConfigPurgeNumFilesMaxValue)
SetSetupFaultCode("Setup Failure: Config: purgeRules.dirNumFilesLimit is too large");
else if (config.purgeRules.dirTotalSizeLimit < 0)
SetSetupFaultCode("Setup Failure: Config: purgeRules.dirTotalSizeLimit is negative");
else if (config.purgeRules.fileAgeLimitInSec < 0.0)
SetSetupFaultCode("Setup Failure: Config: purgeRules.maxFileAgeLimitInSec is negative");
}
DirectoryEntryInfo activeFileInfo = new DirectoryEntryInfo();
if (!SetupFailed)
{
switch (config.fileNamePattern)
{
case FileNamePattern.ByDate: numFileNumberDigits = 0; break;
case FileNamePattern.Numeric2DecimalDigits: numFileNumberDigits = 2; maxFileNumber = 100; break;
case FileNamePattern.Numeric3DecimalDigits: numFileNumberDigits = 3; maxFileNumber = 1000; break;
case FileNamePattern.Numeric4DecimalDigits: numFileNumberDigits = 4; maxFileNumber = 10000; break;
default: SetSetupFaultCode("Setup Failure: Invalid file name pattern in configuration"); break;
}
// go through the directory file info entries (acquired above) from newest to oldest
// and retain the newest valid file that matches the name pattern for this content
// manager. This file will become the initial active file.
activeFileEntryID = DirEntryID_Invalid;
activeFileNumber = 0;
bool matchFound = false;
IList<Int64> itemKeys = dirEntryIDListSortedByCreatedFTimeUtc.Keys;
IList<List<int>> itemValues = dirEntryIDListSortedByCreatedFTimeUtc.Values;
//.........这里部分代码省略.........
示例4: Initializing_pagevariables
private void Initializing_pagevariables()
{
available_elements = new System.Collections.Specialized.StringCollection();
available_elements.AddRange(new string[] {"themecolour", "pagetitle", "pagetagline", "mda", "leftnav", "leftnav_page", "introduction", "headline", "required_sentence", "bandedheader", "content", "button", "divider"});
try
{
Hashtable h_params = new Hashtable();
page_id_from_session = Session["page_id"].ToString();
if(Request.QueryString["element"] != null)
{
string rqst_element = Request.QueryString["element"].ToString();
element_to_edit = rqst_element;
if (!available_elements.Contains(rqst_element))
{
Response.Redirect("index.aspx");
}
}
else
{
if (Request.QueryString["id"] != null)
{
element_id = Request.QueryString["id"].ToString();
h_params.Add("page_id", page_id_from_session);
h_params.Add("element_id", element_id);
element_db = DB.execProc("select_page_variableelements", h_params);
switch (element_db.Rows[0][1].ToString())
{
case "bh": element_to_edit = "bandedheader";
break;
case "di": element_to_edit = "divider";
break;
case "cc": element_to_edit = "content";
break;
case "rh": element_to_edit = "headline";
break;
default: Response.Redirect("index.aspx", true);
break;
}
}
else
{
Response.Redirect("index.aspx", true);
}
}
h_params.Clear();
h_params = new Hashtable();
h_params.Add("page_id", page_id_from_session);
h_params.Add("page_type", "1");
page_type = DB.execProc("select_page_fixedelements", h_params).Rows[0][0].ToString();
Session["page_type"] = page_type;
}
catch
{
Response.Redirect("index.aspx", true);
}
}
示例5: loadAddIns
/// <summary>
/// Load the addins to the FrontEnd
/// </summary>
/// <param name="ownerOfAddIn">Who will own this addin</param>
/// <param name="objectAdapter">Some ice stuff</param>
/// <param name="modulesManager">Modules Manager</param>
/// <param name="displayer">Displayer of the properties (if an Add-in has a property)</param>
private static void loadAddIns(IOwnerOfAddIn ownerOfAddIn,
Ice.ObjectAdapter objectAdapter,
Ferda.ModulesManager.ModulesManager modulesManager, Properties.IOtherObjectDisplayer displayer)
{
System.Collections.Specialized.StringCollection proxies
= new System.Collections.Specialized.StringCollection();
foreach(string file in System.IO.Directory.GetFiles("AddIns"))
{
if(System.IO.Path.GetExtension(file) == ".dll")
{
string path = "Ferda.FrontEnd.AddIns." +
System.IO.Path.GetFileNameWithoutExtension(file) +
".Main";
//tohle se nezvladne
Assembly asembly =
System.Reflection.Assembly.LoadFile(System.IO.Path.GetFullPath(file));
IAddInMain addInMain = (IAddInMain)asembly.CreateInstance(path);
//adding the properties displayer if it is a addin capable of
//displaying properties
if (addInMain is Properties.IPropertyProvider)
{
Properties.IPropertyProvider prov = addInMain as
Properties.IPropertyProvider;
prov.Displayer = displayer;
}
addInMain.OwnerOfAddIn = ownerOfAddIn;
addInMain.ObjectAdapter = objectAdapter;
proxies.AddRange(addInMain.ObjectProxiesToAdd);
addIns.Add(addInMain);
}
}
int count = proxies.Count;
string[] newServices = new string[count];
if(count > 0)
{
proxies.CopyTo(newServices, 0);
}
modulesManager.AddModuleServices(newServices);
}
示例6: CUIExec
// CUIモード
static int CUIExec(bool q, List<string> files) {
IOutputController Output = new CUIOutput(q);
if (files.Count == 0) {
Console.WriteLine(Properties.Resources.NOINPUTFILE);
return -5;
}
try {
Directory.CreateDirectory(Path.GetTempPath());
}
catch (Exception) {
Console.WriteLine(String.Format(Properties.Resources.FAIL_TMPFOLDER, Path.GetTempPath()));
return -7;
}
int failnum = 0;
var outFiles = new System.Collections.Specialized.StringCollection();
for (int i = 0; i < files.Count / 2; ++i) {
string file = Path.GetFullPath(files[2 * i]);
string dir;
if (Properties.Settings.Default.workingDirectory == "file") dir = Path.GetDirectoryName(file);
else if (Properties.Settings.Default.workingDirectory == "current") dir = Directory.GetCurrentDirectory();
else dir = Path.GetTempPath();
string tmpTeXFileName = TempFilesDeleter.GetTempFileName(Path.GetExtension(file), dir);
if (tmpTeXFileName == null) {
Console.WriteLine(String.Format(Properties.Resources.FAIL_TMPFILE, Path.GetTempPath()));
return -6;
}
tmpTeXFileName = Path.Combine(dir, tmpTeXFileName);
// 一時フォルダにコピー
File.Copy(file, tmpTeXFileName, true);
(new FileInfo(tmpTeXFileName)).Attributes = FileAttributes.Normal;
var output = Path.GetFullPath(files[2 * i + 1]);
// 変換!
try {
using (var converter = new Converter(Output, tmpTeXFileName, output)) {
converter.AddInputPath(Path.GetDirectoryName(file));
if (!converter.Convert()) ++failnum;
else outFiles.AddRange(converter.OutputFileNames.ToArray());
}
if (Properties.Settings.Default.setFileToClipBoard) Clipboard.SetFileDropList(outFiles);
}
catch (Exception e) { Console.WriteLine(e.Message); }
}
return failnum;
}
示例7: IsWithIceId
/// <summary>
/// Says if some creator has function with specified ice identifier
/// </summary>
/// <param name="iceId">Ice identifier</param>
/// <param name="creator">Proxy of box module factory creator</param>
/// <returns></returns>
public bool IsWithIceId(string iceId, BoxModuleFactoryCreatorPrx creator)
{
System.Collections.Specialized.StringCollection _functionsIceIds =
new System.Collections.Specialized.StringCollection();
_functionsIceIds.AddRange(
creator.getBoxModuleFunctionsIceIds());
return _functionsIceIds.Contains(iceId);
}
示例8: Refresh
/// <summary>
/// リストリフレッシュ
/// </summary>
private void Refresh()
{
(CollectionViewSource.GetDefaultView(LauncherItems) as ICollectionView).Refresh();
var collection = new System.Collections.Specialized.StringCollection();
collection.AddRange(LauncherItems.Select(a => a.FullPath).ToArray());
Properties.Settings.Default.RegisterdItems = collection;
Properties.Settings.Default.Save();
}
示例9: RegisterSubject
private Guid RegisterSubject(string name, string[] additionalOperations, string username)
{
Logger.Debug("Registered subject " + name);
using (SC.Utility.Lock l = new SC.Utility.Lock(secLock, SC.Utility.Lock.LockType.ForWriting))
{
SecuritySubject subject;
if (!subjects.ContainsKey(name))
{
if (username == null)
subjects[name] = new SecuritySubject(name);
else
subjects[name] = new SecuritySubject(name, username);
}
subject = subjects[name];
Guid guid = Guid.NewGuid();
while (acls.ContainsKey(guid))
guid = Guid.NewGuid();
acls.Add(guid, subject);
if (additionalOperations != null)
{
Logger.Debug("Additional operations " + string.Join(", ", additionalOperations));
System.Collections.Specialized.StringCollection operations = new System.Collections.Specialized.StringCollection();
operations.AddRange(additionalOperations);
foreach (string op in operations)
{
if (!subject.HaveOperation(op))
subject.AddOperation(op);
}
operations.Add(Operation.DEFAULT_OPERATION);
foreach (string op in subject.GetOperations())
{
if (!operations.Contains(op))
subject.RemoveOperation(op);
}
}
return guid;
}
}
示例10: FixAdministrator
private void FixAdministrator()
{
using (SC.Utility.Lock l = new SC.Utility.Lock(secLock, SC.Utility.Lock.LockType.ForReading))
{
if (users.Count == 0)
{
Logger.Warn("No users found, adding Administrator account with default password");
l.UpgradeToWriterLock();
UserInfo adminInfo = new UserInfo("Administrator", "ServerChecker4");
users.Add(adminInfo.Username, adminInfo);
l.DowngradeToReaderLock();
}
SecuritySubject me = acls[securityGuid];
System.Collections.Specialized.StringCollection permissions = new System.Collections.Specialized.StringCollection();
permissions.AddRange(me.GetPermissions());
if (permissions.Count == 0)
{
Logger.Warn("No permissions found for SecurityManager. Adding permission for Administrator account");
l.UpgradeToWriterLock();
me.AddPermission("Administrator");
l.DowngradeToReaderLock();
}
}
}
示例11: SetClipboardFiles
/// <summary>
/// Set files note
/// </summary>
/// <param name="files">files note</param>
/// <returns>return true if success</returns>
public static bool SetClipboardFiles(string[] files)
{
try
{
System.Collections.Specialized.StringCollection coll = new System.Collections.Specialized.StringCollection();
coll.AddRange(files);
FORMS.Clipboard.SetFileDropList(coll);
return true;
}
catch
{
return false;
}
}
示例12: FormatMultiLineMaxChars
// Splits a string containing new lines (assumed to be \n or \r\n) and passes each
// line to FormatSingleLineMaxChars and returns the resulting string array
public static string[] FormatMultiLineMaxChars( int maxLen, string sLine )
{
System.Diagnostics.Debug.Assert( maxLen > 0, "Max must be at least 1" );
if( maxLen <= 0 ) return null;
string[] lines = sLine.Replace( "\r", "" ).Split( new char[]{'\n'} );
System.Collections.Specialized.StringCollection formattedLines = new System.Collections.Specialized.StringCollection();
foreach( string line in lines )
formattedLines.AddRange( FormatSingleLineMaxChars( maxLen, line ) );
string[] multi = new string[ formattedLines.Count ];
formattedLines.CopyTo( multi, 0 );
return multi;
}
示例13: CreateAContentType
private static void CreateAContentType()
{
SPList listFields;
SPWeb myWeb;
SPSite myDemoSite = new SPSite("http://abcuniversity");
Console.WriteLine("Talking to SharePoint, Don't Go Anywhere.");
myWeb = myDemoSite.OpenWeb();
listFields = myWeb.Lists.TryGetList("CustomizableList");
List<SPField> fieldsForContentType = new List<SPField>();
string[] fieldsIWantToAdd = {"AnnualSalary", "SportType", "CurrentStatus"};
foreach(SPField field in listFields.Fields)
{
//Console.WriteLine("Field name: {0}, \nField ID: {1}\nField Group: {2}\n",
//field.StaticName, field.Id.ToString(),field.Group);
//3 differencet ways of adding fields
//-1- Adding field directly to list using ADD()
string newFieldA = null, newFieldB = null, newFieldC = null;
if(listFields.Fields.ContainsField("CurrentTeam") == false)
{
Console.WriteLine("Adding CurrentTeam...");
newFieldA = listFields.Fields.Add("CurrentTeam", SPFieldType.Text, false);
Console.WriteLine("Added CurrentTeam column to list");
}
else
{
Console.WriteLine("Added CurrentTeam column to list.");
}
//-and2- Adding the same field to site columns ausing SPField object and target list.
if (listFields.Fields.ContainsField("PlayerPosition") == false)
{
SPField addANewField = listFields.Fields.CreateNewField("Text", "PlayerPosition");
addANewField.Description = "This position, will vary by sport.";
//Add it to the Web first... We should probably do the duplication here, too...
myWeb.Fields.Add(addANewField);
newFieldB = listFields.Fields.Add(addANewField);
Console.WriteLine("PlayerPosition column added to the list...");
}
else
{
Console.WriteLine("Added PlayerPosition column to list.");
}
//-and3!- //Using System.Collections to create and add choice field
if(listFields.Fields.ContainsField("MyPeronalField") == false)
{
System.Collections.Specialized.StringCollection choices = new System.Collections.Specialized.StringCollection();
choices.AddRange(new string[] {"Healthy","Out","Likely","Probable"});
//Add("DisplayName",FieldType,Required,CompactName,choicelist
newFieldC = listFields.Fields.Add("MyPeronalField", SPFieldType.Choice, false, false, choices);
Console.WriteLine("MyPeronalField field added to the list...");
}
else
{
Console.WriteLine("MyPeronalField not added, already part of the list...");
}
/*//If its one of the fields we're interested in, add it to our collection
if(fieldsIWantToAdd.Contains(field.StaticName))
{
fieldsForContentType.Add(field);
}*/
}//end foreach
SPContentTypeCollection allMyContent = myWeb.ContentTypes;
SPContentType newContentType = new SPContentType(
allMyContent["item"], allMyContent, "TestContentType");
allMyContent.Add(newContentType);
string newField1 = myWeb.Fields.Add("AnnualSalary", SPFieldType.Number, false);
SPFieldLink newField1Link = new SPFieldLink(myWeb.Fields.GetField(newField1));
newContentType.FieldLinks.Add(newField1Link);
string newField2 = myWeb.Fields.Add("CurrentStatus", SPFieldType.Text, false);
SPFieldLink newField2Link = new SPFieldLink(myWeb.Fields.GetField(newField2));
newContentType.FieldLinks.Add(newField2Link);
string newField3 = myWeb.Fields.Add("SportType", SPFieldType.Text, false);
SPFieldLink newField3Link = new SPFieldLink(myWeb.Fields.GetField(newField3));
newContentType.FieldLinks.Add(newField3Link);
//newContentType.Update();
}
示例14: mnuRefreshP4_Click
private void mnuRefreshP4_Click(object sender, System.EventArgs e)
{
LoadFileList();
System.Collections.Specialized.StringCollection opened = new System.Collections.Specialized.StringCollection();
opened.AddRange(m_p4.GetP4OpenFiles ());
foreach(ListViewItem item in m_list.Items)
{
if(opened.Contains( (string)item.Tag))
{
item.ImageIndex = 1;
item.ForeColor = System.Drawing.Color.Blue;
}
}
}
示例15: CLAutoThumbnailer
/// <summary>
/// Prevents a default instance of the <see cref="CLAutoThumbnailer"/> class from being created.
/// </summary>
/// <param name="args">Command line arguments.</param>
/// <param name="baseDir">If created via command file the directory of the command file,
/// otherwise <c>null</c>.</param>
/// <exception cref="NDesk.Options.OptionException">Thrown when option error occurs.</exception>
CLAutoThumbnailer(string[] args, string baseDir)
{
InitializeThumbnailSettings ();
InitializeVideoRE ();
System.Collections.Specialized.StringCollection fixedArgs =
new System.Collections.Specialized.StringCollection ();
foreach (string arg in args)
{
if (arg.EndsWith("\""))
{
fixedArgs.Add(arg.Remove(arg.Length-1));
}
else
fixedArgs.Add(arg);
}
String[] fixedArgsArray = new String[fixedArgs.Count];
fixedArgs.CopyTo(fixedArgsArray, 0);
double doubleInterval = -1;
_oset = new NDesk.Options.OptionSet () {
{ "d|directory=",
"{DIRECTORY} to process. Generate thumbnails for\n" +
"files with the following extensions:\n" +
_videoExtensions,
v => _directoryArg = v },
{ "exts=",
"add/remove video {EXTENSIONS} " +
"(\"[+]ext1, -ext2\")",
v =>
{
string[] exts = _commaRE.Split(v);
foreach (string ext in exts)
{
string s = ext.Trim().ToLower();
bool addExt = true;
if (s[0] == '-')
{
s = s.Substring(1);
addExt = false;
}
else if (s[0] == '+')
{
s = s.Substring (1);
}
if (addExt)
{
if (_videoExts.Contains (s))
THelper.Error ("Error: '{0}' is already in valid video extensions list.", s);
else
{
THelper.Information ("'{0}' added to valid video extensions list.", s);
_videoExts.Add (s);
_videoExtsChanged = true;
}
}
else
{
if (!_videoExts.Contains (s))
THelper.Error ("Error: '{0}' isn't in valid video extensions list.", s);
else
{
THelper.Information ("'{0}' removed from valid video extensions list.", s);
_videoExts.Remove (s);
_videoExtsChanged = true;
}
}
}
if (_videoExtsChanged)
{
System.Collections.ArrayList temp = System.Collections.ArrayList.Adapter(_videoExts);
temp.Sort ();
_videoExts = new System.Collections.Specialized.StringCollection ();
_videoExts.AddRange ((String[]) temp.ToArray(typeof(string)));
}
} },
{ "minsize=",
String.Format("Minimum {{FILESIZE}} of video files (0 to disable) [{0} ({1})]",
_minFileSize, ThumbnailCreator.GetFileSizeString(_minFileSize)),
(long v) =>
{
if (v < 0)
v = 0;
_minFileSize = v;
} },
{ "m|cmddir=",
"create initial command file for {DIRECTORY}",
v => _cmdDirectory = v },
{ "s|start=",
//.........这里部分代码省略.........