public AssetLoadingActionHandlerFactory(Func <IDataAccess> dataAccessFact, CommentsOptions options, List <string> knownAssets) { _options = options ?? throw new ArgumentNullException(nameof(options)); _dataAccessFact = dataAccessFact ?? throw new ArgumentNullException(nameof(dataAccessFact)); _knownAssets = knownAssets; _assembly = GetType().GetTypeInfo().Assembly; _resourceNames = _assembly.GetManifestResourceNames(); }
public static IApplicationBuilder UseComments(this IApplicationBuilder appBuilder, Action <CommentsOptions> setOptions) { var options = new CommentsOptions(); setOptions(options); appBuilder.UseMiddleware <CommentsMiddlware>(options); return(appBuilder); }
public CommentsAuthorization(IAuthorizationService authorizationService, IOptions <CommentsOptions> commentsOptions, OperationKeysContainer operationKeysContainer, DataBaseConnection db) { OperationKeys = operationKeysContainer; this.authorizationService = authorizationService; this.commentsOptions = commentsOptions.Value; this.db = db; }
public static IApplicationBuilder UseCustomComments(this IApplicationBuilder appBuilder) { var options = new CommentsOptions(); options.SqliteDbFilePath = "comments.db"; options.LoadCss = false; options.IncludeHashInUrl = true; options.MarkdigPipeline = null; options.NoCommentsTemplate = "0"; options.MoreThanOneCommentTemplate = "{count}"; //If true, comment's will be visible only after approval of moderator. //op.RequireCommentApproval = true; appBuilder.UseMiddleware <CustomCommentsMiddlware>(options); return(appBuilder); }
public void CanInsertAndSelect() { string file = null; using (var connection = GetDb()) { var options = new CommentsOptions(); file = connection.ConnectionString.Split('=')[1]; options.SqliteDbFilePath = file; var dataAccess = new SqliteDataAccess(options); dataAccess.Initialize(); var model = GetTestModel(); model.Deleted = false; model.Approved = true; var response = dataAccess.PostComment(model); Assert.True(response != null && response.Id > 0); AssertModels(model, response); Assert.NotEqual(response.StaticId, Guid.Empty); var model2 = GetTestModel(); model2.CommentHistory = null; model2.ReplayToCommentId = null; var response2 = dataAccess.PostComment(model2); Assert.True(response2 != null && response2.Id > 0); AssertModels(model2, response2); int count = dataAccess.GetCommentsCount(model.PageUrl); Assert.Equal(1, count); var comments = dataAccess.GetCommentsForPage(model.PageUrl, 0, 5, true).ToArray(); Assert.Equal(1, comments.Length); AssertModels(model, comments[0]); var deletedComment = dataAccess.DeleteComment(comments[0].StaticId, "-"); Assert.True(deletedComment.Deleted); Assert.Equal("-", deletedComment.ReasonForDeleting); Assert.Equal("Comment is deleted", deletedComment.CommentContentRendered); dataAccess.Dispose(); } TryDelete(file); }
public void CanSelectCount() { string file = null; using (var connection = GetDb()) { file = connection.ConnectionString.Split('=')[1]; var options = new CommentsOptions(); file = connection.ConnectionString.Split('=')[1]; options.SqliteDbFilePath = file; var dataAccess = new SqliteDataAccess(options); dataAccess.Initialize(); int count = dataAccess.GetCommentsCount("/"); dataAccess.Dispose(); Assert.Equal(0, count); } TryDelete(file); }
public ApproveCommentActionHandlerFactory(Func <IDataAccess> dataAccessFact, CommentsOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); _dataAccessFact = dataAccessFact ?? throw new ArgumentNullException(nameof(dataAccessFact)); }
public PreviewMarkdownActionHandlerFactory(Func <IDataAccess> dataAccessFact, CommentsOptions options, ICommentsConverter mardownParser) { _options = options ?? throw new ArgumentNullException(nameof(options)); _dataAccessFact = dataAccessFact ?? throw new ArgumentNullException(nameof(dataAccessFact)); _mardownParser = mardownParser ?? throw new ArgumentNullException(nameof(mardownParser)); }
public SqliteDataAccess(CommentsOptions options, IDbConnection connection) { _connection = connection ?? throw new ArgumentNullException(nameof(connection)); _options = options ?? throw new ArgumentNullException(nameof(options)); }
public SqliteDataAccess(CommentsOptions options, string filePath) : this(options, new SqliteConnection($"Data Source={filePath};")) { }
public SqliteDataAccess(CommentsOptions options) : this(options, options.SqliteDbFilePath) { }
public CustomCommentsMiddlware(RequestDelegate next, CommentsOptions options) : base(next, options) { options.InformModerator = OnInformModerator; options.IsUserAdminModeratorCheck = IsUserAdminModerator; }