コード例 #1
0
		} //end method
		
		/// <summary> Checks a code for an exact match, and using certain sequences where some 
		/// characters are wildcards (e.g. HL7nnnn).  If the pattern contains one of 
		/// " or ", " OR ", or "," each operand is checked.
		/// </summary>
		private bool checkCode(System.String code, System.String pattern)
		{
			bool match = false;
			//mod by Neal acharya - Do full match on with the pattern.  If code matches pattern then return true
			//else parse pattern to look for wildcard characters
			if (code.Equals(pattern))
			{
				match = true;
			}
			//end if 
			else
			{
				if (pattern.IndexOf(' ') >= 0 || pattern.IndexOf(',') >= 0)
				{
					SupportClass.Tokenizer tok = new SupportClass.Tokenizer(pattern, ", ", false);
					while (tok.HasMoreTokens() && !match)
					{
						System.String t = tok.NextToken();
						if (!t.ToUpper().Equals("or".ToUpper()))
							match = checkCode(code, t);
					} //end while
				}
				//end if
				else
				{
					if (code.Equals(pattern))
					{
						match = true;
					}
				} //end else
			} //end else 
			return match;
		} //end method
コード例 #2
0
		/// <summary> Determines whether a string is not obviously not a URI. This implements crude checks; this class does not
		/// intend to strictly check URIs as its only function is to represent what is in a barcode, but, it does
		/// need to know when a string is obviously not a URI.
		/// </summary>
		internal static bool isBasicallyValidURI(System.String uri)
		{
			if (uri == null || uri.IndexOf(' ') >= 0 || uri.IndexOf('\n') >= 0)
			{
				return false;
			}
			// Look for period in a domain but followed by at least a two-char TLD
			// Forget strings that don't have a valid-looking protocol
			int period = uri.IndexOf('.');
			if (period >= uri.Length - 2)
			{
				return false;
			}
			int colon = uri.IndexOf(':');
			if (period < 0 && colon < 0)
			{
				return false;
			}
			if (colon >= 0)
			{
				if (period < 0 || period > colon)
				{
					// colon ends the protocol
					for (int i = 0; i < colon; i++)
					{
						char c = uri[i];
						if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z'))
						{
							return false;
						}
					}
				}
				else
				{
					// colon starts the port; crudely look for at least two numbers
					if (colon >= uri.Length - 2)
					{
						return false;
					}
					for (int i = colon + 1; i < colon + 3; i++)
					{
						char c = uri[i];
						if (c < '0' || c > '9')
						{
							return false;
						}
					}
				}
			}
			return true;
		}
コード例 #3
0
        public void IndexOfTestCase2()
        {
            Array array = new[]
            {
                "0",
                "1",
                "2"
            };

            var actual = array.IndexOf( "1", 0, 2 );
            Assert.AreEqual( 1, actual );

            actual = array.IndexOf( "2", 0, 2 );
            Assert.AreEqual( -1, actual );
        }
コード例 #4
0
        public override int GetTargetIndex(System.Collections.Generic.List<WorldObject> availableTargets)
        {
            var target = availableTargets
                .FirstOrDefault(x => x.Owner != 0);

            return availableTargets.IndexOf(target);
        }
コード例 #5
0
 /// <summary> Match a String against the given pattern, supporting the following simple
 /// pattern styles: "xxx*", "*xxx" and "*xxx*" matches, as well as direct equality.
 /// </summary>
 /// <param name="pattern">the pattern to match against
 /// </param>
 /// <param name="str">the String to match
 /// </param>
 /// <returns> whether the String matches the given pattern
 /// </returns>
 public static bool SimpleMatch(System.String pattern, System.String str)
 {
     if (ObjectUtils.NullSafeEquals(pattern, str) || "*".Equals(pattern))
     {
         return true;
     }
     if (pattern == null || str == null)
     {
         return false;
     }
     if (pattern.StartsWith("*") && pattern.EndsWith("*") &&
         str.IndexOf(pattern.Substring(1, (pattern.Length - 1) - (1))) != -1)
     {
         return true;
     }
     if (pattern.StartsWith("*") && str.EndsWith(pattern.Substring(1, (pattern.Length) - (1))))
     {
         return true;
     }
     if (pattern.EndsWith("*") && str.StartsWith(pattern.Substring(0, (pattern.Length - 1) - (0))))
     {
         return true;
     }
     return false;
 }
コード例 #6
0
        public override int GetTargetIndex(System.Collections.Generic.List<WorldObject> availableTargets)
        {
            var target = availableTargets
                .Where(x => x.Owner != 0 && x.Owner != this.Owner)
                .OrderByDescending(x => x.HitPoints)
                .FirstOrDefault();

            return availableTargets.IndexOf(target);
        }
コード例 #7
0
 public void GenericIndexOfTestCase1()
 {
     var array = new[]
     {
         "test",
         "test2"
     };
     var actual = array.IndexOf( "test2", 1 );
     Assert.AreEqual( 1, actual );
 }
コード例 #8
0
		private static System.String parseName(System.String name)
		{
			int comma = name.IndexOf(',');
			if (comma >= 0)
			{
				// Format may be last,first; switch it around
				return name.Substring(comma + 1) + ' ' + name.Substring(0, (comma) - (0));
			}
			return name;
		}
コード例 #9
0
 /// <summary> Resolves SYSTEM and PUBLIC identifiers for CML DTDs.
 /// 
 /// </summary>
 /// <param name="publicId">the PUBLIC identifier of the DTD (unused)
 /// </param>
 /// <param name="systemId">the SYSTEM identifier of the DTD
 /// </param>
 /// <returns> the CML DTD as an InputSource or null if id's unresolvable
 /// </returns>
 public virtual XmlSourceSupport resolveEntity(System.String publicId, System.String systemId)
 {
     //logger.debug("CMLResolver: resolving ", publicId, ", ", systemId);
     systemId = systemId.ToLower();
     if ((systemId.IndexOf("cml-1999-05-15.dtd") != -1) || (systemId.IndexOf("cml.dtd") != -1) || (systemId.IndexOf("cml1_0.dtd") != -1))
     {
         //logger.info("File has CML 1.0 DTD");
         return getCMLType("cml1_0.dtd");
     }
     else if ((systemId.IndexOf("cml-2001-04-06.dtd") != -1) || (systemId.IndexOf("cml1_0_1.dtd") != -1) || (systemId.IndexOf("cml_1_0_1.dtd") != -1))
     {
         //logger.info("File has CML 1.0.1 DTD");
         return getCMLType("cml1_0_1.dtd");
     }
     else
     {
         //logger.warn("Could not resolve systemID: ", systemId);
         return null;
     }
 }
コード例 #10
0
 public void GenericIndexOfTestCase2()
 {
     var array = new[]
     {
         "test",
         "test2",
         "test3",
         "test4"
     };
     var actual = array.IndexOf( "test3", 1, 2 );
     Assert.AreEqual( 2, actual );
 }
コード例 #11
0
	/// <summary> Parses the value string into a recognized type. If
	/// the type specified is not supported, the data will
	/// be held and returned as a string.
	/// *
	/// </summary>
	/// <param name="key">the context key for the data
	/// </param>
	/// <param name="type">the data type
	/// </param>
	/// <param name="value">the data
	///
	/// </param>
	public DataInfo(System.String key, System.String type, System.String value_Renamed) {
	    this.key = key;

	    if (type.ToUpper().Equals(TYPE_BOOLEAN.ToUpper())) {
		this.data = System.Boolean.Parse(value_Renamed);
	    } else if (type.ToUpper().Equals(TYPE_NUMBER.ToUpper())) {
		if (value_Renamed.IndexOf((System.Char) '.') >= 0) {
		    //UPGRADE_TODO: Format of parameters of constructor 'java.lang.Double.Double' are different in the equivalent in .NET. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1092"'
		    this.data = System.Double.Parse(value_Renamed);
		} else {
		    this.data = System.Int32.Parse(value_Renamed);
		}
	    } else {
		this.data = value_Renamed;
	    }
	}
コード例 #12
0
      /// <summary>Replace a string within a string</summary>
      /// <param name="in_sSourceString">The String to modify
      /// </param>
      /// <param name="in_sTokenToReplace">The Token to replace
      /// </param>
      /// <param name="in_sNewToken">The new Token
      /// </param>
      /// <param name="in_nNbTimes">The number of time, the replace operation must be done. -1 means replace all
      /// </param>
      /// <returns> String The new String
      /// </returns>
      /// <exception cref="RuntimeException">where trying to replace by a new token and this new token contains the token to be replaced
      /// </exception>
      static public System.String ReplaceToken(System.String in_sSourceString, System.String in_sTokenToReplace, System.String in_sNewToken, int in_nNbTimes)
      {
         int nIndex = 0;
         bool bHasToken = true;
         System.Text.StringBuilder sResult = new System.Text.StringBuilder(in_sSourceString);
         System.String sTempString = sResult.ToString();
         int nOldTokenLength = in_sTokenToReplace.Length;
         int nTimes = 0;
         
         // To prevent from replace the token with a token containg Token to replace
         if (in_nNbTimes == - 1 && in_sNewToken.IndexOf(in_sTokenToReplace) != - 1)
          {
            throw new System.SystemException("Can not replace by this new token because it contains token to be replaced");
         }
         
         while (bHasToken)
         {
            nIndex = sTempString.IndexOf(in_sTokenToReplace, nIndex);
            bHasToken = (nIndex != - 1);
            
            if (bHasToken)
             {
               // Control number of times
               if (in_nNbTimes != - 1)
                {
                  if (nTimes < in_nNbTimes)
                   {
                     nTimes++;
                  }
                  else
                   {
                     // If we already replace the number of times asked then go out
                     break;
                  }
               }
               
               sResult.Replace(sResult.ToString(nIndex, nIndex + nOldTokenLength - nIndex), in_sNewToken, nIndex, nIndex + nOldTokenLength - nIndex);
               sTempString = sResult.ToString();
            }
            
            nIndex = 0;
         }
         
         return sResult.ToString();
		    }
コード例 #13
0
        public MapEditorLogic(Widget widget, World world, WorldRenderer worldRenderer)
        {
            var gridButton = widget.GetOrNull<ButtonWidget>("GRID_BUTTON");
            var terrainGeometryTrait = world.WorldActor.Trait<TerrainGeometryOverlay>();

            if (gridButton != null && terrainGeometryTrait != null)
            {
                gridButton.OnClick = () => terrainGeometryTrait.Enabled ^= true;
                gridButton.IsHighlighted = () => terrainGeometryTrait.Enabled;
            }

            var zoomDropdown = widget.GetOrNull<DropDownButtonWidget>("ZOOM_BUTTON");
            if (zoomDropdown != null)
            {
                var selectedZoom = Game.Settings.Graphics.PixelDouble ? 2f : 1f;
                var selectedLabel = selectedZoom.ToString();
                Func<float, ScrollItemWidget, ScrollItemWidget> setupItem = (zoom, itemTemplate) =>
                {
                    var item = ScrollItemWidget.Setup(itemTemplate,
                        () => selectedZoom == zoom,
                        () => { worldRenderer.Viewport.Zoom = selectedZoom = zoom; selectedLabel = zoom.ToString(); });

                    var label = zoom.ToString();
                    item.Get<LabelWidget>("LABEL").GetText = () => label;

                    return item;
                };

                var options = new[] { 2f, 1f, 0.5f, 0.25f };
                zoomDropdown.OnMouseDown = _ => zoomDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 150, options, setupItem);
                zoomDropdown.GetText = () => selectedLabel;
                zoomDropdown.GetKey = _ => Game.Settings.Keys.TogglePixelDoubleKey;
                zoomDropdown.OnKeyPress = e =>
                {
                    var key = Hotkey.FromKeyInput(e);
                    if (key != Game.Settings.Keys.TogglePixelDoubleKey)
                        return;

                    var selected = (options.IndexOf(selectedZoom) + 1) % options.Length;
                    worldRenderer.Viewport.Zoom = selectedZoom = options[selected];
                    selectedLabel = selectedZoom.ToString();
                };
            }
        }
コード例 #14
0
ファイル: AssDocument.cs プロジェクト: Rinecamo/SParser
 public static Boolean TryParse(String path, out AssDocument doc)
 {
     var modes = new[] { "[script info]", "[v4+ styles]", "[events]" }.ToList();
     if (!File.Exists(path)) throw new FileNotFoundException(path);
     doc = new AssDocument();
     using (var reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read))) {
         var currentSection = -1;
         while (!reader.EndOfStream) {
             var line = reader.ReadLine();
             if (String.IsNullOrEmpty(line)) continue;
             line = line.Trim();
             if (modes.Contains(line.ToLower())) {
                 currentSection = modes.IndexOf(line.ToLower());
                 reader.ReadLine();
             } else {
                 switch (currentSection) {
                     case 0:
                         doc.Settings.Add(line);
                         break;
                     case 1:
                         Style styleObject;
                         if (!Style.TryParse(line, out styleObject))
                             return false;
                         doc.Styles.Add(styleObject);
                         break;
                     case 2:
                         Line lineObject;
                         if (!Line.TryParse(line, out lineObject))
                             return false;
                         doc.Lines.Add(lineObject);
                         break;
                 }
             }
         }
     }
     return true;
 }
コード例 #15
0
ファイル: Tokeniser.cs プロジェクト: kblc/Royalty
		private ArrayList Tokenize(System.String input)
		{
			ArrayList returnVect = new ArrayList(10);
			int nextGapPos;
			for (int curPos = 0; curPos < input.Length; curPos = nextGapPos)
			{
				char ch = input[curPos];
				if (System.Char.IsWhiteSpace(ch))
					curPos++;
				nextGapPos = input.Length;
				for (int i = 0; i < "\r\n\t \x00A0".Length; i++)
				{					
					int testPos = input.IndexOf((Char) "\r\n\t \x00A0"[i], curPos);
					if (testPos < nextGapPos && testPos != - 1)
						nextGapPos = testPos;
				}
				
				System.String term = input.Substring(curPos, (nextGapPos) - (curPos));
				//if (!stopWordHandler.isWord(term))
				returnVect.Add(term);
			}
			
			return returnVect;
		}
コード例 #16
0
ファイル: LdapUrl.cs プロジェクト: EventStore/csharp-ldap
 // end of list + 1
 private System.String[] parseList(System.String listStr, char delimiter, int listStart, int listEnd)
 {
     System.String[] list;
     // Check for and empty string
     if ((listEnd - listStart) < 1)
     {
         return null;
     }
     // First count how many items are specified
     int itemStart = listStart;
     int itemEnd;
     int itemCount = 0;
     while (itemStart > 0)
     {
         // itemStart == 0 if no delimiter found
         itemCount += 1;
         itemEnd = listStr.IndexOf((System.Char) delimiter, itemStart);
         if ((itemEnd > 0) && (itemEnd < listEnd))
         {
             itemStart = itemEnd + 1;
         }
         else
         {
             break;
         }
     }
     // Now fill in the array with the attributes
     itemStart = listStart;
     list = new System.String[itemCount];
     itemCount = 0;
     while (itemStart > 0)
     {
         itemEnd = listStr.IndexOf((System.Char) delimiter, itemStart);
         if (itemStart <= listEnd)
         {
             if (itemEnd < 0)
                 itemEnd = listEnd;
             if (itemEnd > listEnd)
                 itemEnd = listEnd;
             list[itemCount] = listStr.Substring(itemStart, (itemEnd) - (itemStart));
             itemStart = itemEnd + 1;
             itemCount += 1;
         }
         else
         {
             break;
         }
     }
     return list;
 }
コード例 #17
0
		internal static System.String[] matchPrefixedField(System.String prefix, System.String rawText, char endChar, bool trim)
		{
			System.Collections.ArrayList matches = null;
			int i = 0;
			int max = rawText.Length;
			while (i < max)
			{
				//UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
				i = rawText.IndexOf(prefix, i);
				if (i < 0)
				{
					break;
				}
				i += prefix.Length; // Skip past this prefix we found to start
				int start = i; // Found the start of a match here
				bool done = false;
				while (!done)
				{
					//UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
					i = rawText.IndexOf((System.Char) endChar, i);
					if (i < 0)
					{
						// No terminating end character? uh, done. Set i such that loop terminates and break
						i = rawText.Length;
						done = true;
					}
					else if (rawText[i - 1] == '\\')
					{
						// semicolon was escaped so continue
						i++;
					}
					else
					{
						// found a match
						if (matches == null)
						{
							matches = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(3)); // lazy init
						}
						System.String element = unescapeBackslash(rawText.Substring(start, (i) - (start)));
						if (trim)
						{
							element = element.Trim();
						}
						matches.Add(element);
						i++;
						done = true;
					}
				}
			}
			if (matches == null || (matches.Count == 0))
			{
				return null;
			}
			return toStringArray(matches);
		}
コード例 #18
0
		private static void  appendKeyValue(System.String uri, int paramStart, int paramEnd, System.Collections.Hashtable result)
		{
			//UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
			int separator = uri.IndexOf('=', paramStart);
			if (separator >= 0)
			{
				// key = value
				System.String key = uri.Substring(paramStart, (separator) - (paramStart));
				System.String value_Renamed = uri.Substring(separator + 1, (paramEnd) - (separator + 1));
				value_Renamed = urlDecode(value_Renamed);
				result[key] = value_Renamed;
			}
			// Can't put key, null into a hashtable
		}
コード例 #19
0
		internal static System.Collections.Hashtable parseNameValuePairs(System.String uri)
		{
			int paramStart = uri.IndexOf('?');
			if (paramStart < 0)
			{
				return null;
			}
			System.Collections.Hashtable result = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable(3));
			paramStart++;
			int paramEnd;
			//UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
			while ((paramEnd = uri.IndexOf('&', paramStart)) >= 0)
			{
				appendKeyValue(uri, paramStart, paramEnd, result);
				paramStart = paramEnd + 1;
			}
			appendKeyValue(uri, paramStart, uri.Length, result);
			return result;
		}
コード例 #20
0
		protected internal static System.String unescapeBackslash(System.String escaped)
		{
			if (escaped != null)
			{
				int backslash = escaped.IndexOf('\\');
				if (backslash >= 0)
				{
					int max = escaped.Length;
					System.Text.StringBuilder unescaped = new System.Text.StringBuilder(max - 1);
					unescaped.Append(escaped.ToCharArray(), 0, backslash);
					bool nextIsEscaped = false;
					for (int i = backslash; i < max; i++)
					{
						char c = escaped[i];
						if (nextIsEscaped || c != '\\')
						{
							unescaped.Append(c);
							nextIsEscaped = false;
						}
						else
						{
							nextIsEscaped = true;
						}
					}
					return unescaped.ToString();
				}
			}
			return escaped;
		}
コード例 #21
0
ファイル: DataTypeGenerator.cs プロジェクト: snosrap/nhapi
        /// <summary> Returns a String containing the complete source code for a Primitive HL7 data
        /// type.  Note: this method is no longer used, as all Primitives are now coded manually.  
        /// </summary>
        private static System.String makePrimitive(System.String datatype, System.String description, System.String version)
        {
            System.Text.StringBuilder source = new System.Text.StringBuilder();

            source.Append("using System;\n");
            source.Append("using NHapi.Base.Model;\n");
            source.Append("using NHapi.Base;\n");
            source.Append("using NHapi.Base.Model.Primitive;\r\n");
            source.Append("namespace ");
            source.Append(PackageManager.GetVersionPackageName(version));
            source.Append("Datatype\r\n");
            source.Append("{\r\n");
            source.Append("///<summary>\r\n");
            source.Append("///Represents the HL7 ");
            source.Append(datatype);
            source.Append(" (");
            source.Append(description);
            source.Append(") datatype.  A ");
            source.Append(datatype);
            source.Append(" contains a single String value.\r\n");
            source.Append("///</summary>\r\n");
            source.Append("[Serializable]\r\n");
            source.Append("public class ");
            source.Append(datatype);
            source.Append(" : AbstractPrimitive ");
            source.Append(" {\r\n\r\n");
            //source.append("\tprotected String value;\r\n\r\n");
            source.Append("\t///<summary>\r\n");
            source.Append("\t///Constructs an uninitialized ");
            source.Append(datatype);
            source.Append(".\r\n");
            source.Append("\t///<param name=\"message\">The Message to which this Type belongs</param>\r\n");
            source.Append("\t///</summary>\r\n");
            source.Append("\tpublic ");
            source.Append(datatype);
            source.Append("(IMessage message) : base(message){\r\n");
            source.Append("\t}\r\n\r\n");

            source.Append("\t///<summary>\r\n");
            source.Append("\t///Constructs an uninitialized ");
            source.Append(datatype);
            source.Append(".\r\n");
            source.Append("\t///<param name=\"message\">The Message to which this Type belongs</param>\r\n");
            source.Append("\t///<param name=\"description\">The description of this type</param>\r\n");
            source.Append("\t///</summary>\r\n");
            source.Append("\tpublic ");
            source.Append(datatype);
            source.Append("(IMessage message, string description) : base(message,description){\r\n");
            source.Append("\t}\r\n\r\n");
            source.Append("\t///<summary>\r\n");
            source.Append("\t///  @return \"");
            source.Append(version);
            source.Append("\"\r\n");
            source.Append("\t///</summary>\r\n");
            source.Append("\tpublic string getVersion() {\r\n");
            source.Append("\t    return \"");
            if (version.IndexOf("UCH") > -1)
                source.Append("2.3");
            else
                source.Append(version);
            source.Append("\";\r\n");
            source.Append("}\r\n");
            source.Append("}\r\n");

            return source.ToString();
        }
コード例 #22
0
ファイル: InterfacesTest.cs プロジェクト: T145/razordbx
 public void TrySCIList(System.Collections.IList list)
 {
     // Should be called with a C5.IList<B> which is not a WrappedArray
       Assert.AreEqual(0, list.Count);
       list.CopyTo(new A[0], 0);
       list.CopyTo(new B[0], 0);
       list.CopyTo(new C[0], 0);
       Assert.IsTrue(!list.IsFixedSize);
       Assert.IsFalse(list.IsReadOnly);
       Assert.IsFalse(list.IsSynchronized);
       Assert.AreNotEqual(null, list.SyncRoot);
       Object b1 = new B(), b2 = new B(), c1 = new C(), c2 = new C();
       Assert.AreEqual(0, list.Add(b1));
       Assert.AreEqual(1, list.Add(c1));
       Assert.AreEqual(2, list.Count);
       Assert.IsTrue(list.Contains(c1));
       Assert.IsFalse(list.Contains(b2));
       list[0] = b2;
       Assert.AreEqual(b2, list[0]);
       list[1] = c2;
       Assert.AreEqual(c2, list[1]);
       Assert.IsTrue(list.Contains(b2));
       Assert.IsTrue(list.Contains(c2));
       Array arrA = new A[2], arrB = new B[2];
       list.CopyTo(arrA, 0);
       list.CopyTo(arrB, 0);
       Assert.AreEqual(b2, arrA.GetValue(0));
       Assert.AreEqual(b2, arrB.GetValue(0));
       Assert.AreEqual(c2, arrA.GetValue(1));
       Assert.AreEqual(c2, arrB.GetValue(1));
       Assert.AreEqual(0, list.IndexOf(b2));
       Assert.AreEqual(-1, list.IndexOf(b1));
       list.Remove(b1);
       list.Remove(b2);
       Assert.IsFalse(list.Contains(b2));
       Assert.AreEqual(1, list.Count); // Contains c2 only
       list.Insert(0, b2);
       list.Insert(2, b1);
       Assert.AreEqual(b2, list[0]);
       Assert.AreEqual(c2, list[1]);
       Assert.AreEqual(b1, list[2]);
       list.Remove(c2);
       Assert.AreEqual(b2, list[0]);
       Assert.AreEqual(b1, list[1]);
       list.RemoveAt(1);
       Assert.AreEqual(b2, list[0]);
       list.Clear();
       Assert.AreEqual(0, list.Count);
       list.Remove(b1);
 }
コード例 #23
0
		public virtual bool matches(int lineNumber, System.String line)
		{
			if (line.IndexOf("Jaguar") >= 0 && line.IndexOf("Schrodinger") >= 0)
			{
				return true;
			}
			return false;
		}
コード例 #24
0
ファイル: LdapUrl.cs プロジェクト: EventStore/csharp-ldap
        private void parseURL(System.String url)
        {
            int scanStart = 0;
            int scanEnd = url.Length;

            if ((System.Object) url == null)
                throw new System.UriFormatException("LdapUrl: URL cannot be null");

            // Check if URL is enclosed by < & >
            if (url[scanStart] == '<')
            {
                if (url[scanEnd - 1] != '>')
                    throw new System.UriFormatException("LdapUrl: URL bad enclosure");
                scanStart += 1;
                scanEnd -= 1;
            }

            // Determine the URL scheme and set appropriate default port
            if (url.Substring(scanStart, (scanStart + 4) - (scanStart)).ToUpper().Equals("URL:".ToUpper()))
            {
                scanStart += 4;
            }
            if (url.Substring(scanStart, (scanStart + 7) - (scanStart)).ToUpper().Equals("ldap://".ToUpper()))
            {
                scanStart += 7;
                port = LdapConnection.DEFAULT_PORT;
            }
            else if (url.Substring(scanStart, (scanStart + 8) - (scanStart)).ToUpper().Equals("ldaps://".ToUpper()))
            {
                secure = true;
                scanStart += 8;
                port = LdapConnection.DEFAULT_SSL_PORT;
            }
            else
            {
                throw new System.UriFormatException("LdapUrl: URL scheme is not ldap");
            }

            // Find where host:port ends and dn begins
            int dnStart = url.IndexOf("/", scanStart);
            int hostPortEnd = scanEnd;
            bool novell = false;
            if (dnStart < 0)
            {
                /*
                * Kludge. check for ldap://111.222.333.444:389??cn=abc,o=company
                *
                * Check for broken Novell referral format.  The dn is in
                * the scope position, but the required slash is missing.
                * This is illegal syntax but we need to account for it.
                * Fortunately it can't be confused with anything real.
                */
                dnStart = url.IndexOf("?", scanStart);
                if (dnStart > 0)
                {
                    if (url[dnStart + 1] == '?')
                    {
                        hostPortEnd = dnStart;
                        dnStart += 1;
                        novell = true;
                    }
                    else
                    {
                        dnStart = - 1;
                    }
                }
            }
            else
            {
                hostPortEnd = dnStart;
            }
            // Check for IPV6 "[ipaddress]:port"
            int portStart;
            int hostEnd = hostPortEnd;
            if (url[scanStart] == '[')
            {
                hostEnd = url.IndexOf((System.Char) ']', scanStart + 1);
                if ((hostEnd >= hostPortEnd) || (hostEnd == - 1))
                {
                    throw new System.UriFormatException("LdapUrl: \"]\" is missing on IPV6 host name");
                }
                // Get host w/o the [ & ]
                host = url.Substring(scanStart + 1, (hostEnd) - (scanStart + 1));
                portStart = url.IndexOf(":", hostEnd);
                if ((portStart < hostPortEnd) && (portStart != - 1))
                {
                    // port is specified
                    port = System.Int32.Parse(url.Substring(portStart + 1, (hostPortEnd) - (portStart + 1)));
                }
                else
                {
                }
            }
            else
            {
                portStart = url.IndexOf(":", scanStart);
                // Isolate the host and port
                if ((portStart < 0) || (portStart > hostPortEnd))
                {
                    // no port is specified, we keep the default
                    host = url.Substring(scanStart, (hostPortEnd) - (scanStart));
                }
                else
                {
                    // port specified in URL
                    host = url.Substring(scanStart, (portStart) - (scanStart));
                    port = System.Int32.Parse(url.Substring(portStart + 1, (hostPortEnd) - (portStart + 1)));
                }
            }

            scanStart = hostPortEnd + 1;
            if ((scanStart >= scanEnd) || (dnStart < 0))
                return ;

            // Parse out the base dn
            scanStart = dnStart + 1;

            int attrsStart = url.IndexOf((System.Char) '?', scanStart);
            if (attrsStart < 0)
            {
                dn = url.Substring(scanStart, (scanEnd) - (scanStart));
            }
            else
            {
                dn = url.Substring(scanStart, (attrsStart) - (scanStart));
            }

            scanStart = attrsStart + 1;
            // Wierd novell syntax can have nothing beyond the dn
            if ((scanStart >= scanEnd) || (attrsStart < 0) || novell)
                return ;

            // Parse out the attributes
            int scopeStart = url.IndexOf((System.Char) '?', scanStart);
            if (scopeStart < 0)
                scopeStart = scanEnd - 1;
            attrs = parseList(url, ',', attrsStart + 1, scopeStart);

            scanStart = scopeStart + 1;
            if (scanStart >= scanEnd)
                return ;

            // Parse out the scope
            int filterStart = url.IndexOf((System.Char) '?', scanStart);
            System.String scopeStr;
            if (filterStart < 0)
            {
                scopeStr = url.Substring(scanStart, (scanEnd) - (scanStart));
            }
            else
            {
                scopeStr = url.Substring(scanStart, (filterStart) - (scanStart));
            }
            if (scopeStr.ToUpper().Equals("".ToUpper()))
            {
                scope = LdapConnection.SCOPE_BASE;
            }
            else if (scopeStr.ToUpper().Equals("base".ToUpper()))
            {
                scope = LdapConnection.SCOPE_BASE;
            }
            else if (scopeStr.ToUpper().Equals("one".ToUpper()))
            {
                scope = LdapConnection.SCOPE_ONE;
            }
            else if (scopeStr.ToUpper().Equals("sub".ToUpper()))
            {
                scope = LdapConnection.SCOPE_SUB;
            }
            else
            {
                throw new System.UriFormatException("LdapUrl: URL invalid scope");
            }

            scanStart = filterStart + 1;
            if ((scanStart >= scanEnd) || (filterStart < 0))
                return ;

            // Parse out the filter
            scanStart = filterStart + 1;

            System.String filterStr;
            int extStart = url.IndexOf((System.Char) '?', scanStart);
            if (extStart < 0)
            {
                filterStr = url.Substring(scanStart, (scanEnd) - (scanStart));
            }
            else
            {
                filterStr = url.Substring(scanStart, (extStart) - (scanStart));
            }

            if (!filterStr.Equals(""))
            {
                filter = filterStr; // Only modify if not the default filter
            }

            scanStart = extStart + 1;
            if ((scanStart >= scanEnd) || (extStart < 0))
                return ;

            // Parse out the extensions
            int end = url.IndexOf((System.Char) '?', scanStart);
            if (end > 0)
                throw new System.UriFormatException("LdapUrl: URL has too many ? fields");
            extensions = parseList(url, ',', scanStart, scanEnd);

            return ;
        }
コード例 #25
0
ファイル: SDFFormat.cs プロジェクト: xuchuansheng/GenXSource
		public virtual bool matches(int lineNumber, System.String line)
		{
			if (lineNumber == 4 && (line.IndexOf("v2000") >= 0 || line.IndexOf("V2000") >= 0))
			{
				return true;
			}
			else if (line.StartsWith("M  END"))
			{
				return true;
			}
			else if (lineNumber == 4 && line.Length > 7)
			{
				// possibly a MDL mol file
				try
				{
					System.String atomCountString = line.Substring(0, (3) - (0)).Trim();
					System.String bondCountString = line.Substring(3, (6) - (3)).Trim();
					System.Int32.Parse(atomCountString);
					System.Int32.Parse(bondCountString);
					bool mdlFile = true;
					if (line.Length > 6)
					{
						System.String remainder = line.Substring(6).Trim();
						for (int i = 0; i < remainder.Length; ++i)
						{
							char c = remainder[i];
							if (!(System.Char.IsDigit(c) || System.Char.IsWhiteSpace(c)))
							{
								mdlFile = false;
							}
						}
					}
					// all tests succeeded, likely to be a MDL file
					if (mdlFile)
					{
						return true;
					}
				}
				catch (System.FormatException nfe)
				{
					// Integers not found on fourth line; therefore not a MDL file
				}
			}
			return false;
		}
コード例 #26
0
 public void IListIndexOfWorks()
 {
     IList<string> l = new[] { "x", "y", "z" };
     Assert.AreEqual(l.IndexOf("y"), 1);
     Assert.AreEqual(l.IndexOf("a"), -1);
 }
コード例 #27
0
		public virtual bool matches(int lineNumber, System.String line)
		{
			if (line.IndexOf("MOPAC:  VERSION  7.00") >= 0)
			{
				return true;
			}
			return false;
		}
コード例 #28
0
		/// <summary>Inserts a DOCTYPE declaration in the string if there isn't one </summary>
		private System.String insertDoctype(System.String profileString)
		{
			System.String result = profileString;
			if (profileString.IndexOf("<!DOCTYPE") < 0)
			{
				System.Text.StringBuilder buf = new System.Text.StringBuilder();
				int loc = profileString.IndexOf("?>");
				if (loc > 0)
				{
					buf.Append(profileString.Substring(0, (loc + 2) - (0)));
					buf.Append("<!DOCTYPE HL7v2xConformanceProfile SYSTEM \"\">");
					buf.Append(profileString.Substring(loc + 2));
					result = buf.ToString();
				}
			}
			return result;
		}
コード例 #29
0
ファイル: DebugEncoder.cs プロジェクト: heon21st/flashdevelop
		/// <summary> C: The SWD generation for fdb is... flaky, especially the way to figure out
		/// the bitmap category based on debug module names. DebugModule and DebugScript
		/// must be set with a flag indicating whether they are classes, frame actions,
		/// etc, etc, etc.
		/// 
		/// R: I don't particularly like it either and would prefer it if this stuff
		/// lived on the fdb side, not in here.
		/// </summary>
		private bool isFrameworkClass(System.String name)
		{
			bool isIt = (name.StartsWith("mx.") && name.IndexOf(":") != - 1 && name.EndsWith(".as")) || (name.IndexOf("/mx/") > - 1);
			
			return isIt;
		}
コード例 #30
0
ファイル: LdapUrl.cs プロジェクト: EventStore/csharp-ldap
        /// <summary> Decodes a URL-encoded string.
        /// 
        /// Any occurences of %HH are decoded to the hex value represented.
        /// However, this method does NOT decode "+" into " ".
        /// 
        /// </summary>
        /// <param name="URLEncoded">    String to decode.
        /// 
        /// </param>
        /// <returns> The decoded string.
        /// 
        /// </returns>
        /// <exception> MalformedURLException The URL could not be parsed.
        /// </exception>
        public static System.String decode(System.String URLEncoded)
        {
            int searchStart = 0;
            int fieldStart;

            fieldStart = URLEncoded.IndexOf("%", searchStart);
            // Return now if no encoded data
            if (fieldStart < 0)
            {
                return URLEncoded;
            }

            // Decode the %HH value and copy to new string buffer
            int fieldEnd = 0; // end of previous field
            int dataLen = URLEncoded.Length;

            System.Text.StringBuilder decoded = new System.Text.StringBuilder(dataLen);

            while (true)
            {
                if (fieldStart > (dataLen - 3))
                {
                    throw new System.UriFormatException("LdapUrl.decode: must be two hex characters following escape character '%'");
                }
                if (fieldStart < 0)
                    fieldStart = dataLen;
                // Copy to string buffer from end of last field to start of next
                decoded.Append(URLEncoded.Substring(fieldEnd, (fieldStart) - (fieldEnd)));
                fieldStart += 1;
                if (fieldStart >= dataLen)
                    break;
                fieldEnd = fieldStart + 2;
                try
                {
                    decoded.Append((char) System.Convert.ToInt32(URLEncoded.Substring(fieldStart, (fieldEnd) - (fieldStart)), 16));
                }
                catch (System.FormatException ex)
                {
                    throw new System.UriFormatException("LdapUrl.decode: error converting hex characters to integer \"" + ex.Message + "\"");
                }
                searchStart = fieldEnd;
                if (searchStart == dataLen)
                    break;
                fieldStart = URLEncoded.IndexOf("%", searchStart);
            }

            return (decoded.ToString());
        }