本文整理汇总了C#中ParserOptions类的典型用法代码示例。如果您正苦于以下问题:C# ParserOptions类的具体用法?C# ParserOptions怎么用?C# ParserOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParserOptions类属于命名空间,在下文中一共展示了ParserOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DecodePhrase
/// <summary>
/// Decodes the specified number of bytes of the phrase starting
/// at the specified starting index.
/// </summary>
/// <returns>The decoded phrase.</returns>
/// <param name="options">The parser options to use.</param>
/// <param name="phrase">The phrase to decode.</param>
/// <param name="startIndex">The starting index.</param>
/// <param name="count">The number of bytes to decode.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="options"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="phrase"/> is <c>null</c>.</para>
/// </exception>
/// <exception cref="System.ArgumentOutOfRangeException">
/// <paramref name="startIndex"/> and <paramref name="count"/> do not specify
/// a valid range in the byte array.
/// </exception>
public static string DecodePhrase(ParserOptions options, byte[] phrase, int startIndex, int count)
{
if (options == null)
throw new ArgumentNullException ("options");
if (phrase == null)
throw new ArgumentNullException ("phrase");
if (startIndex < 0 || startIndex > phrase.Length)
throw new ArgumentOutOfRangeException ("startIndex");
if (count < 0 || startIndex + count > phrase.Length)
throw new ArgumentOutOfRangeException ("count");
if (count == 0)
return string.Empty;
unsafe {
fixed (byte* inbuf = phrase) {
var tokens = TokenizePhrase (options, inbuf, startIndex, count);
return DecodeTokens (options, tokens, phrase, inbuf, count);
}
}
}
开发者ID:vdaron,项目名称:MimeKit,代码行数:43,代码来源:Rfc2047.cs
示例2: GenerateCodeBlockFromFile
private static string GenerateCodeBlockFromFile(string languageAsString, string value, string documentationVersion, ParserOptions options)
{
var language = (Language)Enum.Parse(typeof(Language), languageAsString, true);
var samplesDirectory = options.GetPathToCodeDirectory(language, documentationVersion);
var values = value.Split('@');
var section = values[0];
var file = values[1];
string content;
var builder = new StringBuilder();
switch (language)
{
case Language.Csharp:
content = ExtractSectionFromCsharpFile(section, Path.Combine(samplesDirectory, file));
break;
case Language.Java:
content = ExtractSectionFromJavaFile(section, Path.Combine(samplesDirectory, file));
break;
default:
throw new NotSupportedException(language.ToString());
}
builder.AppendLine(string.Format("<pre class='line-numbers'><code class='{0}'>{1}</code></pre>", ConvertLanguageToCssClass(language), content));
return builder.ToString();
}
开发者ID:ravendb,项目名称:docs,代码行数:27,代码来源:CodeBlockHelper.cs
示例3: Parse
public dynamic Parse(string code, ParserOptions options)
{
dynamic program = null;
_lineNumber = (code.Length > 0) ? 1 : 0;
_lineStart = 0;
_length = code.Length;
_buffer = null;
_state = new State
{
AllowIn = true,
LabelSet = new Dictionary<string, object>(),
LastParenthesized = null,
InFunctionBody = false,
InIteration = false,
InSwitch = false
};
if (_length > 0)
{
_source = StringToArray(code).ToList();
}
return ParseProgram();
}
开发者ID:Diullei,项目名称:Shion,代码行数:25,代码来源:Esprima.cs
示例4: ValidateArguments
public static void ValidateArguments (ParserOptions options, byte[] buffer)
{
if (options == null)
throw new ArgumentNullException ("options");
if (buffer == null)
throw new ArgumentNullException ("buffer");
}
开发者ID:dcga,项目名称:MimeKit,代码行数:8,代码来源:ParseUtils.cs
示例5: LoadPublicGoogleDoc
public static JObject LoadPublicGoogleDoc(string docIdOrUrl, ParserOptions options = ParserOptions.None)
{
const string GDRIVE_DOWNLOAD = @"https://docs.google.com/feeds/download/documents/export/Export?id={0}&exportFormat=txt";
// extract document ID from url
var match = Regex.Match(docIdOrUrl, @"[-\w]{25,}");
var docId = (match.Success) ? match.Value : docIdOrUrl;
return LoadUrl(string.Format(GDRIVE_DOWNLOAD, docId));
}
开发者ID:partlyhuman,项目名称:archieml-net,代码行数:8,代码来源:Archie.cs
示例6: GenerateCodeBlocks
public static string GenerateCodeBlocks(string content, string documentationVersion, ParserOptions options)
{
content = CodeTabsFinder.Replace(content, match => GenerateCodeTabsBlock(match.Groups[1].Value.Trim(), documentationVersion, options));
content = CodeWithLanguageFinder.Replace(content, match => GenerateCodeBlockFromFile(match.Groups[1].Value.Trim(), match.Groups[2].Value.Trim(), documentationVersion, options));
content = CodeWithoutLanguageFinder.Replace(content, match => GenerateCodeBlockFromFile("csharp", match.Groups[1].Value.Trim(), documentationVersion, options));
content = CodeBlockFinder.Replace(content, match => GenerateCodeBlock(match.Groups[1].Value.Trim(), match.Groups[2].Value.Trim()));
return content;
}
开发者ID:ravendb,项目名称:docs,代码行数:9,代码来源:CodeBlockHelper.cs
示例7: FromArgumentString
public static FlagMatch FromArgumentString(string arg, ParserOptions options)
{
var match = Regex.Match(arg, string.Format("{0}(.+?)({1}(.*))?$",
Util.RegexForAnyLiteral(options.LongFlagHeaders.Union(options.ShortFlagHeaders)),
Util.RegexForAnyLiteral(options.FlagValueSeparators)
));
return match.Success ? new FlagMatch(match, options) : null;
}
开发者ID:robhol,项目名称:RCommandLine,代码行数:9,代码来源:FlagMatch.cs
示例8: ToParserOptions
public ParserOptions ToParserOptions()
{
var parserOptions = new ParserOptions();
foreach (var variable in Variables)
{
parserOptions.AddVariable(variable);
}
return parserOptions;
}
开发者ID:davetayls,项目名称:rivet,代码行数:10,代码来源:RivetParameters.cs
示例9: TypeParser
internal TypeParser(ParserOptions parserOptions)
: base(parserOptions)
{
_typeRefParser = new TypeRefParser(new StrangerTypeParser(parserOptions), parserOptions);
_typeParameterParser = new TypeParameterParser(_typeRefParser, parserOptions);
_eventParser = new EventParser(_typeRefParser, parserOptions);
_fieldParser = new FieldParser(_typeRefParser, parserOptions);
_methodParser = new MethodParser(_typeParameterParser, _typeRefParser, parserOptions);
_propertyParser = new PropertyParser(_typeRefParser, parserOptions);
}
开发者ID:Geaz,项目名称:sharpDox,代码行数:10,代码来源:TypeParser.cs
示例10: FlagMatch
private FlagMatch(Match match, ParserOptions options)
: this(options)
{
Header = match.Groups[1].Value;
FlagName = match.Groups[2].Value;
AssignmentOperator = match.Groups.Count >= 5 ? match.Groups[4].Value : null;
AssignmentValue = match.Groups.Count >= 6 ? match.Groups[5].Value : null;
Type |= options.ShortFlagHeaders.Contains(Header) ? FlagType.Short : 0;
Type |= options.LongFlagHeaders.Contains(Header) ? FlagType.Long : 0;
}
开发者ID:robhol,项目名称:RCommandLine,代码行数:11,代码来源:FlagMatch.cs
示例11: Scanner
//
// Constructor takes the string to parse and the culture.
//
internal Scanner(string expressionToParse, ParserOptions options)
{
// We currently have no support (and no scenarios) for disallowing property references
// in Conditions.
ErrorUtilities.VerifyThrow(0 != (options & ParserOptions.AllowProperties),
"Properties should always be allowed.");
_expression = expressionToParse;
_parsePoint = 0;
_errorState = false;
_errorPosition = -1; // invalid
_options = options;
}
开发者ID:cameron314,项目名称:msbuild,代码行数:16,代码来源:Scanner.cs
示例12: ValidateArguments
public static void ValidateArguments (ParserOptions options, byte[] buffer, int startIndex, int length)
{
if (options == null)
throw new ArgumentNullException (nameof (options));
if (buffer == null)
throw new ArgumentNullException (nameof (buffer));
if (startIndex < 0 || startIndex > buffer.Length)
throw new ArgumentOutOfRangeException (nameof (startIndex));
if (length < 0 || length > (buffer.Length - startIndex))
throw new ArgumentOutOfRangeException (nameof (length));
}
开发者ID:surekqomi,项目名称:MimeKit,代码行数:14,代码来源:ParseUtils.cs
示例13: GenerateCodeTabsBlock
private static string GenerateCodeTabsBlock(string content, string documentationVersion, ParserOptions options)
{
var tabs = new List<CodeTab>();
var matches = CodeTabFinder.Matches(content);
foreach (Match match in matches)
{
var languageAndTitle = match.Groups[1].Value.Trim();
var parts = languageAndTitle.Split(':');
var languageAsString = parts[0];
var title = parts.Length > 1 ? parts[1] : null;
var value = match.Groups[2].Value.Trim();
tabs.Add(GenerateCodeTabFromFile(languageAsString, title, value, documentationVersion, options));
}
matches = CodeTabBlockFinder.Matches(content);
foreach (Match match in matches)
tabs.Add(GenerateCodeTab(match.Groups[1].Value.Trim(), match.Groups[2].Value.Trim()));
var builder = new StringBuilder();
builder.AppendLine("<div class='code-tabs'>");
builder.AppendLine("<ul class='nav nav-tabs'>");
for (int index = 0; index < tabs.Count; index++)
{
var tab = tabs[index];
builder.AppendLine(string.Format("<li class='code-tab {2}'><a href='#{0}' data-toggle='tab'>{1}</a></li>", tab.Id, tab.Title ?? ConvertLanguageToDisplayName(tab.Language), index == 0 ? "active" : string.Empty));
}
builder.AppendLine("</ul>");
builder.AppendLine("<div class='tab-content'>");
for (int index = 0; index < tabs.Count; index++)
{
var tab = tabs[index];
builder.AppendLine(string.Format("<div class='tab-pane code-tab {1}' id='{0}'>", tab.Id, index == 0 ? "active" : string.Empty));
builder.AppendLine(string.Format("<pre class='line-numbers'><code class='{0}'>{1}</code></pre>", ConvertLanguageToCssClass(tab.Language), tab.Content));
builder.AppendLine("</div>");
}
builder.AppendLine("</div>");
builder.AppendLine("</div>");
return builder.ToString();
}
开发者ID:ravendb,项目名称:docs,代码行数:41,代码来源:CodeBlockHelper.cs
示例14: TokenizeText
static unsafe IList<Token> TokenizeText (ParserOptions options, byte* inbuf, int startIndex, int length)
{
byte* text, word, inptr = inbuf + startIndex;
byte* inend = inptr + length;
var tokens = new List<Token> ();
bool encoded = false;
Token token = null;
Token lwsp = null;
bool ascii;
int n;
while (inptr < inend) {
text = inptr;
while (inptr < inend && IsLwsp (*inptr))
inptr++;
if (inptr > text)
lwsp = new Token ((int) (text - inbuf), (int) (inptr - text));
else
lwsp = null;
if (inptr < inend) {
word = inptr;
ascii = true;
if (options.Rfc2047ComplianceMode == RfcComplianceMode.Loose) {
// Make an extra effort to detect and separate encoded-word
// tokens that have been merged with other words.
bool is_rfc2047 = false;
if (inptr + 2 < inend && *inptr == '=' && *(inptr + 1) == '?') {
inptr += 2;
// skip past the charset (if one is even declared, sigh)
while (inptr < inend && *inptr != '?') {
ascii = ascii && IsAscii (*inptr);
inptr++;
}
// sanity check encoding type
if (inptr + 3 >= inend || *inptr != '?' || !IsBbQq (*(inptr + 1)) || *(inptr + 2) != '?') {
ascii = true;
goto non_rfc2047;
}
inptr += 3;
// find the end of the rfc2047 encoded word token
while (inptr + 2 < inend && !(*inptr == '?' && *(inptr + 1) == '=')) {
ascii = ascii && IsAscii (*inptr);
inptr++;
}
if (inptr + 2 > inend || *inptr != '?' || *(inptr + 1) != '=') {
// didn't find an end marker...
inptr = word + 2;
ascii = true;
goto non_rfc2047;
}
is_rfc2047 = true;
inptr += 2;
}
non_rfc2047:
if (!is_rfc2047) {
// stop if we encounter a possible rfc2047 encoded
// token even if it's inside another word, sigh.
while (inptr < inend && !IsLwsp (*inptr)) {
if (inptr + 2 < inend && *inptr == '=' && *(inptr + 1) == '?')
break;
ascii = ascii && IsAscii (*inptr);
inptr++;
}
}
} else {
// find the end of a run of text...
while (inptr < inend && !IsLwsp (*inptr)) {
ascii = ascii && IsAscii (*inptr);
inptr++;
}
}
n = (int) (inptr - word);
if (TryGetEncodedWordToken (inbuf, word, n, out token)) {
// rfc2047 states that you must ignore all whitespace between
// encoded-word tokens
if (!encoded && lwsp != null) {
// previous token was not encoded, so preserve whitespace
tokens.Add (lwsp);
}
tokens.Add (token);
encoded = true;
} else {
// append the lwsp and atom tokens
if (lwsp != null)
tokens.Add (lwsp);
//.........这里部分代码省略.........
开发者ID:naeemkhedarun,项目名称:MimeKit,代码行数:101,代码来源:Rfc2047.cs
示例15: ParserOptions
protected ParserOptions(ParserOptions.Internal* native, bool isInternalImpl = false)
{
__Instance = new global::System.IntPtr(native);
}
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:4,代码来源:CppParser.cs
示例16: __CopyValue
private static ParserOptions.Internal* __CopyValue(ParserOptions.Internal native)
{
var ret = Marshal.AllocHGlobal(192);
CppSharp.Parser.ParserOptions.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return (ParserOptions.Internal*) ret;
}
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:6,代码来源:CppParser.cs
示例17: __CreateInstance
public static ParserOptions __CreateInstance(ParserOptions.Internal native)
{
return new ParserOptions(native);
}
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:4,代码来源:CppParser.cs
示例18: DecodeText
/// <summary>
/// Decodes unstructured text.
/// </summary>
/// <remarks>
/// Decodes the unstructured text buffer using the specified parser options.
/// </remarks>
/// <returns>The decoded text.</returns>
/// <param name="options">The parser options to use.</param>
/// <param name="text">The text to decode.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="options"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="text"/> is <c>null</c>.</para>
/// </exception>
public static string DecodeText (ParserOptions options, byte[] text)
{
return DecodeText (options, text, 0, text.Length);
}
开发者ID:naeemkhedarun,项目名称:MimeKit,代码行数:18,代码来源:Rfc2047.cs
示例19: DecodePhrase
/// <summary>
/// Decodes the phrase.
/// </summary>
/// <remarks>
/// Decodes the phrase(s) within the specified buffer using the supplied parser options.
/// </remarks>
/// <returns>The decoded phrase.</returns>
/// <param name="options">The parser options to use.</param>
/// <param name="phrase">The phrase to decode.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="options"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="phrase"/> is <c>null</c>.</para>
/// </exception>
public static string DecodePhrase (ParserOptions options, byte[] phrase)
{
return DecodePhrase (options, phrase, 0, phrase.Length);
}
开发者ID:naeemkhedarun,项目名称:MimeKit,代码行数:18,代码来源:Rfc2047.cs
示例20: DecodeTokens
static unsafe string DecodeTokens (ParserOptions options, IList<Token> tokens, byte[] input, byte* inbuf, int length)
{
var decoded = new StringBuilder (length);
var qp = new QuotedPrintableDecoder (true);
var base64 = new Base64Decoder ();
var output = new byte[length];
Token token;
int len;
fixed (byte* outbuf = output) {
for (int i = 0; i < tokens.Count; i++) {
token = tokens[i];
if (token.Encoding != ContentEncoding.Default) {
// In order to work around broken mailers, we need to combine the raw
// decoded content of runs of identically encoded word tokens before
// converting to unicode strings.
ContentEncoding encoding = token.Encoding;
int codepage = token.CodePage;
IMimeDecoder decoder;
int outlen, n;
byte* outptr;
// find the end of this run (and measure the buffer length we'll need)
for (n = i + 1; n < tokens.Count; n++) {
if (tokens[n].Encoding != encoding || tokens[n].CodePage != codepage)
break;
}
// base64 / quoted-printable decode each of the tokens...
if (encoding == ContentEncoding.Base64)
decoder = base64;
else
decoder = qp;
outptr = outbuf;
outlen = 0;
do {
// Note: by not resetting the decoder state each loop, we effectively
// treat the payloads as one continuous block, thus allowing us to
// handle cases where a hex-encoded triplet of a quoted-printable
// encoded payload is split between 2 or more encoded-word tokens.
len = DecodeToken (tokens[i], decoder, inbuf, outptr);
outptr += len;
outlen += len;
i++;
} while (i < n);
decoder.Reset ();
i--;
var unicode = CharsetUtils.ConvertToUnicode (options, codepage, output, 0, outlen, out len);
decoded.Append (unicode, 0, len);
} else if (token.Is8bit) {
// *sigh* I hate broken mailers...
var unicode = CharsetUtils.ConvertToUnicode (options, input, token.StartIndex, token.Length, out len);
decoded.Append (unicode, 0, len);
} else {
// pure 7bit ascii, a breath of fresh air...
byte* inptr = inbuf + token.StartIndex;
byte* inend = inptr + token.Length;
while (inptr < inend)
decoded.Append ((char) *inptr++);
}
}
}
return decoded.ToString ();
}
开发者ID:naeemkhedarun,项目名称:MimeKit,代码行数:71,代码来源:Rfc2047.cs
注:本文中的ParserOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论