private void Delete_Click(object sender, RoutedEventArgs e) { try { string selected = GenreList.SelectedItem.ToString(); Properties.Settings.Default.Genres.Remove(selected); Properties.Settings.Default.Save(); Properties.Settings.Default.Reload(); GenreList.Items.Clear(); //check for null (first run) if (Properties.Settings.Default.Genres != null) { //create a new collection again StringCollection collection = new StringCollection(); //set the collection from the settings variable collection = Properties.Settings.Default.Genres; //convert the collection back to a list List <string> followedList = collection.Cast <string>().ToList(); //populate the listview again from the new list foreach (var item in followedList) { GenreList.Items.Add(item); } } } catch { MessageBox.Show("Select genre first!"); } }
protected IEnumerable <Uri> GetTransformedUrls() { return(_urls.Cast <string>().Select(s => { var url = s; if (string.IsNullOrEmpty(url)) { return null; } if (url.Contains("$(")) { url = GlobalVariables.Aggregate(url, (current, variable) => current.Replace("$(" + variable.Key + ")", variable.Value)); } if (!url.StartsWith("http://") && !url.StartsWith("https://")) { url = "http://" + url; } if (Uri.IsWellFormedUriString(url, UriKind.Absolute)) { return new Uri(url, UriKind.Absolute); } if (Uri.IsWellFormedUriString(url, UriKind.Relative)) { return new Uri(url, UriKind.Relative); } return null; }).Where(s => s != null)); }
private void GetTargetIds() { Configuration.LayerRow layer = Configuration.Layer.First(o => o.LayerID == Request.Form["layer"]); StringCollection data = layer.GetTargetIds(Request.Form["params"]); ReturnJson <String[]>("ids", data.Cast <String>().ToArray()); }
public void ConvertJsonToStringCollection() { Random randNum = new Random(); int[] randomInts = Enumerable .Repeat(0, 1000) .Select(i => randNum.Next(0, int.MaxValue)) .ToArray(); StringCollection inputStringCollection = new StringCollection(); inputStringCollection.AddRange(randomInts.Select(t => t.ToString()).ToArray()); Assert.IsTrue(inputStringCollection.Count == randomInts.Length); string result = InternalDbAppSettingBase.ConvertStringCollectionToJson(inputStringCollection); Assert.IsNotNull(result); StringCollection resultStringCollection = InternalDbAppSettingBase.ConvertJsonToStringCollection(result); Assert.IsNotNull(resultStringCollection); List <string> inputToList = inputStringCollection.Cast <string>().ToList(); List <string> resultToList = resultStringCollection.Cast <string>().ToList(); Assert.IsTrue(inputToList.SequenceEqual(resultToList)); }
public static void LoadMRUListFromSettings(this ComboBox combo, StringCollection settingsMRUList) { if (settingsMRUList != null) { combo.SetMRUList(settingsMRUList.Cast <string>()); } }
private IEnumerable <string> GetSelectOptions() { // Manual items source if (items != null && items.Count > 0) { return(items.Cast <string>().ToList()); } // Lookup List Field data source if (!string.IsNullOrEmpty(LookupList)) { var web = SPContext.Current.Web; var list = web.Lists[LookupList]; var field = list.Fields[LookupField]; var listItems = list.GetItems(field.InternalName); return(listItems.Cast <SPListItem>() .Select(i => Convert.ToString(i[field.Id])).Distinct(StringComparer.InvariantCultureIgnoreCase). OrderBy(i => i) .ToList()); } // Default field data source var thisField = (SPFieldChoice)Field; return(thisField.Choices.Cast <string>().ToList()); }
protected void AddQuery(string fieldName, BoolQuery <ESDocument> query, StringCollection filter, bool lowerCase = true) { fieldName = fieldName.ToLower(); if (filter.Count > 0) { if (filter.Count == 1) { if (!String.IsNullOrEmpty(filter[0])) { AddQuery(fieldName, query, filter[0], lowerCase); } } else { var booleanQuery = new BoolQuery <ESDocument>(); var containsFilter = false; foreach (var index in filter.Cast <string>().Where(index => !String.IsNullOrEmpty(index))) { booleanQuery.Should(q => q.Custom("{{\"wildcard\" : {{ \"{0}\" : \"{1}\" }}}}", fieldName.ToLower(), lowerCase ? index.ToLower() : index)); containsFilter = true; } if (containsFilter) { query.Must(q => q.Bool(b => booleanQuery)); } } } }
public List <ValidGroup> ValidGroupMembership_loggedInUser() { StringCollection stringColl = new StringCollection(); List <ValidGroup> userIsMemberOfGroup_list = new List <ValidGroup>(); if (Properties.Settings.Default.validGroupList != null) { stringColl = Properties.Settings.Default.validGroupList; List <string> validGroup_list = stringColl.Cast <string>().ToList(); string loggedInUser_username = samaccountnameCurrentUser(); foreach (string item in validGroup_list) { string delimiter = ";VALUE="; if (item.Contains(delimiter)) { int index = item.IndexOf(delimiter); string groupName = item.Substring(0, index); string groupValue = item.Substring(item.LastIndexOf(delimiter) + delimiter.Length); if (UserIsInGroup(groupName, loggedInUser_username)) { userIsMemberOfGroup_list.Add(new ValidGroup(groupName, groupValue)); } } } } return(userIsMemberOfGroup_list); }
private void OnFilePaste(object sender, EventArgs e) { try { if (Clipboard.ContainsData(DataFormats.FileDrop)) { var paths = new StringCollection(); paths = Clipboard.GetFileDropList(); modelCopy = new ModelProcessCopy(); modelCopy.Source = paths.Cast <string>().ToList(); modelCopy.DestPath = CurrentPath; modelCopy.SourceCurrentPath = Directory.GetParent(modelCopy.Source[0]).FullName; var cmd = new CommandCopyFiles(modelCopy.Source.Count > 0 && !String.IsNullOrEmpty(modelCopy.DestPath), strings.noSelectedFiles, true, modelCopy, isMove); var presenterProgress = new PresenterProgress(); if (modelCopy != null) { presenterProgress.AddModel(modelCopy); } presenterProgress.AddCommand(cmd); presenterProgress.Show(); CommandManager.Execute(cmd); } if (isMove) { Clipboard.Clear(); } } catch (Exception ex) { MyLog.logger.Error(ex.StackTrace); view.MessageShow(ex.Message, strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 获取指定的Section名称中的所有Key /// </summary> /// <param name="section">section</param> /// <returns>结果</returns> public string[] GetKeys(string section) { StringCollection keyList = new StringCollection(); GetKeys(section, keyList); return(keyList.Cast <string>().ToArray()); }
public void ScriptObject(Table table, Options options) { // script table without constraints StringCollection script = table.Script(_scriptingOptions); string path = _directoryService.GetTablesDirectory(options.Root); string fileName = Path.Combine(path, string.Concat(table.Name, ".sql")); _fileWriter.WriteFile(fileName, script.Cast <string>()); // script constraints string foreignKeyPath = _directoryService.GetForeignKeysDirectory(options.Root); string addForeignKeyFileName = Path.Combine(foreignKeyPath, string.Concat(table.Name, "AddFks.sql")); string addForeignKeys = string.Join("\r\nGO\r\n\r\n", table.ForeignKeys.Cast <ForeignKey>().SelectMany(fk => fk.Script().Cast <string>())); string dropForeignKeyFileName = Path.Combine(foreignKeyPath, string.Concat(table.Name, "DropFks.sql")); string dropForeignKeys = string.Join("\r\nGO\r\n\r\n", table.ForeignKeys .Cast <ForeignKey>() .SelectMany(fk => fk.Script(new ScriptingOptions { ScriptDrops = true }).Cast <string>())); if (table.ForeignKeys.Cast <ForeignKey>().Any()) { _fileWriter.WriteFile(addForeignKeyFileName, new [] { addForeignKeys }); _fileWriter.WriteFile(dropForeignKeyFileName, new [] { dropForeignKeys }); } }
private void dayButton_Click(object sender, RoutedEventArgs e) { DayTasks window = new DayTasks(); string content = (sender as Button).Content.ToString(); window.dayMonth.Text = months[month - 1] + " " + content + " " + year.ToString(); if (Properties.Settings.Default.Tasks != null) { StringCollection collection = new StringCollection(); collection = Properties.Settings.Default.Tasks; List <string> list = collection.Cast <string>().ToList(); foreach (var item in list) { ListViewItem lItem = new ListViewItem(); lItem.Content = item; window.listViewTasks.Items.Add(lItem); } } if (window.ShowDialog() == true) { //textBoxTasks.Text = "True"; //debug } else { //textBoxTasks.Text = "False"; //debug } }
public static string[] ToArray(this StringCollection self) { var result = new List <string>(); result.AddRange(self.Cast <string>()); return(result.ToArray()); }
internal static bool IsStringCollectionsEqual(StringCollection col1, StringCollection col2) { List <string> list1 = col1.Cast <string>().ToList(); List <string> list2 = col2.Cast <string>().ToList(); List <string> resList = list1.Except(list2).ToList(); return(resList.Count == 0); }
private static IEnumerable <string> TransformScript(StringCollection script) { Trace.WriteLine(script.Cast <string>().Aggregate((s1, s2) => s1 + Environment.NewLine + s2)); return(script.Cast <string>() .Where(c => !c.StartsWith("USE ", StringComparison.OrdinalIgnoreCase)) .Select(c => { // some SMO statements are prefixed with a comment like: /**** bla bla ****/\r\n string endOfComment = "*/" + Environment.NewLine; int endOfCommentIndex = c.IndexOf(endOfComment, StringComparison.OrdinalIgnoreCase); if (endOfCommentIndex > 0) { return c.Substring(endOfCommentIndex + endOfComment.Length); } return c; })); }
public TableScript(DirectoryInfo sourceDirectory, FullTableName tableName, StringCollection sqlScripts) { _tableName = tableName; var allScripts = sqlScripts.Cast <string>().ToList(); _singleSqlScript = String.Join(string.Format("\r\n{0}\r\n", SqlExecuteSafe.SqlBatchSeparator), allScripts); _tableScriptFile = CalculateTableFileInfo(tableName, sourceDirectory); }
public void ScriptObject(StoredProcedure storedProcedure, Options options) { StringCollection script = storedProcedure.Script(_scriptingOptions); string path = _directoryService.GetStoredProceduresDirectory(options.Root); string fileName = Path.Combine(path, string.Concat(storedProcedure.Name, ".sql")); _fileWriter.WriteFile(fileName, script.Cast <string>()); }
public void ScriptObject(UserDefinedFunction function, Options options) { StringCollection script = function.Script(_scriptingOptions); string path = _directoryService.GetFunctionsDirectory(options.Root); string fileName = Path.Combine(path, string.Concat(function.Name, ".sql")); _fileWriter.WriteFile(fileName, script.Cast <string>()); }
public void ScriptObject(View view, Options options) { StringCollection script = view.Script(_scriptingOptions); string path = _directoryService.GetViewsDirectory(options.Root); string fileName = Path.Combine(path, string.Concat(view.Name, ".sql")); _fileWriter.WriteFile(fileName, script.Cast <string>()); }
/// <summary> /// Converts a <see cref="StringCollection"/> to a sequence of <see cref="string"/>s. /// </summary> /// <param name="stringCollection">The <see cref="StringCollection"/>.</param> /// <returns>The sequence of <see cref="string"/>s.</returns> internal static IEnumerable <string> AsEnumerable(this StringCollection stringCollection) { if (stringCollection == null) { return(Enumerable.Empty <string>()); } return(stringCollection.Cast <string>()); }
private static string Join(StringCollection collection) { if (collection == null) { return(string.Empty); } return(string.Join(Environment.NewLine, collection.Cast <string>())); }
private static void OnPreviewDrop(object sender, DragEventArgs dragEventArgs) { var data = dragEventArgs.Data as DataObject; if (data != null && data.ContainsFileDropList()) { StringCollection itemList = data.GetFileDropList(); Ioc.Get <MainViewModel>().HandlePaths(itemList.Cast <string>().ToList()); } }
public HalfPersistentList(StringCollection persistentData, int maxItemsToKeep = 2) { this.MaxItemsToKeep = maxItemsToKeep; if (persistentData != null) { PersistentDataLen = persistentData.Count; base.AddRange(persistentData.Cast <T>()); } }
private static List <SchemaDataSet.ColumnsRow> GetAuditedColumnsForTable(string schema, string tableName, AuditUpdateParameters updateParameters) { StringCollection columnsNotAudited = updateParameters.ColumnsNotAudited; IEnumerable <SchemaDataSet.ColumnsRow> columnsRows = GetColumnsForTable(schema, tableName, updateParameters); IEnumerable <SchemaDataSet.ColumnsRow> query = from columnRow in columnsRows where !(columnsNotAudited.Cast <string>().Any(columnName => columnName.Equals(columnRow.COLUMN_NAME, StringComparison.OrdinalIgnoreCase))) select columnRow; return(query.ToList()); }
public ObservableStringCollection(StringCollection stringCollection) { Observable = new ObservableCollection <T>(stringCollection.Cast <T>()); Observable.CollectionChanged += (_, _) => { // since performance isn't a concern, keep things simple and verbatim overwrite the settings.. i.e. ignore event type add/remove/move/et stringCollection.Clear(); stringCollection.AddRange(Observable.Select(x => x.ToString()).ToArray()); }; }
private void settingsButton_Click(object sender, RoutedEventArgs e) { Settings_Window window = new Settings_Window(); //Loading listView settings if (Properties.Settings.Default.__Genre != null) { StringCollection collection = new StringCollection(); collection = Properties.Settings.Default.__Genre; List <string> list = collection.Cast <string>().ToList(); foreach (var item in list) { ListViewItem lItem = new ListViewItem(); lItem.Content = item; window.listViewGenre.Items.Add(lItem); } } if (window.ShowDialog() == true) { //Saving to Settings.settings var list = new List <string>(); foreach (ListViewItem item in window.listViewGenre.Items) { String s = ""; String temp; temp = item.ToString(); for (int i = 0; i < temp.Length; i++) { if (temp[i] == ':') { for (int j = i + 2; j < temp.Length; j++) { s += temp[j]; } } } list.Add(s); } StringCollection collection = new StringCollection(); foreach (string element in list) { collection.Add(element); } Properties.Settings.Default.__Genre = collection; Properties.Settings.Default.Save(); if (window.AutoSaveCheckbox.IsChecked == true) { StartAutoSaveTimer(); } } }
/// <summary> /// Makes temp tables when extraction does not use grouping /// </summary> public string MakeTempTableJustValues(string VariableName, string VariableNumber, bool UseTemporaryTables, StringCollection valueCodes) { #if DEBUG System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); #endif bool makeGroupFactorCol = false; string tempTableId = this.GetTempTableId(VariableNumber, UseTemporaryTables); createTempTable(tempTableId, VariableName, VariableNumber, makeGroupFactorCol, UseTemporaryTables); // inserts the same code in 2 columns, so the table looks the same as for grouping. string sqlString = "INSERT INTO /*** MakeTempTableJustValues_01 ***/ " + tempTableId; //sqlString += " VALUES (" + this.GetParameterRef("aValueCode1") + ", " + this.GetParameterRef("aValueCode2") + "," + this.GetParameterRef("aValueCounter") + ")"; //is this easier to read?: sqlString += string.Format(" VALUES ({0}, {1}, {2})", this.GetParameterRef("aValueCode1"), this.GetParameterRef("aValueCode2"), this.GetParameterRef("aValueCounter")); DbParameter[] parameters = new DbParameter[3]; parameters[0] = this.GetStringParameter("aValueCode1", "WillBeOverwritten"); parameters[1] = this.GetStringParameter("aValueCode2", "WillBeOverwritten"); parameters[2] = this.myDbVendor.GetEmptyDbParameter(); parameters[2].DbType = DbType.Int32; parameters[2].ParameterName = "aValueCounter"; parameters[2].Value = 123; // ( all groups have 1 member) int[] parentCodeCounter = Enumerable.Range(1, valueCodes.Count).ToArray(); String[] valueCodesArray = valueCodes.Cast <String>().ToList().Select(c => c).ToArray(); //createTempTable(tempTableId, VariableName, VariableNumber, makeGroupFactorCol, UseTemporaryTables); var columnsTempTable = new List <string>(); columnsTempTable.Add("A" + VariableName); columnsTempTable.Add("Group" + VariableNumber); columnsTempTable.Add("GroupNr" + VariableNumber); //createTempTable(tempTableId, VariableName, VariableNumber, makeGroupFactorCol, UseTemporaryTables); //sqlString += "(A" + VariableName + " VARCHAR(20), Group" + VariableNumber + " VARCHAR(20), GroupNr" + VariableNumber + " INTEGER"; var tempColumnList = new List <string>(); myDbVendor.BulkInsertIntoTemp(tempTableId, columnsTempTable, sqlString, parameters, valueCodesArray, valueCodesArray, parentCodeCounter); #if DEBUG stopWatch.Stop(); logTime.DebugFormat(" Completed " + System.Reflection.MethodBase.GetCurrentMethod().Name + " in ms = {0} for VariableName ={1}", stopWatch.ElapsedMilliseconds, VariableName); #endif return(tempTableId); }
public static StringCollection Op(StringCollection sc) { var array = sc.Cast <string>().ToArray(); Exe(array); var r = new StringCollection(); r.AddRange(array); return(r); }
//--------------------------------------------------------------------- public static ReadOnlyCollection <string> AsReadOnly(this StringCollection collection) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } var result = new List <string>(collection.Count); result.AddRange(collection.Cast <string>()); return(result.AsReadOnly()); }
private void AddReferences(CompilerParameters parameters, StringCollection referencedAssemblies) { Error.AssertObject(parameters, nameof(parameters)); //TODO: Add assenblies from web.config foreach (var ass in AppDomainAssemblies) { parameters.ReferencedAssemblies.Add(ass); } referencedAssemblies?.Cast <String>().ToList().ForEach(referencedAssenbly => { parameters.ReferencedAssemblies.Add(referencedAssenbly); }); }