本文整理汇总了C#中ParseMode类的典型用法代码示例。如果您正苦于以下问题:C# ParseMode类的具体用法?C# ParseMode怎么用?C# ParseMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParseMode类属于命名空间,在下文中一共展示了ParseMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendMessage
public async Task SendMessage(int id, string message, ParseMode mode = ParseMode.None, bool webPreview = true, int replyToMessageId = -1, object replyMarkup = null)
{
if (message.Length > 4096)
{
message = message.Substring(4090);
}
List<Param> param = new List<Param>
{
new Param("chat_id", id.ToString()),
new Param("text", message),
new Param("disable_web_page_preview", (!webPreview).ToString()),
};
switch (mode)
{
case ParseMode.HTML:
param.Add(new Param("parse_mode", "HTML"));
break;
case ParseMode.Markdown:
param.Add(new Param("parse_mode", "Markdown"));
break;
}
if (replyToMessageId != -1)
{
param.Add(new Param("reply_to_message_id", replyToMessageId.ToString()));
}
if (replyMarkup != null)
{
param.Add(new Param("reply_markup", JsonConvert.SerializeObject(replyMarkup)));
}
Message m = await MakeRequest<Message>("/sendMessage", Call.GET, param);
}
示例2: SetMode
public void SetMode(ParseMode mode)
{
Mode = mode;
foreach (ConsoleCharacter consoleCharacter in _characterList)
{
consoleCharacter.SetMode(mode);
}
}
示例3: GetParser
/// <summary>
/// Returns parser instance for given parse mode.
/// </summary>
/// <param name="mode">Parse mode.</param>
/// <returns>Parser instance.</returns>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="mode" /> is out of range.</exception>
public static IParser GetParser(ParseMode mode)
{
switch (mode)
{
case ParseMode.Fast:
return FastParser;
case ParseMode.Classic:
return ClassicParser;
default:
throw new ArgumentOutOfRangeException("mode");
}
}
示例4: GetParser
/// <summary>
/// Returns parser instance for given parse mode.
/// </summary>
/// <param name="mode">Parse mode.</param>
/// <returns>Parser instance.</returns>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="mode" /> is out of range.</exception>
public static IParser GetParser(ParseMode mode)
{
// Check value
if (!Enum.IsDefined(typeof(ParseMode), mode))
{
throw new ArgumentOutOfRangeException("mode");
}
switch (mode)
{
case ParseMode.Fast:
return FastParser;
default:
return ClassicParser;
}
}
示例5: Parse
public Dictionary<string, string> Parse(ParseMode mode)
{
switch (mode)
{
case ParseMode.WhithoutArray:
if (data.Count > 0)
data.Clear();
string[] arr = cleaned.Split(',');
foreach (string item in arr)
{
string[] tmp = item.Split(':');
data.Add(tmp[0].Trim().Replace("\"", ""), tmp[1].Replace("\"", "").Trim());
}
break;
case ParseMode.WithArray:
if (data.Count > 0)
data.Clear();
arr = cleaned.Split(',');
for (int i = 0; i < arr.Length; i++)
{
string[] tmp = arr[i].Split(':');
data.Add(tmp[0].Trim(), tmp[1].Trim());
if (i == 0)
break;
}
string upd = cleaned.Substring(cleaned.IndexOf("updates:")).Remove(0, 8).Trim();
upd = upd.Remove(upd.Length - 1, 1).Remove(0, 1);
Regex oRegex = new Regex(@"(?<data>[\w*|\d+])");
MatchCollection oMatchCollection = oRegex.Matches(upd);
List<string> list = new List<string>();
foreach (Match oMatch in oMatchCollection)
{
list.Add(oMatch.Groups["data"].Value);
}
break;
default:
break;
}
return data;
}
示例6: ParseIDL
public SinTD ParseIDL(string idlString, SinTD targetSinTD)
{
CurrentlyParsedSinTD = targetSinTD;
lineNumberParsed = 0;
currentlyParsing = ParseMode.NONE;
wasParsingBeforeComment = ParseMode.NONE;
string[] idlLines =
idlString.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
foreach (string line in idlLines)
{
++lineNumberParsed;
parseLine(line.Trim());
}
return CurrentlyParsedSinTD;
}
示例7: Parse
public bool Parse(bool onlyHeader)
{
if (!File.Exists(FileName))
{
Utils.Log(FileName + " doesn't exist. Can't parse data.");
return false;
}
Map = new FOMap();
StreamReader r = File.OpenText(FileName);
mode = ParseMode.Nothing;
while (!r.EndOfStream && mode != ParseMode.Finished)
{
if (mode == ParseMode.Tiles && onlyHeader)
break;
if (mode == ParseMode.Objects)
{
parseObjects(r);
break;
}
string line = r.ReadLine();
if (String.IsNullOrEmpty(line))
continue;
if (updateModeLine(line)) continue;
switch (mode)
{
case ParseMode.Header: parseHeaderLine(line); break;
case ParseMode.Tiles: parseTileLine(line); break;
default: break;
}
}
r.Close();
_IsParsed = true;
return true;
}
示例8: AddCondition
static void AddCondition(string line, ParseMode parseMode)
{
ModifyCondition(line, parseMode, false);
}
示例9: BuildTree
public syntax_tree_node BuildTree(string FileName, string Text,string[] SearchPatchs, ParseMode ParseMode)
{
if (parser == null)
Reset();
parser.errors = Errors;
parser.current_file_name = FileName;
switch (ParseMode)
{
case ParseMode.Expression:
case ParseMode.Statement:
return null;
}
syntax_tree_node cu = (syntax_tree_node)parser.Parse(Text);
if (cu != null && cu is compilation_unit)
(cu as compilation_unit).file_name = FileName;
return cu;
}
示例10: updateModeLine
private bool updateModeLine(string line)
{
if (line.Equals("[Header]"))
{
mode = ParseMode.Header;
return true;
}
if (line.Equals("[Tiles]"))
{
mode = ParseMode.Tiles;
return true;
}
if (line.Equals("[Objects]"))
{
mode = ParseMode.Objects;
return true;
}
return false;
}
示例11: splitIRI
/**
* Parses an Internationalized Resource Identifier (IRI) reference
* under RFC3987. If the IRI is syntactically valid, splits
* the _string into its components and returns an array containing
* the indices into the components.
*
* @param s A _string.
* @param parseMode Specifies whether certain characters are allowed
* in the _string.
* @return If the _string is a valid IRI reference, returns an array of 10
* integers. Each of the five pairs corresponds to the start
* and end index of the IRI's scheme, authority, path, query,
* or fragment component, respectively. If a component is absent,
* both indices in that pair will be -1. If the _string is null
* or is not a valid IRI, returns null.
*/
public static int[] splitIRI(string s, ParseMode parseMode)
{
if(s==null)return null;
return splitIRI(s,0,s.Length,parseMode);
}
示例12: ParseExpression
private static string ParseExpression(string code, string id, ParseMode mode, bool whenCondition, DekiScriptEnv env, DekiScriptRuntime runtime, Dictionary<string, string> channels, ref int i) {
StringBuilder result = new StringBuilder();
int nesting = 0;
for(; i < code.Length; ++i) {
int start;
switch(code[i]) {
case '"':
case '\'':
// process strings
start = i;
ScanString(code, code[i], ref i);
result.Append(code, start, i - start);
--i;
break;
case '/':
// check if / denotes the beginning of a comment, if so process it
start = i;
if(TryScanComment(code, ref i)) {
// NOTE: remove comments in when-condition
if(!whenCondition) {
result.Append(code, start, i - start);
result.Append("\n");
}
--i;
} else {
result.Append(code[i]);
}
break;
case '\\':
// backslash (\) always appends the next character
result.Append(code[i++]);
if(i < code.Length) {
result.Append(code[i]);
}
break;
case '(':
// increase nesting level
result.Append(code[i]);
++nesting;
break;
case '{':
// check if this is the beginning of a dekiscript block {{ }}
if(((i + 1) < code.Length) && (code[i + 1] == '{')) {
++i;
string value;
start = i;
if(TryParseDekiScriptExpression(code, env, runtime, ref i, out value)) {
result.Append(value);
} else {
++nesting;
result.Append('{');
result.Append(code, start, i - start);
--i;
}
} else {
++nesting;
result.Append(code[i]);
}
break;
case ')':
case '}':
// decrease nesting level and check if this is the end of the sougth expression
result.Append(code[i]);
--nesting;
// NOTE: only exit if
// 1) we don't have to read all of the code
// 2) there are no open parentheses or cruly braces
// 3) we don't on a complete statement or the current characteris a closing curly brace
if((mode != ParseMode.ALL) && (nesting <= 0) && ((mode != ParseMode.STATEMENT) || (code[i] == '}'))) {
// found the end of the expression
++i;
return result.ToString();
}
break;
case ';':
// check if the statement is the end of the sougth expression
result.Append(code[i]);
// NOTE: only exit if
// 1) we don't have to read all of the code
// 2) there are no open parentheses or cruly braces
// 3) we stop on a complete statement
if((nesting <= 0) && (mode == ParseMode.STATEMENT)) {
// found the end of the expression
++i;
return result.ToString();
//.........这里部分代码省略.........
示例13: BuildTree
public syntax_tree_node BuildTree(string FileName, string Text, ParseMode ParseMode, List<string> DefinesList = null)
{
MatchCollection mc = Regex.Matches(Text, @"(([\f\t\v\x85\p{Z}])*///.*\r\n)*([\f\t\v\x85\p{Z}])*'''.*", RegexOptions.Compiled);
syntax_tree_node cu = null;
documentation_comment_list dcl = new documentation_comment_list();
if (mc.Count > 0)
{
int i = 0;
int mci = 0, curmindex = mc[0].Index;
int line_num = 1;
int col = 1;
documentation_comment_section dcs=null;
int dcs_count = 0;
int dcs_length = 0;
while (true)
{
if (Text[i] == '\n')
{
line_num++;
}
if (dcs!=null && dcs_count == dcs_length)
{
dcs.source_context = new SourceContext(dcs.source_context.begin_position.line_num, dcs.source_context.begin_position.column_num, line_num-1, col);
dcs = null;
}
if (Text[i] == '\n')
{
col = 0;
}
if (curmindex == i)
{
dcs = parse_section(mc[mci].Value);
if (dcs.tags.Count > 0 || dcs.text!=null)
{
dcs.source_context = new SourceContext(line_num, col, -1, -1);
dcl.sections.Add(dcs);
dcs_count = 0;
dcs_length = mc[mci].Length;
}
mci++;
if (mci < mc.Count)
curmindex = mc[mci].Index;
else
curmindex = -1;
}
i++;
col++;
if (dcs != null)
dcs_count++;
if(i==Text.Length || (curmindex==-1 && dcs==null))
break;
}
}
return dcl;
}
示例14: BuildTree
public syntax_tree_node BuildTree(string FileName, string Text, ParseMode ParseMode)
{
if (string.IsNullOrEmpty(Text))
return null;
ICSharpCode.NRefactory.IParser parser = ICSharpCode.NRefactory.ParserFactory.CreateParser(ICSharpCode.NRefactory.SupportedLanguage.VBNet,new StringReader(Text));
syntax_tree_node cu = null;
ASTConverter conv = new ASTConverter();
if (ParseMode == ParseMode.Expression)
{
ICSharpCode.NRefactory.Ast.Expression expr = parser.ParseExpression();
cu = conv.get_expression(expr);
}
else
{
parser.Parse();
cu = conv.get_syntax_tree(parser.CompilationUnit, FileName);
}
parser.Dispose();
return cu;
}
示例15: EditMessageTextAsync
/// <summary>
/// Edits text messages sent by the bot or via the bot (for inline bots).
/// </summary>
/// <param name="chatId">
/// Unique identifier for the target chat or username of the target channel (in the format
/// @channelusername).
/// </param>
/// <param name="messageId">Unique identifier of the sent message.</param>
/// <param name="text">New text of the message</param>
/// <param name="parseMode">
/// A value from <see cref="ParseMode" /> enum indicates the way that the Telegram should parse the
/// sent message. Send <see cref="ParseMode.Markdown" />, if you want Telegram apps to show bold,
/// italic, fixed-width text or inline URLs in your bot's message.
/// </param>
/// <param name="disableWebPagePreview">Disables link previews for links in this message</param>
/// <param name="replyMarkup">
/// An <see cref="InlineKeyboardMarkup" /> object for a custom reply keyboard.
/// </param>
/// <param name="cancellationToken">
/// A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to
/// complete.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation. The task results contains the edited
/// <see cref="Message" /> on success.
/// </returns>
public Task<Message> EditMessageTextAsync([NotNull] string chatId, long messageId, [NotNull] string text, ParseMode parseMode = ParseMode.Normal, bool disableWebPagePreview = false, InlineKeyboardMarkup replyMarkup = null, CancellationToken cancellationToken = default(CancellationToken))
{
Contracts.EnsureNotNull(chatId, nameof(chatId));
Contracts.EnsurePositiveNumber(messageId, nameof(messageId));
return this.EditMessageTextAsync(chatId, messageId, null, text, parseMode, disableWebPagePreview, replyMarkup, cancellationToken);
}