本文整理汇总了C#中BehaviorChain类的典型用法代码示例。如果您正苦于以下问题:C# BehaviorChain类的具体用法?C# BehaviorChain怎么用?C# BehaviorChain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BehaviorChain类属于命名空间,在下文中一共展示了BehaviorChain类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Matches
public bool Matches(BehaviorChain chain)
{
if (chain.Route == null) return false;
if (chain.IsPartialOnly) return false;
return chain.Route.RespondsToMethod(_method);
}
开发者ID:NeilSorensen,项目名称:fubumvc,代码行数:7,代码来源:HttpMethodFilter.cs
示例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();
}
开发者ID:DarthFubuMVC,项目名称:FubuMVC.Diagnostics,代码行数:26,代码来源:ApplyTracingIntegrationTesting.cs
示例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;
}
开发者ID:JordanZaerr,项目名称:FubuMVC.Diagnostics,代码行数:30,代码来源:ApplyTracing.cs
示例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"}
};
}
开发者ID:jemacom,项目名称:fubumvc,代码行数:28,代码来源:CurrentChainTester.cs
示例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;
}
开发者ID:DarthFubuMVC,项目名称:FubuMVC.Diagnostics,代码行数:30,代码来源:EndpointExplorerFubuDiagnostics.cs
示例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;
}
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:7,代码来源:CustomReadersAndWriters.cs
示例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;
}
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:7,代码来源:CustomReadersAndWriters.cs
示例8: IsNotDiagnosticRoute
public static bool IsNotDiagnosticRoute(BehaviorChain chain)
{
if (chain is DiagnosticChain) return false;
if (chain.Tags.Contains("Diagnostics")) return false;
return true;
}
开发者ID:jbogard,项目名称:fubumvc,代码行数:7,代码来源:EndpointExplorerFubuDiagnostics.cs
示例9: VisitRoute
public void VisitRoute(IRouteDefinition route, BehaviorChain chain)
{
if (_behaviorFilters.MatchesAll(chain) && _routeFilters.MatchesAll(route))
{
_actions.Do(route, chain);
}
}
开发者ID:bbehrens,项目名称:fubumvc,代码行数:7,代码来源:RouteVisitor.cs
示例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;
}
开发者ID:RyanHauert,项目名称:FubuMVC.Diagnostics,代码行数:29,代码来源:ChainVisualization.cs
示例11: ExecutionPlan
public ExecutionPlan(Configuration config)
{
classBehaviors =
BuildClassBehaviorChain(config,
BuildFixtureBehaviorChain(config,
BuildCaseBehaviorChain(config)));
}
开发者ID:JakeGinnivan,项目名称:fixie,代码行数:7,代码来源:ExecutionPlan.cs
示例12: Matches
public bool Matches(BehaviorChain chain)
{
var call = chain.FirstCall();
if (call == null) return true;
return !call.HasAttribute<NotValidatedAttribute>() && !call.InputType().HasAttribute<NotValidatedAttribute>();
}
开发者ID:stevematney,项目名称:fubuvalidation,代码行数:7,代码来源:NotValidatedAttributeFilter.cs
示例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);
}
开发者ID:JakeGinnivan,项目名称:fixie,代码行数:7,代码来源:ExecutionPlan.cs
示例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;
}
开发者ID:cothienlac86,项目名称:fubumvc,代码行数:7,代码来源:DefaultReadersAndWriters.cs
示例15: VisitBehavior
public void VisitBehavior(BehaviorChain chain)
{
if (_filters.MatchesAll(chain))
{
_actions.Do(chain);
}
}
开发者ID:bbehrens,项目名称:fubumvc,代码行数:7,代码来源:BehaviorVisitor.cs
示例16: Apply
public void Apply(BehaviorGraph graph, BehaviorChain chain)
{
// Don't override the route if it already exists
if (chain.Route != null)
{
return;
}
// Don't override the route if the chain is a partial
if (chain.IsPartialOnly)
{
return;
}
var call = chain.Calls.FirstOrDefault();
if (call == null) return;
var policy = _policies.FirstOrDefault(x => x.Matches(call)) ?? _defaultUrlPolicy;
call.Trace("First matching UrlPolicy (or default): {0}", policy.GetType().Name);
var route = policy.Build(call);
_constraintPolicy.Apply(call, route);
route.Trace("Route definition determined by url policy: [{0}]", route.ToRoute().Url);
chain.Route = route;
}
开发者ID:aluetjen,项目名称:fubumvc,代码行数:28,代码来源:RouteDefinitionResolver.cs
示例17: Apply
public void Apply(BehaviorGraph graph, BehaviorChain chain)
{
// Don't override the route if it already exists
if (chain.Route != null)
{
return;
}
// Don't override the route if the chain is a partial
if (chain.IsPartialOnly)
{
return;
}
_observer = graph.Observer;
ActionCall call = chain.Calls.FirstOrDefault();
if (call == null) return;
IUrlPolicy policy = _policies.FirstOrDefault(x => x.Matches(call, _observer)) ?? _defaultUrlPolicy;
_observer.RecordCallStatus(call, "First matching UrlPolicy (or default): {0}".ToFormat(policy.GetType().Name));
IRouteDefinition route = policy.Build(call);
_constraintPolicy.Apply(call, route, _observer);
_observer.RecordCallStatus(call, "Route definition determined by url policy: [{0}]".ToFormat(route.ToRoute().Url));
chain.Route = route;
}
开发者ID:roynmoore,项目名称:fubumvc,代码行数:28,代码来源:RouteDefinitionResolver.cs
示例18: Text
public string Text(BehaviorChain chain)
{
if (chain.Route == null) return " -";
var httpMethodConstraint = chain.Route.Constraints.Where(kv => kv.Key == RouteConstraintPolicy.HTTP_METHOD_CONSTRAINT).Select(kv => kv.Value).FirstOrDefault() as HttpMethodConstraint;
var methodList = httpMethodConstraint == null ? string.Empty : "[" + httpMethodConstraint.AllowedMethods.Join(",") + "] ";
return methodList + chain.Route.Pattern;
}
开发者ID:shashankshetty,项目名称:fubumvc,代码行数:7,代码来源:RouteColumn.cs
示例19: scanChain
private static void scanChain(BehaviorChain chain)
{
chain.Calls
.SelectMany(x => x.Method.GetAllAttributes<WrapWithAttribute>())
.SelectMany(x => x.BehaviorTypes.Select(t => new Wrapper(t)))
.Reverse()
.Each(chain.Prepend);
}
开发者ID:RobertTheGrey,项目名称:fubumvc,代码行数:8,代码来源:WrapWithAttributeConvention.cs
示例20: automatically_excludes_the_NotAuthenticated_attribute
public void automatically_excludes_the_NotAuthenticated_attribute()
{
var chain = new BehaviorChain();
chain.AddToEnd(ActionCall.For<AuthenticatedEndpoints>(x => x.get_notauthenticated()));
new AuthenticationSettings().ShouldBeExcluded(chain)
.ShouldBeTrue();
}
开发者ID:DarthFubuMVC,项目名称:FubuMVC.Authentication,代码行数:8,代码来源:AuthenticationSettingsTester.cs
注:本文中的BehaviorChain类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论