public Node Put(Node x, String key, char val, int d) { if (x == null) x = new Node(); if(d == key.Length) { x.Value = val; return x; } var c = key.ElementAt(d); if (x.next[c] != null) { if (x.next[c].HasItem) { Count++; } } x.next[c] = Put(x.next[c], key, val, d + 1); x.next[c].HasItem = true; return x; }
public String formatarDataHora(String dataHora) { if (dataHora.ElementAt(2).Equals('/')) { String dia, mes, ano,h,min,seg; dia = dataHora.Substring(0, 2); mes = dataHora.Substring(3, 2); ano = dataHora.Substring(6, 4); h = dataHora.Substring(11,2); min = dataHora.Substring(14,2); seg = dataHora.Substring(17,2); String dataFormt = ano + "/" + mes + "/"+dia+" "+h+":"+min+":"+seg; String dataN = dataFormt; return dataN; } else { String dia, mes, ano, h, min, seg; ano = dataHora.Substring(0, 4); mes = dataHora.Substring(5, 2); dia = dataHora.Substring(8, 2); h = dataHora.Substring(11, 2); min = dataHora.Substring(14, 2); seg = dataHora.Substring(17, 2); String dataFormt = dia + "/" + mes + "/" + ano + " " + h + ":" + min + ":" + seg; String dataN = dataFormt; return dataN; } }
public System.String EncodeToNonLossyAscii(System.String original) { Charset asciiCharset = Charset.ForName("US-ASCII"); if (asciiCharset.NewEncoder().CanEncode(original)) { return(original); } StringBuffer stringBuffer = new StringBuffer(); for (int i = 0; i < original.Length; i++) { char c = original.ElementAt(i); if (c < 128) { stringBuffer.Append(c.ToString()); } else if (c < 256) { System.String octal = Integer.ToOctalString(c); stringBuffer.Append("\\"); stringBuffer.Append(octal); } else { System.String hex = Integer.ToHexString(c); stringBuffer.Append("\\u"); stringBuffer.Append(hex); } } return(stringBuffer.ToString()); }
public void runMe(String input) { if (input.Length > 0) { Console.Write(input.ElementAt(input.Length - 1)); runMe(input.Remove(input.Length - 1)); } }
public static LinkedList<String> getRelacion(String line) { LinkedList<String> UA = new LinkedList<string>(); int i = 2; while (line.Length > i) { String word = ""; while (line.ElementAt(i) >= 'A' && line.ElementAt(i) <= 'Z' || line.ElementAt(i) >= 'a' && line.ElementAt(i) <= 'z') { word = String.Concat(word, line.ElementAt(i).ToString()); ++i; } if (word.Length > 0) UA.AddLast(word); ++i; } return UA; }
public String setNomInstrumentSansEspaces(String nom) { String nomCopie = ""; for (int i = 0; i < nom.Length; i++) { if (nom.ElementAt(i) == ' ') { nomCopie += '_'; } else { nomCopie += nom.ElementAt(i); } } return nomCopie; }
public String setNomMusicienSansEspaces(String nom) { //Il faut remplacer les espaces du nom par un caractère (ici _) pour pouvoir l'envoyer dans l'url String nomCopie = ""; for (int i = 0; i < nom.Length; i++) { if (nom.ElementAt(i) == ' ') { nomCopie += '_'; } else { nomCopie += nom.ElementAt(i); } } return nomCopie; }
private void PrintVertical(String input) { for (int i = 0; i < input.Length; i++) { Console.CursorLeft = cursorIndex; Console.Write(input.ElementAt(i)); cursorIndex = Console.CursorLeft; if (!(input.Length - i == 1)) { cursorIndex--; Console.Write("\n"); } } }
private Boolean checkCorrect(String s) { if (s.Equals("") || s.Equals("\n")) { return false; } for (int i = 0; i < s.Length; i++) { if (!char.IsLetterOrDigit(s.ElementAt(i))) { return false; } } return true; }
public static void recursFunct(String begining,String ending) { if(ending.Length<=1) { Console.WriteLine(begining + ending); } else { for(int i=0;i<ending.Length;i++) { String newString = ending.Substring(0, i) + ending.Substring(i + 1); recursFunct(begining + ending.ElementAt(i), newString); } } }
public List<string> PermuteString(String beginningString, String endingString) { List<string> result = new List<string>(); if (endingString.Length <= 1) result.Add(beginningString + endingString); else { for (int i = 0; i < endingString.Length; i++) { String newString = endingString.Substring(0, i) + endingString.Substring(i + 1); result.AddRange(PermuteString(beginningString + endingString.ElementAt(i), newString)); } } return result; }
public static String Reverse(String str) { if (str == null) { throw new ArgumentNullException("str"); } if (str.Trim().Length == 0) { return str; } StringBuilder reverseString = new StringBuilder(); for (int i = 0; i < str.Length; i++) { reverseString.Append(str.ElementAt(str.Length - 1 - i)); } return reverseString.ToString(); }
/** Writes a string that is known to contain only ASCII characters. Non-ASCII strings passed to this method will be corrupted. * Each byte is a 7 bit character with the remaining byte denoting if another character is available. This is slightly more * efficient than {@link #writeString(String)}. The string can be read using {@link Input#readString()} or * {@link Input#readStringBuilder()}. * @param value May be null. */ public void writeAscii(String value) { if (value == null) { writeByte(0x80); // 0 means null, bit 8 means UTF8. return; } int charCount = value.Length; switch (charCount) { case 0: writeByte(1 | 0x80); // 1 is string length + 1, bit 8 means UTF8. return; case 1: writeByte(2 | 0x80); // 2 is string length + 1, bit 8 means UTF8. writeByte(value.ElementAt(0)); return; } byte[] buffer = new byte[charCount]; Encoding.UTF8.GetBytes(value.ToCharArray(), 0, charCount, buffer, 0); buffer[charCount - 1] |= 0x80; // Bit 8 means end of ASCII. WriteBytes(buffer); }
public String formatarData(String data) { if (data.ElementAt(2).Equals('/')) { String dia, mes, ano; dia = data.Substring(0, 2); mes = data.Substring(3, 2); ano = data.Substring(6, 4); String dataFormt = ano + "/" + mes + "/" + dia; String dataN = dataFormt; return dataN; } else { String dia, mes, ano; ano = data.Substring(0, 4); mes = data.Substring(5, 2); dia = data.Substring(8, 2); String dataFormt = dia + "/" + mes + "/" + ano; String dataN = dataFormt; return dataN; } }
private static String GetMasuVerb1(String sourceWord) { char lastSign = sourceWord.ElementAt(sourceWord.Length - 1); switch (lastSign) { case 'う': lastSign = 'い'; break; case 'く': lastSign = 'き'; break; case 'す': lastSign = 'し'; break; case 'つ': lastSign = 'ち'; break; case 'ぬ': lastSign = 'に'; break; case 'ふ': lastSign = 'ひ'; break; case 'む': lastSign = 'み'; break; case 'る': lastSign = 'り'; break; case 'ぐ': lastSign = 'ぎ'; break; case 'ず': lastSign = 'じ'; break; case 'づ': lastSign = 'ぢ'; break; case 'ぶ': lastSign = 'び'; break; case 'ぷ': lastSign = 'ぴ'; break; } return sourceWord.Substring(0, sourceWord.Length - 1) + lastSign + "ます"; }
static void handleChatInput(String line) { StringBuilder sb = new StringBuilder(); if (line.Length > 0) { if (quitHelperMessageShow && (line == "q" || line == "Q")) { enqueuePluginChatMessage("If you are trying to quit, use the !quit command.", true); quitHelperMessageShow = false; } bool handled = false; if (line.ElementAt(0) == '!') { String line_lower = line.ToLower(); // There's atleast one character (!), so we can be sure that line_part will have length 1 at minimum. String[] line_part = line_lower.Split(' '); if (line_lower == "!quit") { handled = true; intentionalConnectionEnd = true; endSession = true; sendConnectionEndMessage("Quit"); } else if (line_lower == "!ping") { handled = true; if (!pingStopwatch.IsRunning) { queueOutgoingMessage(KMPCommon.ClientMessageID.PING, null); pingStopwatch.Start(); } } else if (line_lower == "!debug") { handled = true; debugging = !debugging; if (debugging) Log.MinLogLevel = Log.LogLevels.Debug; else Log.MinLogLevel = Log.LogLevels.Info; enqueuePluginChatMessage("debug " + debugging); } else if(line_lower == "!clear") { KMPChatDX.chatLineQueue.Clear(); handled = true; } else if (line_lower == "!whereami") { handled = true; sb.Append("You are connected to: "); sb.Append(hostname); enqueuePluginChatMessage(sb.ToString()); } else if (line_lower == "!bubble") { if (gameManager.horizontalDistanceToSafetyBubbleEdge() < 1 || gameManager.verticalDistanceToSafetyBubbleEdge() < 1) { sb.Append("The bubble radius is: "); sb.Append(gameManager.safetyBubbleRadius.ToString("N1", CultureInfo.CreateSpecificCulture("en-US"))); sb.Append("m\n"); sb.Append("You are outside of the bubble!"); } else { sb.Append("The bubble radius is: "); sb.Append(gameManager.safetyBubbleRadius.ToString("N1", CultureInfo.CreateSpecificCulture("en-US"))); sb.Append("m\n"); sb.Append("You are "); sb.Append(gameManager.verticalDistanceToSafetyBubbleEdge().ToString("N1", CultureInfo.CreateSpecificCulture("en-US"))); sb.Append("m away from the bubble top.\n"); sb.Append("You are "); sb.Append(gameManager.horizontalDistanceToSafetyBubbleEdge().ToString("N1", CultureInfo.CreateSpecificCulture("en-US"))); sb.Append("m away from the nearest bubble side."); } enqueuePluginChatMessage(sb.ToString()); handled = true; } else if (line_part[0] == "!chat") { handled = true; int length = line_part.Length; if (length > 1) { string command = line_part[1]; if (command == "dragwindow") { bool state = false; if (length >= 3) { // Set they requested value state = line_part[2] == "true"; } else { // Or toggle. state = !KMPChatDX.draggable; } if (!state) { KMPChatDX.chatboxX = KMPChatDX.windowPos.x; KMPChatDX.chatboxY = KMPChatDX.windowPos.y; } KMPChatDX.draggable = state; enqueueTextMessage(String.Format("The chat window is now {0}", (KMPChatDX.draggable) ? "draggable" : "not draggable")); } else if (command == "offsetting") { bool state = true; if (length >= 3) { state = line_part[2] == "true"; } else { state = !KMPChatDX.offsettingEnabled; } KMPChatDX.offsettingEnabled = state; enqueueTextMessage(String.Format("Chat window offsetting has been {0}", (KMPChatDX.offsettingEnabled) ? "enabled" : "disabled")); } else if (command == "offset") { if (length >= 5) { try { // 0 = tracking station, 1 = editor/sph int target = (line_part[2] == "tracking") ? 0 : 1; float offsetX = Convert.ToSingle(line_part[3]); float offsetY = Convert.ToSingle(line_part[4]); if (target == 0) { KMPChatDX.trackerOffsetX = offsetX; KMPChatDX.trackerOffsetY = offsetY; } else if (target == 1) { KMPChatDX.editorOffsetX = offsetX; KMPChatDX.editorOffsetY = offsetY; } enqueueTextMessage(String.Format("The {0} offsets has been set to X: {1} Y: {2}", (target == 0) ? "tracking station" : "rocket/spaceplane editor", offsetX, offsetY)); } catch (Exception e) { Log.Debug("Exception thrown in handleChatInput(), catch 1, Exception: {0}", e.ToString()); enqueueTextMessage("Syntax error. Usage: !chat offset [tracking|editor] [offsetX] [offsetY]"); } } } else if (command == "width" || command == "height" || command == "top" || command == "left") { if (length >= 3) { try { float size = Convert.ToSingle(line_part[2]); bool percent = true; if (length >= 4) { percent = line_part[3] == "percent"; } switch (command) { case "width": KMPChatDX.chatboxWidth = (percent) ? Screen.width * (size / 100) : size; sb.Append(String.Format("Chatbox width has been set to {0} {1}", size, (percent) ? "percent" : "pixels")); break; case "height": KMPChatDX.chatboxHeight = (percent) ? Screen.height * (size / 100) : size; sb.Append(String.Format("Chatbox height has been set to {0} {1}", size, (percent) ? "percent" : "pixels")); break; case "top": KMPChatDX.chatboxY = (percent) ? Screen.height * (size / 100) : size; sb.Append(String.Format("Chatbox top offset has been set to {0} {1}", size, (percent) ? "percent" : "pixels")); break; case "left": KMPChatDX.chatboxX = (percent) ? Screen.width * (size / 100) : size; sb.Append(String.Format("Chatbox left offset has been set to {0} {1}", size, (percent) ? "percent" : "pixels")); break; } KMPChatDX.windowPos.x = KMPChatDX.chatboxX; KMPChatDX.windowPos.y = KMPChatDX.chatboxY; KMPChatDX.windowPos.height = KMPChatDX.chatboxHeight; KMPChatDX.windowPos.width = KMPChatDX.chatboxWidth; enqueueTextMessage(sb.ToString()); } catch (Exception e) { Log.Debug("Exception thrown in handleChatInput(), catch 2, Exception: {0}", e.ToString()); enqueueTextMessage("Syntax error. Usage: !chat [width|height|top|left] [value] <percent|pixels>\nWhere value is a number."); } } else { enqueueTextMessage("Syntax error. Usage: !chat [width|height|top|left] [value] <percent|pixels>"); } } } } else if (line_lower.Length > (KMPCommon.SHARE_CRAFT_COMMAND.Length + 1) && line_lower.Substring(0, KMPCommon.SHARE_CRAFT_COMMAND.Length) == KMPCommon.SHARE_CRAFT_COMMAND) { handled = true; //Share a craft file String craft_name = line.Substring(KMPCommon.SHARE_CRAFT_COMMAND.Length + 1); KMPCommon.CraftType craft_type = KMPCommon.CraftType.VAB; String filename = findCraftFilename(craft_name, ref craft_type); if (filename != null && filename.Length > 0) { try { //byte[] craft_bytes = KSP.IO.File.ReadAllBytes<KMPClientMain>(filename); byte[] craft_bytes = System.IO.File.ReadAllBytes(filename); sendShareCraftMessage(craft_name, craft_bytes, craft_type); } catch (Exception e) { Log.Debug("Exception thrown in handleChatInput(), catch 3, Exception: {0}", e.ToString()); enqueueTextMessage("Error reading craft file: " + filename); } } else enqueueTextMessage("Craft file not found: " + craft_name); } } if (!handled) { sendTextMessage(line); } } }
private static bool CloseAndOpenBracketOrEndIsFound(String stringInput, int i) { return (stringInput.ElementAt(i).Equals(']') && i < stringInput.Length - 2 && stringInput.ElementAt(i + 1).Equals('[')) || (stringInput.ElementAt(i).Equals(']') && i == stringInput.Length - 1); }
} // End getEchelon /** * checks symbol code to see if graphic has a DOM (Q) modifier * @param symbolID * @return */ public static String getUnitAffiliationModifier(String symbolID, int symStd) { String textChar = null; char affiliation; try { affiliation = symbolID.ElementAt(1); if (affiliation == ('F') || affiliation == ('H') || affiliation == ('U') || affiliation == ('N') || affiliation == ('P')) textChar = null; else if (affiliation == ('A') || affiliation == ('S')) { if (symStd == RendererSettings.Symbology_2525Bch2_USAS_13_14) textChar = "?"; else textChar = null; } else if (affiliation == ('J')) textChar = "J"; else if (affiliation == ('K')) textChar = "K"; else if (affiliation == ('D') || affiliation == ('L') || affiliation == ('G') || affiliation == ('W')) textChar = "X"; else if (affiliation == ('M')) { if (symStd == RendererSettings.Symbology_2525Bch2_USAS_13_14) textChar = "X?"; else textChar = "X"; } //check sea mine symbols if (symStd == RendererSettings.Symbology_2525C) { if (symbolID.ElementAt(0) == 'S' && symbolID.IndexOf("WM") == 4) {//variuos sea mine exercises if (symbolID.IndexOf("GX") == 6 || symbolID.IndexOf("MX") == 6 || symbolID.IndexOf("FX") == 6 || symbolID.IndexOf("X") == 6 || symbolID.IndexOf("SX") == 6) textChar = "X"; else textChar = null; } } } catch (Exception exc) { ErrorLogger.LogException("SymbolUtilities", "getUnitAffiliationModifier", exc);// Level.WARNING); return null; } return textChar; }
/** * Determines if a symbol is an EMS Incident * @param strSymbolID * @return */ public static Boolean isEMSIncident(String strSymbolID) { Boolean blRetVal = false; try { if (strSymbolID.ElementAt(0) == 'E' && strSymbolID.ElementAt(2) == 'I') { blRetVal = true; } } catch (Exception exc) { Debug.Write(exc); } return blRetVal; }
/** * Returns true if Symbol is an Air Track * @param strSymbolID * @return */ public static Boolean isAirTrack(String strSymbolID) { if (strSymbolID.ElementAt(0) == 'S' && strSymbolID.ElementAt(2) == 'A') { return true; } else { return false; } }
public void Should_be_possible_to_generate_items_to_collect_from_an_object_with_referenced_variable_and_pattern_match_operation_at_same_time() { #region //<textfilecontent54_object id="oval:modulo:obj:991"> // <path var_ref="oval:modulo:var:911" /> // <filename operation="pattern match">.*.ini</filename> // <pattern>3gp</pattern> // <instance datatype="int">2</instance> //</textfilecontent54_object> #endregion var fakeFileLines = new string[] { "3gp=MPEGVideo" }; var fakeFilepaths = new string[] { @"c:\windows\boot.ini", @"c:\windows\file.txt", @"c:\windows\win.ini" }; var sourceObjectType = (textfilecontent54_object)ProbeHelper.GetDefinitionObjectTypeByID("definitionsSimple", "991"); var fakeEvaluatedVariables = CreateFakeEvaluateVariablesForAllEntities(sourceObjectType.id); var itemTypeGenerator = CreateItemTypeGeneratorWithMockedBehavior(fakeFileLines, true, fakeFilepaths); var expectedPaths = new String[] { @"c:\windows\boot.ini", @"c:\windows\win.ini", @"c:\windows NT\boot.ini", @"c:\windows NT\win.ini" }; var result = itemTypeGenerator.GetItemsToCollect(sourceObjectType, fakeEvaluatedVariables).ToArray(); ItemTypeChecker.DoBasicAssertForItems(result, 4, typeof(textfilecontent_item)); AssertGeneratedTextFileContentItem(result.ElementAt(0), expectedPaths.ElementAt(0), "3gp", "2"); AssertGeneratedTextFileContentItem(result.ElementAt(1), expectedPaths.ElementAt(1), "3gp", "2"); AssertGeneratedTextFileContentItem(result.ElementAt(2), expectedPaths.ElementAt(2), "3gp", "2"); AssertGeneratedTextFileContentItem(result.ElementAt(3), expectedPaths.ElementAt(3), "3gp", "2"); }
public int decodeResponse(String challenge, String str) { if (str.Length>100) return 0; int[] shuzi = new int[] { 1, 2, 5, 10, 50}; String chongfu = ""; Hashtable key = new Hashtable(); int count = 0; for (int i=0;i<challenge.Length;i++) { String item = challenge.ElementAt(i) + ""; if (chongfu.Contains(item)) continue; else { int value = shuzi[count % 5]; chongfu += item; count++; key.Add(item, value); } } int res = 0; for (int i = 0; i < str.Length; i++) res += (int)key[str[i]+""]; res = res - this.decodeRandBase(challenge); return res; }
private static String GetVolitionalVerb1(String sourceWord) { char lastSign = sourceWord.ElementAt(sourceWord.Length - 1); switch (lastSign) { case 'う': lastSign = 'お'; break; case 'く': lastSign = 'こ'; break; case 'す': lastSign = 'そ'; break; case 'つ': lastSign = 'と'; break; case 'ぬ': lastSign = 'の'; break; case 'ふ': lastSign = 'ほ'; break; case 'む': lastSign = 'も'; break; case 'る': lastSign = 'ろ'; break; case 'ぐ': lastSign = 'ご'; break; case 'ず': lastSign = 'ぞ'; break; case 'づ': lastSign = 'ど'; break; case 'ぶ': lastSign = 'ぼ'; break; case 'ぷ': lastSign = 'ぽ'; break; } return sourceWord.Substring(0, sourceWord.Length - 1) + lastSign + "う"; }
private static String GetRuVerb1(String sourceWord) { char lastSign = sourceWord.ElementAt(sourceWord.Length - 3); switch (lastSign) { case 'い': lastSign = 'う'; break; case 'き': lastSign = 'く'; break; case 'し': lastSign = 'す'; break; case 'ち': lastSign = 'つ'; break; case 'に': lastSign = 'ぬ'; break; case 'ひ': lastSign = 'ふ'; break; case 'み': lastSign = 'む'; break; case 'り': lastSign = 'る'; break; case 'ぎ': lastSign = 'ぐ'; break; case 'じ': lastSign = 'ず'; break; case 'ぢ': lastSign = 'づ'; break; case 'び': lastSign = 'ぶ'; break; case 'ぴ': lastSign = 'ぷ'; break; } return sourceWord.Substring(0, sourceWord.Length - 3) + lastSign; }
private static String GetPassiveVerb1(String sourceWord) { char lastSign = sourceWord.ElementAt(sourceWord.Length - 1); switch (lastSign) { case 'う': lastSign = 'わ'; break; case 'く': lastSign = 'か'; break; case 'す': lastSign = 'さ'; break; case 'つ': lastSign = 'た'; break; case 'ぬ': lastSign = 'な'; break; case 'ふ': lastSign = 'は'; break; case 'む': lastSign = 'ま'; break; case 'る': lastSign = 'ら'; break; case 'ぐ': lastSign = 'が'; break; case 'ず': lastSign = 'ざ'; break; case 'づ': lastSign = 'だ'; break; case 'ぶ': lastSign = 'ば'; break; case 'ぷ': lastSign = 'ぱ'; break; } return sourceWord.Substring(0, sourceWord.Length - 1) + lastSign + "れる"; }
private static String GetPotentialVerb1(String sourceWord) { char lastSign = sourceWord.ElementAt(sourceWord.Length - 1); switch (lastSign) { case 'う': lastSign = 'え'; break; case 'く': lastSign = 'け'; break; case 'す': lastSign = 'せ'; break; case 'つ': lastSign = 'て'; break; case 'ぬ': lastSign = 'ね'; break; case 'ふ': lastSign = 'へ'; break; case 'む': lastSign = 'め'; break; case 'る': lastSign = 'れ'; break; case 'ぐ': lastSign = 'げ'; break; case 'ず': lastSign = 'ぜ'; break; case 'づ': lastSign = 'で'; break; case 'ぶ': lastSign = 'べ'; break; case 'ぷ': lastSign = 'ぺ'; break; } return sourceWord.Substring(0, sourceWord.Length - 1) + lastSign + "る"; }
/// <summary> /// Construct an Instance from the given string, assuming the start of an Argument element at the given position. /// </summary> /// <param name="strParse">Command Line to parse.</param> /// <param name="Position">Location to start. This variable will be updated with the ending position of the argument that was discovered upon return.</param> public ArgumentItem(String strParse, ref int Position) { int startpos = Position; int sloc = startpos; while (char.IsWhiteSpace(strParse.ElementAt(sloc))) sloc++; if (strParse.ElementAt(sloc) == '"') { sloc++; while (true) { if (sloc >= strParse.Length) break; bool doublequote = strParse.Length > sloc + 2 && strParse.Substring(sloc, 2).Equals("\""); //if we found a quote and it's not a double quote... if (strParse.ElementAt(sloc) == '"' && !doublequote) { sloc++; break; } if (doublequote) sloc++; //add an extra spot for the dual quote. sloc++; } } else { sloc = strParse.IndexOfAny(new char[] {'/', ' '}, sloc); } _Argument = strParse.Substring(Position, sloc - startpos); Position = sloc; }
private static String GetTeVerb1(String sourceWord) { if (sourceWord == "行く") { return "行って"; } char lastSign = sourceWord.ElementAt(sourceWord.Length - 1); switch (lastSign) { case 'う': return sourceWord.Substring(0, sourceWord.Length - 1) + "って"; case 'く': return sourceWord.Substring(0, sourceWord.Length - 1) + "いて"; case 'す': return sourceWord.Substring(0, sourceWord.Length - 1) + "して"; case 'つ': return sourceWord.Substring(0, sourceWord.Length - 1) + "って"; case 'ぬ': return sourceWord.Substring(0, sourceWord.Length - 1) + "んで"; case 'ふ': return sourceWord.Substring(0, sourceWord.Length - 1) + "んで"; case 'む': return sourceWord.Substring(0, sourceWord.Length - 1) + "んで"; case 'る': return sourceWord.Substring(0, sourceWord.Length - 1) + "って"; case 'ぐ': return sourceWord.Substring(0, sourceWord.Length - 1) + "いで"; case 'ず': return sourceWord.Substring(0, sourceWord.Length - 1) + "して"; case 'づ': return sourceWord.Substring(0, sourceWord.Length - 1) + "って"; case 'ぶ': return sourceWord.Substring(0, sourceWord.Length - 1) + "んで"; case 'ぷ': return sourceWord.Substring(0, sourceWord.Length - 1) + "んで"; } return ""; }
public Switch(String strParse, ref int StartLocation) { while (String.IsNullOrWhiteSpace(strParse.ElementAt(StartLocation).ToString())) StartLocation++; var sLoc = StartLocation; var retrieved = SwitchPreceders. FirstOrDefault((s) => !(sLoc + s.Length > strParse.Length) && strParse.Substring(sLoc, s.Length) .Equals(s, StringComparison.OrdinalIgnoreCase)); if (retrieved == null) { throw new ArgumentException("Passed String " + strParse + " Does not have a switch preceder at position " + StartLocation); } var NextSpace = strParse.IndexOfAny(new char[] {' ', '\t', '/', ':'}, sLoc + 1); //if(((NextSpace-sLoc)-sLoc+1) <= 0) throw new ArgumentException("Error Parsing Switch"); _SwitchValue = strParse.Substring(sLoc + 1, NextSpace - sLoc - 1); sLoc += retrieved.Length; //we don't want the switch itself. //now we need to determine where the Switch ends. colon or space seems reasonable. If a colon, the next entity will be an argument. StartLocation = NextSpace; //if the char at NextSpace is a Colon... if (strParse.ElementAt(NextSpace) == ':') { //interpret as an argument NextSpace++; _Argument = new ArgumentItem(strParse, ref NextSpace); } StartLocation = NextSpace; }
public static Boolean isUsuario(String cadena) { Boolean resultado = true; if (cadena.Length < 15) { for (int x = 0; x < cadena.Length; x++) { Char ch = cadena.ElementAt(x); if (x == 0) { if (!Char.IsLetter(ch)) { resultado = false; break; } } else { if (!(Char.IsLetter(ch) || Char.IsNumber(ch) || ch.Equals('.') || ch.Equals('-') || ch.Equals('_'))) { resultado = false; break; } } } } else { resultado = false; } return resultado; }
private void ParseCommandLine(String cmdLine) { int currpos = 0; int initialpos = 0; while (currpos < cmdLine.Length) { while (char.IsWhiteSpace(cmdLine.ElementAt(currpos))) currpos++; initialpos = currpos; if (Switch.SwitchAtPos(cmdLine, currpos)) { Switch sw = new Switch(cmdLine, ref currpos); _Elements.Add(sw); if (!storedSwitches.ContainsKey(sw.SwitchValue)) storedSwitches.Add(sw.SwitchValue, new List<Switch>()); storedSwitches[sw.SwitchValue].Add(sw); } else { _Elements.Add(new ArgumentItem(cmdLine, ref currpos)); } if (initialpos == currpos) break; } }