public WebClient(IAppLogger logger, string url, IContentBuilder builder) { _logger = logger; _url = url; _builder = builder.CheckNull(nameof(builder)); #if NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_1 _handler = new SocketsHttpHandler(); _client = new HttpClient(_handler); #else _client = new HttpClient(); if (!string.IsNullOrWhiteSpace(url)) { var uri = new Uri(_url); _servicePoint = ServicePointManager.FindServicePoint(uri); } #endif ConnectionsLimit = 1024; MaxIdleTime = 300000; // 5 мин ConnectionLeaseTimeout = 0; // закрываем соединение сразу после выполнения запроса Culture = CultureInfo.CurrentCulture; }
public WebClient(HttpClient client, IContentBuilder builder) { _builder = builder.CheckNull(nameof(builder)); _client = client; Culture = CultureInfo.CurrentCulture; }
public static IContentBuilder AddUpdater(this IContentBuilder builder, Action <ContentUpdaterOptions> options) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (options is null) { throw new ArgumentNullException(nameof(options)); } var o = new ContentUpdaterOptions(); options(o); var ourBuilder = (LocalizerConfiguration)builder; ourBuilder.UpdaterFactory = new Lazy <ContentUpdater>(() => new ContentUpdater( ourBuilder.Sources[0], o.StartupDelay, o.Frequency, ourBuilder.ContentLogger, ourBuilder.ClassGenerator )); return(builder); }
public static IContentLocalizer BuildLocalizer(this IContentBuilder builder) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } var ourBuilder = (LocalizerConfiguration)builder; var list = ourBuilder.Sources; IContentSource last = null; foreach (var source in list) { if (last != null) { last.NextSource = source; } last = source; } var updater = ourBuilder.UpdaterFactory?.Value; _ = updater?.StartAsync(); return(new LocalizerContainer( contentLocalizer: new ContentLocalizer(list[0], "en-US"), updater: updater )); }
public void LogRequestPayload(IContentBuilder contentBuilder) { _logger.Debug(() => { return($">>> Request Payload: {Environment.NewLine}{contentBuilder.GetPayloadForLogging()}{Environment.NewLine}"); }); }
public ReflectionContentManager([ImportMany] IEnumerable <Lazy <IContentManager, IPrioritisedMefMetaData> > contentManagers, IReflectionModuleBuilder moduleBuilder, IContentBuilder contentBuilder, [ImportMany] IEnumerable <Lazy <ICultureManager, IPrioritisedMefMetaData> > cultureInfoManagers /*, * IContentPublicationStateManager contentPublicationStateManager, IContentPublicationDateTimeManager contentPublicationDateTimeManager*/) : this(contentManagers.OrderByDescending(x => x.Metadata.Priority).First().Value, moduleBuilder, contentBuilder, cultureInfoManagers.OrderByDescending(x => x.Metadata.Priority).First().Value /*, contentPublicationStateManager, contentPublicationDateTimeManager*/) { }
public static IContentBuilder Name(this IContentBuilder @this, string name) { var last = @this.Last(); last.Headers.ContentDisposition.Name = name; return(@this); }
public static IContentBuilder AddManager <TEntry, TModel>(this IContentBuilder builder) where TEntry : class, IContentEntry where TModel : class { AddManager <ContentManager <TEntry, TModel>, TEntry, TModel>(builder); return(builder); }
public static IContentBuilder AddStore <TEntry, TStore>(this IContentBuilder builder, ServiceLifetime serviceLifetime) where TEntry : class, IContentEntry where TStore : class, IContentStore <TEntry> { builder.Services.Add(new ServiceDescriptor(typeof(IContentStore <TEntry>), typeof(TStore), serviceLifetime)); return(builder); }
public static IServiceCollection GetServices(this IContentBuilder builder) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } return(((NetCoreLocalizationBuilder)builder).Services); }
public static IContentBuilder AddSerilog(this IContentBuilder builder) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } return(builder.AddSerilog(Log.Logger)); }
public static void Register(string key, IContentBuilder builder) { if (_RegisteredFactories.ContainsKey(key)) { throw new ArgumentException(String.Format("{0} has already been registered", key)); } _RegisteredFactories.Add(key, builder); }
public EmailService(ISmtpClientProvider smtpClient, ITemplateProvider templateProvider, IContentBuilder contentBuilder, ICredentialsProvider credentialsProvider) { this.smtpClient = smtpClient; this.templateProvider = templateProvider; this.contentBuilder = contentBuilder; this.credentialsProvider = credentialsProvider; }
public static IContentBuilder AddMemorySource(this IContentBuilder builder) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } builder.AddContentSource(() => new MemoryContentSource()); return(builder); }
public static IContentBuilder ContentDisposition(this IContentBuilder @this, string type, string name, string fileName = null) { var h = new ContentDispositionHeaderValue(type) { Name = name, FileName = fileName, FileNameStar = fileName }; return(@this.ContentDisposition(h)); }
public static IContentBuilder File(this IContentBuilder @this, string fileName) { var last = @this.Last(); fileName = Path.GetFileName(fileName); last.Headers.ContentDisposition.FileName = fileName; last.Headers.ContentDisposition.FileNameStar = fileName; return(@this); }
//private readonly IContentPublicationStateManager _contentPublicationStateManager; //private readonly IContentPublicationDateTimeManager _contentPublicationDateTimeManager; public ReflectionContentManager(IContentManager contentManager, IReflectionModuleBuilder moduleBuilder, IContentBuilder contentBuilder, ICultureManager cultureInfoManager /*, * IContentPublicationStateManager contentPublicationStateManager, IContentPublicationDateTimeManager contentPublicationDateTimeManager*/) { _contentManager = contentManager; _moduleBuilder = moduleBuilder; _contentBuilder = contentBuilder; _cultureInfoManager = cultureInfoManager; //_contentPublicationStateManager = contentPublicationStateManager; //_contentPublicationDateTimeManager = contentPublicationDateTimeManager; }
public static IContentBuilder AddManager <TManager, TEntry, TModel>(this IContentBuilder builder) where TManager : class, IContentManager <TEntry, TModel> where TEntry : class, IContentEntry where TModel : class { builder.Services.AddScoped <IContentManager <TEntry, TModel>, TManager>(); builder.Services.AddScoped(s => (TManager)s.GetRequiredService <IContentManager <TEntry, TModel> >()); builder.Services.AddSingleton <IContentStore <TEntry>, MemoryContentStore <TEntry> >(); return(builder); }
public static IContentBuilder AddSerilog(this IContentBuilder builder, ILogger logger) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } builder.AddLogger(() => new SerilogContentLogger(logger)); return(builder); }
/// <summary> /// Wordpress Recipe Builder. Takes a wordpress export and creates an Orchard Core recipe. /// </summary> /// <param name="fileToImport">Path to wordpress export file</param> /// <param name="recipeTemplateFile">Path to template Orchard Core recipe containing required content definitions</param> /// <param name="workingFolder">Output folder where recipe zip will end up</param> public WPRecipeBuilder(string fileToImport, string recipeTemplateFile, string workingFolder, RecipeSettings recipeSettings) { creationDateTime = DateTime.UtcNow.ToString("o"); this.fileToImport = fileToImport; this.recipeTemplateFile = recipeTemplateFile; // Setup folder for saving files to this.workingFolder = workingFolder; recipeFolder = Path.Combine(workingFolder, "recipe"); Directory.CreateDirectory(recipeFolder); this.recipeSettings = recipeSettings; wordpressItems = new List <WordpressItem>(); wordpressCategories = new List <WordpressCategory>(); wordpressTags = new List <WordpressTag>(); urlCleaner = new UrlCleaner(); failedMediaUrls = new List <string>(); // initialise content builders to reflect the desired recipe switch (recipeSettings.Theme) { case RecipeSettings.Themes.TheBlog: postBuilder = new TheBlogPostBuilder { ParentId = "4m2pj0mpy25450jcz817odyhbg", WordpressItems = wordpressItems, WordpressCategories = wordpressCategories, WordpressTags = wordpressTags }; pageBuilder = new TheBlogPageBuilder { WordpressItems = wordpressItems }; break; case RecipeSettings.Themes.EtchPlayBoilerplate: postBuilder = new EtchPlayBoilerplatePostBuilder { ParentId = "4dzdnpafscnp33y8xdz4ch45xt", WordpressItems = wordpressItems, WordpressCategories = wordpressCategories, WordpressTags = wordpressTags }; pageBuilder = new EtchPlayBoilerplatePageBuilder { WordpressItems = wordpressItems }; break; } }
public AppController( IContentBuilder <TreeList, PremissionAgency> agencyTreeListBuilder, IContentBuilder <SelectedList, PremissionAgency> agencySelectedListBuilder, IContentBuilder <SelectedList, PremissionRegion> regionSelectedListBuilder) { _agencyTreeListBuilder = agencyTreeListBuilder; _agencySelectedListBuilder = agencySelectedListBuilder; _regionSelectedListBuilder = regionSelectedListBuilder; int dictAgencyId = 123; var treeListAgency = _agencyTreeListBuilder.BuildContent(dictAgencyId, new List <PremissionAgency>()); var selectListAgency = _agencySelectedListBuilder.BuildContent(dictAgencyId, new List <PremissionAgency>()); int dictRegionId = 321; var selectListRegion = _regionSelectedListBuilder.BuildContent(dictRegionId, new List <PremissionRegion>()); }
public static IContentBuilder AddJsonFileSource(this IContentBuilder builder, Action <JsonFileContentSourceOptions> options) { if (options is null) { throw new ArgumentNullException(nameof(options)); } var o = new JsonFileContentSourceOptions(); options(o); builder.AddContentSource(() => new JsonFileContentSource(o.Location)); return(builder); }
public static IContentBuilder AddProtoFileSource(this IContentBuilder builder, string location) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (location is null) { throw new ArgumentNullException(nameof(location)); } builder.AddContentSource(() => new ProtoFileContentSource(location, builder.ContentLogger)); return(builder); }
public IApiRequest AddFormParameter(string key, string value) { StringContentBuilder stringContentBuilder; if (_contentBuilder == null || !(_contentBuilder is StringContentBuilder)) { _contentBuilder = stringContentBuilder = new StringContentBuilder(); } else { stringContentBuilder = _contentBuilder as StringContentBuilder; } stringContentBuilder.AddParameter(key, value); return(this); }
public static IContentBuilder AddClassGenerator(this IContentBuilder builder, Action <ClassGeneratorOptions> options) { if (options is null) { throw new ArgumentNullException(nameof(options)); } var ourBuilder = (LocalizerConfiguration)builder; var o = new ClassGeneratorOptions(); options(o); ourBuilder.ClassGenerator = new StaticContentClassGenerator(o); return(builder); }
public static IApiBuilder AddContentApi(this IContentBuilder contentBuilder, Action <ApiBuilderDependency> configureDependency = null, Func <IExtensionBuilder, ApiBuilderDependency, IApiBuilder> builderFactory = null) { var builder = contentBuilder.AddApi(configureDependency, builderFactory); var parameterMapper = contentBuilder.AccessorTypeParameterMapper; var apiMutationType = typeof(ContentGraphApiMutation <, , , , , , , , , , , ,>).MakeGenericType( parameterMapper.Category.ArgumentType, parameterMapper.Source.ArgumentType, parameterMapper.Claim.ArgumentType, parameterMapper.Tag.ArgumentType, parameterMapper.Unit.ArgumentType, parameterMapper.UnitClaim.ArgumentType, parameterMapper.UnitTag.ArgumentType, parameterMapper.UnitVisitCount.ArgumentType, parameterMapper.Pane.ArgumentType, parameterMapper.PaneClaim.ArgumentType, parameterMapper.BaseMapper.GenId.ArgumentType, parameterMapper.BaseMapper.IncremId.ArgumentType, parameterMapper.BaseMapper.CreatedBy.ArgumentType); var apiQueryType = typeof(ContentGraphApiQuery <, , , , , , , , , , , ,>).MakeGenericType( parameterMapper.Category.ArgumentType, parameterMapper.Source.ArgumentType, parameterMapper.Claim.ArgumentType, parameterMapper.Tag.ArgumentType, parameterMapper.Unit.ArgumentType, parameterMapper.UnitClaim.ArgumentType, parameterMapper.UnitTag.ArgumentType, parameterMapper.UnitVisitCount.ArgumentType, parameterMapper.Pane.ArgumentType, parameterMapper.PaneClaim.ArgumentType, parameterMapper.BaseMapper.GenId.ArgumentType, parameterMapper.BaseMapper.IncremId.ArgumentType, parameterMapper.BaseMapper.CreatedBy.ArgumentType); contentBuilder.Services.TryReplaceAll(typeof(IGraphApiMutation), apiMutationType); contentBuilder.Services.TryReplaceAll(typeof(IGraphApiQuery), apiQueryType); return(builder); }
public TreeListContentBuilder(IContentBuilder <RDSElement, TPremission> contentBuilder) { _contentBuilder = contentBuilder; }
public IApiRequest AddJsonContent <T>(T obj) { _contentBuilder = new ObjectContentBuilder <T>(obj); return(this); }
public void AppendTo(IContentBuilder builder) { throw new NotSupportedException(); }
public IApiRequest AddFile(string filePath, string contentType = null) { _contentBuilder = new FileContentBuilder(filePath, contentType); return(this); }