private void SetPathRelatedFields(String path) { // Set the path this.path = path; // Extract the file name from the path if (path.IndexOf('/') == -1) { fileName = path; } else { fileName = path.Substring(path.LastIndexOf('/')+1); } // Extract the extension from the file name if (fileName.IndexOf('.') == -1) { extension = String.Empty; } else { extension = fileName.Substring(fileName.LastIndexOf('.') + 1); } }
public Video(String url) { //http://v.iask.com/v_play.php?vid=75314790&uid=1648211320&pid=478&tid=&plid=4001&prid=ja_7_3485822616&referrer=http%3A%2F%2Fcontrol.video.sina.com.cn%2Fcontrol%2Fvideoset%2Findex.php&ran=0.4922798699699342&r=video.sina.com.cn this.url = url; xmlUrl = @"http://v.iask.com/v_play.php?vid=" + url.Substring(url.LastIndexOf('/') + 1, url.LastIndexOf('-') - url.LastIndexOf('/') - 1); }
public static String getFile(String deviceId, String fileFullPath) { int extLength = fileFullPath.Length - fileFullPath.LastIndexOf("."); String fileExt = fileFullPath.Substring(fileFullPath.LastIndexOf("."), extLength); JSONRequestIndex reqMsg = new JSONRequestIndex(deviceId, fileFullPath); JSONMessageWrapper msgWrapper = new JSONMessageWrapper("getFile", reqMsg.request()); try { String response = HttpClient.GET("getFile", msgWrapper.getMessage()); if (!string.IsNullOrEmpty(response)) { byte[] filebytes = Convert.FromBase64String(response); Guid gid = Guid.NewGuid(); FileStream fs = new FileStream(TEMP_LOCATION + gid + fileExt, FileMode.CreateNew, FileAccess.Write, FileShare.None); fs.Write(filebytes, 0, filebytes.Length); fs.Close(); return TEMP_LOCATION + gid.ToString() + fileExt; } return ""; } catch (WebException e) { //return Device Not Found return "DNF"; } }
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()); }
static int findLastSlash(String path) { int nPos = path.LastIndexOf('/'); if (nPos >= 0) return nPos; return path.LastIndexOf('\\'); }
private static String getUrlWithouExt( String url ) { int lastDot = url.LastIndexOf( '.' ); int lastSlash = url.LastIndexOf( '/' ); if (lastDot > lastSlash) return url.Substring( 0, lastDot ); else return url; }
internal static string GetFilename(String URL) { string Filename = URL.Substring(URL.LastIndexOf("/") + 2, URL.Length - URL.LastIndexOf("/") - 2); if (Filename.IndexOf("&") != -1) Filename = JustBefore(Filename, "&"); return Filename; }
public static String RemoveArgumentFromPath(String path) { if (path.Contains("/")) { path = path.Substring(0, path.LastIndexOf("/") ); } if (path.Contains("-")) { path = path.Substring(0, path.LastIndexOf("-")); } return path; }
public static String GetObjectName(String myObjectLocation) { // "/home////" -> "/home" while (myObjectLocation.EndsWith(FSPathConstants.PathDelimiter) && !myObjectLocation.Equals(FSPathConstants.PathDelimiter)) myObjectLocation = myObjectLocation.Substring(0, myObjectLocation.LastIndexOf(FSPathConstants.PathDelimiter)); if (myObjectLocation.Equals(FSPathConstants.PathDelimiter)) return ""; return myObjectLocation.Substring(myObjectLocation.LastIndexOf(FSPathConstants.PathDelimiter) + FSPathConstants.PathDelimiter.Length); }
public VideoItem(String path) { if (path.Contains('\\')) { this.path = path; this.name = path.Substring(path.LastIndexOf('\\') + 1, path.Length - path.LastIndexOf('\\') - 1); } else { this.name = path; } vf = new VideoInfo(path); //this.bitRate = vf.BitRate; }
private ImageType extractTypeFromFilename(String str) { ImageType output = ImageType.PROPELLER; if (str.Substring(str.LastIndexOf(".") + 1) == "png") output = ImageType.IMAGE; if (str.Substring(str.LastIndexOf(".") + 1) == "type") output = ImageType.TYPE; return output; }
public LogHeader(String header) { this.raw = header; //Alert sig Line int sigIndex = header.IndexOf ("[**]"); String sig = header.Substring (sigIndex + 4, header.LastIndexOf ("[**]") - sigIndex-4).Trim(); this.alertSig = new AlertSig (sig); //Alert MatchCollection sigInfos = Regex.Matches ( header.Substring(header.LastIndexOf("[**]")), "\\[(.*?)\\]"); foreach (Match sigInfo in sigInfos) { String sigStr = sigInfo.Value.Substring(1,sigInfo.Value.Length-2); if (sigStr.IndexOf (":") != -1) { int optionIndex = sigStr.IndexOf (":"); String optionKey = sigStr.Substring (0, optionIndex).Trim(); String optionValue = sigStr.Substring (optionIndex+1).Trim(); switch (optionKey.ToLower ()) { case "classification": this.clasific = optionValue; break; case "priority": this.priority = optionValue; break; } } if (sigStr.IndexOf ("=>") != -1) { int optionIndex = sigStr.IndexOf ("=>"); String optionKey = sigStr.Substring (0, optionIndex).Trim(); String optionValue = sigStr.Substring (optionIndex+2).Trim(); switch (optionKey.ToLower()) { case "xref": if (xrefList == null) { xrefList = new List<String> (); } xrefList.Add (optionValue); break; } } } }
private static void ExtractTrackNumbers(TrackInfo trackInfo, String content) { Int32 indexOfOpenParen = content.IndexOf('('); Int32 indexOfColon = content.LastIndexOf(':'); Int32 indexOfCloseParen = content.LastIndexOf(')'); if (indexOfOpenParen > 1 && indexOfColon > indexOfOpenParen + 1 && indexOfCloseParen > indexOfColon + 1) { String trackNum = content.Substring(0, indexOfOpenParen - 1); String mkvToolsTrackNum = content.Substring(indexOfColon + 2, indexOfCloseParen - (indexOfColon + 2)); trackInfo.TrackNumber = Int32.Parse(trackNum); trackInfo.MkvToolsTrackNumber = Int32.Parse(mkvToolsTrackNum); } }
public ShapeObject(LayerManager layerManager, String filePath) { this.layerManager = layerManager; this.filePath = filePath; this.fileName = filePath.Split('\\')[filePath.Split('\\').Length-1]; this.access = "rb"; this.shapePen = new Pen(layerManager.GetRandomColor(), 1.0f); int i = filePath.LastIndexOf("\\"); name = filePath.Substring(i + 1, filePath.LastIndexOf(".") - i - 1); }
public void notifyIsProductPurchasedAndNotConsumed(String ans) { Boolean first, second; if (ans.Length == 0) { return; } first = setBoolState (ans [0]); second = setBoolState (ans [1]); String newSku = ans.Substring(2, ans.LastIndexOf(" ") - 2); String purchaseId = ans.Substring (ans.LastIndexOf (" "), ans.Length - ans.LastIndexOf(" ")); if (isProductPurchasedAndNotConsumedAction.ContainsKey(newSku)){ isProductPurchasedAndNotConsumedAction[newSku](first, second, purchaseId); } }
/// <summary> /// Extracts the name of the file. /// </summary> /// <returns> /// The filename only. /// </returns> /// <param name='fileName'> /// Filename with path. /// </param> public static String extractFileName(String fileName) { if (fileName.Contains("/")) { return (fileName.LastIndexOf('/') == 0 ? fileName : fileName.Substring(fileName.LastIndexOf('/') + 1)); } else { return (fileName.LastIndexOf('\\') == 0 ? fileName : fileName.Substring(fileName.LastIndexOf('\\') + 1)); } }
public void DegiskenSil(DataGridView dgv,String degiskenler) { if (degiskenler.LastIndexOf(',') == 0) { degiskenler = degiskenler.Substring(0, degiskenler.Length - 1); } string[] degisken_deger = degiskenler.Split(','); for (int i = 0; i < degisken_deger.Length; i++) { try { if (degisken_deger[i].IndexOf('=') != -1) { String[] dv = degisken_deger[i].Split('='); ht.Remove(dv[0]); } else { ht.Remove(degisken_deger[i]); } } catch (Exception) { } } DegiskenYazdir(dgv); }
public static String ChangeExtension(String Path,String Ext) { int sindex = Path.LastIndexOf('.'); if (sindex == -1) return Path; return Path.Remove(sindex) + '.' + Ext.Trim(' ', '.').ToLower(); }
public void Resolve(String name, bool ip4Only) { // Find the ':' at end that separates address from the port number. int delimiter = name.LastIndexOf(':'); if (delimiter < 0) { throw InvalidException.Create(); } // Separate the address/port. String addrStr = name.Substring(0, delimiter); String portStr = name.Substring(delimiter + 1); // Remove square brackets around the address, if any. if (addrStr.Length >= 2 && addrStr[0] == '[' && addrStr[addrStr.Length - 1] == ']') addrStr = addrStr.Substring(1, addrStr.Length - 2); int port; // Allow 0 specifically, to detect invalid port error in atoi if not if (portStr.Equals("*") || portStr.Equals("0")) // Resolve wildcard to 0 to allow autoselection of port port = 0; else { // Parse the port number (0 is not a valid port). port = Convert.ToInt32(portStr); if (port == 0) { throw InvalidException.Create(); } } IPEndPoint addrNet = null; if (addrStr.Equals("*")) { addrStr = "0.0.0.0"; } IPAddress ipAddress; if (!IPAddress.TryParse(addrStr, out ipAddress)) { ipAddress = Dns.GetHostEntry(addrStr).AddressList.FirstOrDefault(); if (ipAddress == null) { throw InvalidException.Create(string.Format("Unable to find an IP address for {0}", name)); } } addrNet = new IPEndPoint(ipAddress, port); //if (addr_net == null) { // throw new ArgumentException(name_); //} Address = addrNet; }
public static bool SaveTextToFile(String _File, String _Text, bool _Append) { String var_Path = _File.Remove(_File.LastIndexOf("/")); if (CreatePath(var_Path)) { try { StreamWriter writer; if (_Append) { writer = new StreamWriter(File.Open(_File, FileMode.Append)); } else { writer = new StreamWriter(File.Open(_File, FileMode.CreateNew)); } writer.Write(_Text); writer.Flush(); writer.Close(); return true; } catch { // Error! } } else { // Error! } return false; }
static String GetExpectedMethodName( String path ) { //WARN: questo è un bug: impedisce di chiamare effettivamente il metodo nel VM qualcosa del tipo FooCommand perchè noi cercheremmo solo Foo var methodName = path.EndsWith( "Command" ) ? path.Remove( path.LastIndexOf( "Command" ) ) : path; return methodName; }
public virtual void OnInit(System.Collections.IList commits) { for (System.Collections.IEnumerator iterator = commits.GetEnumerator(); iterator.MoveNext();) { IndexCommit commit = (IndexCommit)iterator.Current; System.Collections.Generic.IDictionary <string, string> userData = commit.GetUserData(); if (userData.Count > 0) { // Label for a commit point is "Records 1-30" // This code reads the last id ("30" in this example) and deletes it // if it is after the desired rollback point System.String x = (System.String)userData["index"]; System.String lastVal = x.Substring(x.LastIndexOf("-") + 1); int last = System.Int32.Parse(lastVal); if (last > rollbackPoint) { /* * System.out.print("\tRolling back commit point:" + * " UserData="+commit.getUserData() +") ("+(commits.size()-1)+" commit points left) files="); * Collection files = commit.getFileNames(); * for (Iterator iterator2 = files.iterator(); iterator2.hasNext();) { * System.out.print(" "+iterator2.next()); * } * System.out.println(); */ commit.Delete(); } } } }
public ASPXHandler(String fileName, Dictionary<String, String> envVariables) { this.fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1); this.fullFilePath = fileName; this.fileExtension = this.fileName.Substring(this.fileName.IndexOf('.')); if (File.Exists(fileName)) { // Create an instance of Host class var aspxHost = new Host(); // Pass to it filename and query string this.responseBody = aspxHost.CreateHost( fileName, envVariables["server_root"], envVariables["query_string"]); this.responseHeader = new ResponseHeader("Status: 200 OK\r\nContent-Type: text/html\r\n"); this.responseHeader.setContentLength(this.responseBody.Length); } else { var error = new Error404(); this.responseHeader = error.getResponseHeader(); this.responseBody = error.getResponseBody(); } }
/// <summary> /// 隐藏邮箱 /// </summary> public static System.String HideEmail(this System.String Email) { int index = Email.LastIndexOf('@'); if (index == 1) { return("*" + Email.Substring(index)); } if (index == 2) { return(Email[0] + "*" + Email.Substring(index)); } StringBuilder sb = new StringBuilder(); sb.Append(Email.Substring(0, 2)); int count = index - 2; while (count > 0) { sb.Append("*"); count--; } sb.Append(Email.Substring(index)); return(sb.ToString()); }
void Save(String fullAddress, String uik) { using (var ctx = new Context()) { var sepIndex = fullAddress.LastIndexOf(", "); String parentAddress = fullAddress.Substring(0, sepIndex).Trim(); String address = fullAddress.Substring(sepIndex+1).Trim(); //var addrList = fullAddress.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList(); var parentNode = ctx.Nodes.Where(n => n.Address == parentAddress).FirstOrDefault(); if (parentNode == null) parentNode = new Node() { Address = parentAddress }; var currentNode = new Node() { Address = address, Uik = uik, Parent = parentNode }; ctx.Nodes.Add(currentNode); try { ctx.SaveChanges(); } catch (Exception ex) { throw ex; } } }
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; }
public BarList(ContentManager Content, String s_Path, float f_Y, bool b_Player, int i_Items, int i_Entities, int i_Obstacles, String s_Tex = "Editor/BarList") : base(Content, s_Tex) { bRemove = new AnimatedSprite(Content, "Editor/Remove"); bRemove.Position = new Vector2(128 + 704 + 48, f_Y); bPlayer = b_Player; iItems = i_Items; iEntities = i_Entities; iObstacles = i_Obstacles; sName = s_Path.Substring(s_Path.LastIndexOf("/") + 1, s_Path.LastIndexOf(".") - (s_Path.LastIndexOf("/") + 1)); Alpha = 0.8f; Position = new Vector2(128, f_Y); }
/* (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); }
protected RepositoryBase(String username, String password, string domain, string projectCollection, String url) { string fullUrl = url; bool collectionExists = !String.IsNullOrEmpty(projectCollection); if (String.IsNullOrEmpty(username)) throw new ArgumentNullException(username, "Username is null or empty!"); if (String.IsNullOrEmpty(password)) throw new ArgumentNullException(password, "Password is null or empty!"); if (collectionExists) fullUrl = url.LastIndexOf('/') == url.Length - 1 ? String.Concat(url, projectCollection) : String.Concat(url, "/", projectCollection); if (String.IsNullOrEmpty(url)) throw new ArgumentNullException(url, "TFSServerUrl is null or empty!"); var credentials = new NetworkCredential(username, password, domain); _configuration = new TfsConfigurationServer(new Uri(url), credentials); _configuration.EnsureAuthenticated(); if (collectionExists) { _tfs = new TfsTeamProjectCollection(new Uri(fullUrl), credentials); _tfs.EnsureAuthenticated(); } }
static internal String UnmangleTypeName(String typeName) { // Gets the original type name, without '+' name mangling. int i = typeName.Length - 1; while (true) { i = typeName.LastIndexOf('+', i); if (i == -1) break; bool evenSlashes = true; int iSlash = i; while (typeName[--iSlash] == '\\') evenSlashes = !evenSlashes; // Even number of slashes means this '+' is a name separator if (evenSlashes) break; i = iSlash; } return typeName.Substring(i + 1); }
/// <summary> /// Removes all the occurrences of a given substring in a given string. /// </summary> /// <param name="str">the source string.</param> /// <param name="substr">the substring to remove.</param> /// <returns>a copy of the original string without any occurrences of substr.</returns> public static String removeSubstring(String str, String substr) { if (String.IsNullOrEmpty(substr)) return str; if (String.IsNullOrEmpty(str)) { throw new ArgumentException( String.Format("Cannot remove substring: {0}, from a null string.", substr)); } if (!str.Contains(substr)) { return str; } String source = str.Substring(0,str.Length);//clone of str int indexStart = str.IndexOf(substr); int indexLast = str.LastIndexOf(substr); if (indexStart == indexLast) { //only one occurrence return removeSubStr(source, substr); } else { //more than one occurrence while (source.Contains(substr)) { source = removeSubStr(source, substr); } } return source; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { prevPage = Request.UrlReferrer.ToString(); String prevPageName = prevPage.Substring(prevPage.LastIndexOf("/") + 1); String strQuery = "SELECT [StampId], [Name], [Price], [Picture] FROM [TabularStamps] WHERE ([StampId] = @StampId)"; if (prevPageName.Equals("Specials.aspx")) { if (User.IsInRole("member")) { strQuery = "SELECT [StampId], [Name], [Price] * 0.85 AS [Price], [Picture] FROM [TabularStamps] WHERE ([StampId] = @StampId)"; } else { if (User.IsInRole("dealer") || User.IsInRole("admin")) { strQuery = "SELECT [StampId], [Name], [Price] * 0.70 AS [Price], [Picture] FROM [TabularStamps] WHERE ([StampId] = @StampId)"; } } } StampDetailDataSource.SelectParameters.Add("StampId", Request.QueryString[0]); StampDetailDataSource.SelectCommand = strQuery; StampDetailDataList.DataBind(); } }
/// <summary> /// Constructor /// </summary> /// <param name="fileName">Path and file name of log</param> /// <param name="debInf">Debug informations includng level, verbose, rotation information</param> public Debug(String fileName, ref DebugInformations debInf) { if (fileName.CompareTo("") == 0) { fileName = this._FileName; } Regex re = new Regex(@"\w+:\\\w+", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled); if (re.IsMatch(fileName)) { this._Path = fileName.Substring(0, fileName.LastIndexOf('\\')); if (System.IO.Directory.Exists(this._Path)) { this._FileName = fileName; } else { String exepath = Environment.GetCommandLineArgs()[0]; this._Path = exepath.Substring(0, exepath.LastIndexOf('\\')); this._FileName = this._Path + "\\" + fileName; } } else { String exepath = Environment.GetCommandLineArgs()[0]; this._Path = exepath.Substring(0, exepath.LastIndexOf('\\')); this._FileName = this._Path + "\\" + fileName; } this._DebugInfo = debInf; this._DebugInfo.Level = 1; }
private String TrimParameterString(String source) { var indexOfStartBreak = source.IndexOf('['); var indexOfLastBreak = source.LastIndexOf(']'); return source.Substring( indexOfStartBreak + 1, indexOfLastBreak - indexOfStartBreak - 1); }
/// <summary>Utility method to return a file's extension. </summary> public static System.String GetExtension(System.String name) { int i = name.LastIndexOf('.'); if (i == -1) { return(""); } return(name.Substring(i + 1, (name.Length) - (i + 1))); }
/// <summary> ///获得邮箱提供者 /// </summary> /// <param name="Email">邮箱</param> public static System.String GetEmailProvider(this System.String Email) { int index = Email.LastIndexOf('@'); if (index > 0) { return(Email.Substring(index + 1)); } return(System.String.Empty); }
public virtual XLRTargetNode checkPrefix(System.Globalization.CultureInfo fileLocale, System.String fileId, System.Globalization.CultureInfo locale, System.String id) { XLRTargetNode t = loadNode(fileLocale, fileId, locale, id); if (t == null) { int sep = fileId.LastIndexOf('$'); if (sep == -1) { sep = fileId.LastIndexOf('.'); } if (sep != -1) { t = checkPrefix(fileLocale, fileId.Substring(0, (sep) - (0)), locale, id); } } return(t); }
public bool Matches(System.String url) { bool match = false; int index = url.LastIndexOf((System.Char) '.'); if ((index != -1) && (index < url.Length - 1)) { // There's an extension, so try to find if it matches mines match = _collExtensions.Contains(url.Substring(index + 1)); } return(match); }
internal virtual System.String getExtension(System.IO.FileInfo f) { System.String ext = null; System.String s = f.Name; int i = s.LastIndexOf('.'); if (i > 0 && i < s.Length - 1) { ext = s.Substring(i + 1).ToLower(); } return(ext); }
/// <summary> /// Returns the name of the package specified by the given fully /// qualified class name. /// </summary> /// <param name="className">the fully qualified class name /// </param> /// <returns> the package name, or <code>null</code> for the base package /// </returns> private System.String GetPackageName(System.String className) { int index; if ((index = className.LastIndexOf((System.Char) '.')) == -1) { return(null); } else { return(className.Substring(0, (index) - (0))); } }
public static void ImportToMultipleXLSheets(System.String SqlSelect, System.String mOutputFileName) { string FolderPath; FolderPath = mOutputFileName.Remove(mOutputFileName.LastIndexOf("\\"), mOutputFileName.Length - mOutputFileName.LastIndexOf("\\")); File.Copy(FolderPath + "\\Sample.xls", mOutputFileName, true); SqlConnection SqlConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ArmsConnStr"].ToString()); SqlConn.Open(); DataSet DS = new DataSet(); string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mOutputFileName + ";Extended Properties='Excel 8.0'"; OleDbConnection xlConn = new OleDbConnection(connstr); try { xlConn.Open(); SqlDataAdapter SqlDA = new SqlDataAdapter(SqlSelect, SqlConn); SqlDA.Fill(DS); SqlConn.Close(); SqlConn.Dispose(); PrepareScript(DS.Tables[0]); StartImport(DS.Tables[0], xlConn); } catch (Exception exp) { throw new Exception("ImportToMultipleXLSheets", exp.InnerException); } finally { if (xlConn != null) { if (xlConn.State == ConnectionState.Open) { xlConn.Close(); } xlConn.Dispose(); } if (SqlConn != null) { if (SqlConn.State == ConnectionState.Open) { SqlConn.Close(); } SqlConn.Dispose(); } } }
/// <summary> /// Parse a rfc 2822 name-address specification. rfc 2822 section 3.4 /// </summary> /// <param name="from">address</param> /// <param name="part">1 is display-name; 2 is addr-spec</param> /// <returns>the requested <see cref="System.String" /></returns> public static System.String parseFrom(System.String from, int part) { int pos; if (from == null || from.Length < 1) { return(System.String.Empty); } switch (part) { case 1: pos = from.LastIndexOf('<'); pos = (pos < 0)?from.Length:pos; from = from.Substring(0, pos).Trim(); from = anmar.SharpMimeTools.SharpMimeTools.parserfc2047Header(from); return(from); case 2: pos = from.LastIndexOf('<') + 1; return(from.Substring(pos, from.Length - pos).Trim(new char[] { '<', '>', ' ' })); } return(from); }
/// <summary> Tests a Type against the corresponding section of a profile.</summary> /// <param name="encoded">optional encoded form of type (if you want to specify this -- if null, /// default pipe-encoded form is used to check length and constant val) /// </param> public virtual NuGenHL7Exception[] testType(Genetibase.NuGenHL7.model.Type type, AbstractComponent profile, System.String encoded, System.String profileID) { System.Collections.ArrayList exList = new System.Collections.ArrayList(); if (encoded == null) { encoded = NuGenPipeParser.encode(type, this.enc); } NuGenHL7Exception ue = testUsage(encoded, profile.Usage, profile.Name); if (ue != null) { exList.Add(ue); } if (!profile.Usage.Equals("X")) { //check datatype System.String typeClass = type.GetType().FullName; if (typeClass.IndexOf("." + profile.Datatype) < 0) { typeClass = typeClass.Substring(typeClass.LastIndexOf('.') + 1); exList.Add(new NuGenProfileNotHL7CompliantException("HL7 datatype " + typeClass + " doesn't match profile datatype " + profile.Datatype)); } //check length if (encoded.Length > profile.Length) { exList.Add(new NuGenProfileNotFollowedException("The type " + profile.Name + " has length " + encoded.Length + " which exceeds max of " + profile.Length)); } //check constant value if (profile.ConstantValue != null && profile.ConstantValue.Length > 0) { if (!encoded.Equals(profile.ConstantValue)) { exList.Add(new NuGenProfileNotFollowedException("'" + encoded + "' doesn't equal constant value of '" + profile.ConstantValue + "'")); } } NuGenHL7Exception[] te = testTypeAgainstTable(type, profile, profileID); for (int i = 0; i < te.Length; i++) { exList.Add(te[i]); } } return(this.toArray(exList)); }
/// <summary> Returns an array of matching MimeTypes from the specified name /// (many MimeTypes can have the same registered extensions). /// </summary> private MimeType[] GetMimeTypes(System.String name) { System.Collections.IList mimeTypes = null; int index = name.LastIndexOf((System.Char) '.'); if ((index != -1) && (index != name.Length - 1)) { // There's an extension, so try to find // the corresponding mime-types System.String ext = name.Substring(index + 1); mimeTypes = (System.Collections.IList)extIdx[ext]; } return((mimeTypes != null) ? (MimeType[])SupportUtil.ToArray(mimeTypes, new MimeType[mimeTypes.Count]) : null); }
/// <summary> Returns true if this is a file that would be contained /// in a CFS file. This function should only be called on /// files that pass the above "accept" (ie, are already /// known to be a Lucene index file). /// </summary> public virtual bool IsCFSFile(System.String name) { int i = name.LastIndexOf((System.Char) '.'); if (i != -1) { System.String extension = name.Substring(1 + i); if (extensionsInCFS.Contains(extension)) { return(true); } if (extension.StartsWith("f") && (new System.Text.RegularExpressions.Regex("f\\d+")).Match(extension).Success) { return(true); } } return(false); }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <returns></returns> protected override System.IO.MemoryStream getStreamDataPortion(System.IO.MemoryStream data) { System.IO.StreamReader reader = new System.IO.StreamReader(data, System.Text.ASCIIEncoding.ASCII); System.String line = reader.ReadLine(); if (line.StartsWith("*")) { int size = this.parseInteger((line.Substring(line.LastIndexOf('{'))).Trim(new Char[] { '{', '}' })); if (size > 0) { int offset = System.Text.ASCIIEncoding.ASCII.GetByteCount(line + "\r\n"); reader.DiscardBufferedData(); reader = null; data.Seek(offset, System.IO.SeekOrigin.Begin); data.SetLength(offset + size); } } return(data); }
public void GetLogsByProgramFilter(INTEGER appNumber, STRING programNameFilter) { programNameFilter = programNameFilter.Trim(); if (programNameFilter.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) { programNameFilter = programNameFilter.Remove(programNameFilter.LastIndexOf('.'), 4); } if (_cachedLogEntries == null) { return; } var data = new LogEntryArray(_cachedLogEntries.Array.Where( entry => entry.Program.StartsWith(programNameFilter, StringComparison.OrdinalIgnoreCase)).ToArray()); OnLogsUpdated(data); }
public static String SubstringAfter(this System.String value, System.String afterString) { Int32 position = value.LastIndexOf(afterString); if (position == -1) { return(string.Empty); } Int32 adjustedPosition = position + afterString.Length; if (adjustedPosition >= value.Length) { return(string.Empty); } return(value.Substring(adjustedPosition)); }
/// <summary> <p>Creates an XML Document that corresponds to the given Message object. </p> /// <p>If you are implementing this method, you should create an XML Document, and insert XML Elements /// into it that correspond to the groups and segments that belong to the message type that your subclass /// of XMLParser supports. Then, for each segment in the message, call the method /// <code>encode(Segment segmentObject, Element segmentElement)</code> using the Element for /// that segment and the corresponding Segment object from the given Message.</p> /// </summary> public override System.Xml.XmlDocument encodeDocument(Message source) { System.String messageClassName = source.GetType().FullName; System.String messageName = messageClassName.Substring(messageClassName.LastIndexOf('.') + 1); System.Xml.XmlDocument doc = null; try { doc = new System.Xml.XmlDocument(); System.Xml.XmlElement root = doc.CreateElement(messageName); doc.AppendChild(root); } catch (System.Exception e) { throw new NuGenHL7Exception("Can't create XML document - " + e.GetType().FullName, NuGenHL7Exception.APPLICATION_INTERNAL_ERROR, e); } encode(source, (System.Xml.XmlElement)doc.DocumentElement); return(doc); }
static StackObject *LastIndexOf_28(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Char @value = (char)ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.String instance_of_this_method = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.LastIndexOf(@value); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
//returns a name for a class of a Structure in this Message private System.String getName(System.Type c) { System.String fullName = c.FullName; int dotLoc = fullName.LastIndexOf('.'); System.String name = fullName.Substring(dotLoc + 1, (fullName.Length) - (dotLoc + 1)); //remove message name prefix from group names for compatibility with getters ... if (typeof(Group).IsAssignableFrom(c) && !typeof(Message).IsAssignableFrom(c)) { System.String messageName = Message.getName(); if (name.StartsWith(messageName) && name.Length > messageName.Length) { name = name.Substring(messageName.Length + 1); } } return(name); }
/// <summary> <p>Creates an XML Document that corresponds to the given Message object. </p> /// <p>If you are implementing this method, you should create an XML Document, and insert XML Elements /// into it that correspond to the groups and segments that belong to the message type that your subclass /// of XMLParser supports. Then, for each segment in the message, call the method /// <code>encode(Segment segmentObject, Element segmentElement)</code> using the Element for /// that segment and the corresponding Segment object from the given Message.</p> /// </summary> public override System.Xml.XmlDocument encodeDocument(Message source) { System.String messageClassName = source.GetType().FullName; System.String messageName = messageClassName.Substring(messageClassName.LastIndexOf('.') + 1); System.Xml.XmlDocument doc = null; try { //UPGRADE_TODO: Class 'javax.xml.parsers.DocumentBuilder' was converted to 'System.Xml.XmlDocument' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxxmlparsersDocumentBuilder'" doc = new System.Xml.XmlDocument(); System.Xml.XmlElement root = doc.CreateElement(messageName); doc.AppendChild(root); } catch (System.Exception e) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new HL7Exception("Can't create XML document - " + e.GetType().FullName, HL7Exception.APPLICATION_INTERNAL_ERROR, e); } encode(source, (System.Xml.XmlElement)doc.DocumentElement); return(doc); }
//returns a name for a class of a Structure in this Message private System.String getStructureName(System.Type c) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.String fullName = c.FullName; int dotLoc = fullName.LastIndexOf('.'); System.String name = fullName.Substring(dotLoc + 1, (fullName.Length) - (dotLoc + 1)); //remove message name prefix from group names for compatibility with getters ... if (typeof(Group).IsAssignableFrom(c) && !typeof(Message).IsAssignableFrom(c)) { System.String messageName = Message.getStructureName(); if (name.StartsWith(messageName) && name.Length > messageName.Length) { name = name.Substring(messageName.Length + 1); } } return(name); }
static void RunCase(int CaseNum, System.IO.TextReader TR, System.IO.TextWriter TW) { char[] Splits = new char[] { ' ', '\t', '\n', '\r' }; int L = System.Convert.ToInt32(TR.ReadLine()); System.String TreeStr = ""; for (int i = 0; i < L; i++) { TreeStr += TR.ReadLine(); } int Start = TreeStr.IndexOf('('); int End = TreeStr.LastIndexOf(')'); Node N = new Node(TreeStr.Substring(Start + 1, End - Start - 1)); System.String Result = "Case #" + (CaseNum + 1) + ":"; int A = System.Convert.ToInt32(TR.ReadLine()); for (int i = 0; i < A; i++) { System.String AStr = TR.ReadLine(); System.String[] Strs = AStr.Split(Splits, StringSplitOptions.RemoveEmptyEntries); int NumChar = System.Convert.ToInt32(Strs[1]); System.String[] Chars = new System.String[NumChar]; for (int j = 0; j < NumChar; j++) { Chars[j] = Strs[j + 2]; } Result += "\n" + N.Eval(Chars).ToString("0.0000000"); } if (TW == null) { System.Console.WriteLine(Result); } else { TW.WriteLine(Result); } }
/* ---------------------------------- */ public static FILE createPath(char[] fileName) { System.String fName = mkStr(fileName); try { int ix = fName.LastIndexOf(GPFiles.GPFiles.fileSep); if (ix > 0) { System.String path = fName.Substring(0, ix); if (!System.IO.Directory.Exists(path)) { System.IO.DirectoryInfo junk = System.IO.Directory.CreateDirectory(path); } } FILE cpf = new FILE(); cpf.path = fName; System.IO.FileStream fStr = System.IO.File.Create(fName); cpf.strW = new System.IO.StreamWriter(fStr); return(cpf); } catch { return(null); } }
/// <summary> /// get next picture /// </summary> /// <param name="sender">next button</param> /// <param name="b"></param> protected void _OnNextClick(object sender, EventArgs b) { if (picture != null) { while (pictures[currentTab].MoveNext()) { picToDisplay = (System.String)pictures[currentTab].Current; int lastIndex = picToDisplay.LastIndexOf("\\") + 1; System.Windows.Forms.TabPage thisTab = (System.Windows.Forms.TabPage)tabs.Controls[currentTab]; thisTab.Text = picToDisplay.Substring(lastIndex, picToDisplay.Length - lastIndex); Text = "Pict0 Vi3w3r! - " + picToDisplay; DisplayPics( ); System.Console.WriteLine(picToDisplay); break; } } else { return; } }
static StackObject *LastIndexOf_10(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.StringComparison @comparisonType = (System.StringComparison) typeof(System.StringComparison).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.String @value = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.String instance_of_this_method = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.LastIndexOf(@value, @comparisonType); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
public static System.String Uid2url(System.String uid) { System.String url = uid.Replace('\u0000', '/'); // replace nulls with slashes return(url.Substring(0, (url.LastIndexOf('/')) - (0))); // remove date from end }
/* (non-Javadoc) * @see org.javarosa.core.reference.ReferenceFactory#derive(java.lang.String, java.lang.String) */ public virtual Reference derive(System.String URI, System.String context) { System.String referenceURI = context.Substring(0, (context.LastIndexOf('/') + 1) - (0)) + URI; return(ReferenceManager._().DeriveReference(referenceURI)); }
/// <summary> Decode a punycoded string. /// * /// </summary> /// <param name="input">Punycode string /// </param> /// <returns> Unicode string. /// /// </returns> public static System.String decode(System.String input) { int n = INITIAL_N; int i = 0; int bias = INITIAL_BIAS; System.Text.StringBuilder output = new System.Text.StringBuilder(); int d = input.LastIndexOf((System.Char)DELIMITER); if (d > 0) { for (int j = 0; j < d; j++) { char c = input[j]; if (!isBasic(c)) { throw new PunycodeException(PunycodeException.BAD_INPUT); } output.Append(c); } d++; } else { d = 0; } while (d < input.Length) { int oldi = i; int w = 1; for (int k = BASE; ; k += BASE) { if (d == input.Length) { throw new PunycodeException(PunycodeException.BAD_INPUT); } int c = input[d++]; int digit = codepoint2digit(c); if (digit > (System.Int32.MaxValue - i) / w) { throw new PunycodeException(PunycodeException.OVERFLOW); } i = i + digit * w; int t; if (k <= bias) { t = TMIN; } else if (k >= bias + TMAX) { t = TMAX; } else { t = k - bias; } if (digit < t) { break; } w = w * (BASE - t); } bias = adapt(i - oldi, output.Length + 1, oldi == 0); if (i / (output.Length + 1) > System.Int32.MaxValue - n) { throw new PunycodeException(PunycodeException.OVERFLOW); } n = n + i / (output.Length + 1); i = i % (output.Length + 1); output.Insert(i, (char)n); i++; } return(output.ToString()); }