本文整理汇总了C#中ParseMode类的典型用法代码示例。如果您正苦于以下问题:C# ParseMode类的具体用法?C# ParseMode怎么用?C# ParseMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseMode类属于命名空间,在下文中一共展示了ParseMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:newnottakenname,项目名称:ApiLibs,代码行数:33,代码来源:TelegramService.cs
示例2: SetMode
public void SetMode(ParseMode mode)
{
Mode = mode;
foreach (ConsoleCharacter consoleCharacter in _characterList)
{
consoleCharacter.SetMode(mode);
}
}
开发者ID:redolentquack,项目名称:mdcat,代码行数:8,代码来源:ConsoleLine.cs
示例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");
}
}
开发者ID:devoyster,项目名称:IntXLib,代码行数:18,代码来源:ParseManager.cs
示例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;
}
}
开发者ID:juanplopes,项目名称:euler,代码行数:22,代码来源:ParseManager.cs
示例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;
}
开发者ID:OleksandrKulchytskyi,项目名称:VkManager,代码行数:47,代码来源:JSONParser.cs
示例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;
}
开发者ID:tospie,项目名称:SINFONI,代码行数:18,代码来源:IDLParser.cs
示例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;
}
开发者ID:MisterDr,项目名称:FOCommon,代码行数:41,代码来源:FOMapParser.cs
示例8: AddCondition
static void AddCondition(string line, ParseMode parseMode)
{
ModifyCondition(line, parseMode, false);
}
开发者ID:webba,项目名称:WurmAssistant2,代码行数:4,代码来源:LogQueueParseHelper.cs
示例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;
}
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:17,代码来源:Parser.cs
示例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;
}
开发者ID:MisterDr,项目名称:FOCommon,代码行数:19,代码来源:FOMapParser.cs
示例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);
}
开发者ID:peteroupc,项目名称:HtmlParserCSharp,代码行数:21,代码来源:URIUtility.cs
示例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();
//.........这里部分代码省略.........
开发者ID:heran,项目名称:DekiWiki,代码行数:101,代码来源:DekiJemProcessor.cs
示例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;
}
开发者ID:Slav76,项目名称:pascalabcnet,代码行数:55,代码来源:DocParser.cs
示例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;
}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:20,代码来源:Parser.cs
示例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);
}
开发者ID:mrtaikandi,项目名称:Telebot,代码行数:33,代码来源:Telebot.message-edit.cs
示例16: PrologCode
private void PrologCode(TerminalSet _TS)
{
inQueryMode = false;
try
{
SeeEndOfLine = false;
GetSymbol(_TS.Union(LeftParen, Identifier, IntLiteral, RealLiteral, StringLiteral, Operator, Atom, Anonymous, CutSym,
LSqBracket, LCuBracket, OpSym, BuiltinSym, ProgramSym, ReadingSym, PrologString, QMark), false,
true);
if (symbol.IsMemberOf(LeftParen, Identifier, IntLiteral, RealLiteral, StringLiteral, Operator, Atom, Anonymous, CutSym,
LSqBracket, LCuBracket, OpSym, BuiltinSym, ProgramSym, ReadingSym, PrologString, QMark))
{
GetSymbol(new TerminalSet(LeftParen, Identifier, IntLiteral, RealLiteral, StringLiteral, Operator, Atom, Anonymous,
CutSym, LSqBracket, LCuBracket, OpSym, BuiltinSym, ProgramSym, ReadingSym, PrologString,
QMark), false, true);
if (symbol.Terminal == BuiltinSym)
{
symbol.SetProcessed();
parseMode = ParseMode.Builtin;
Initialize();
Predefineds(_TS);
}
else if (symbol.Terminal == ProgramSym)
{
symbol.SetProcessed();
parseMode = ParseMode.Program;
Initialize();
Program(_TS);
}
else if (symbol.Terminal == ReadingSym)
{
symbol.SetProcessed();
parseMode = ParseMode.Reading;
ClauseSequence(_TS);
}
else
{
Globals.EraseVariables();
parseMode = ParseMode.Query;
inQueryMode = true;
GetSymbol(new TerminalSet(LeftParen, Identifier, IntLiteral, RealLiteral, StringLiteral, Operator, Atom, Anonymous,
CutSym, LSqBracket, LCuBracket, OpSym, PrologString, QMark), false, true);
if (symbol.IsMemberOf(LeftParen, Identifier, IntLiteral, RealLiteral, StringLiteral, Operator, Atom, Anonymous,
CutSym, LSqBracket, LCuBracket, PrologString, QMark))
{
terminalTable[DOT] = Dot;
Set1000Operators(true);
Query(new TerminalSet(Dot), out queryNode);
}
else
{
OperatorDefinition(new TerminalSet(Dot), true);
queryNode = null;
}
GetSymbol(new TerminalSet(Dot), true, true);
}
}
}
finally
{
terminalTable[COMMA] = Operator;
terminalTable[OP] = OpSym;
terminalTable[DOT] = Dot;
Terminate();
}
}
开发者ID:adesproject,项目名称:ADES,代码行数:66,代码来源:PL.cs
示例17: ParseAttributes
private void ParseAttributes()
{
// the node must be an element or Identifier for this to be a valid call
if (m_NodeType != HtmlNodeType.Element && m_NodeType != HtmlNodeType.Identifier) return;
// if parse state isn't None, the full node hasn't yet been parsed.
if (m_ParseState != HtmlParseState.None)
{
// the call to Parse can throw if the end of stream is reached.
// set m_ParseMode to ParseMode.Normal to capture attributes
m_ParseMode = ParseMode.Normal;
try
{
while (m_ParseState != HtmlParseState.None)
{
Parse();
}
}
catch (EndOfStreamException)
{
// do nothing
}
}
}
开发者ID:supermuk,项目名称:iudico,代码行数:23,代码来源:HtmlTextReader.cs
示例18: ConsoleLine
public ConsoleLine(string text, ParseMode mode)
{
_characterList = new ConsoleCharacterList();
_characterList.AddRange(text.ToCharArray(), mode);
Mode = mode;
}
开发者ID:redolentquack,项目名称:mdcat,代码行数:6,代码来源:ConsoleLine.cs
示例19: GetNextNode
/// <summary>
/// Parses until a new node is found. Skips over the remainder of the currently parsing node.
/// </summary>
/// <returns>true if a new node is found. false if end of stream is reached.</returns>
internal bool GetNextNode()
{
try
{
// set Parse mode to Skip for the following calls to Parse, to parse over the
// current node.
m_ParseMode = ParseMode.Skip;
while (m_ParseState != HtmlParseState.None) Parse();
// Now read the next node. Once Parse has parsed enough of the next node to
// know what it is, it will set the m_NodeType, m_Name, etc. and return.
// Set Parse mode to normal so the name of the node is stored in m_Name.
m_ParseMode = ParseMode.Normal;
Parse();
}
catch (EndOfStreamException)
{
return false;
}
return true;
}
开发者ID:supermuk,项目名称:iudico,代码行数:25,代码来源:HtmlTextReader.cs
示例20: GetOuterHtml
/// <summary>
/// Returns the Html/Xml of the current Element up to its corresponding EndElement, unless the
/// current Element is an empty element (e.g. ends with a /> and not just a >). If it is an
/// empty element, returns only the current Element.
/// </summary>
/// <returns>
/// Returns a <Typ>TextReader</Typ> that gives access to the HTML (or XML as the case may be) from
/// the current node (which must be an Element node) to the corresponding EndElement
/// node (or the end of the file if the EndElement doesn't exist.)
/// </returns>
/// <remarks>
/// After calling this method, the state of the parser will be that the current note type is "none."
/// </remarks>
/// <exception cref="InvalidOperationException">If the node type isn't an Element node,
/// or the node's name is blank.</exception>
internal TextReader GetOuterHtml()
{
PlainTextString name = Name;
// the current node type must be an Element node and have a name.
if (m_NodeType != HtmlNodeType.Element || String.IsNullOrEmpty(name)) throw new InvalidOperationException();
// Move m_ParseWriter over to m_GetOuterHtmlWriter so everything gets copied into it, and it never
// gets replaced (see ReadNextChar() - if m_GetOuterHtmlWriter is non-null, characters get
// copied into it instead of m_ParseWriter.)
m_GetOuterHtmlWriter = m_ParseWriter;
m_ParseWriter = null;
// Capture the rest of the current Element. Set m_ParseMode to Skip to avoid saving
// attribute values.
m_ParseMode = ParseMode.Skip;
try
{
while (m_ParseState != HtmlParseState.None) Parse();
}
catch (EndOfStreamException)
{
// do nothing
}
// If this isn't an empty element, find the corresponding EndElement
if (!IsEmptyElement)
{
// keep a count of Element node names equivalent to the current node name, to
// account for Elements of the same name that are inside the current Element,
// in order to stop parsing at the corrent EndElement.
int count = 1; // count the current Element
while (count > 0 && GetNextNode())
{
if (m_NodeType == HtmlNodeType.Element && 0 == String.Compare(Name, name, StringComparison.OrdinalIgnoreCase)) count++;
else if (m_NodeType == HtmlNodeType.EndElement && 0 == String.Compare(Name, name, StringComparison.OrdinalIgnoreCase)) count--;
}
// If there is still a count, it means GetNextNode returned false, meaning end of stream.
if (count == 0)
{
// make sure to finish parsing the current node
try
{
while (m_ParseState != HtmlParseState.None)
{
Parse();
}
}
catch (EndOfStreamException)
{
// do nothing
}
}
}
// transfer the stream writer's stream into a text reader and return it.
m_GetOuterHtmlWriter.Flush();
// the stream is a DetachableStream from the ReadNextChar() method
DetachableStream detachableStream = (DetachableStream)m_GetOuterHtmlWriter.BaseStream;
Stream stream = detachableStream.Stream; // the underlying stream
// detach the stream from the m_GetOuterHtmlWriter
detachableStream.Detach();
// position the underlying stream at position 0 and hand it off to the StreamReader
stream.Position = 0;
StreamReader reader = new StreamReader(stream, m_GetOuterHtmlWriter.Encoding);
m_GetOuterHtmlWriter.Dispose();
m_GetOuterHtmlWriter = null;
// set the current node type to "none"
m_NodeType = HtmlNodeType.None;
// return the reader
return reader;
}
开发者ID:supermuk,项目名称:iudico,代码行数:87,代码来源:HtmlTextReader.cs
注:本文中的ParseMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论