private void ValidateCaptcha(CommentInput input, Commenter commenter) { if (Request.IsAuthenticated || (commenter != null && commenter.IsTrustedCommenter == true)) { return; } if (RecaptchaValidatorWrapper.Validate(ControllerContext.HttpContext)) { return; } ModelState.AddModelError("CaptchaNotValid", "You did not type the verification word correctly. Please try again."); }
private void SetCommenter(Commenter commenter, bool isSpamComment) { if (_requestValues.IsAuthenticated) { return; } _commentInput.MapPropertiesToInstance(commenter); commenter.IsTrustedCommenter = isSpamComment == false; if (isSpamComment) { commenter.NumberOfSpamComments++; } DocumentSession.Store(commenter); }
private void SetCommenter(Commenter commenter, PostComments.Comment comment) { if (requestValues.IsAuthenticated) { return; } commentInput.MapPropertiesToInstance(commenter); commenter.IsTrustedCommenter = comment.IsSpam == false; if (comment.IsSpam) { commenter.NumberOfSpamComments++; } DocumentSession.Store(commenter); comment.CommenterId = commenter.Id; }
/// <summary> /// Uncomment the currently selected spans. /// </summary> /// <remarks> /// The base implementation calls <see cref="ICommenter.UncommentSpans"/> to perform /// the uncommenting operation and update the currently selected spans. It then /// updates the selection in the editor to match the result of the operation. /// </remarks> protected virtual void UncommentSelection() { var undoHistory = TextUndoHistoryRegistry.RegisterHistory(TextView.TextBuffer); using (var transaction = undoHistory.CreateTransaction("Uncomment Selection")) { EditorOperations.AddBeforeTextBufferChangePrimitive(); bool reversed = TextView.Selection.IsReversed; var newSelection = Commenter.UncommentSpans(TextView.Selection.VirtualSelectedSpans); // TODO: detect rectangle selection if present if (newSelection.Count > 0) { VirtualSnapshotPoint anchorPoint = reversed ? newSelection[0].End : newSelection[0].Start; VirtualSnapshotPoint activePoint = reversed ? newSelection[0].Start : newSelection[0].End; TextView.Selection.Select(anchorPoint, activePoint); } EditorOperations.AddAfterTextBufferChangePrimitive(); transaction.Complete(); } }
private void ValidateCaptcha(CommentInput input, Commenter commenter) { if (Request.IsAuthenticated || (commenter != null && commenter.IsTrustedCommenter == true)) { return; } var captchaChallegeSupplied = CheckRecaptchaChallengeSupplied(); if (captchaChallegeSupplied == false) { ModelState.AddModelError("CaptchaNotValid", "ReCaptcha challenge was not supplied."); return; } if (RecaptchaValidatorWrapper.Validate(ControllerContext.HttpContext)) { return; } ModelState.AddModelError("CaptchaNotValid", "You did not type the verification word correctly. Please try again."); }
public override IReadOnlyList <string> MergedQualifiers() { var parameters = new List <string>(); if (Type != null) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "type:{0}", Type.ToParameter())); } if (In != null) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "in:{0}", string.Join(",", In.Select(i => i.ToParameter())))); } if (Author.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "author:{0}", Author)); } if (Assignee.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "assignee:{0}", Assignee)); } if (Mentions.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "mentions:{0}", Mentions)); } if (Commenter.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "commenter:{0}", Commenter)); } if (Involves.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "involves:{0}", Involves)); } if (Team.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "team:{0}", Team)); } if (State.HasValue) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "state:{0}", State.Value.ToParameter())); } if (Labels != null) { parameters.AddRange(Labels.Select(label => string.Format(CultureInfo.InvariantCulture, "label:{0}", label))); } if (No.HasValue) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "no:{0}", No.Value.ToParameter())); } if (Language != null) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language.ToParameter())); } if (Is != null) { parameters.AddRange(Is.Select(x => string.Format(CultureInfo.InvariantCulture, "is:{0}", x.ToParameter()))); } if (Created != null) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "created:{0}", Created)); } if (Updated != null) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "updated:{0}", Updated)); } if (Merged != null) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "merged:{0}", Merged)); } if (Status.HasValue) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "status:{0}", Status.Value.ToParameter())); } if (Head.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "head:{0}", Head)); } if (Base.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "base:{0}", Base)); } if (Closed != null) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "closed:{0}", Closed)); } if (Comments != null) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "comments:{0}", Comments)); } if (User.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "user:{0}", User)); } if (Repos.Any()) { var invalidFormatRepos = Repos.Where(x => !x.IsNameWithOwnerFormat()); if (invalidFormatRepos.Any()) { throw new RepositoryFormatException(invalidFormatRepos); } parameters.AddRange(Repos.Select(x => string.Format(CultureInfo.InvariantCulture, "repo:{0}", x))); } // Add any exclusion parameters if (Exclusions != null) { parameters.AddRange(Exclusions.MergedQualifiers()); } return(new ReadOnlyCollection <string>(parameters)); }
private static void SetCommenterValuesFromOpenIdResponse(IAuthenticationResponse response, Commenter commenter) { var claimsResponse = response.GetExtension <ClaimsResponse>(); if (claimsResponse != null) { if (string.IsNullOrWhiteSpace(commenter.Name) && string.IsNullOrWhiteSpace(claimsResponse.Nickname) == false) { commenter.Name = claimsResponse.Nickname; } else if (string.IsNullOrWhiteSpace(commenter.Name) && string.IsNullOrWhiteSpace(claimsResponse.FullName) == false) { commenter.Name = claimsResponse.FullName; } if (string.IsNullOrWhiteSpace(commenter.Email) && string.IsNullOrWhiteSpace(claimsResponse.Email) == false) { commenter.Email = claimsResponse.Email; } } var fetchResponse = response.GetExtension <FetchResponse>(); if (fetchResponse != null) // let us try from the attributes { if (string.IsNullOrWhiteSpace(commenter.Email)) { commenter.Email = fetchResponse.GetAttributeValue(WellKnownAttributes.Contact.Email); } if (string.IsNullOrWhiteSpace(commenter.Name)) { commenter.Name = fetchResponse.GetAttributeValue(WellKnownAttributes.Name.FullName) ?? fetchResponse.GetAttributeValue(WellKnownAttributes.Name.First) + " " + fetchResponse.GetAttributeValue(WellKnownAttributes.Name.Last); } if (string.IsNullOrWhiteSpace(commenter.Url)) { commenter.Url = fetchResponse.GetAttributeValue(WellKnownAttributes.Contact.Web.Blog) ?? fetchResponse.GetAttributeValue(WellKnownAttributes.Contact.Web.Homepage); } } }
public override IReadOnlyList <string> MergedQualifiers() { var parameters = new List <string>(); if (In != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "in:{0}", String.Join(",", In.Select(i => i.ToParameter())))); } if (Type != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "type:{0}", Type.ToParameter())); } if (Author.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "author:{0}", Author)); } if (Assignee.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "assignee:{0}", Assignee)); } if (Mentions.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "mentions:{0}", Mentions)); } if (Commenter.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "commenter:{0}", Commenter)); } if (Involves.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "involves:{0}", Involves)); } if (State.HasValue) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "state:{0}", State.Value.ToParameter())); } if (Labels != null) { parameters.AddRange(Labels.Select(label => String.Format(CultureInfo.InvariantCulture, "label:{0}", label))); } if (Language != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "language:{0}", Language)); } if (Created != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "created:{0}", Created)); } if (Updated != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "updated:{0}", Updated)); } if (Merged != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "merged:{0}", Merged)); } if (Comments != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "comments:{0}", Comments)); } if (User.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "user:{0}", User)); } if (Repos.Any()) { var invalidFormatRepos = Repos.Where(x => !x.IsNameWithOwnerFormat()); if (invalidFormatRepos.Any()) { throw new RepositoryFormatException(invalidFormatRepos); } parameters.Add( string.Join("+", Repos.Select(x => "repo:" + x))); } return(new ReadOnlyCollection <string>(parameters)); }
private static void SetCommenterValuesFromResponse(ExternalLoginInfo response, Commenter commenter) { var claims = response.ExternalIdentity; var emailClaim = claims.FindFirst(ClaimTypes.Email); var nameClaim = claims.FindFirst(ClaimTypes.Name); var urlClaim = claims.FindFirst("urn:google:profile"); if (string.IsNullOrWhiteSpace(commenter.Email) && emailClaim != null && string.IsNullOrWhiteSpace(emailClaim.Value) == false) { commenter.Email = emailClaim.Value; } if (string.IsNullOrWhiteSpace(commenter.Name) && nameClaim != null && string.IsNullOrWhiteSpace(nameClaim.Value) == false) { commenter.Name = nameClaim.Value; } if (string.IsNullOrWhiteSpace(commenter.Url) && urlClaim != null && string.IsNullOrWhiteSpace(urlClaim.Value) == false) { commenter.Url = urlClaim.Value; } }
public IReadOnlyList <string> MergedQualifiers() { var parameters = new List <string>(); if (Author.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-author:{0}", Author)); } if (Assignee.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-assignee:{0}", Assignee)); } if (Mentions.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-mentions:{0}", Mentions)); } if (Commenter.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-commenter:{0}", Commenter)); } if (Involves.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-involves:{0}", Involves)); } if (State.HasValue) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-state:{0}", State.Value.ToParameter())); } if (Labels != null) { parameters.AddRange(Labels.Select(label => string.Format(CultureInfo.InvariantCulture, "-label:{0}", label))); } if (Language != null) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-language:{0}", Language.ToParameter())); } if (Status.HasValue) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-status:{0}", Status.Value.ToParameter())); } if (Head.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-head:{0}", Head)); } if (Base.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-base:{0}", Base)); } if (Milestone.IsNotBlank()) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "-milestone:\"{0}\"", Milestone.EscapeDoubleQuotes())); } return(new ReadOnlyCollection <string>(parameters)); }
public override IReadOnlyList <string> MergedQualifiers() { var parameters = new List <string>(); if (In != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "in:{0}", String.Join(",", In.Select(i => i.ToParameter())))); } if (Type != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "type:{0}", Type.ToParameter())); } if (Author.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "author:{0}", Author)); } if (Assignee.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "assignee:{0}", Assignee)); } if (Mentions.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "mentions:{0}", Mentions)); } if (Commenter.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "commenter:{0}", Commenter)); } if (Involves.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "involves:{0}", Involves)); } if (State.HasValue) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "state:{0}", State.Value.ToParameter())); } if (Labels != null) { foreach (var label in Labels) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "label:{0}", label)); } } if (Language != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "language:{0}", Language)); } if (Created != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "created:{0}", Created)); } if (Updated != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "updated:{0}", Updated)); } if (Comments != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "comments:{0}", Comments)); } if (User.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "user:{0}", User)); } if (Repo.IsNotBlank()) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "repo:{0}", Repo)); } return(new ReadOnlyCollection <string>(parameters)); }
public ITranslatedTypeMetadata Process(Type specificTargetType) { Debug.Assert(CanProcess(specificTargetType)); if (IsProcessed) // Prevent from reevaluation on reentry in case of circular type references. { return(TranslatedTypeMetadata); } IsProcessed = true; TranslatedTypeMetadata.Symbol = SymbolNamer.GetNameFor(TypeInfo); var sb = new StringBuilder(); // TODO Class case only now, think of interfaces sb.Append(Commenter.TypeCommentFor(TypeInfo)); sb.Append(Expression.NewLine()); sb.Append(Expression.ClassNameExpression(TranslatedTypeMetadata.Symbol)); if (SourceTypeMetadata.BaseType != null) { var baseTypeType = SourceTypeMetadata.BaseType.AsType(); var typeTranslationContext = TranslationContext.GetByType(baseTypeType); var translatedBaseTypeMetadata = typeTranslationContext.Process(baseTypeType); var baseTypeSymbol = translatedBaseTypeMetadata.Symbol; sb.Append(Expression.InheritedClassExpression(baseTypeSymbol)); } sb.Append(Expression.BlockBegin()); foreach (var memberName in SourceTypeMetadata.Members) { var sourceMemberInfo = SourceTypeMetadata[memberName]; if (SkipTypeRule.AppliesTo(sourceMemberInfo)) { continue; } var type = ((sourceMemberInfo as PropertyInfo)?.GetPropertyTypeSafe()) .NullTo((sourceMemberInfo as FieldInfo)?.GetFieldTypeSafe()); // TODO Log this at least // Debug.Assert(type != null, $"sourceMemberInfo is supposed to be either a PropertyInfo or FieldInfo but was {sourceMemberInfo.GetType().Name}"); if (type == null) { continue; } var memberTypeTranslationContext = TranslationContext.GetByType(type); var translatedMemberTypeMetadata = memberTypeTranslationContext.Process(type); // TODO Process is not needed as a part of Interface!!! var sourceTypeComment = Commenter.TypeCommentFor(type.GetTypeInfo()); sb.Append(Expression.MemberDefinitionExpression(sourceMemberInfo.Name, translatedMemberTypeMetadata.Symbol, sourceTypeComment)); } sb.Append(Expression.BlockEnd()); TranslatedTypeMetadata.Definition = sb.ToString(); return(TranslatedTypeMetadata); }
public static void CreateOneCommenter(MyStoryContext dbContext) { var commenter = new Commenter { Id = 1, Name = CommenterName, Email = CommenterEmail }; dbContext.Commenters.Add(commenter); dbContext.SaveChanges(); }
protected override void Execute(EditorFrame ef) { Commenter c = new Commenter(ef.XmlEditor); c.Comment(); }
/// <summary> /// String form /// </summary> /// <returns>string form of this state</returns> public override string ToString() { return(Commenter.Comment(this)); }
public void Initialize() { OrbManager = GetComponentInChildren <OrbManager>(true); Fader = GetComponentInChildren <Fader>(); Commenter = GetComponentInChildren <Commenter>(); }