public static DomElementLocator GenerateLocator(String raw) { if (!raw.StartsWith(Constant.DOMElementPrefix)) { return null; } LocatorMethod method; raw = raw.Substring(1); if (raw.StartsWith(Constant.DOMIDPrefix)) { method = LocatorMethod.ID; raw = raw.Substring(Constant.DOMIDPrefix.Length); } else if (raw.StartsWith(Constant.DOMNamePrefix)) { method = LocatorMethod.Name; raw = raw.Substring(Constant.DOMNamePrefix.Length); } else if (raw.StartsWith(Constant.DOMXPathPrefix)) { method = LocatorMethod.XPath; raw = raw.Substring(Constant.DOMXPathPrefix.Length); } else { return null; } return new DomElementLocator(method, raw); }
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; }
private dynamic GetValue(Process p, String type, DeepPointer pointer) { if (type == "int") return pointer.Deref<int>(p); else if (type == "uint") return pointer.Deref<uint>(p); else if (type == "float") return pointer.Deref<float>(p); else if (type == "double") return pointer.Deref<double>(p); else if (type == "byte") return pointer.Deref<byte>(p); else if (type == "sbyte") return pointer.Deref<sbyte>(p); else if (type == "short") return pointer.Deref<short>(p); else if (type == "ushort") return pointer.Deref<ushort>(p); else if (type == "bool") return pointer.Deref<bool>(p); else if (type.StartsWith("string")) { var length = Int32.Parse(type.Substring("string".Length)); return pointer.DerefString(p, length); } else if (type.StartsWith("byte")) { var length = Int32.Parse(type.Substring("byte".Length)); return pointer.DerefBytes(p, length); } throw new ArgumentException(string.Format("The provided type, '{0}', is not supported", type)); }
public static Uri NormalizeIdentityUrl(String identityUrl) { Uri retVal = null; // To get an iname to fit onto a Uri object, we prefix // with "xri:". This is because Uri object will not allow "xri://". if (identityUrl.StartsWith("xri://")) { identityUrl = identityUrl.Substring("xri://".Length); retVal = new Uri("xri:" + identityUrl); } else if (identityUrl.StartsWith("=") || identityUrl.StartsWith("@")) { retVal = new Uri("xri:" + identityUrl); } else if (!identityUrl.StartsWith("http://")) { retVal = Janrain.OpenId.UriUtil.NormalizeUri(string.Format("http://{0}/", identityUrl.Trim("/".ToCharArray()))); } else { retVal = Janrain.OpenId.UriUtil.NormalizeUri(identityUrl); } return retVal; }
// 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'"); } }
public static String MergeHttp(String server, String path) { if (server.StartsWith("http:")) { server = server.Substring(5); } while (server.StartsWith("/")) { server = server.Substring(1); } while (server.EndsWith("/")) { server = server.Substring(0, server.Length - 1); } while (path.StartsWith("/")) { path = path.Substring(1); } if (path.StartsWith(":")) { return "http://" + server + "" + path; } else { return "http://" + server + "/" + path; } }
public void process( String s) { reply = s; if( reply.StartsWith("I:")){ this.init(); } else if( reply.StartsWith("S:")){ this.setUp(); } else if (reply.StartsWith("G:")) { this.update(); } else if (reply.StartsWith("C:")) { this.coin(); } else if (reply.StartsWith("L:")) { this.lifePack(); } }
/// <summary> /// Modifies the specified CommandBar item /// </summary> public static void ExecuteFlagAction(ToolStripItem item, String action, Boolean value) { if (action.StartsWith("Check:")) { if (item is ToolStripMenuItem) { ((ToolStripMenuItem)item).Checked = value; } } else if (action.StartsWith("Uncheck:")) { if (item is ToolStripMenuItem) { ((ToolStripMenuItem)item).Checked = !value; } } else if (action.StartsWith("Enable:")) { item.Enabled = value; } else if (action.StartsWith("Disable:")) { item.Enabled = !value; } }
public static bool SendMessageCustomToken(String Channel, String Message, String Token) { APICaller apic = new APICaller(Token); bool returned = false; Dictionary<String, dynamic> Params = new Dictionary<string, dynamic>(); if (Token.Equals("someone")) { Token = "xoxp-5007212458-11027941589-11025314452-ac4fcf3c3b"; } else if (Token.Equals("timo")) { Token = "xoxb-5134150563-iZKW7CIodzRbffqVmFmz6m2S"; } else if (Token.Equals("lily")) { Token = "xoxb-7444634401-UTU2IHZE2kULUWu70hgKV0FA"; } if (Channel.StartsWith("C") || Channel.StartsWith("D")) { Params.Add("channel", Channel); Params.Add("text", Message); Params.Add("as_user", "true"); Params.Add("token", Token); returned = apic.CallMethodCustomToken("chat.postMessage", Params).Result["ok"]; } Console.WriteLine("Posted message: " + Message + " to Channel: " + Channel + " with return code: " + returned); return returned; }
public void UpdateApp(XApplication app, String path, XAppInstallListener listener) { bool isAbsolute = path.StartsWith("/") || path.StartsWith("\\"); String tmp = isAbsolute ? path : ResolvePathUsingWorkspace(app.GetWorkSpace(), path); String abspath = XUtils.BuildabsPathOnIsolatedStorage(tmp); appManagement.UpdateApp(abspath, listener); }
public static String removeFirstSlash(String path) { if (path.StartsWith("/") || path.StartsWith("\\") ) return path.Substring(1); return path; }
public Address(String sourceAddressCode) { if (sourceAddressCode.StartsWith(LexicalSymbols.LabelAddress)) { this.IsLabelledAddress = true; this.AddressLabel = sourceAddressCode.Replace(LexicalSymbols.LabelAddress, String.Empty); } else if (sourceAddressCode.StartsWith(LexicalSymbols.BinaryAddress)) { this.BinaryAddress = int.Parse(sourceAddressCode.Replace(LexicalSymbols.BinaryAddress, String.Empty)); this.SourceAddress = BinaryToSource(this.BinaryAddress); } else { this.SourceAddress = int.Parse(sourceAddressCode); if (this.SourceAddress >= 0) { this.BinaryAddress = SourceToBinary(this.SourceAddress); } else { this.BinaryAddress = this.SourceAddress; } } }
//- ~CreateHttpHandler -// internal static IHttpHandler CreateHttpHandler(String text) { IHttpHandler handler = null; if (!text.StartsWith("{") && text.Contains(",")) { return ObjectCreator.CreateAs<IHttpHandler>(text); } //+ if (!text.StartsWith("{") && RouteCache.HandlerFactoryCache != null) { String lowerCaseText = text.ToLower(CultureInfo.CurrentCulture); List<IFactory> handlerFactoryList = RouteCache.HandlerFactoryCache.GetValueList(); foreach (IFactory factory in handlerFactoryList) { handler = ((HandlerFactory)factory).CreateHttpHandler(lowerCaseText); if (handler != null) { break; } } } if (handler == null && text.StartsWith("{")) { text = text.Substring(1, text.Length - 2); List<Type> list = ScannedTypeCache.GetTypeData("httpHandler"); Type httpHandlerType = list.SingleOrDefault(p => p.Name == text + "HttpHandler"); if (httpHandlerType != null) { handler = ObjectCreator.CreateAs<IHttpHandler>(httpHandlerType); } } //+ return handler; }
protected override void TraceSimpleEvent(DateTime eventTime, Int32 threadId, TraceEventType eventType, String message, Int32 eventId, TraceEventCache eventCache, String source) { if (_table != null) { if (message.StartsWith("#Status ") || message.StartsWith("#Status:")) { Status status = new Status(eventTime.ToUniversalTime()); status.Level = eventType.ToString(); status.ThreadId = threadId; string messageText; string dataText; GetMessageParts(message, out messageText, out dataText); status.Message = messageText; status.Data = dataText; try { TableOperation operation = TableOperation.Insert(status); this._table.Execute(operation); } catch (Exception e) { Console.WriteLine("Exception while saving to Azure storage."); Console.WriteLine(e.ToString()); throw; } } } }
/// <summary> /// Tries to the map the C# to JS namespace. /// </summary> /// <param name="serverNs">The namespace.</param> /// <param name="clientNs">The client namespace.</param> /// <returns></returns> public bool TryMapNamespace(String serverNs, out string clientNs) { foreach (var m in namespaceMapping) switch (m.Mode) { case NamespaceMappingMode.Exact: if (m.Namespace == serverNs) { clientNs = m.ClientNamespace; return true; } break; case NamespaceMappingMode.Prefix: if (serverNs.StartsWith(m.Namespace)) { clientNs = m.ClientNamespace + serverNs.Substring(m.Namespace.Length); return true; } break; case NamespaceMappingMode.PrefixExact: if (serverNs.StartsWith(m.Namespace)) { clientNs = m.ClientNamespace; return true; } break; } clientNs = null; return false; }
Boolean isInDB(String dbname, String type, String regex, signCls s) { if (falsegrp.Contains(s.group)) return false; SQLiteCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.Text; if (type.StartsWith("reg")) cmd.CommandText = "select * from reglist where reglist.path REGEXP @param1;"; else if (type.StartsWith("file")) cmd.CommandText = "select * from filelist where filelist.path REGEXP @param1;"; cmd.Parameters.Add(new SQLiteParameter("@param1", regex)); SQLiteDataReader r = cmd.ExecuteReader(); bool res = r.HasRows; if (res == false) falsegrp.Add(s.group); else { while(r.Read()) { s.matchedList.Add(r["path"].ToString()); } } return res; }
bool IsTagOpen(String sb) { if (sb.StartsWith("</") && sb.EndsWith(">")) return false; else if (sb.StartsWith("<") && sb.EndsWith(">")) return true; else return false; }
private static void EditVcardEncoding(ref String contents, ref String lineEdited, String line) { lineEdited = line; if (line.StartsWith("FN:")) lineEdited = line.Substring(0, 2) + ";ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:" + line.Substring(3); if (line.StartsWith("N:")) lineEdited = line.Substring(0, 1) + ";ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:" + line.Substring(2).Replace("\\",""); if (line.StartsWith("ORG:")) lineEdited = line.Substring(0, 3) + ";ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:" + line.Substring(4); contents += System.Environment.NewLine + lineEdited; }
// Schemes that are generally considered safe for the purposes of redirects or other places where URLs are rendered to the page. internal static bool IsSafeScheme(String url) { return url.IndexOf(":", StringComparison.Ordinal) == -1 || url.StartsWith("http:", StringComparison.OrdinalIgnoreCase) || url.StartsWith("https:", StringComparison.OrdinalIgnoreCase) || url.StartsWith("ftp:", StringComparison.OrdinalIgnoreCase) || url.StartsWith("file:", StringComparison.OrdinalIgnoreCase) || url.StartsWith("news:", StringComparison.OrdinalIgnoreCase); }
private static bool IsSpecified(String argument, String parameter) { if (String.IsNullOrEmpty(argument)) return false; return argument.StartsWith("-" + parameter, StringComparison.OrdinalIgnoreCase) || argument.StartsWith("--" + parameter, StringComparison.OrdinalIgnoreCase); }
public Boolean Contains(String argument) { if (argument.StartsWith("-") || argument.StartsWith("/")) { argument = argument.Remove(0, 1); } return _arguments.Contains(argument); }
public static void ProcessCommand(String message) { int distOut; message = message.ToLower().Trim(); Console.WriteLine(message); if (message.Contains("buy") || message.Contains("get") || message.Contains("rush") || message.Contains("purchase")) { Shop.RushItem = Shop.GetItemByName(message); return; } else if (message.StartsWith("distance ")) { String distance = message.Split(" ".ToCharArray())[1].Trim(); int dist = Int32.Parse(distance); Core.MaxDistanceFromCarry = dist; } else if (message.StartsWith("frdm ") || message.StartsWith("freedom ")) { String freedom = message.Split(" ".ToCharArray())[1].Trim(); Console.WriteLine("Setting freedom " + freedom); HeatMap.Frdm = HeatMap.freedomFromString(freedom.ToUpper()); return; } else if (message.StartsWith("pos ")) { String position = message.Split(" ".ToCharArray())[1].Trim(); Console.WriteLine("Setting position " + position); HeatMap.Pos = HeatMap.posFromString(position.ToUpper()); return; } else if (Utility.Map.GetMap().Type == Utility.Map.MapType.SummonersRift && (message == "b" || message.Contains("back") || message.Contains("recall"))) { PingManager.Mode = BehaviourMode.PASSIVE; PingManager.Location = null; PingManager.Target = null; RecallManager.UserRecallRequest = true; return; } else if (Int32.TryParse(message, out distOut) ) { Core.MaxDistanceFromCarry = distOut; } }
private static String StripQuotes(String value) { if (value.StartsWith("\"") && value.EndsWith("\"")) { value = value.Substring(1, value.Length - 2); } else if (value.StartsWith("\'") && value.EndsWith("\'")) { value = value.Substring(1, value.Length - 2); } return value; }
/// <summary> /// 是否为系统数据集[无法删除] /// </summary> /// <param name="mongoDBName"></param> /// <param name="mongoColName"></param> /// <returns></returns> public static Boolean IsSystemCollection(String mongoDBName, String mongoColName) { //config数据库,默认为系统 //local数据库,默认为系统 //系统文件 if (mongoColName.StartsWith("system.")) return true; if (mongoColName.StartsWith("fs.")) return true; return IsSystemDataBase(mongoDBName); }
public static String ResolvePath(String path, String relativeTo) { if (path == null || path.Length == 0) return null; Boolean isPathNetworked = path.StartsWith("\\\\") || path.StartsWith("//"); if (Path.IsPathRooted(path) || isPathNetworked) return path; String resolvedPath = Path.Combine(relativeTo, path); if (Directory.Exists(resolvedPath) || File.Exists(resolvedPath)) return resolvedPath; return null; }
/// <summary> /// Abbreviates a ref-name, used in internal output /// </summary> /// <param name="dst">long ref</param> /// <param name="abbreviateRemote">abbreviate as remote</param> /// <returns></returns> protected string AbbreviateRef(String dst, bool abbreviateRemote) { if (dst.StartsWith(Constants.R_HEADS)) dst = dst.Substring(Constants.R_HEADS.Length); else if (dst.StartsWith(Constants.R_TAGS)) dst = dst.Substring(Constants.R_TAGS.Length); else if (abbreviateRemote && dst.StartsWith(Constants.R_REMOTES)) dst = dst.Substring(Constants.R_REMOTES.Length); return dst; }
public PsEscapeSequenceParser(String text) { this.text = text; // quotes are included, so start at 1 this.start = 1; // single-quoted strings in powershell // don't support escape sequences if ( text.StartsWith("'") || text.StartsWith("@'") ) this.start = text.Length; }
private String DecideType(String trainNo) { if (trainNo.StartsWith("DJ")) { return "DJ"; } if (char.IsLetter(trainNo[0]) || trainNo.StartsWith("0")) { return trainNo[0].ToString(); } if (trainNo.Length < 5) { return "客"; } else { if (trainNo.Substring(0, 1) == "5") { return "路用"; } else{return "货";} } }
public CEscapeSequenceParser(String text) { this.text = text; // always skip the first char // (since quotes are included in the string) this.start = 1; // If this is an at-string, or a C preprocessor include // skip it if ( text.StartsWith("@") || text.StartsWith("<") ) this.start = text.Length; }
/// <summary> /// Creates a new Variable Expression /// </summary> /// <param name="name">Variable Name</param> public VariableTerm(String name) { if (name.StartsWith("?") || name.StartsWith("$")) { this._name = name.Substring(1); } else { this._name = name; } }