public static CrawlerBuilder UseDefaultService(this CrawlerBuilder builder) { builder.UseHtmlLoader <HtmlAgilityHelper>() .UseHttpClient <HttpClientFactoryClient>() .Services .AddHttpClient() .AddSingleton <ICrawlerFactory, DefaultCrawlerFactory>() .AddTransient <IConfigureOptions <CrawlerContext>, CrawlerContextConfigureOptions>(); return(builder); }
protected override void OnInitialize() { MonsterBuilder builder = new CrawlerBuilder(); builder.Build(Owner); Tree tree = CreateTree(); tree.Initialize(); Owner.AddComponent(tree); spriterComponent = new SpriterComponent <Texture2D>(Owner, @"Animations\Crawler\crawler"); spriterComponent.Initialize(); spriterComponent.ChangeAnimation("NewAnimation"); spriterComponent.Scale = 0.3f; Owner.AddComponent(spriterComponent); steeringComponent = Owner.FirstComponentOfType <SteeringComponent>(); SteeringBehavior flee = new FleeBehavior() { DesiredVelocity = new Vector2(2.25f), MaxSpeed = 1.25f }; SteeringBehavior seek = new SeekBehavior() { DesiredVelocity = new Vector2(2.25f), MaxSpeed = 1.25f }; steeringComponent.AddBehavior(flee); steeringComponent.AddBehavior(seek); steeringComponent.ChangeActiveBehavior(typeof(SeekBehavior)); }
public static CrawlerBuilder UseHttpClient(this CrawlerBuilder builder, Func <HttpRequestMessage, Task <HttpResponseMessage> > send) { builder.Services.Replace(ServiceDescriptor.Transient <IHttpClient>(p => new DefaultHttpClient(send))); return(builder); }
public static CrawlerBuilder AddFilter(this CrawlerBuilder builder, Func <HtmlNode, bool> predicate) { builder.AddFilter(p => new DefaultFilter <HtmlNode>(predicate)); return(builder); }