本文整理汇总了C#中BehaviorChain类的典型用法代码示例。如果您正苦于以下问题:C# BehaviorChain类的具体用法?C# BehaviorChain怎么用?C# BehaviorChain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BehaviorChain类属于命名空间,在下文中一共展示了BehaviorChain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Matches
public bool Matches(BehaviorChain chain)
{
if (chain.Route == null) return false;
if (chain.IsPartialOnly) return false;
return chain.Route.RespondsToMethod(_method);
}
示例2: do_nothing_if_tracing_is_off
public void do_nothing_if_tracing_is_off()
{
var registry = new FubuRegistry();
registry.AlterSettings<DiagnosticsSettings>(x => x.TraceLevel = TraceLevel.None);
registry.Configure(graph =>
{
chain1 = new BehaviorChain();
chain1.AddToEnd(Wrapper.For<SimpleBehavior>());
chain1.AddToEnd(Wrapper.For<DifferentBehavior>());
chain1.Route = new RouteDefinition("something");
graph.AddChain(chain1);
chain2 = new BehaviorChain();
chain2.IsPartialOnly = true;
chain2.AddToEnd(Wrapper.For<SimpleBehavior>());
chain2.AddToEnd(Wrapper.For<DifferentBehavior>());
graph.AddChain(chain2);
});
registry.Policies.Add<ApplyTracing>();
var notTracedGraph = BehaviorGraph.BuildFrom(registry);
notTracedGraph.Behaviors.SelectMany(x => x).Any(x => x is DiagnosticBehavior).ShouldBeFalse();
notTracedGraph.Behaviors.SelectMany(x => x).Any(x => x is BehaviorTracer).ShouldBeFalse();
}
示例3: ShouldApply
public static bool ShouldApply(BehaviorChain chain)
{
// TODO -- Get the BehaviorChainFilter thing going again?
if ( (chain.GetRoutePattern() ?? string.Empty).Contains(DiagnosticUrlPolicy.DIAGNOSTICS_URL_ROOT) )
{
return false;
}
if (chain.Calls.Any(x => x.HandlerType.Assembly == DiagnosticAssembly))
{
return false;
}
if (chain.Calls.Any(x => x.HasAttribute<NoDiagnosticsAttribute>()))
{
return false;
}
if (chain.InputType() != null && chain.InputType().Assembly == DiagnosticAssembly)
{
return false;
}
if (chain.ResourceType() != null && chain.ResourceType().Assembly == DiagnosticAssembly)
{
return false;
}
return true;
}
示例4: SetUp
public void SetUp()
{
theChain = new BehaviorChain(){
Route = new RouteDefinition("some/pattern/url")
};
theSecondChain = new BehaviorChain()
{
Route = new RouteDefinition("some/other/pattern")
};
theThirdChain = new BehaviorChain()
{
Route = new RouteDefinition("yet/another/pattern")
};
theRouteData = new Dictionary<string, object>{
{"A", "1"},
{"B", "2"},
{"C", "3"}
};
someDifferentRouteData = new Dictionary<string, object>{
{"A", "1"},
{"B", "2"},
{"C", "33"}
};
}
示例5: IsNotDiagnosticRoute
public static bool IsNotDiagnosticRoute(BehaviorChain chain)
{
if (chain is DiagnosticChain) return false;
if (chain.Calls.Any(x => x.HandlerType.Assembly == Assembly.GetExecutingAssembly()))
{
return false;
}
if (chain.Calls.Any(x => x.HasInput && x.InputType().Assembly == Assembly.GetExecutingAssembly()))
{
return false;
}
if (chain.HasOutput() && chain.ResourceType().Assembly == Assembly.GetExecutingAssembly())
{
return false;
}
if (chain.HasOutput())
{
if (chain.Output.Writers.OfType<ViewNode>().Any(x => x.View.Namespace.Contains("Visualization.Visualizers")))
{
return false;
}
}
return true;
}
示例6: applyOutputs
protected override DoNext applyOutputs(IOutputNode node, BehaviorChain chain, ConnegSettings settings)
{
var graph = settings.Graph ?? new ConnegGraph();
graph.WriterTypesFor(node.ResourceType).Each(type => node.Add((IMediaWriter) Activator.CreateInstance(type)));
return DoNext.Continue;
}
示例7: applyInputs
protected override DoNext applyInputs(IInputNode node, BehaviorChain chain, ConnegSettings settings)
{
var graph = settings.Graph ?? new ConnegGraph();
graph.ReaderTypesFor(node.InputType()).Each(type => node.Add(Activator.CreateInstance((Type) type).As<IReader>()));
return DoNext.Continue;
}
示例8: IsNotDiagnosticRoute
public static bool IsNotDiagnosticRoute(BehaviorChain chain)
{
if (chain is DiagnosticChain) return false;
if (chain.Tags.Contains("Diagnostics")) return false;
return true;
}
示例9: VisitRoute
public void VisitRoute(IRouteDefinition route, BehaviorChain chain)
{
if (_behaviorFilters.MatchesAll(chain) && _routeFilters.MatchesAll(route))
{
_actions.Do(route, chain);
}
}
示例10: TitleForChain
public static string TitleForChain(BehaviorChain chain)
{
if (chain.GetRoutePattern().IsNotEmpty())
{
return chain.GetRoutePattern();
}
if (chain.GetRoutePattern() == string.Empty)
{
return "(home)";
}
if (chain.Calls.Any())
{
return chain.Calls.Select(x => x.Description).Join(", ");
}
if (chain.HasOutput() && chain.Output.Writers.Any())
{
return chain.Output.Writers.Select(x => Description.For(x).Title).Join(", ");
}
if (chain.InputType() != null)
{
return "Handler for " + chain.InputType().FullName;
}
return "BehaviorChain " + chain.UniqueId;
}
示例11: ExecutionPlan
public ExecutionPlan(Configuration config)
{
classBehaviors =
BuildClassBehaviorChain(config,
BuildFixtureBehaviorChain(config,
BuildCaseBehaviorChain(config)));
}
示例12: Matches
public bool Matches(BehaviorChain chain)
{
var call = chain.FirstCall();
if (call == null) return true;
return !call.HasAttribute<NotValidatedAttribute>() && !call.InputType().HasAttribute<NotValidatedAttribute>();
}
示例13: GetInnermostBehavior
static ClassBehavior GetInnermostBehavior(Configuration config, BehaviorChain<Fixture> fixtureBehaviors)
{
if (config.ConstructionFrequency == ConstructionFrequency.PerCase)
return new CreateInstancePerCase(config.TestClassFactory, fixtureBehaviors);
return new CreateInstancePerClass(config.TestClassFactory, fixtureBehaviors);
}
示例14: applyOutputs
protected override DoNext applyOutputs(IOutputNode node, BehaviorChain chain, ConnegSettings settings)
{
node.Add(settings.FormatterFor(MimeType.Json));
node.Add(settings.FormatterFor(MimeType.Xml));
return DoNext.Continue;
}
示例15: VisitBehavior
public void VisitBehavior(BehaviorChain chain)
{
if (_filters.MatchesAll(chain))
{
_actions.Do(chain);
}
}