本文整理汇总了C#中ExCSS.Model.TextBlocks.Block类的典型用法代码示例。如果您正苦于以下问题:C# Block类的具体用法?C# Block怎么用?C# Block使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Block类属于ExCSS.Model.TextBlocks命名空间,在下文中一共展示了Block类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseDocumentFunction
private bool ParseDocumentFunction(Block token)
{
SetParsingContext(ParsingContext.AfterDocumentFunction);
if (token.GrammarSegment != GrammarSegment.String) return false;
CastRuleSet<DocumentRule>().Conditions.Add(Tuple.Create(DocumentFunction.RegExp, ((StringBlock)token).Value));
return true;
}
示例2: ParseCharacterSet
private bool ParseCharacterSet(Block token)
{
SetParsingContext(ParsingContext.AfterInstruction);
if (token.GrammarSegment != GrammarSegment.String)
{
return ParsePostInstruction(token);
}
CastRuleSet<CharacterSetRule>().Encoding = ((StringBlock)token).Value;
return true;
}
示例3: ParseCondition
private bool ParseCondition(Block token)
{
switch (token.GrammarSegment)
{
case GrammarSegment.CurlyBraceOpen:
CastRuleSet<SupportsRule>().Condition = _buffer.ToString();
SetParsingContext(ParsingContext.DataBlock);
break;
default:
_buffer.Append(token);
break;
}
return true;
}
示例4: ParseDocumentFunctions
private bool ParseDocumentFunctions(Block token)
{
if (token.GrammarSegment == GrammarSegment.Comma)
{
SetParsingContext(ParsingContext.BeforeDocumentFunction);
return true;
}
if (token.GrammarSegment == GrammarSegment.CurlyBraceOpen)
{
SetParsingContext(ParsingContext.DataBlock);
return true;
}
SetParsingContext(ParsingContext.DataBlock);
return false;
}
示例5: ParseDeclaration
private bool ParseDeclaration(Block token)
{
if (token.GrammarSegment == GrammarSegment.CurlyBracketClose)
{
FinalizeProperty();
SetParsingContext(CurrentRule is KeyframeRule ? ParsingContext.KeyframesData : ParsingContext.DataBlock);
return FinalizeRule();
}
if (token.GrammarSegment != GrammarSegment.Ident)
{
return false;
}
AddProperty(new Property(((SymbolBlock)token).Value));
SetParsingContext(ParsingContext.AfterProperty);
return true;
}
示例6: ParseSelector
private bool ParseSelector(Block token)
{
switch (token.GrammarSegment)
{
case GrammarSegment.CurlyBraceOpen:
{
var rule = CurrentRule as ISupportsSelector;
if (rule != null)
{
rule.Selector = _selectorFactory.GetSelector();
}
SetParsingContext(CurrentRule is StyleRule
? ParsingContext.InDeclaration
: ParsingContext.DataBlock);
}
break;
case GrammarSegment.CurlyBracketClose:
return false;
default:
_selectorFactory.Apply(token);
break;
}
return true;
}
示例7: ParseSingleValue
private bool ParseSingleValue(Block token)
{
switch (token.GrammarSegment)
{
case GrammarSegment.Dimension: // "3px"
return AddTerm(new PrimitiveTerm(((UnitBlock)token).Unit, ((UnitBlock)token).Value));
case GrammarSegment.Hash:// "#ffffff"
return ParseSingleValueHexColor(((SymbolBlock)token).Value);
case GrammarSegment.Delimiter: // "#"
return ParseValueDelimiter((DelimiterBlock)token);
case GrammarSegment.Ident: // "auto"
return ParseSingleValueIdent((SymbolBlock)token);
case GrammarSegment.String:// "'some value'"
return AddTerm(new PrimitiveTerm(UnitType.String, ((StringBlock)token).Value));
case GrammarSegment.Url:// "url('http://....')"
return AddTerm(new PrimitiveTerm(UnitType.Uri, ((StringBlock)token).Value));
case GrammarSegment.Percentage: // "10%"
return AddTerm(new PrimitiveTerm(UnitType.Percentage, ((UnitBlock)token).Value));
case GrammarSegment.Number: // "123"
return AddTerm(new PrimitiveTerm(UnitType.Number, ((NumericBlock)token).Value));
case GrammarSegment.Whitespace: // " "
_terms.AddSeparator(GrammarSegment.Whitespace);
SetParsingContext(ParsingContext.InValueList);
return true;
case GrammarSegment.Function: // rgba(...)
_functionBuffers.Push(new FunctionBuffer(((SymbolBlock)token).Value));
SetParsingContext(ParsingContext.InFunction);
return true;
case GrammarSegment.Comma: // ","
_terms.AddSeparator(GrammarSegment.Comma);
SetParsingContext(ParsingContext.InValuePool);
return true;
case GrammarSegment.Colon: // ":"
_terms.AddSeparator(GrammarSegment.Colon);
return true;
case GrammarSegment.Semicolon: // ";"
case GrammarSegment.CurlyBracketClose: // "}"
return ParsePostValue(token);
case GrammarSegment.ParenClose: // ")"
SetParsingContext(ParsingContext.AfterValue);
return true;
default:
return false;
}
}
示例8: ParseKeyframesData
private bool ParseKeyframesData(Block token)
{
if (token.GrammarSegment == GrammarSegment.CurlyBracketClose)
{
SetParsingContext(ParsingContext.DataBlock);
return FinalizeRule();
}
_buffer = new StringBuilder();
return ParseKeyframeText(token);
}
示例9: ParsePreKeyframesData
private bool ParsePreKeyframesData(Block token)
{
if (token.GrammarSegment != GrammarSegment.CurlyBraceOpen)
{
return false;
}
SetParsingContext(ParsingContext.BeforeKeyframesData);
return true;
}
示例10: ParseValueFunction
private bool ParseValueFunction(Block token)
{
switch (token.GrammarSegment)
{
case GrammarSegment.ParenClose:
{
var functionBuffer = _functionBuffers.Pop().Done();
if (_functionBuffers.Any()) return AddTerm(functionBuffer);
SetParsingContext(ParsingContext.InSingleValue);
return AddTerm(functionBuffer);
}
case GrammarSegment.Whitespace:
{
if (!_functionBuffers.Any()) return AddTerm(new Whitespace());
var functionBuffer = _functionBuffers.Peek();
var lastTerm = functionBuffer.TermList.LastOrDefault();
if (lastTerm is Comma || lastTerm is Whitespace)
return true;
return AddTerm(new Whitespace());
}
case GrammarSegment.Comma:
return AddTerm(new Comma());
case GrammarSegment.Delimiter:
return AddTerm(new EqualSign());
default:
return ParseSingleValue(token);
}
}
示例11: ParseValuePool
private bool ParseValuePool(Block token)
{
if (token.GrammarSegment == GrammarSegment.Semicolon || token.GrammarSegment == GrammarSegment.CurlyBracketClose)
{
ParsePostValue(token);
}
else
{
SetParsingContext(ParsingContext.InSingleValue);
return ParseSingleValue(token);
}
return false;
}
示例12: ParseKeyframesName
private bool ParseKeyframesName(Block token)
{
//SetParsingContext(ParsingContext.BeforeKeyframesData);
if (token.GrammarSegment == GrammarSegment.Ident)
{
CastRuleSet<KeyframesRule>().Identifier = ((SymbolBlock)token).Value;
return true;
}
if (token.GrammarSegment == GrammarSegment.CurlyBraceOpen)
{
SetParsingContext(ParsingContext.KeyframesData);
return true;
}
return false;
}
示例13: ParseValue
private bool ParseValue(Block token)
{
switch (token.GrammarSegment)
{
case GrammarSegment.Semicolon:
SetParsingContext(ParsingContext.InDeclaration);
break;
case GrammarSegment.CurlyBracketClose:
ParseDeclaration(token);
break;
default:
SetParsingContext(ParsingContext.InSingleValue);
return ParseSingleValue(token);
}
return false;
}
示例14: ParsePageSelector
private bool ParsePageSelector(Block token)
{
if (token.GrammarSegment == GrammarSegment.Colon || token.GrammarSegment == GrammarSegment.Whitespace)
{
return true;
}
if (token.GrammarSegment == GrammarSegment.Ident)
{
CastRuleSet<PageRule>().Selector = new SimpleSelector(token.ToString());
return true;
}
if (token.GrammarSegment == GrammarSegment.CurlyBraceOpen)
{
SetParsingContext(ParsingContext.InDeclaration);
return true;
}
return false;
}
示例15: ParseSymbol
private bool ParseSymbol(Block token)
{
if (token.GrammarSegment == GrammarSegment.AtRule)
{
var value = ((SymbolBlock)token).Value;
switch (value)
{
case RuleTypes.Media:
{
AddRuleSet(new MediaRule());
SetParsingContext(ParsingContext.InMediaList);
break;
}
case RuleTypes.Page:
{
AddRuleSet(new PageRule());
//SetParsingContext(ParsingContext.InSelector);
SetParsingContext(ParsingContext.BeforePageSelector);
break;
}
case RuleTypes.Import:
{
AddRuleSet(new ImportRule());
SetParsingContext(ParsingContext.BeforeImport);
break;
}
case RuleTypes.FontFace:
{
AddRuleSet(new FontFaceRule());
//SetParsingContext(ParsingContext.InDeclaration);
SetParsingContext(ParsingContext.BeforeFontFace);
break;
}
case RuleTypes.CharacterSet:
{
AddRuleSet(new CharacterSetRule());
SetParsingContext(ParsingContext.BeforeCharset);
break;
}
case RuleTypes.Namespace:
{
AddRuleSet(new NamespaceRule());
SetParsingContext(ParsingContext.BeforeNamespacePrefix);
break;
}
case RuleTypes.Supports:
{
_buffer = new StringBuilder();
AddRuleSet(new SupportsRule());
SetParsingContext(ParsingContext.InCondition);
break;
}
case BrowserPrefixes.Microsoft + RuleTypes.Keyframes:
case BrowserPrefixes.Mozilla + RuleTypes.Keyframes:
case BrowserPrefixes.Opera + RuleTypes.Keyframes:
case BrowserPrefixes.Webkit + RuleTypes.Keyframes:
case RuleTypes.Keyframes:
{
AddRuleSet(new KeyframesRule(value));
SetParsingContext(ParsingContext.BeforeKeyframesName);
break;
}
case RuleTypes.Document:
{
AddRuleSet(new DocumentRule());
SetParsingContext(ParsingContext.BeforeDocumentFunction);
break;
}
default:
{
_buffer = new StringBuilder();
AddRuleSet(new GenericRule());
SetParsingContext(ParsingContext.InUnknown);
ParseUnknown(token);
break;
}
}
return true;
}
if (token.GrammarSegment == GrammarSegment.CurlyBracketClose)
{
return FinalizeRule();
}
if (token.GrammarSegment == GrammarSegment.Semicolon)
{
return true;
}
AddRuleSet(new StyleRule());
SetParsingContext(ParsingContext.InSelector);
ParseSelector(token);
return true;
}