public String cmd(String cnd) { cnd = cnd.Trim(); String output = " "; Console.WriteLine(cnd); if ((cnd.Substring(0, 3).ToLower() == "cd_") && (cnd.Length > 2)) { if (System.IO.Directory.Exists(cnd.Substring(2).Trim())) cpath = cnd.Substring(2).Trim(); } else { cnd = cnd.Insert(0, "/B /c "); Process p = new Process(); p.StartInfo.WorkingDirectory = cpath; p.StartInfo.CreateNoWindow = true; p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = cnd; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.Start(); output = p.StandardOutput.ReadToEnd(); // output of cmd output = (output.Length == 0) ? " " : output; p.WaitForExit(); } return output; } // end cmd
private static String encrypt (Dictionary<String, String> data, String api_key) { JavaScriptSerializer serializer = new JavaScriptSerializer(); String json_data = serializer.Serialize(data); String iv = api_key.Substring(16, 16); api_key = api_key.Substring(0, 16); byte[] data_bytes = Encoding.UTF8.GetBytes(json_data); byte[] api_bytes = Encoding.ASCII.GetBytes(api_key); byte[] iv_bytes = Encoding.ASCII.GetBytes(iv); RijndaelManaged AES = new RijndaelManaged(); AES.Padding = PaddingMode.PKCS7; AES.Mode = CipherMode.CBC; AES.BlockSize = 128; AES.KeySize = 128; MemoryStream memStream = new MemoryStream(); CryptoStream cryptoStream = new CryptoStream(memStream, AES.CreateEncryptor(api_bytes, iv_bytes), CryptoStreamMode.Write); cryptoStream.Write(data_bytes, 0, data_bytes.Length); cryptoStream.FlushFinalBlock(); byte[] encryptedMessageBytes = new byte[memStream.Length]; memStream.Position = 0; memStream.Read(encryptedMessageBytes, 0, encryptedMessageBytes.Length); string encryptedMessage = System.Convert.ToBase64String(encryptedMessageBytes); return HttpUtility.UrlEncode(encryptedMessage); }
public static String encode(String s, Encoding encoding) { if (s == null) return null; StringBuilder builder = new StringBuilder(); int start = -1; for (int i = 0; i < s.Length; i++) { char ch = s[i]; if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9' || " .-*_".IndexOf(ch) > -1)) { if (start >= 0) { convert(s.Substring(start, i - start), builder, encoding); start = -1; } if (ch != ' ') builder.Append(ch); else builder.Append('+'); } else { if (start < 0) start = i; } } if (start >= 0) convert(s.Substring(start, s.Length - start), builder, encoding); return builder.ToString().Trim().Replace("+", "%20").Replace("*", "%2A").Replace("%2F", "/"); }
static Student? toStudent(String line) { if (line.StartsWith("#")) return new Nullable<Student>(); int nr = int.Parse(line.Substring(0, 5)); String name = line.Substring(6); return new Nullable<Student>(new Student(nr, name)); }
public unsafe static String ExpandEnvironmentVariables(String name) { if (name == null) throw new ArgumentNullException("name"); if (name.Length == 0) { return name; } int currentSize = 100; StringBuilder blob = new StringBuilder(currentSize); // A somewhat reasonable default size int lastPos = 0, pos; while (lastPos < name.Length && (pos = name.IndexOf('%', lastPos + 1)) >= 0) { if (name[lastPos] == '%') { string key = name.Substring(lastPos + 1, pos - lastPos - 1); string value = Environment.GetEnvironmentVariable(key); if (value != null) { blob.Append(value); lastPos = pos + 1; continue; } } blob.Append(name.Substring(lastPos, pos - lastPos)); lastPos = pos; } blob.Append(name.Substring(lastPos)); return blob.ToString(); }
public Dictionary<string, string> JsonToDictionary(String input, String firstCol) { //if(input.IndexOf("{" //input = input.Replace('\"',''); /* input = input.Substring(input.IndexOf("{" + firstCol) + 1); input = input.Substring(0, input.IndexOf("}")); */ /* while (input.IndexOf('\\') >= 0) { int index = input.IndexOf('\\'); input = input.Substring(0, index) + input.Substring(index + 1); } */ input = input.Substring(1); input = input.Substring(0,input.Length-1); while (input.IndexOf('\"') >= 0) { int index = input.IndexOf('\"'); input = input.Substring(0, index) + input.Substring(index + 1); } /* input.Replace(':', '='); input.Replace(',', ';'); */ return input.TrimEnd(',').Split(',').ToDictionary(item => item.Split(':')[0], item => item.Split(':')[1]); }
public static String Dechiffrer(String str, int Value) { //String temporaire String Encoder = ""; Encoder = str.Substring(str.Length - (Value % str.Length)) + str.Substring(0, str.Length - (Value % str.Length)); return Encoder; }
public void DrawLine(Point fromPoint, Point toPoint, String color, int strockeThickness) { byte r = Convert.ToByte(color.Substring(1, 2), 16); byte g = Convert.ToByte(color.Substring(3, 2), 16); byte b = Convert.ToByte(color.Substring(5, 2), 16); DrawLine(fromPoint, toPoint, Color.FromArgb(255, r, g, b), strockeThickness); }
public static String GetStringWith(String str, int length) { str = str.PadRight(length, " "[0]); char [] strs = str.ToCharArray(); str = ""; int i = 0; foreach (char s in strs) { str = str + s.ToString(); i = i + Encoding.Default.GetByteCount(s.ToString()); if (i == length || i == length -1 ) { str = str.Substring(0, str.Length - 2) + " "; break; } } str = str.PadRight(length, " "[0]); int bytecount = Encoding.Default.GetByteCount(str); int strlength = str.Length; int zh_count = bytecount - strlength; str = str.Substring(0, length - zh_count); return str; }
/// <summary> /// 根据申请号和卷期号获得中文全文文献路径 /// </summary> /// <param name="applyno">申请号</param> /// <param name="weekno">卷期号</param> /// <param name="type">D表示说明书,C表示权利要求</param> /// <returns>文献路径</returns> public static String getFullFilePath_CN(String applyno, String weekno, String type) { if (applyno.Length == 14) { String path = Common.CN_Full_Root; if (applyno.Substring(4, 1) == "1" || applyno.Substring(4, 1) == "8") { path = path + "FM//"; } if (applyno.Substring(4, 1) == "2" || applyno.Substring(4, 1) == "9") { path = path + "XX//"; } if (applyno.Substring(4, 1) == "3") { path = path + "WG//"; } path = path + applyno.Substring(0, 4) + "//" + weekno + "//" + applyno.Substring(11, 1) + "//" + applyno + "//" + applyno + type + ".xml"; return path; } else { throw new Exception("中文全文文献对应的申请号格式不正确"); } }
// accept either a POINT(X Y) or a "X Y" public point(String ps) { if (ps.StartsWith(geomType, StringComparison.InvariantCultureIgnoreCase)) { // remove point, and matching brackets ps = ps.Substring(geomType.Length); if (ps.StartsWith("(")) { ps = ps.Substring(1); } if (ps.EndsWith(")")) { ps = ps.Remove(ps.Length - 1); } } ps = ps.Trim(); // trim leading and trailing spaces String[] coord = ps.Split(CoordSeparator.ToCharArray()); if (coord.Length == 2) { X = Double.Parse(coord[0]); Y = Double.Parse(coord[1]); } else { throw new WaterOneFlowException("Could not create a point. Coordinates are separated by a space 'X Y'"); } }
void calculate(System.String inp) { if (inp != null) { Debug.Log(inp); if (inp.Contains("(") && inp.Contains(")")) { System.Int32 openI = inp.IndexOf("("); System.Int32 Mid = inp.IndexOf(" "); System.Int32 closeI = inp.IndexOf(")"); System.String PosS = inp.Substring(openI + 1, Mid - openI - 1); System.String VelS = inp.Substring(Mid + 1, closeI - Mid - 1); System.Int32.TryParse(PosS, out outputI); System.Int32.TryParse(VelS, out outputI2); } // if (inp.Contains("-")) // { // inp = inp.Remove(inp.IndexOf("-"), 1); // if (inp.Contains("-")) // { // s = inp.Remove(inp.IndexOf("-"), 1); // } // int.TryParse(inp, out outputI); // outputS = outputI.ToString(); // int HLen = outputS.Length / 2; // outputS2 = outputS.Substring(0, HLen); // int.TryParse(outputS2, out outputI2); // outputI2 *= -1; // Debug.Log(HLen.ToString() + " " + inp + " " + outputS + " " + outputS2 + " " + outputI.ToString() + " " + outputI2.ToString()); // } // else // { // //Debug.Log(inp); // //int HLen = inp.Length / 2; // //outputS = inp.Substring(HLen - 1, HLen); // int.TryParse(inp, out outputI); // outputS = outputI.ToString(); // int HLen = outputS.Length / 2; // outputS2 = outputS.Substring(0, HLen); // int.TryParse(outputS2, out outputI2); // Debug.Log(HLen.ToString() + " " + inp + " " + outputS + " " + outputS2 + " " + outputI.ToString() + " " + outputI2.ToString()); // } // outputF = (float)outputI2 / (float)max; } Debug.Log(inp); }
private void Add(String fullyQualifiedProperty) { String atomicProperty = null; String subProperty = null; int dotIndex = fullyQualifiedProperty.IndexOf('.'); if (dotIndex != - 1) { atomicProperty = fullyQualifiedProperty.Substring(0, dotIndex); subProperty = fullyQualifiedProperty.Substring(dotIndex + 1); } else { atomicProperty = fullyQualifiedProperty; } Relations subRelation = (Relations) _relationsMap[atomicProperty]; if (subRelation != null) { subRelation.Add(subProperty); } else { if ((Object) subProperty != null) { subRelation = new Relations(subProperty); } } _relationsMap[atomicProperty] = subRelation; }
public static Color ColorFromString(String hex) { //remove the # at the front hex = hex.Replace("#", ""); byte a = 255; byte r = 255; byte g = 255; byte b = 255; int start = 0; //handle ARGB strings (8 characters long) if (hex.Length == 8) { a = byte.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber); start = 2; } //convert RGB characters to bytes r = byte.Parse(hex.Substring(start, 2), System.Globalization.NumberStyles.HexNumber); g = byte.Parse(hex.Substring(start + 2, 2), System.Globalization.NumberStyles.HexNumber); b = byte.Parse(hex.Substring(start + 4, 2), System.Globalization.NumberStyles.HexNumber); return Color.FromArgb(a, r, g, b); }
/** * * @param decl a string from header or meta tag to detect encoding * @return encoding String */ public static String GetDeclaredEncoding(String decl) { if (decl == null) return null; int idx = decl.IndexOf("encoding"); if (idx < 0) return null; int idx1 = decl.IndexOf('"', idx); int idx2 = decl.IndexOf('\'', idx); if (idx1 == idx2) return null; if (idx1 < 0 && idx2 > 0 || idx2 > 0 && idx2 < idx1) { int idx3 = decl.IndexOf('\'', idx2 + 1); if (idx3 < 0) return null; return decl.Substring(idx2 + 1, idx3 - (idx2 + 1)); } if (idx2 < 0 && idx1 > 0 || idx1 > 0 && idx1 < idx2) { int idx3 = decl.IndexOf('"', idx1 + 1); if (idx3 < 0) return null; return decl.Substring(idx1 + 1, idx3 - (idx1 + 1)); } return null; }
public static Boolean MatchWildcardString(String pattern, String input) { if (String.Compare(pattern, input) == 0) { return true; } else if (String.IsNullOrEmpty(input)) { if (String.IsNullOrEmpty(pattern.Trim(new Char[1] { '*' }))) { return true; } else { return false; } } else if (pattern.Length == 0) { return false; } else if (pattern[0] == '?') { return MatchWildcardString(pattern.Substring(1), input.Substring(1)); } else if (pattern[pattern.Length - 1] == '?') { return MatchWildcardString(pattern.Substring(0, pattern.Length - 1), input.Substring(0, input.Length - 1)); } else if (pattern[0] == '*') { if (MatchWildcardString(pattern.Substring(1), input)) { return true; } else { return MatchWildcardString(pattern, input.Substring(1)); } } else if (pattern[pattern.Length - 1] == '*') { if (MatchWildcardString(pattern.Substring(0, pattern.Length - 1), input)) { return true; } else { return MatchWildcardString(pattern, input.Substring(0, input.Length - 1)); } } else if (pattern[0] == input[0]) { return MatchWildcardString(pattern.Substring(1), input.Substring(1)); } return false; }
public String BuildAbsoluteUrl(String rootUrl) { if (String.IsNullOrWhiteSpace(rootUrl)) throw new ArgumentNullException("rootUrl"); return !RelativeUrl.Contains(rootUrl.Substring(6)) && !RelativeUrl.Contains(rootUrl.Substring(6)) ? rootUrl + RelativeUrl : RelativeUrl; }
public GeocodeAddress RequestGeocodeAddress(String address) { //�����������geocoder�� String urlString = "http://geocoder.us/service/rest/geocode?address=" + HttpUtility.UrlEncode(address); HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(urlString); getRequest.Method = "GET"; WebResponse response = null; response = getRequest.GetResponse(); Stream responseStream = response.GetResponseStream(); GeocodeAddress addr = new GeocodeAddress(); XmlDocument doc = new XmlDocument(); doc.Load(responseStream); addr.lon = doc.GetElementsByTagName("geo:long").Item(0).FirstChild.Value; addr.lat = doc.GetElementsByTagName("geo:lat").Item(0).FirstChild.Value; address = doc.GetElementsByTagName("dc:description").Item(0).FirstChild.Value; int sep = address.IndexOf(','); if (sep != -1) { addr.address1 = address.Substring(0, sep); addr.address2 = address.Substring(sep + 1); } else { addr.address1 = address; } return addr; }
} // StartsWithHttp // Used by http channels to implement IChannel::Parse. // It returns the channel uri and places object uri into out parameter. internal static String ParseURL(String url, out String objectURI) { // Set the out parameters objectURI = null; int separator = StartsWithHttp(url); if (separator == -1) return null; // find next slash (after end of scheme) separator = url.IndexOf('/', separator); if (-1 == separator) { return url; // means that the url is just "tcp://foo:90" or something like that } // Extract the channel URI which is the prefix String channelURI = url.Substring(0, separator); // Extract the object URI which is the suffix (leave the slash) objectURI = url.Substring(separator); InternalRemotingServices.RemotingTrace("HTTPChannel.Parse URI in: " + url); InternalRemotingServices.RemotingTrace("HTTPChannel.Parse channelURI: " + channelURI); InternalRemotingServices.RemotingTrace("HTTPChannel.Parse objectURI: " + objectURI); return channelURI; } // ParseURL
/// <inheritdoc /> public override sealed bool ExecuteCommand(String args) { int index = args.IndexOf('='); String dots = args.Substring(0, (index) - (0)).Trim(); String v = args.Substring(index + 1).Trim(); PropertyEntry entry = PropertyConstraints.Instance .FindEntry(dots); if (entry == null) { throw new AnalystError("Unknown property: " + args.ToUpper()); } // strip quotes if (v[0] == '\"') { v = v.Substring(1); } if (v.EndsWith("\"")) { v = v.Substring(0, (v.Length - 1) - (0)); } String[] cols = dots.Split('.'); String section = cols[0]; String subSection = cols[1]; String name = cols[2]; entry.Validate(section, subSection, name, v); Prop.SetProperty(entry.Key, v); return false; }
private bool TestChangeExtension(String path, String extension) { string expected = ""; int iIndex = path.LastIndexOf(".") ; if ( iIndex > -1 ){ switch (extension) { case null: expected = path.Substring(0, iIndex); break; case "": expected = path.Substring(0, iIndex + 1); break; default: expected = path.Substring(0, iIndex) + extension; break; } } else expected = path + extension ; Log.Comment("Original Path: " + path); Log.Comment("Expected Path: " + expected); string result = Path.ChangeExtension(path, extension); if (result != expected) { Log.Exception("Got Path: " + result); return false; } return true; }
static String process(String s){ //analyze parens int bidx=s.IndexOf("("); while(bidx!=-1){ int count=1,eidx=bidx+1; for(;count!=0;eidx++){ if(s[eidx]=='(')count++; if(s[eidx]==')')count--; } s=s.Substring(0,bidx)+process(s.Substring(bidx+1,eidx-1-(bidx+1)))+s.Substring(eidx); bidx=s.IndexOf("("); } //calc without parens MatchCollection m=muldiv.Matches(s); while(m.Count>0){ if(m[0].Groups[3].Value=="*") s=m[0].Groups[1].Value+(int.Parse(m[0].Groups[2].Value)*int.Parse(m[0].Groups[4].Value))+m[0].Groups[5].Value; else s=m[0].Groups[1].Value+(int.Parse(m[0].Groups[2].Value)/int.Parse(m[0].Groups[4].Value))+m[0].Groups[5].Value; m=muldiv.Matches(s); } m=addsub.Matches(s); while(m.Count>0){ if(m[0].Groups[3].Value=="+") s=m[0].Groups[1].Value+(int.Parse(m[0].Groups[2].Value)+int.Parse(m[0].Groups[4].Value))+m[0].Groups[5].Value; else s=m[0].Groups[1].Value+(int.Parse(m[0].Groups[2].Value)-int.Parse(m[0].Groups[4].Value))+m[0].Groups[5].Value; m=addsub.Matches(s); } return s; }
void DataReceived(GT.Interfaces.Serial sender, System.IO.Ports.SerialData daten) { int BytesToRead = usbSerial.SerialLine.BytesToRead; byte[] buffer = new byte[BytesToRead]; usbSerial.SerialLine.Read(buffer, 0, BytesToRead); Debug.Print("Data received: " + BytesToRead + " Bytes" ); GT.Interfaces.PWMOutput ServoA = extender1.SetupPWMOutput(GT.Socket.Pin.Seven); GT.Interfaces.PWMOutput ServoB = extender1.SetupPWMOutput(GT.Socket.Pin.Eight); GT.Interfaces.PWMOutput ServoC = extender1.SetupPWMOutput(GT.Socket.Pin.Nine); GT.Interfaces.PWMOutput ServoD = extender2.SetupPWMOutput(GT.Socket.Pin.Nine); String bufferString = new String(UTF8Encoding.UTF8.GetChars(buffer)); Debug.Print("DATA: " + bufferString); String servo = bufferString.Substring(0, 1); UInt32 position = UInt32.Parse(bufferString.Substring(1, bufferString.Length - 1)); switch (servo) { case "g": setServo(ServoA, position); break; case "1": setServo(ServoB, position); break; case "2": setServo(ServoC, position); break; case "r": setServo(ServoD, position); break; } }
internal static String buildNONSDSName(String inName, esriWorkspaceType theWSType) { switch (theWSType) { case esriWorkspaceType.esriLocalDatabaseWorkspace: return "NONATT_" + inName; break; case esriWorkspaceType.esriFileSystemWorkspace: if (inName.Length <= 23) return "NONATT_" + inName; else { inName = inName.Substring(30 - inName.Length, inName.Length * 2 - 30); return "NONATT_" + inName; } break; case esriWorkspaceType.esriRemoteDatabaseWorkspace: if (inName.Length <= 23) return "NONATT_" + inName; else { inName = inName.Substring(30 - inName.Length, inName.Length * 2 - 30); return "NONATT_" + inName; } break; default: return inName; break; } }
private void parse(String message) { int i = -1; int j = message.IndexOf(" :"); String trailing = ""; if (message.StartsWith(":")) { i = message.IndexOf(" "); prefix = message.Substring(1, i - 1); } if (j >= 0) { trailing = message.Substring(j + 2); } else { j = message.Length; } var commandAndParameters = message.Substring(i + 1, j - i - 1).Split(' '); command = commandAndParameters.First(); if (commandAndParameters.Length > 1) parameters = commandAndParameters.Skip(1).ToArray(); if (!String.IsNullOrEmpty(trailing)) { parameters = parameters.Concat(new string[] { trailing }).ToArray(); } }
public static byte[] parseHex(String hex) { try { var data = new List<byte>(hex.Length / 3); for (int i = 0; i < hex.Length; i++) { if (i == hex.Length - 1) { data.Add(Byte.Parse(hex.Substring(i, 1), System.Globalization.NumberStyles.HexNumber)); break; } data.Add(Byte.Parse(hex.Substring(i, 2), System.Globalization.NumberStyles.HexNumber)); if ((i + 1) < hex.Length && !Char.IsWhiteSpace(hex[i + 1])) i++; while ((i + 1) < hex.Length && Char.IsWhiteSpace(hex[i + 1])) i++; } return data.ToArray(); } catch (Exception e) { throw e; } }
private bool login(String username,String password) { string com1 = "select * from LoginAccess where username = '******'"; if (username.Substring(0, 1) == "\'" || username.Substring(0, 1) == " ") { MessageBox.Show("Do not try to hack this!"); return false; } reader(com1); if (b.Read()) { if (password == (b["pass"].ToString())) { b.Close(); return true; } else { b.Close(); return false; } } else { b.Close(); return false; } }
public static String ReturnType2Java(SmaliLine.LineReturnType rt, String customType) { if (rt.ToString().EndsWith("Array")) { if (rt == SmaliLine.LineReturnType.CustomArray) { if (customType != "") return customType.Substring(1) + "[] "; else return customType.Substring(1) + "[]"; } else return Name2Java(rt.ToString().Replace("Array","").ToLowerInvariant().Trim()) + "[] "; } else { if (rt == SmaliLine.LineReturnType.Custom) { if (customType != "") return customType + ' '; else return customType; } else return Name2Java(rt.ToString().ToLowerInvariant().Trim()) + ' '; } }
public String getActive(String captcha, Bitmap bitmapTips) { int indexTips = 0; String tips = this.orcTips[indexTips].getCharFromPic(bitmapTips, 0, 0); String numbers = ""; if (tips.StartsWith("请输入")) numbers = this.orcNo.getCharFromPic(bitmapTips); else { indexTips++; tips = this.orcTips[indexTips].getCharFromPic(bitmapTips, x: 20); numbers = this.orcNo.getCharFromPic(bitmapTips, x:20); } this.subImgs = new List<Bitmap>(); for (int i = 0; i < this.orcTips[indexTips].SubImgs.Count; i++) this.subImgs.Add(this.orcTips[indexTips].SubImgs[i]); for (int i = 0; i < this.orcNo.SubImgs.Count; i++) this.subImgs.Add(this.orcNo.SubImgs[i]); char[] arrayno = numbers.ToCharArray(); String start = String.Format("{0}", arrayno[0]); String end = String.Format("{0}", arrayno[1]); if ('第'.Equals(tips[3])) return captcha.Substring(Int16.Parse(start) - 1, Int16.Parse(end) - Int16.Parse(start) + 1); else if ('前'.Equals(tips[3])) return captcha.Substring(0, Int16.Parse(start)); else if ('后'.Equals(tips[3])) return captcha.Substring(captcha.Length - Int16.Parse(start), Int16.Parse(start)); else return captcha; }
public new String Clean(String value) { // get rid of commas value = StringUtils.ReplaceAnyOf(value, ",().-_", ' '); // do basic cleaning value = _sub.Clean(value); if (String.IsNullOrEmpty(value)) return ""; // perform pre-registered transforms value = base.Clean(value); // renormalize whitespace, since being able to replace tokens with spaces // makes writing transforms easier value = StringUtils.NormalizeWs(value); // transforms: // "as foo bar" -> "foo bar as" // "al foo bar" -> "foo bar al" if (value.StartsWith("as ") || value.StartsWith("al ")) value = value.Substring(3) + ' ' + value.Substring(0, 2); return value; }
public void markMovement(List <Tile.tileType> blockType, int speed, Tile unitTile, Tile currentTile) { if (speed < 0 || (unitTile != currentTile && blockType.Contains(currentTile.setType))) { return; } for (int i = 0; i < 6; i++) { markMovement(blockType, speed - 1, unitTile, getNeighborByDirection((tileDirections)i, currentTile)); } if (unitTile != currentTile) { System.String name = currentTile.gameObject.name; int commaBreak = name.IndexOf(','); int x1 = System.Convert.ToInt32(name.Substring(4, commaBreak - 4)); int y1 = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak)); MeshRenderer currentMesh = board[y1, x1].GetComponent <MeshRenderer>(); int materialCount = currentMesh.materials.Length; List <Material> materialList = new List <Material>(); for (int i = 0; i < materialCount; i++) { if (currentMesh.materials[i].name == "Highlight (Instance)") { return; } materialList.Add(currentMesh.materials[i]); } materialList.Add(Resources.Load <Material>("Models/Materials/Highlight")); currentMesh.materials = materialList.ToArray(); } }
public Cliente(String _cliente) { if (_cliente.Length >= 45) { this.Nome = _cliente.Substring(14, 31); this.Documento = _cliente.Substring(45); } }
public void claimTile(Tile toClaim, Player owner, int radius) { System.String name = toClaim.gameObject.name; int commaBreak = name.IndexOf(','); int x1 = System.Convert.ToInt32(name.Substring(4, commaBreak - 4)); int y1 = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak)); claimTile(y1, x1, owner, radius); }
/// <summary> /// Returns neighbor based on the direction and the current tile /// </summary> /// <param name="direction">Direction of neighbor to return</param> /// <param name="tile">Current tile</param> /// <returns></returns> public Tile getNeighborByDirection(tileDirections direction, Tile tile) { System.String name = tile.gameObject.name; int commaBreak = name.IndexOf(','); int x1 = System.Convert.ToInt32(name.Substring(4, commaBreak - 4)); int y1 = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak)); return(getNeighborByDirection(direction, y1, x1)); }
public int distanceBetweenTiles(Tile t1, Tile t2) { System.String name = t1.gameObject.name; int commaBreak = name.IndexOf(','); int x1 = System.Convert.ToInt32(name.Substring(4, commaBreak - 4)); int y1 = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak)); name = t2.gameObject.name; commaBreak = name.IndexOf(','); int x2 = System.Convert.ToInt32(name.Substring(4, commaBreak - 4)); int y2 = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak)); return(distanceBetweenTiles(x1, x2, y1, y2)); }
public void GetLetters(System.String stringInput) { myLetters.Clear(); for (int i = 0; i < stringInput.Length; i += 2) { myLetters.Add(stringInput.Substring(i, 2)); } string newWord = ""; for (int i = 0; i < myLetters.Count; i++) { int temp = System.Int32.Parse(myLetters[i]); //int.TryParse(myLetters[i]), out temp); if (temp == 0) { newWord += " "; } else { newWord += alphabeth.Substring(temp - 1, 1); } } print(newWord); }
public static System.String ToString(long lval) { if (lval == 0) { return("0"); } int maxStrLen = powersOf36.Length; long curval = lval; char[] tb = new char[maxStrLen]; int outpos = 0; for (int i = 0; i < maxStrLen; i++) { long pval = powersOf36[maxStrLen - i - 1]; int pos = (int)(curval / pval); tb[outpos++] = digits.Substring(pos, 1).ToCharArray()[0]; curval = curval % pval; } if (outpos == 0) { tb[outpos++] = '0'; } return(new System.String(tb, 0, outpos).TrimStart('0')); }
internal int SelectVersion(System.String remoteIdentification) { // Get the index of the seperators int l = remoteIdentification.IndexOf("-"); int r = remoteIdentification.IndexOf("-", l + 1); // Get the version System.String remoteVersion = remoteIdentification.Substring(l + 1, (r) - (l + 1)); // Evaluate the version if (remoteVersion.Equals("2.0")) { return(SSH2); } else if (remoteVersion.Equals("1.99")) { return(SSH1 | SSH2); } else if (remoteVersion.Equals("1.5")) { return(SSH1); } else { throw new SSHException("Unsupported version " + remoteVersion + " detected!", SSHException.CONNECT_FAILED); } }
public static TelParsedResult parse(Result result) { System.String rawText = result.Text; if (rawText == null || (!rawText.StartsWith("tel:") && !rawText.StartsWith("TEL:"))) { return(null); } // Normalize "TEL:" to "tel:" System.String telURI = rawText.StartsWith("TEL:")?"tel:" + rawText.Substring(4):rawText; // Drop tel, query portion //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 queryStart = rawText.IndexOf('?', 4); System.String number = queryStart < 0?rawText.Substring(4):rawText.Substring(4, (queryStart) - (4)); return(new TelParsedResult(number, telURI, null)); }
/// <summary> /// Converts a System.String number to long. /// </summary> /// <param name="s"></param> /// <returns></returns> public static long ToInt64(System.String s) { long number = 0; long factor; // handle negative number if (s.StartsWith("-")) { s = s.Substring(1); factor = -1; } else { factor = 1; } // generate number for (int i = s.Length - 1; i > -1; i--) { int n = digits.IndexOf(s[i]); // not supporting fractional or scientific notations if (n < 0) { throw new System.ArgumentException("Invalid or unsupported character in number: " + s[i]); } number += (n * factor); factor *= 36; } return(number); }
/// <summary> /// Turns a base file name into a test case name. /// </summary> /// <param name="s"> /// The base file name. /// </param> /// <returns> /// The test case name. /// </returns> protected internal static System.String getTestCaseName(System.String s) { System.Text.StringBuilder name = new System.Text.StringBuilder(); name.Append(System.Char.ToUpper(s[0])); name.Append(s.Substring(1, (s.Length) - (1)).ToLower()); return(name.ToString()); }
private static void AddGram(System.String text, Document doc, int ng1, int ng2) { int len = text.Length; for (int ng = ng1; ng <= ng2; ng++) { System.String key = "gram" + ng; System.String end = null; for (int i = 0; i < len - ng + 1; i++) { System.String gram = text.Substring(i, (i + ng) - (i)); doc.Add(new Field(key, gram, Field.Store.YES, Field.Index.UN_TOKENIZED)); if (i == 0) { doc.Add(new Field("start" + ng, gram, Field.Store.YES, Field.Index.UN_TOKENIZED)); } end = gram; } if (end != null) { // may not be present if len==ng1 doc.Add(new Field("end" + ng, end, Field.Store.YES, Field.Index.UN_TOKENIZED)); } } }
protected internal static void logForce(System.String type, System.String message) { System.Console.Error.WriteLine("logger> " + type + ": " + message); if (message.Length > MAX_MSG_LENGTH) { System.Console.Error.WriteLine(" (message truncated)"); } message = message.Substring(0, (System.Math.Min(message.Length, MAX_MSG_LENGTH)) - (0)); if (logger != null) { try { System.DateTime tempAux = System.DateTime.Now; //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" logger.log(type, message, ref tempAux); } catch (System.SystemException e) { //do not catch exceptions here; if this fails, we want the exception to propogate System.Console.Error.WriteLine("exception when trying to write log message! " + WrappedException.printException(e)); logger.panic(); //be conservative for now //throw e; } } }
/// <summary> Derives a reference from a URI in the current environment. /// /// </summary> /// <param name="uri">The URI representing a reference. /// </param> /// <param name="context">A reference URI which provides context for any /// relative reference accessors. /// </param> /// <returns> A reference which is identified by the provided URI. /// </returns> /// <throws> InvalidReferenceException If the current reference could </throws> /// <summary> not be derived by the current environment, or if the context URI /// is not valid in the current environment. /// </summary> public virtual Reference DeriveReference(System.String uri, System.String context) { if (uri == null) { throw new InvalidReferenceException("Null references aren't valid", uri); } //Relative URI's need to determine their context first. if (isRelative(uri)) { //Clean up the relative reference to lack any leading separators. if (uri.StartsWith("./")) { uri = uri.Substring(2); } if (context == null) { throw new System.SystemException("Attempted to retrieve local reference with no context"); } else { return(derivingRoot(context).derive(uri, context)); } } else { return(derivingRoot(uri).derive(uri)); } }
/* (non-Javadoc) * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String) */ public virtual bool Accept(System.IO.FileInfo dir, System.String name) { int i = name.LastIndexOf((System.Char) '.'); if (i != -1) { System.String extension = name.Substring(1 + i); if (extensions.Contains(extension)) { return(true); } else if (extension.StartsWith("f") && (new System.Text.RegularExpressions.Regex("f\\d+")).Match(extension).Success) { return(true); } else if (extension.StartsWith("s") && (new System.Text.RegularExpressions.Regex("s\\d+")).Match(extension).Success) { return(true); } } else { if (name.Equals(IndexFileNames.DELETABLE)) { return(true); } else if (name.StartsWith(IndexFileNames.SEGMENTS)) { return(true); } } return(false); }
private static System.String generateShortName(System.String name) { System.String s = name; /* do we have a file name? */ int dotAt = name.LastIndexOf('.'); if (dotAt != -1) { /* yes let's strip the directory off */ //UPGRADE_WARNING: Method 'java.lang.String.lastIndexOf' was converted to 'System.String.LastIndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'" int lastSlashAt = name.LastIndexOf((System.Char)System.IO.Path.DirectorySeparatorChar, dotAt); if (lastSlashAt == -1 && System.IO.Path.DirectorySeparatorChar == '\\') { //UPGRADE_WARNING: Method 'java.lang.String.lastIndexOf' was converted to 'System.String.LastIndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'" lastSlashAt = name.LastIndexOf('/', dotAt); } s = name.Substring(lastSlashAt + 1); } else { /* not a file name ... */ s = name; } return(s.Trim()); }
private int Compare(System.String name, System.String v) { int v0 = System.Int32.Parse(name.Substring(0, (2) - (0))); int v1 = System.Int32.Parse(v); return(v0 - v1); }
private System.Boolean _CheckCharBeforLong(System.String strLine, System.Int32 nIndexOfValue) { System.Boolean bCheckCharBeforLongRes = false; System.String strCharBeforeLong; System.String strAZazString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; char[] szArrayAZazString = strAZazString.ToCharArray(); System.Int32 nIndex = -1; if (0 == nIndexOfValue) { bCheckCharBeforLongRes = true; return(bCheckCharBeforLongRes); } strCharBeforeLong = m_strLine.Substring(nIndexOfValue - 1, 1); nIndex = strCharBeforeLong.IndexOfAny(szArrayAZazString); if (-1 == nIndex) { bCheckCharBeforLongRes = true; } else { bCheckCharBeforLongRes = false; } return(bCheckCharBeforLongRes); }
public System.String get_AssigenStrSQL(System.String strSQLLine) { System.String strGet = System.String.Empty; System.String strPartAssigen = System.String.Empty; Int32 nIndex = 0; //std::string strSql = databaseConnection->prepareSQLStatement(ALARMRULE_SELECT_1008, string[] splitStrObject = strSQLLine.Split(new Char[] { '=' }); //std::string strSql //databaseConnection->prepareSQLStatement(ALARMRULE_SELECT_1008, strPartAssigen = splitStrObject[0]; strPartAssigen = strPartAssigen.Trim(); nIndex = strPartAssigen.IndexOf(" "); if (-1 == nIndex) { strGet = strPartAssigen; } else { strGet = strPartAssigen.Substring(nIndex + 1); strGet.Trim(); } return(strGet); }
/// <summary> Populates the given Segment object with data from the given XML Element.</summary> /// <throws> HL7Exception if the XML Element does not have the correct name and structure </throws> /// <summary> for the given Segment, or if there is an error while setting individual field values. /// </summary> public virtual void parse(Segment segmentObject, System.Xml.XmlElement segmentElement) { SupportClass.HashSetSupport done = new SupportClass.HashSetSupport(); System.Xml.XmlNodeList all = segmentElement.ChildNodes; for (int i = 0; i < all.Count; i++) { System.String elementName = all.Item(i).Name; if (System.Convert.ToInt16(all.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element && !done.Contains(elementName)) { done.Add(elementName); int index = elementName.IndexOf('.'); if (index >= 0 && elementName.Length > index) { //properly formatted element System.String fieldNumString = elementName.Substring(index + 1); int fieldNum = System.Int32.Parse(fieldNumString); parseReps(segmentObject, segmentElement, elementName, fieldNum); } else { } } } //set data type of OBX-5 if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0) { Varies.fixOBX5(segmentObject, Factory); } }
/// <summary> Given a string that contains HL7 messages, and possibly other junk, /// returns an array of the HL7 messages. /// An attempt is made to recognize segments even if there is other /// content between segments, for example if a log file logs segments /// individually with timestamps between them. /// /// </summary> /// <param name="theSource">a string containing HL7 messages /// </param> /// <returns> the HL7 messages contained in theSource /// </returns> private static System.String[] getHL7Messages(System.String theSource) { System.Collections.ArrayList messages = new System.Collections.ArrayList(20); Match startMatch = new Regex("^MSH", RegexOptions.Multiline).Match(theSource); foreach (Group group in startMatch.Groups) { System.String messageExtent = getMessageExtent(theSource.Substring(group.Index), "^MSH"); char fieldDelim = messageExtent[3]; Match segmentMatch = Regex.Match(messageExtent, "^[A-Z]{3}\\" + fieldDelim + ".*$", RegexOptions.Multiline); System.Text.StringBuilder msg = new System.Text.StringBuilder(); foreach (Group segGroup in segmentMatch.Groups) { msg.Append(segGroup.Value.Trim()); msg.Append('\r'); } messages.Add(msg.ToString()); } String[] retVal = new String[messages.Count]; messages.CopyTo(retVal); return(retVal); }
/// <summary> Attempts to retrieve the value of a leaf tag without using DOM or SAX. /// This method searches the given message string for the given tag name, and returns /// everything after the given tag and before the start of the next tag. Whitespace /// is stripped. This is intended only for lead nodes, as the value is considered to /// end at the start of the next tag, regardless of whether it is the matching end /// tag or some other nested tag. /// </summary> /// <param name="message">a string message in XML form /// </param> /// <param name="tagName">the name of the XML tag, e.g. "MSA.2" /// </param> /// <param name="startAt">the character location at which to start searching /// </param> /// <throws> HL7Exception if the tag can not be found </throws> protected internal virtual System.String parseLeaf(System.String message, System.String tagName, int startAt) { System.String value_Renamed = null; int tagStart = message.IndexOf("<" + tagName, startAt); if (tagStart < 0) { tagStart = message.IndexOf("<" + tagName.ToUpper(), startAt); } int valStart = message.IndexOf(">", tagStart) + 1; int valEnd = message.IndexOf("<", valStart); if (tagStart >= 0 && valEnd >= valStart) { value_Renamed = message.Substring(valStart, (valEnd) - (valStart)); } else { throw new NuGenHL7Exception("Couldn't find " + tagName + " in message beginning: " + message.Substring(0, (System.Math.Min(150, message.Length)) - (0)), NuGenHL7Exception.REQUIRED_FIELD_MISSING); } // Escape codes, as defined at http://hdf.ncsa.uiuc.edu/HDF5/XML/xml_escape_chars.htm value_Renamed = Regex.Replace(value_Renamed, """, "\""); value_Renamed = Regex.Replace(value_Renamed, "'", "'"); value_Renamed = Regex.Replace(value_Renamed, "&", "&"); value_Renamed = Regex.Replace(value_Renamed, "<", "<"); value_Renamed = Regex.Replace(value_Renamed, ">", ">"); return(value_Renamed); }
public System.String get_DatabaseHandle(System.String strSQLLine) { System.String strPartDatabaseSQL = System.String.Empty; System.String strPartDatabase = System.String.Empty; Int32 nIndex = 0; //std::string strSql = databaseConnection->prepareSQLStatement(ALARMRULE_SELECT_1008, string[] splitStrObject = strSQLLine.Split(new Char[] { '=' }); //std::string strSql //databaseConnection->prepareSQLStatement(ALARMRULE_SELECT_1008, strPartDatabaseSQL = splitStrObject[1]; strPartDatabaseSQL = strPartDatabaseSQL.Trim(); nIndex = strPartDatabaseSQL.IndexOf("->"); if (-1 == nIndex) { strPartDatabase = "databaseConnection"; } else { strPartDatabase = strPartDatabaseSQL.Substring(0, nIndex); strPartDatabase = strPartDatabase.Trim(); } return(strPartDatabase); }
public virtual void Check(Lexer lexer, Node node) { Attribute attribute; AttVal lang, type; node.checkUniqueAttributes(lexer); lang = node.getAttrByName("language"); type = node.getAttrByName("type"); if (type == null) { Report.attrError(lexer, node, "type", Report.MISSING_ATTRIBUTE); /* check for javascript */ if (lang != null) { System.String str = lang.value_Renamed; if (str.Length > 10) { str = str.Substring(0, (10) - (0)); } if ((Lexer.wstrcasecmp(str, "javascript") == 0) || (Lexer.wstrcasecmp(str, "jscript") == 0)) { node.addAttribute("type", "text/javascript"); } } else { node.addAttribute("type", "text/javascript"); } } }
/* * Create a node with the given name and cookie. **/ protected internal AbstractNode(System.String name, System.String cookie, bool shortName) { InitBlock(); this._cookie = cookie; int i = name.IndexOf((System.Char) '@', 0); if (i < 0) { _alive = name; _host = localHost; } else { _alive = name.Substring(0, (i) - (0)); _host = name.Substring(i + 1, (name.Length) - (i + 1)); } if (_alive.Length > 0xff) { _alive = _alive.Substring(0, (0xff) - (0)); } _longName = _alive + "@" + _host; _useShortName = shortName || useShortNames; _node = node(_longName, _useShortName); }
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); }
public virtual void TestSkipChars() { byte[] bytes = new byte[] { (byte)(0x80), (byte)(0x01), (byte)(0xFF), (byte)(0x7F), (byte)(0x80), (byte)(0x80), (byte)(0x01), (byte)(0x81), (byte)(0x80), (byte)(0x01), (byte)(0x06), (byte)'L', (byte)'u', (byte)'c', (byte)'e', (byte)'n', (byte)'e' }; System.String utf8Str = "\u0634\u1ea1"; byte[] utf8Bytes = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(utf8Str); byte[] theBytes = new byte[bytes.Length + 1 + utf8Bytes.Length]; Array.Copy(bytes, 0, theBytes, 0, bytes.Length); theBytes[bytes.Length] = (byte)utf8Str.Length; //Add in the number of chars we are storing, which should fit in a byte for this test Array.Copy(utf8Bytes, 0, theBytes, bytes.Length + 1, utf8Bytes.Length); IndexInput is_Renamed = new MockIndexInput(theBytes); Assert.AreEqual(128, is_Renamed.ReadVInt(null)); Assert.AreEqual(16383, is_Renamed.ReadVInt(null)); Assert.AreEqual(16384, is_Renamed.ReadVInt(null)); Assert.AreEqual(16385, is_Renamed.ReadVInt(null)); int charsToRead = is_Renamed.ReadVInt(null); //number of chars in the Lucene string Assert.IsTrue(0x06 == charsToRead, 0x06 + " does not equal: " + charsToRead); is_Renamed.SkipChars(3, null); char[] chars = new char[3]; //there should be 6 chars remaining is_Renamed.ReadChars(chars, 0, 3, null); System.String tmpStr = new System.String(chars); Assert.IsTrue(tmpStr.Equals("ene") == true, tmpStr + " is not equal to " + "ene"); //Now read the UTF8 stuff charsToRead = is_Renamed.ReadVInt(null) - 1; //since we are skipping one is_Renamed.SkipChars(1, null); Assert.IsTrue(utf8Str.Length - 1 == charsToRead, utf8Str.Length - 1 + " does not equal: " + charsToRead); chars = new char[charsToRead]; is_Renamed.ReadChars(chars, 0, charsToRead, null); tmpStr = new System.String(chars); Assert.IsTrue(tmpStr.Equals(utf8Str.Substring(1)) == true, tmpStr + " is not equal to " + utf8Str.Substring(1)); }
public RegexTermEnum(IndexReader reader, Term term) : base() { field = term.Field(); System.String text = term.Text(); pattern = new Pattern(text); // Find the first regex character position, to find the // maximum prefix to use for term enumeration int index = 0; while (index < text.Length) { char c = text[index]; if (!System.Char.IsLetterOrDigit(c)) { break; } index++; } pre = text.Substring(0, (index) - (0)); SetEnum(reader.Terms(new Term(term.Field(), pre))); }
static void RunCase(int CaseNum, System.IO.TextReader TR, System.IO.TextWriter TW) { char[] Splits = new char[] { ' ', '\t' }; System.String Str = "0" + TR.ReadLine(); System.String BestStr = ""; for (int i = 1; i < Str.Length; i++) { for (int j = 0; j < i; j++) { System.String NewStr = Str.Substring(0, j) + Str[i] + MinString(Str.Substring(j, i - j) + Str.Substring(i + 1)); if ((BestStr == "" || NewStr.CompareTo(BestStr) < 0) && NewStr.CompareTo(Str) > 0) { BestStr = NewStr; } } } if (BestStr[0] == '0') { BestStr = BestStr.Substring(1); } System.String Result = "Case #" + (CaseNum + 1) + ": " + BestStr; if (TW == null) { System.Console.WriteLine(Result); } else { TW.WriteLine(Result); } }
public static string BytesToNBNSQuery(byte[] field) { string nbnsUTF8 = BitConverter.ToString(field); nbnsUTF8 = nbnsUTF8.Replace("-00", String.Empty); string[] nbnsArray = nbnsUTF8.Split('-'); string nbnsQuery = ""; foreach (string character in nbnsArray) { nbnsQuery += new System.String(Convert.ToChar(Convert.ToInt16(character, 16)), 1); } if (nbnsQuery.Contains("CA")) { nbnsQuery = nbnsQuery.Substring(0, nbnsQuery.IndexOf("CA")); } int i = 0; string nbnsQuerySubtracted = ""; do { byte nbnsQuerySub = (byte)Convert.ToChar(nbnsQuery.Substring(i, 1)); nbnsQuerySub -= 65; nbnsQuerySubtracted += Convert.ToString(nbnsQuerySub, 16); i++; }while (i < nbnsQuery.Length); i = 0; string nbnsQueryHost = ""; do { nbnsQueryHost += (Convert.ToChar(Convert.ToInt16(nbnsQuerySubtracted.Substring(i, 2), 16))); i += 2; }while (i < nbnsQuerySubtracted.Length - 1); if (nbnsQuery.StartsWith("ABAC") && nbnsQuery.EndsWith("AC")) { nbnsQueryHost = nbnsQueryHost.Substring(2); nbnsQueryHost = nbnsQueryHost.Substring(0, nbnsQueryHost.Length - 1); nbnsQueryHost = String.Concat("<01><02>", nbnsQueryHost, "<02>"); } return(nbnsQueryHost); }