本文整理汇总了C#中System.String.TrimStart方法的典型用法代码示例。如果您正苦于以下问题:C# String.TrimStart方法的具体用法?C# String.TrimStart怎么用?C# String.TrimStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String
的用法示例。
在下文中一共展示了String.TrimStart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValidTrQueryString
public static Boolean IsValidTrQueryString(String queryString, BraintreeService service)
{
string[] delimeters = new string[1];
delimeters[0] = "&hash=";
String[] dataSections = queryString.TrimStart('?').Split(delimeters, StringSplitOptions.None);
return dataSections[1] == new Crypto().HmacHash(service.PrivateKey, dataSections[0]).ToLower();
}
示例2: TestManifest
public async Task TestManifest()
{
var stream = new MemoryStream();
var cli = new SpeechClient();
cli.SetStream(stream);
await cli.SendManifest();
stream.Seek(0, SeekOrigin.Begin);
var reader = new StreamReader(stream);
var size = Convert.ToInt32(reader.ReadLine());
var outp = new char[size];
reader.ReadBlock(outp, 0, size);
var str = new String(outp);
var re = new Regex(@"^([A-Z_]*)");
Assert.IsTrue(re.Match(str).Value == "APP_MANIFEST");
var jsonstr = str.TrimStart(re.Match(str).Value.ToCharArray());
var jsonstream = new MemoryStream(Encoding.UTF8.GetBytes(jsonstr));
var ser = new DataContractJsonSerializer(typeof(Manifest));
Manifest jsonobj = (Manifest)ser.ReadObject(jsonstream);
Assert.IsTrue(jsonobj.Version == "0.0.1");
Assert.IsTrue(jsonobj.Name == "speech-recognizer");
Assert.IsTrue(jsonobj.DisplayName == "Mycroft Networked Speech Recognizer");
Assert.IsTrue(jsonobj.Description == "Lets applications register speech triggers for Mycroft to look for.");
Assert.IsTrue(jsonobj.InstanceId == "primary");
}
示例3: CreateInstanceCssContext
private CssContext CreateInstanceCssContext(String selector)
{
CssContext ctx = null;
selector = selector.TrimStart();
if (selector.StartsWith("@"))
{
ctx = new CssMediaContext(selector)
{
OnOpen = VisitBeginAtRule,
OnClose = VisitEndAtRule
};
}
else
{
ctx = new CssSelectorContext(selector)
{
OnOpen = VisitBeginSelector,
OnClose = VisitEndSelector,
OnVisitProperty = VisitProperty
};
}
return ctx;
}
示例4: getResource
/// <summary>
/// Get this resource
/// </summary>
/// <param name="resource">
/// A String with SubResources.
/// If this is simply '/' then return the collection as returned by the get command.
/// If it's a path like '/elementName' then return the element.
/// </param>
public IRestNode getResource(String resource)
{
resource = resource.TrimStart('/');
int param = resource.IndexOf(' ');
if (param > 0)
{
resource = resource.Substring(0, param);
}
IRestNode pNode = m_root;
while (pNode != null && resource.Length > 0)
{
int index = resource.IndexOf('/');
if (index > 0)
{
// test for data
String test = resource.Substring(0, index);
int end = test.IndexOf(' ');
//if (end != -1)
//{
// index = end;
//}
pNode = pNode.OnElement(resource.Substring(0, index));
resource = resource.Substring(index, resource.Length - index).TrimStart('/').Trim();
}
else
{
pNode.OnElement(resource);
return pNode;
}
}
return pNode;
}
示例5: TransparentRedirectRequest
public TransparentRedirectRequest(String queryString, BraintreeService service)
{
queryString = queryString.TrimStart('?');
Dictionary<String, String> paramMap = new Dictionary<String, String>();
String[] queryParams = queryString.Split('&');
foreach (String queryParam in queryParams)
{
String[] items = queryParam.Split('=');
paramMap[items[0]] = items[1];
}
String message = null;
if (paramMap.ContainsKey("bt_message"))
{
message = HttpUtility.UrlDecode(paramMap["bt_message"]);
}
BraintreeService.ThrowExceptionIfErrorStatusCode((HttpStatusCode)Int32.Parse(paramMap["http_status"]), message);
if (!TrUtil.IsValidTrQueryString(queryString, service))
{
throw new ForgedQueryStringException();
}
Id = paramMap["id"];
}
示例6: ParseColumnExpression
static Func<float[], float> ParseColumnExpression(String str)
{
str = str.TrimStart();
Func<float[], float> head = x => 0;
if (str.Length == 0) return head;
if (str[0] == '(') {
int c = 0, i;
for (i = 0; i < str.Length; ++i) {
if (str[i] == '(') ++c;
if (str[i] == ')') {
--c;
if (c == 0) {
break;
}
}
}
head = ParseColumnExpression(str.Substring(1, i - 1));
str = str.Substring(i + 1);
} else if (char.IsDigit(str[0])) {
String number = "";
while (str.Length > 0 && char.IsDigit(str[0])) {
number += str[0];
str = str.Substring(1);
}
int val = int.Parse(number);
head = x => val;
} else if (char.IsLetter(str[0])) {
int digit = str[0] - 'a';
head = x => x[digit];
str = str.Substring(1).TrimStart();
}
if (str.Length == 0) return head;
switch (str[0]) {
case '+':
return x => head(x) + ParseColumnExpression(str.Substring(1))(x);
case '-':
return x => head(x) - ParseColumnExpression(str.Substring(1))(x);
case '*':
return x => head(x) * ParseColumnExpression(str.Substring(1))(x);
case '/':
return x => {
float denom = ParseColumnExpression(str.Substring(1))(x);
return denom != 0 ? head(x) / denom : 0;
};
}
return head;
}
示例7: ToCapit
public static string ToCapit(String name)
{
string clone = name.TrimStart('_');
return String.Format("{0}{1}",
Char.ToUpper(clone[0]),
clone.Substring(1,clone.Length-1)
);
}
示例8: GetApplicationPath
public static String GetApplicationPath(String partialUrl)
{
/* Remove the leading / character, since the last character
in the String returned by GetApplicationPath is guaranteed
to be a / character. */
return HttpUtils.GetApplicationPath() + partialUrl.TrimStart("/".ToCharArray());
}
示例9: IsDecimal
/// <summary>
/// 判断字符串是否是小数或整数
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static Boolean IsDecimal( String str ) {
if (strUtil.IsNullOrEmpty( str ))
return false;
if (str.StartsWith( "-" ))
return isDecimal_private( str.TrimStart( '-' ) );
else
return isDecimal_private( str );
}
示例10: GetIodcFromSapDataBase
/// <summary>
/// 根据IDOC编号从SAP系统里读取一个idoc
/// </summary>
/// <param name="idocNumber"></param>
/// <returns></returns>
public Idoc GetIodcFromSapDataBase(String idocNumber)
{
SAPINT.Utils.ReadTable idocReadItem = null;
SAPINT.Utils.ReadTable idocReadHeader = null;
DataTable dtIdocItem = new DataTable();
DataTable dtIdocHeder = new DataTable();
idocNumber = idocNumber.TrimStart('0');
String criteria = idocNumber.PadLeft(16, '0');
criteria = String.Format("DOCNUM = '{0}'", criteria);
String readTableFunction = ConfigFileTool.SAPGlobalSettings.GetReadTableFunction();
idocReadItem = new Utils.ReadTable(SystemName);
idocReadItem.TableName = "EDID4";
idocReadItem.SetCustomFunctionName(readTableFunction);
idocReadItem.AddCriteria(criteria);
idocReadItem.Run();
dtIdocItem = idocReadItem.Result;
if (dtIdocItem.Rows.Count == 0)
{
idocReadItem = new Utils.ReadTable(SystemName);
idocReadItem.TableName = "EDID2";
idocReadItem.SetCustomFunctionName(readTableFunction);
idocReadItem.AddCriteria(criteria);
idocReadItem.Run();
dtIdocItem = idocReadItem.Result;
}
if (dtIdocItem.Rows.Count == 0)
{
idocReadItem = new Utils.ReadTable(SystemName);
idocReadItem.TableName = "EDIDD_OLD";
idocReadItem.SetCustomFunctionName(readTableFunction);
idocReadItem.AddCriteria(criteria);
idocReadItem.Run();
dtIdocItem = idocReadItem.Result;
}
if (dtIdocItem.Rows.Count == 0)
{
throw new SAPException(String.Format("无法找到IDOC{0}明细", idocNumber));
}
//读取IDOC头
idocReadHeader = new Utils.ReadTable(SystemName);
idocReadHeader.TableName = "EDIDC";
idocReadHeader.SetCustomFunctionName(readTableFunction);
idocReadHeader.AddCriteria(criteria);
idocReadHeader.Run();
dtIdocHeder = idocReadHeader.Result;
if (dtIdocHeder.Rows.Count != 1)
{
throw new SAPException(String.Format("无法找到IDOC{0}抬头定义", idocNumber));
}
Idoc idoc = ProcessSingleIdocFromDataTable(dtIdocHeder, dtIdocItem);
return idoc;
}
示例11: GetFullPath
public static String GetFullPath(String applicationDirPath, String relativeOrAbsolutePath)
{
if (String.IsNullOrEmpty(relativeOrAbsolutePath) || relativeOrAbsolutePath.StartsWith(Path.DirectorySeparatorChar.ToString())) {
return Path.Combine(applicationDirPath, relativeOrAbsolutePath.TrimStart(Path.DirectorySeparatorChar));
}
else {
return relativeOrAbsolutePath;
}
}
示例12: QueryParamsToDictionary
/// <summary>
/// convert the query string into the dictionary
/// </summary>
/// <param name="query">?p1=v1...</param>
/// <returns>dictionary</returns>
public static Dictionary<string, string> QueryParamsToDictionary(String query)
{
return String.IsNullOrEmpty(query)
? new Dictionary<string, string>()
: query
.TrimStart(new[] { ' ', '?' })
.Split(new[] { '&' })
.Select(item => item.Split(new[] { '=' }))
.Where(array => array.Length == 2)
.ToDictionary(array => array[0].Trim(), array => array[1].Trim());
}
示例13: GetBaseDomain
public static String GetBaseDomain(String hostedRegion)
{
var baseHost = ConfigurationManager.AppSettings["core.base-domain"];
if (String.IsNullOrEmpty(hostedRegion)) return baseHost;
if (String.IsNullOrEmpty(baseHost)) return baseHost;
if (baseHost.IndexOf('.') == -1) return baseHost;
var subdomain = baseHost.Remove(baseHost.IndexOf('.'));
return hostedRegion.StartsWith(subdomain + ".") ? hostedRegion : String.Join(".", new[] { subdomain, hostedRegion.TrimStart('.') });
}
示例14: StartProcess
private ISystemProcess StartProcess(String binary, String arguments)
{
binary = binary.TrimStart();
//-1 or 0
if (binary.IndexOf(" ") > 0)
{
var splitBinary = binary.Split(new char[] { ' ' });
binary = splitBinary[0];
arguments = String.Join(" ",splitBinary.Skip(1).ToArray()) + " " + arguments;
}
return _system.System.StartProcess(binary, arguments);
}
示例15: Combine
/// <summary>
/// Combines several path elements
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
public static String Combine(String left, String right)
{
// remove delimiter
right = right.TrimStart(Delimiter);
left = left.TrimEnd(Delimiter);
// build the path
if (right.Length == 0)
return left;
else
return left + Delimiter + right;
}