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


C# StringCollection.Contains方法代码示例

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


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

示例1: GetAllAssembly

 private static void GetAllAssembly(Assembly assembly, StringCollection stringCollection)
 {
     string location = assembly.Location;
     if (!stringCollection.Contains(location))
     {
         stringCollection.Add(location);
     }
 }
开发者ID:nakijun,项目名称:FastDBEngine,代码行数:8,代码来源:CompileAssemblyHelper.cs

示例2: FindServers

        /// <summary>
        /// Invokes the FindServers service.
        /// </summary>
        /// <param name="requestHeader">The request header.</param>
        /// <param name="endpointUrl">The endpoint URL.</param>
        /// <param name="localeIds">The locale ids.</param>
        /// <param name="serverUris">The server uris.</param>
        /// <param name="servers">List of Servers that meet criteria specified in the request.</param>
        /// <returns>
        /// Returns a <see cref="ResponseHeader"/> object
        /// </returns>
        public override ResponseHeader FindServers(
            RequestHeader                        requestHeader,
            string                               endpointUrl,
            StringCollection                     localeIds,
            StringCollection                     serverUris,
            out ApplicationDescriptionCollection servers)
        {
            servers = new ApplicationDescriptionCollection();
            
            ValidateRequest(requestHeader);
            
            lock (m_lock)
            {
                // parse the url provided by the client.
                IList<BaseAddress> baseAddresses = BaseAddresses;

                Uri parsedEndpointUrl = Utils.ParseUri(endpointUrl);

                if (parsedEndpointUrl != null)
                {
                    baseAddresses = FilterByEndpointUrl(parsedEndpointUrl, baseAddresses);
                }

                // check if nothing to do.
                if (baseAddresses.Count == 0)
                {
                    servers = new ApplicationDescriptionCollection();
                    return CreateResponse(requestHeader, StatusCodes.Good);
                }

                // build list of unique servers.
                Dictionary<string,ApplicationDescription> uniqueServers = new Dictionary<string,ApplicationDescription>();

                foreach (EndpointDescription description in GetEndpoints())
                {
                    ApplicationDescription server = description.Server;

                    // skip servers that have been processed.
                    if (uniqueServers.ContainsKey(server.ApplicationUri))
                    {
                        continue;
                    }

                    // check client is filtering by server uri.
                    if (serverUris != null && serverUris.Count > 0)
                    {
                        if (!serverUris.Contains(server.ApplicationUri))
                        {
                            continue;
                        }
                    }

                    // localize the application name if requested.
                    LocalizedText applicationName = server.ApplicationName;

                    if (localeIds != null && localeIds.Count > 0)
                    {
                        applicationName = m_serverInternal.ResourceManager.Translate(localeIds, applicationName);
                    }

                    // get the application description.
                    ApplicationDescription application = TranslateApplicationDescription(
                        parsedEndpointUrl,
                        server,
                        baseAddresses,
                        applicationName);

                    uniqueServers.Add(server.ApplicationUri, application);

                    // add to list of servers to return.
                    servers.Add(application);
                }
            }
                            
            return CreateResponse(requestHeader, StatusCodes.Good);
        }
开发者ID:yuriik83,项目名称:UA-.UWP-Universal-Windows-Platform,代码行数:87,代码来源:StandardServer.cs

示例3: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. RemoveAt() from empty collection");
         iCountTestcases++;
         if (sc.Count > 0)
             sc.Clear();
         try 
         {
             sc.RemoveAt(0);
             iCountErrors++;
             Console.WriteLine("Err_0001_{0}a, no exception");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine(" expected exception: " + ex.Message);
         }    
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001_{0}b, unexpected exception: " + e.ToString());
         }    
         Console.WriteLine("2. RemoveAt() on filled collection");
         strLoc = "Loc_002oo"; 
         Console.WriteLine(" - at the beginning");
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         iCountTestcases++;
         sc.RemoveAt(0);
         if (sc.Count != values.Length - 1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002b, Count returned {0} instead of {1}", sc.Count, values.Length - 1);
         } 
         iCountTestcases++;
         if (sc.Contains(values[0])) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002c, removed wrong item");
         } 
         for (int i = 0; i < values.Length; i++) 
         { 
             iCountTestcases++;
             if (sc.IndexOf(values[i]) != i-1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}d, IndexOf returned {1} instead of {2}", i, sc.IndexOf(values[i]), i-1);
             } 
         }
         Console.WriteLine(" - at the end");
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002e, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         iCountTestcases++;
         sc.RemoveAt(values.Length-1);
         if (sc.Count != values.Length - 1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002f, Count returned {0} instead of {1}", sc.Count, values.Length - 1);
         } 
         iCountTestcases++;
         if (sc.Contains(values[values.Length - 1])) 
         {
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8747removeat_int.cs

示例4: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     int cnt = 0;            
     int ind = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. add simple strings");
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             cnt = sc.Count;
             sc.Add(values[i]);
             if (sc.Count != cnt+1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}a, count is {1} instead of {2}", i, sc.Count, cnt+1);
             } 
             iCountTestcases++;
             if (!sc.Contains(values[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}b, collection doesn't contain new item", i);
             } 
             iCountTestcases++;
             ind = sc.IndexOf(values[i]);
             if (ind != sc.Count - 1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}c, returned index {1} instead of {2}", i, ind, sc.Count - 1);
             } 
             if (ind != -1) 
             {
                 iCountTestcases++;
                 if (String.Compare(sc[ind], values[i], false) != 0) 
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_0001_{0}d, returned item \"{1}\" instead of \"{2}\"", i, sc[ind], values[i]);
                 } 
             }
         }
         Console.WriteLine("2. add intl strings");
         string [] intlValues = new string [values.Length];
         for (int i = 0; i < values.Length; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         Console.WriteLine(" initial number of items: " + sc.Count);
         strLoc = "Loc_002oo"; 
         for (int i = 0; i < intlValues.Length; i++) 
         {
             iCountTestcases++;
             cnt = sc.Count;
             sc.Add(intlValues[i]);
             if (sc.Count != cnt+1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}a, count is {1} instead of {2}", i, sc.Count, cnt+1);
             } 
             iCountTestcases++;
             if (!sc.Contains(intlValues[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}b, collection doesn't contain new item", i);
             } 
             iCountTestcases++;
             ind = sc.IndexOf(intlValues[i]);
             if (ind != sc.Count - 1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}c, returned index {1} instead of {2}", i, ind, sc.Count - 1);
             } 
             if (ind != -1) 
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8738add_str.cs

示例5: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     try
     {
         Console.WriteLine("--- default ctor ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. compare to null");
         iCountTestcases++;
         if (sc == null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, collection is null after default ctor");
         } 
         Console.WriteLine("2. check Count");
         iCountTestcases++;
         if (sc.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002, Count = {0} after default ctor", sc.Count);
         }
         Console.WriteLine("3. check Contains()");
         iCountTestcases++;
         if (sc.Contains("string")) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003, Contains() returned true after default ctor");
         }
         Console.WriteLine("4. check ToString()");
         iCountTestcases++;
         string temp = sc.ToString();
         Console.WriteLine(" ToString(): " + temp);
         if (temp.IndexOf("StringCollection") == -1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004, ToString() doesn't contain \"StringCollection\"");
         }
         Console.WriteLine("5. check returned Type");
         iCountTestcases++;
         temp = sc.GetType().ToString().Trim();
         Console.WriteLine(" GetType(): " + temp);
         if (temp.IndexOf("StringCollection") == -1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0005: returned type doesn't contain \"StringCollection\"");
         }
         Console.WriteLine("6. compare returned Type of two collection");
         iCountTestcases++;
         string temp1 = (new StringCollection()).GetType().ToString().Trim();
         if (String.Compare(temp, temp1) != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0006: returned types of two collections differ");
         }
         Console.WriteLine("7. check IsReadOnly");
         iCountTestcases++;
         Console.WriteLine(" IsReadOnly: " + sc.IsReadOnly);
         if (sc.IsReadOnly) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0007: IsReadOnly returned {0}", sc.IsReadOnly);
         }
         Console.WriteLine("8. check IsSynchronized");
         iCountTestcases++;
         Console.WriteLine(" IsSynchronized: " + sc.IsSynchronized);
         if (sc.IsSynchronized) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0008: IsSynchronized returned {0}", sc.IsSynchronized);
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:93,代码来源:co8737ctor.cs

示例6: Main

	// Main entry point for the application.
	public static int Main(String[] args)
			{
#if CONFIG_EXTENDED_NUMERICS && CONFIG_REFLECTION
				StreamReader reader = null;
				int len;
				VsaEngine engine;
				IVsaCodeItem item;
				StringCollection scripts = new StringCollection();

				// Create an engine instance and add the script to it.
				engine = VsaEngine.CreateEngine();
				engine.SetOption("print", true);

				// get command-line arguments
				int i = 0;
				String arg = args.Length == 0 ? null : args[0];
				while(arg != null)
				{
					String next = null;
					if (arg.StartsWith("-") && !arg.StartsWith("--") &&
							arg.Length > 2)
					{
						next = "-" + arg.Substring(2, arg.Length - 2);
						arg = arg.Substring(0,2);
					}
					switch(arg)
					{
					case "-h":
					case "--help":
						Usage();
						return 0;
					case "-v":
					case "--version":
						Version();
						return 0;
					default:
						// matches both short and long options. (-/--)
						if (arg.StartsWith("-"))
						{
#if !CONFIG_SMALL_CONSOLE
							Console.Error.WriteLine
#else
							Console.WriteLine
#endif
								("jsrun: unkown option `{0}'", arg);
							return 1;
						}
						// not an option - assumes script path
						else
						{
							// To prevent a relative and a absolute pathname to same file!
							FileInfo fi = new FileInfo(arg);
							if(!fi.Exists)
							{
#if !CONFIG_SMALL_CONSOLE
								Console.Error.WriteLine
#else
								Console.WriteLine
#endif
									("jsrun: {0}: No such file or directory", arg);
								return 1;
							}
							// Cannot load same script source twice!
							if(scripts.Contains(fi.FullName))
							{
#if !CONFIG_SMALL_CONSOLE
								Console.Error.WriteLine
#else
								Console.WriteLine
#endif
								("jsrun: {0}: use of duplicate sources illegal.", fi.FullName);
							}
							else
							{
								scripts.Add(fi.FullName);
							}
							// Load script file
							try
							{
								reader = new StreamReader(arg);
							}
							catch(Exception e)
							{
#if !CONFIG_SMALL_CONSOLE
								Console.Error.WriteLine
#else
								Console.WriteLine
#endif
									("jsrun: ({0}): {1}", e.GetType(), e.Message);
							}

							// Load the script into memory as a string.
							StringBuilder scriptBuilder = new StringBuilder();
							char[] scriptBuffer = new char [512];
							while((len = reader.Read(scriptBuffer, 0, 512)) > 0)
							{
								scriptBuilder.Append(scriptBuffer, 0, len);
							}
							reader.Close();
//.........这里部分代码省略.........
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:101,代码来源:jsrun.cs

示例7: Remove_IListTest

 public static void Remove_IListTest(StringCollection collection, string[] data)
 {
     Assert.All(data, element =>
     {
         Assert.True(collection.Contains(element));
         Assert.True(((IList)collection).Contains(element));
         ((IList)collection).Remove(element);
         Assert.False(collection.Contains(element));
         Assert.False(((IList)collection).Contains(element));
     });
     Assert.Equal(0, collection.Count);
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:12,代码来源:StringCollectionTests.cs

示例8: Constructor_DefaultTest

 public static void Constructor_DefaultTest()
 {
     StringCollection sc = new StringCollection();
     Assert.Equal(0, sc.Count);
     Assert.False(sc.Contains(null));
     Assert.False(sc.Contains(""));
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:7,代码来源:StringCollectionTests.cs

示例9: WriteToStream

        /// <summary>
        /// This can be used to write a calendar to a PDI data stream
        /// </summary>
        /// <param name="tw">A <see cref="System.IO.TextWriter"/> derived class to which the calendar is
        /// written.</param>
        /// <param name="sb">A <see cref="System.Text.StringBuilder"/> used by the properties as a temporary
        /// buffer.  This can be null if the TextWriter is a <see cref="System.IO.StringWriter"/>.</param>
        /// <remarks>This is called by <see cref="CalendarObject.ToString"/> as well as owning objects when they
        /// convert themselves to a string or write themselves to a PDI data stream.</remarks>
        public override void WriteToStream(TextWriter tw, StringBuilder sb)
        {
            PropagateVersion();

            tw.Write("BEGIN:VCALENDAR\r\n");

            if(this.Version == SpecificationVersions.vCalendar10)
                tw.Write("VERSION:1.0\r\n");
            else
                tw.Write("VERSION:2.0\r\n");

            // The product ID is required for iCalendar 2.0 so we'll enforce it for both specs
            BaseProperty.WriteToStream(this.ProductId, sb, tw);

            // Save version-specific properties
            if(this.Version == SpecificationVersions.vCalendar10)
            {
                BaseProperty.WriteToStream(daylight, sb, tw);
                BaseProperty.WriteToStream(geo, sb, tw);
                BaseProperty.WriteToStream(tz, sb, tw);
            }
            else
            {
                BaseProperty.WriteToStream(calScale, sb, tw);
                BaseProperty.WriteToStream(method, sb, tw);

                // Time zones are usually listed first.  Build a list to see which time zones are needed and
                // stream only those.
                StringCollection tzIds = new StringCollection();
                this.TimeZonesUsed(tzIds);

                if(tzIds.Count != 0)
                {
                    // Lock it while we write the collection out
                    timeZones.Lock.AcquireReaderLock(250);

                    try
                    {
                        foreach(VTimeZone tz in timeZones)
                            if(tzIds.Contains(tz.TimeZoneId.Value))
                                tz.WriteToStream(tw, sb);
                    }
                    finally
                    {
                        timeZones.Lock.ReleaseReaderLock();
                    }
                }

                if(journals != null && journals.Count != 0)
                    foreach(VJournal j in journals)
                        j.WriteToStream(tw, sb);

                if(freebusy != null && freebusy.Count != 0)
                    foreach(VFreeBusy f in freebusy)
                        f.WriteToStream(tw, sb);
            }

            if(events != null && events.Count != 0)
                foreach(VEvent v in events)
                    v.WriteToStream(tw, sb);

            if(todos != null && todos.Count != 0)
                foreach(VToDo t in todos)
                    t.WriteToStream(tw, sb);

            if(customProps != null && customProps.Count != 0)
                foreach(CustomProperty c in customProps)
                    BaseProperty.WriteToStream(c, sb, tw);

            tw.Write("END:VCALENDAR\r\n");
        }
开发者ID:modulexcite,项目名称:PDI,代码行数:80,代码来源:VCalendar.cs

示例10: AddTimeZoneIfUsed

        /// <summary>
        /// This helper method can be used to add a time zone ID to the string collection when one is used on the
        /// passed property.
        /// </summary>
        /// <param name="dateProp">The date/time property to check.</param>
        /// <param name="timeZoneIds">The string collection to which the time zone ID is added if there is one on
        /// the date/time property and it is not already in the collection.</param>
        /// <remarks>If the date/time property has no time zone ID or if it is set to <see cref="DateTime.MinValue"/>,
        /// the collection is not modified.</remarks>
        protected static void AddTimeZoneIfUsed(BaseDateTimeProperty dateProp, StringCollection timeZoneIds)
        {
            if(dateProp != null && dateProp.TimeZoneDateTime != DateTime.MinValue)
            {
                string tzId = dateProp.TimeZoneId;

                if(tzId != null && !timeZoneIds.Contains(tzId))
                    timeZoneIds.Add(tzId);
            }
        }
开发者ID:modulexcite,项目名称:PDI,代码行数:19,代码来源:CalendarObject.cs

示例11: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     int cnt = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. Remove() from empty collection");
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             sc.Remove(values[i]);
             if (sc.Count != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}, Remove changed Count for empty collection", i);
             }
         } 
         Console.WriteLine("2. add simple strings and test Remove()");
         strLoc = "Loc_002oo"; 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             if (!sc.Contains(values[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}b, doesn't contain {0} item", i);
             }
             cnt = sc.Count; 
             iCountTestcases++;
             sc.Remove(values[i]);
             if (sc.Count != cnt - 1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}c, didn't remove anything", i);
             } 
             if (sc.Contains(values[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}d, removed wrong item", i);
             } 
         }
         Console.WriteLine("3. add intl strings and test Remove()");
         strLoc = "Loc_003oo"; 
         string [] intlValues = new string [values.Length];
         for (int i = 0; i < values.Length; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         int len = values.Length;
         Boolean caseInsensitive = false;
         for (int i = 0; i < len; i++) 
         {
             if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper())
                 caseInsensitive = true;
         }
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(intlValues);
         if ( sc.Count != intlValues.Length ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, intlValues.Length);
         } 
         for (int i = 0; i < intlValues.Length; i++) 
         {
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co8746remove_str.cs

示例12: TimeZonesUsed

        /// <summary>
        /// This is used to get a list of time zones used by all owned objects
        /// </summary>
        /// <param name="timeZoneIds">A <see cref="StringCollection"/> that will be used to store the list of
        /// unique time zone IDs used by the calendar objects.</param>
        public override void TimeZonesUsed(StringCollection timeZoneIds)
        {
            string timeZoneId;

            if(rDates != null)
                foreach(RDateProperty rdt in rDates)
                    if(rdt.ValueLocation == ValLocValue.DateTime && rdt.TimeZoneDateTime != DateTime.MinValue)
                    {
                        timeZoneId = rdt.TimeZoneId;

                        if(timeZoneId != null && !timeZoneIds.Contains(timeZoneId))
                            timeZoneIds.Add(timeZoneId);
                    }

            if(exDates != null)
                foreach(ExDateProperty edt in exDates)
                    CalendarObject.AddTimeZoneIfUsed(edt, timeZoneIds);
        }
开发者ID:modulexcite,项目名称:PDI,代码行数:23,代码来源:RecurringObject.cs

示例13: PrepareIds

  private void PrepareIds(out StringCollection targetIds, out StringCollection filteredIds, out StringCollection selectionIds)
  {
    targetIds = _appState.TargetIds.Clone();
    selectionIds = _appState.SelectionIds.Clone();

    // segregate the target IDs that pass through the query from
    // those that do not

    if (String.IsNullOrEmpty(_appState.Query))
    {
      filteredIds = new StringCollection();
    }
    else
    {
      Configuration config = AppContext.GetConfiguration();
      Configuration.QueryRow query = config.Query.FindByQueryID(_appState.Query);

      using (OleDbCommand command = query.GetDatabaseCommand())
      {
        command.Parameters[0].Value = _appState.TargetIds.Join(",");

        if (command.Parameters.Count > 1)
        {
          command.Parameters[1].Value = AppUser.GetRole();
        }

        using (OleDbDataReader reader = command.ExecuteReader())
        {
          int mapIdColumn = reader.GetOrdinal("MapID");

          filteredIds = targetIds;
          targetIds = new StringCollection();

          while (reader.Read())
          {
            if (!reader.IsDBNull(mapIdColumn))
            {
              string mapId = reader.GetValue(mapIdColumn).ToString();

              filteredIds.Remove(mapId);

              if (!targetIds.Contains(mapId))
              {
                targetIds.Add(mapId);
              }
            }
          }
        }

        command.Connection.Dispose();
      }
    }

    if (targetIds.Count > 0)
    {
      // remove the active ID from the targets

      if (_appState.ActiveMapId.Length > 0)
      {
        targetIds.Remove(_appState.ActiveMapId);
      }

      // remove the selection IDs from the targets if necessary

      if (_appState.TargetLayer == _appState.SelectionLayer && _appState.SelectionIds.Count > 0)
      {
        if (_appState.ActiveMapId.Length > 0)
        {
          selectionIds.Remove(_appState.ActiveMapId);
        }

        foreach (string selectionId in _appState.SelectionIds)
        {
          targetIds.Remove(selectionId);
        }
      }
    }
  }
开发者ID:ClaireBrill,项目名称:GPV,代码行数:78,代码来源:MapMaker.cs

示例14: RemoveStopWords

    /// 
    /// Removes stop words from the text.
    /// 
    public static string RemoveStopWords(string inputText)
    {
        inputText = inputText
                                        .Replace("\\", string.Empty)
                                        .Replace("|", string.Empty)
                                        .Replace("(", string.Empty)
                                        .Replace(")", string.Empty)
                                        .Replace("[", string.Empty)
                                        .Replace("]", string.Empty)
                                        .Replace("*", string.Empty)
                                        .Replace("?", string.Empty)
                                        .Replace("}", string.Empty)
                                        .Replace("{", string.Empty)
                                        .Replace("^", string.Empty)
                                        .Replace("+", string.Empty);

        // transform given text into array of words
        char[] wordSeparators = new char[] { ' ', '\n', '\r', ',', ';', '.', '!', '?', '-', ' ', '"', '\'' };
        string[] words = inputText.Split(wordSeparators, StringSplitOptions.RemoveEmptyEntries);

        // Create and initializes a new StringCollection.
        StringCollection myStopWordsCol = new StringCollection();
        // Add a range of elements from an array to the end of the StringCollection.
        myStopWordsCol.AddRange(stopWordsArrary);

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < words.Length; i++)
        {
            string word = words[i].ToLowerInvariant().Trim();
            if (word.Length > 1 && !myStopWordsCol.Contains(word))
                sb.Append(word + " ");
        }

        return sb.ToString();
    }
开发者ID:TaNeRs,项目名称:SSSS,代码行数:38,代码来源:WordStopper.cs

示例15: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     int cnt = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. add simple strings");
         iCountTestcases++;
         cnt = sc.Count;
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         Console.WriteLine("2. verify that collection contains all added items");    
         strLoc = "Loc_002oo"; 
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             if (!sc.Contains(values[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}, collection doesn't contain new item", i);
             } 
         }
         Console.WriteLine("3. add intl strings");
         string [] intlValues = new string [values.Length];
         for (int i = 0; i < values.Length; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         strLoc = "Loc_003oo"; 
         cnt = sc.Count;
         Console.WriteLine(" initial number of items: " + cnt);
         iCountTestcases++;
         sc.AddRange(intlValues);
         if (sc.Count != (cnt + intlValues.Length)) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003, count is {0} instead of {1}", sc.Count, cnt + intlValues.Length);
         }
         Console.WriteLine("4. verify that collection contains all added items");    
         strLoc = "Loc_004oo"; 
         for (int i = 0; i < intlValues.Length; i++) 
         {
             iCountTestcases++;
             iCountTestcases++;
             if (!sc.Contains(intlValues[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0004_{0}, collection doesn't contain new item", i);
             } 
         }
         Console.WriteLine("5. add empty range");
         strLoc = "Loc_005oo"; 
         iCountTestcases++;
         cnt = sc.Count;
         string [] empty = {};
         sc.AddRange(empty);
         if (sc.Count != cnt) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005, count is {0} instead of {1}", sc.Count, cnt);
         } 
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8739addrange_stra.cs


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