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


C# StringCollection.Cast方法代码示例

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


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

示例1: StringCollection2List

        public static void StringCollection2List()
        {
            StringCollection stringCollection = new StringCollection();

            stringCollection.Add("String 1");
            stringCollection.Add("String 2");
            stringCollection.Add("String 3");

            Console.WriteLine("*** StringCollection:");
            foreach (String s in stringCollection)
            {
                Console.WriteLine(s);
            }

            List<String> stringList = stringCollection.Cast<String>().ToList();

            Console.WriteLine("*** List<String>:");
            foreach (String s in stringList)
            {
                Console.WriteLine(s);
            }
        }
开发者ID:vurdalakov,项目名称:codeblog_examples,代码行数:22,代码来源:StringCollection2IEnumerableString.cs

示例2: StripElementAttributes

		private void StripElementAttributes(params string[] attributeNames)
		{
			StringCollection selectors = new StringCollection();

			foreach (string attribute in attributeNames)
			{
				selectors.Add(String.Format("*[{0}]", attribute));
			}

			CQ elementsWithAttributes = _document.Find(String.Join(",", selectors.Cast<string>().ToList()));
			foreach (var item in elementsWithAttributes)
			{
				foreach (string attribute in attributeNames)
				{
					item.RemoveAttribute(attribute);
				}
			}
		}
开发者ID:granstel,项目名称:PreMailer.Net,代码行数:18,代码来源:PreMailer.cs

示例3: ParseWurflFiles

        /// <summary>
        /// Parses the wurfl file into a instance of WurflFile.
        /// </summary>
        /// <param name="devices">Instance of Devices to store data.</param>
        /// <param name="wurflFilePath">Wurfl file path.</param>
        /// <param name="capabilitiesWhiteList">List of capabilities to be used. If none, all capabilities will be loaded into the memory.</param>
        /// <param name="wurflPatchFiles">Null, string or array of strings representing the wurfl patch files
        /// which must be applied against the main file.</param>
        /// <returns>Returns an instance of WurflFile. 
        /// <remarks>If none file is found a null value will be returned.</remarks>
        /// </returns>
        /// <exception cref="System.IO.FileNotFoundException">Thrown if the parameter <paramref name="wurflFilePath"/> 
        /// referes to a file that does not exists.</exception>
        /// <exception cref="System.ArgumentNullException">Thrown if the parameter <paramref name="wurflFilePath"/> 
        /// is an empty string or a null value.</exception>
        private static void ParseWurflFiles(
            Provider devices,
            string wurflFilePath,
            StringCollection capabilitiesWhiteList,
            params string[] wurflPatchFiles)
        {
            if (string.IsNullOrEmpty(wurflFilePath))
                throw new ArgumentNullException("wurflFilePath");

            if (!File.Exists(wurflFilePath))
                throw new FileNotFoundException(Constants.WurflFileNotFound, wurflFilePath);

            // Load white listed capabilities
            if (capabilitiesWhiteList != null)
            {
                _loadOnlyCapabilitiesWhiteListed = capabilitiesWhiteList.Count > 0;
            #if VER4
                foreach (string capability in
                    capabilitiesWhiteList.Cast<string>().Where(capability => !_capabilitiesWhiteListed.Contains(capability)))
                {
                    _capabilitiesWhiteListed.Add(capability);
                }
            #elif VER2
                foreach (string capability in capabilitiesWhiteList)
                    if (!_capabilitiesWhiteListed.Contains(capability))
                        _capabilitiesWhiteListed.Add(capability);
            #endif
            }

            StringCollection wurflFilePaths = new StringCollection();
            wurflFilePaths.Add(wurflFilePath);
            wurflFilePaths.AddRange(wurflPatchFiles);

            ParseWurflFiles(devices, wurflFilePaths, File.GetCreationTimeUtc(wurflFilePath));
        }
开发者ID:irobinson,项目名称:51DegreesDNN,代码行数:50,代码来源:Processor.cs

示例4: AddQuery

        protected void AddQuery(string fieldName, BoolQuery<ESDocument> query, StringCollection filter)
        {
            fieldName = fieldName.ToLower();
            if (filter.Count > 0)
            {
                if (filter.Count == 1)
                {
                    if (!String.IsNullOrEmpty(filter[0]))
                    {
                        AddQuery(fieldName, query, filter[0].ToLower());
                    }
                }
                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(), index.ToLower()));
	                    containsFilter = true;
                    }
                    if (containsFilter)
                        query.Must(q => q.Bool(b => booleanQuery));
                }
            }
        }
开发者ID:rdi-drew,项目名称:vc-community,代码行数:26,代码来源:ElasticSearchQueryBuilder.cs

示例5: FromCollection

 public static string FromCollection(StringCollection collection)
 {
     return string.Join(Environment.NewLine, collection.Cast<string>().ToArray());
 }
开发者ID:kohlmann0,项目名称:Resx2Xls,代码行数:4,代码来源:StringHelper.cs

示例6: TransformScript

 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;
             });
 }
开发者ID:richardprior,项目名称:MigSharp,代码行数:17,代码来源:SmoProvider.cs


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