本文整理汇总了C#中Analyzer类的典型用法代码示例。如果您正苦于以下问题:C# Analyzer类的具体用法?C# Analyzer怎么用?C# Analyzer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Analyzer类属于命名空间,在下文中一共展示了Analyzer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(String[] args)
{
try
{
ITransformer transformer = new Transformer();
IReader reader = new ConsoleReader();
IAnalyzer analyzer = new Analyzer(reader, transformer);
AnalysisResult analysisResult = analyzer.Analyze();
IDumper fileDumper = new ConsoleDumper(analysisResult);
// A better way to inform about the result would be an Enum with some codes (error dumping, error reading, error connecting to db, etc)
bool operationFinished = fileDumper.Dump();
string message = "";
if (operationFinished) { message = ""; }
else { message = "The application encountered an error. Please check the logs. Press Enter to exit."; }
Console.WriteLine(message);
Console.ReadLine();
}
catch (Exception ex)
{
ex.Log("");
Console.WriteLine("The application encountered an error. Please check the logs. Press Enter to exit.");
Console.ReadLine();
}
}
开发者ID:gophlb,项目名称:FraudPrevention,代码行数:26,代码来源:Solution.cs
示例2: IsArcValid
public static bool IsArcValid (Movement from, Analyzer.Node.Movement to) {
if (from == Movement.Unknown) {
return
to == Analyzer.Node.Movement.JustDown ||
to == Analyzer.Node.Movement.JustDownOrStayDown;
} else if (from == Movement.Tap) {
return
to == Analyzer.Node.Movement.JustDown ||
to == Analyzer.Node.Movement.JustDownOrStayDown;
} else if (from == Movement.ForceDownStart) {
return
to == Analyzer.Node.Movement.StayDown ||
to == Analyzer.Node.Movement.Relax;
} else if (from == Movement.ForceDown) {
return
to == Analyzer.Node.Movement.StayDown ||
to == Analyzer.Node.Movement.Relax;
} else if (from == Movement.PassiveDown) {
return
to == Analyzer.Node.Movement.JustDown ||
to == Analyzer.Node.Movement.JustDownOrStayDown;
} else {
throw new ArgumentException();
}
}
开发者ID:baguio,项目名称:SSC-AI,代码行数:27,代码来源:MovementHelper.cs
示例3: Analyze
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
analyzer.AddCurrentRoutineProperty(RoutineProperties.ContainsLocalsWorker);
body.Analyze(analyzer);
return new Evaluation(this);
}
开发者ID:hansdude,项目名称:Phalanger,代码行数:7,代码来源:Linq.cs
示例4: QueryTermVector
public QueryTermVector(System.String queryString, Analyzer analyzer)
{
if (analyzer != null)
{
TokenStream stream = analyzer.TokenStream("", new System.IO.StringReader(queryString));
if (stream != null)
{
IList<string> terms = new List<string>();
try
{
bool hasMoreTokens = false;
stream.Reset();
ITermAttribute termAtt = stream.AddAttribute<ITermAttribute>();
hasMoreTokens = stream.IncrementToken();
while (hasMoreTokens)
{
terms.Add(termAtt.Term);
hasMoreTokens = stream.IncrementToken();
}
ProcessTerms(terms.ToArray());
}
catch (System.IO.IOException)
{
}
}
}
}
开发者ID:mindis,项目名称:Transformalize,代码行数:29,代码来源:QueryTermVector.cs
示例5: IsArcValid
public static bool IsArcValid (Part from, Analyzer.Node.Part to) {
if (to == null) { return true; }
if (!MovementHelper.IsArcValid(from.movement, to.movement)) {
return false;
}
//Transition is valid if we consider movement only
//Consider hold notes
if (from.movement == Movement.ForceDownStart) {
if (to.movement == Analyzer.Node.Movement.StayDown) {
return from.panel == to.panel; //Continue hold note
} else if (to.movement == Analyzer.Node.Movement.Relax) {
return from.panel == to.panel; //End hold note
} else {
throw new ArgumentException();
}
} else if (from.movement == Movement.ForceDown) {
if (to.movement == Analyzer.Node.Movement.StayDown) {
return from.panel == to.panel; //Continue hold note
} else if (to.movement == Analyzer.Node.Movement.Relax) {
return from.panel == to.panel; //End continued hold note
} else {
throw new ArgumentException();
}
}
return true;
}
开发者ID:baguio,项目名称:SSC-AI,代码行数:26,代码来源:PartHelper.cs
示例6: TransitionTo
public static Part TransitionTo (Part from, Analyzer.Node.Part to, float cur_second) {
if (!IsArcValid(from, to)) {
throw new ArgumentException();
}
if (to == null) {
throw new ArgumentException();
/*return new Part(
from.movement,
from.panel,
cur_second,
from.cur_moved_second,
from.prv_moved_second
);*/
} else {
Movement nxt_movement = MovementHelper.TransitionTo(from.movement, to.movement);
if (nxt_movement == Movement.PassiveDown) {
if (from.movement == Movement.PassiveDown) {
return new Part(nxt_movement, from.panel, cur_second, from.cur_moved_second, from.prv_moved_second);
} else {
return new Part(nxt_movement, from.panel, cur_second, cur_second, from.cur_moved_second);
}
} else {
return new Part(nxt_movement, to.panel, cur_second, cur_second, from.cur_moved_second);
}
}
}
开发者ID:baguio,项目名称:SSC-AI,代码行数:26,代码来源:PartHelper.cs
示例7: Initialize
public override void Initialize(AnalysisContext analysisContext)
{
// this is stateless analyzer, can run concurrently
analysisContext.EnableConcurrentExecution();
// this has no meaning on running on generated code which user can't control
analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
analysisContext.RegisterCompilationStartAction(c =>
{
INamedTypeSymbol @string = WellKnownTypes.String(c.Compilation);
INamedTypeSymbol uri = WellKnownTypes.Uri(c.Compilation);
if (@string == null || uri == null)
{
// we don't have required types
return;
}
var analyzer = new Analyzer(c.Compilation, @string, uri, GetInvocationExpression);
// REVIEW: I need to do this thing because OperationAnalysisContext doesn't give me OwningSymbol
c.RegisterOperationBlockStartAction(sc =>
{
sc.RegisterOperationAction(oc => analyzer.Analyze(oc, sc.OwningSymbol), OperationKind.InvocationExpression);
});
});
}
开发者ID:vweijsters,项目名称:roslyn-analyzers,代码行数:27,代码来源:PassSystemUriObjectsInsteadOfStrings.cs
示例8: Main
public static void Main(string[] args)
{
string inputname = args[0];
string outputname = args[1];
string[] lines = File.ReadAllLines(inputname);
int ncases = int.Parse(lines[0]);
int nline = 0;
IList<string> results = new List<string>();
Analyzer analyzer = new Analyzer();
for (int k = 0; k < ncases; k++)
{
Console.WriteLine(string.Format("Solving Case #{0}", k + 1));
nline++;
string[] words = lines[nline].Split(' ');
string text = words[0];
int length = int.Parse(words[1]);
int count = analyzer.Count(text, length);
results.Add(string.Format("Case #{0}: {1}", k + 1, count));
}
File.WriteAllLines(outputname, results.ToArray());
}
开发者ID:ajlopez,项目名称:TddRocks,代码行数:25,代码来源:Program.cs
示例9: NoReportItems
public void NoReportItems()
{
analyzer = new Analyzer(CreateMockParser(0));
Assert.AreEqual(0, analyzer.ActualReportItems.Count);
analyzer.Run();
Assert.AreEqual(0, analyzer.ExpectedReportItems.Count);
}
开发者ID:matthargett,项目名称:bugreport,代码行数:7,代码来源:AnalyzerTest.cs
示例10: SetUp
/// <summary>
/// Set up a new index in RAM with three test phrases and the supplied Analyzer.
/// </summary>
/// <exception cref="Exception"> if an error occurs with index writer or searcher </exception>
public override void SetUp()
{
base.SetUp();
analyzer = new ShingleAnalyzerWrapper(new MockAnalyzer(Random(), MockTokenizer.WHITESPACE, false), 2);
directory = NewDirectory();
IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
Document doc;
doc = new Document();
doc.Add(new TextField("content", "please divide this sentence into shingles", Field.Store.YES));
writer.AddDocument(doc);
doc = new Document();
doc.Add(new TextField("content", "just another test sentence", Field.Store.YES));
writer.AddDocument(doc);
doc = new Document();
doc.Add(new TextField("content", "a sentence which contains no test", Field.Store.YES));
writer.AddDocument(doc);
writer.Dispose();
reader = DirectoryReader.Open(directory);
searcher = NewSearcher(reader);
}
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:29,代码来源:ShingleAnalyzerWrapperTest.cs
示例11: Analyze
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
Evaluation cond_eval = condExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo);
if (cond_eval.HasValue)
{
if (Convert.ObjectToBoolean(cond_eval.Value))
{
if (trueExpr != null)
return trueExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo);
else
return cond_eval; // condExpr ?: falseExpr // ternary shortcut
}
else
return falseExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo);
}
else
{
if (trueExpr != null)
{
analyzer.EnterConditionalCode();
trueExpr = trueExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
analyzer.LeaveConditionalCode();
}
analyzer.EnterConditionalCode();
falseExpr = falseExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
analyzer.LeaveConditionalCode();
return new Evaluation(this);
}
}
开发者ID:jdluzen,项目名称:Phalanger,代码行数:34,代码来源:TernaryEx.cs
示例12: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Expression.Analyze"]/*'/>
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
ExInfoFromParent operand_info = ExInfoFromParent.DefaultExInfo;
Evaluation left_eval = leftExpr.Analyze(analyzer, operand_info);
Evaluation right_eval;
// Boolean expression evaluation semantics:
if (operation == Operations.Or)
{
analyzer.EnterConditionalCode();
right_eval = rightExpr.Analyze(analyzer, operand_info);
analyzer.LeaveConditionalCode();
}
else
{
right_eval = rightExpr.Analyze(analyzer, operand_info);
}
Evaluation result = Evaluation.Evaluate(this, left_eval, out leftExpr, right_eval, out rightExpr);
// division by zero check:
if ((operation == Operations.Div || operation == Operations.Mod) && result.HasValue && result.Value is bool && (bool)result.Value == false)
{
analyzer.ErrorSink.Add(Warnings.DivisionByZero, analyzer.SourceUnit, rightExpr.Position);
}
else if ((operation == Operations.Div || operation == Operations.Mod) && right_eval.HasValue && right_eval.Value is int && (int)right_eval.Value == 0)
{
result = new Evaluation(this, false);
analyzer.ErrorSink.Add(Warnings.DivisionByZero, analyzer.SourceUnit, rightExpr.Position);
}
return result;
}
开发者ID:Ashod,项目名称:Phalanger,代码行数:36,代码来源:BinaryEx.cs
示例13: Analyze
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
bool already_resolved = constant != null;
if (!already_resolved)
{
access = info.Access;
ResolveName(analyzer);
}
if (constant.IsUnknown)
return new Evaluation(this);
KnownConstant known_const = (KnownConstant)constant;
if (known_const.HasValue)
{
// constant value is known:
return new Evaluation(this, known_const.Value);
}
else if (already_resolved)
{
// circular definition:
constant.ReportCircularDefinition(analyzer.ErrorSink);
return new Evaluation(this);
}
else
{
// value is not known yet, try to resolve it:
if (known_const.Node != null)
known_const.Node.Analyze(analyzer);
return (known_const.HasValue) ? new Evaluation(this, known_const.Value) : new Evaluation(this);
}
}
开发者ID:proff,项目名称:Phalanger,代码行数:35,代码来源:ConstantUse.cs
示例14: GetAnalyzer
protected override Analyzer GetAnalyzer(CompilationStartAnalysisContext context, CompilationSecurityTypes types, Version targetFrameworkVersion)
{
Analyzer analyzer = new Analyzer(types, CSharpSyntaxNodeHelper.Default, targetFrameworkVersion);
context.RegisterSyntaxNodeAction(analyzer.AnalyzeNode, SyntaxKind.MethodDeclaration, SyntaxKind.ConstructorDeclaration);
return analyzer;
}
开发者ID:Anniepoh,项目名称:roslyn-analyzers,代码行数:7,代码来源:CSharpDoNotUseInsecureDtdProcessingInApiDesigner.cs
示例15: ShingleAnalyzerWrapper
/// <summary>
/// Creates a new ShingleAnalyzerWrapper
/// </summary>
/// <param name="delegate"> Analyzer whose TokenStream is to be filtered </param>
/// <param name="minShingleSize"> Min shingle (token ngram) size </param>
/// <param name="maxShingleSize"> Max shingle size </param>
/// <param name="tokenSeparator"> Used to separate input stream tokens in output shingles </param>
/// <param name="outputUnigrams"> Whether or not the filter shall pass the original
/// tokens to the output stream </param>
/// <param name="outputUnigramsIfNoShingles"> Overrides the behavior of outputUnigrams==false for those
/// times when no shingles are available (because there are fewer than
/// minShingleSize tokens in the input stream)?
/// Note that if outputUnigrams==true, then unigrams are always output,
/// regardless of whether any shingles are available. </param>
/// <param name="fillerToken"> filler token to use when positionIncrement is more than 1 </param>
public ShingleAnalyzerWrapper(Analyzer @delegate, int minShingleSize, int maxShingleSize,
string tokenSeparator, bool outputUnigrams, bool outputUnigramsIfNoShingles, string fillerToken)
: base(@delegate.Strategy)
{
[email protected] = @delegate;
if (maxShingleSize < 2)
{
throw new ArgumentOutOfRangeException("Max shingle size must be >= 2");
}
this.maxShingleSize = maxShingleSize;
if (minShingleSize < 2)
{
throw new ArgumentOutOfRangeException("Min shingle size must be >= 2");
}
if (minShingleSize > maxShingleSize)
{
throw new ArgumentOutOfRangeException("Min shingle size must be <= max shingle size");
}
this.minShingleSize = minShingleSize;
this.tokenSeparator = (tokenSeparator == null ? "" : tokenSeparator);
this.outputUnigrams = outputUnigrams;
this.outputUnigramsIfNoShingles = outputUnigramsIfNoShingles;
this.fillerToken = fillerToken;
}
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:42,代码来源:ShingleAnalyzerWrapper.cs
示例16: LimitTokenCountAnalyzer
/// <summary>
/// Build an analyzer that limits the maximum number of tokens per field. </summary>
/// <param name="delegate"> the analyzer to wrap </param>
/// <param name="maxTokenCount"> max number of tokens to produce </param>
/// <param name="consumeAllTokens"> whether all tokens from the delegate should be consumed even if maxTokenCount is reached. </param>
public LimitTokenCountAnalyzer(Analyzer @delegate, int maxTokenCount, bool consumeAllTokens)
: base(@delegate.Strategy)
{
[email protected] = @delegate;
this.maxTokenCount = maxTokenCount;
this.consumeAllTokens = consumeAllTokens;
}
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:12,代码来源:LimitTokenCountAnalyzer.cs
示例17: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Expression.Analyze"]/*'/>
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
fileNameEx = fileNameEx.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
analyzer.AddCurrentRoutineProperty(RoutineProperties.ContainsInclude);
analyzer.CurrentScope = this.scope;
return new Evaluation(this);
}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:9,代码来源:BuiltInFunctions.CoreCLR.cs
示例18: GetAnalyzer
protected override Analyzer GetAnalyzer(CompilationStartAnalysisContext context, CompilationSecurityTypes cryptTypes)
{
Analyzer analyzer = new Analyzer(cryptTypes);
context.RegisterSyntaxNodeAction(analyzer.AnalyzeNode,
SyntaxKind.InvocationExpression,
SyntaxKind.ObjectCreationExpression);
return analyzer;
}
开发者ID:maggiemsft,项目名称:roslyn-analyzers,代码行数:8,代码来源:CSharpDoNotUseInsecureCyrptographicAlgorithms.cs
示例19: AstCache
public AstCache(Analyzer analyzer, IFileSystem fs, ILogger logger, string cacheDir)
{
this.analyzer = analyzer;
this.fs = fs;
this.LOG = logger;
this.cacheDir = cacheDir;
this.cache = new Dictionary<string, Module>();
}
开发者ID:uxmal,项目名称:pytocs,代码行数:8,代码来源:AstCache.cs
示例20: Verify
private static void Verify(Compilation compilation, string context)
{
var analyzer = new Analyzer(s => context == s);
var diagnostics = compilation.GetAnalyzerDiagnostics(new DiagnosticAnalyzer[] { analyzer });
Assert.Equal(1, diagnostics.Length);
Assert.True(diagnostics[0].Descriptor.Description.ToString().IndexOf(analyzer.Info.GetContext()) >= 0);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:AnalysisContextInfoTests.cs
注:本文中的Analyzer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论