protected override long ExecuteWorkImplementation() { var now = DateTime.UtcNow; TextComment parentTextComment = null; if (m_newComment.ParentCommentId != null) { parentTextComment = m_resourceRepository.FindById <TextComment>(m_newComment.ParentCommentId); if (parentTextComment.ParentComment != null) { throw new MainServiceException(MainServiceErrorCode.CommentsToSecondLevel, "Only comments to second level are allowed"); } m_newComment.TextReferenceId = parentTextComment.TextReferenceId; // Subcomments must have the same TextReferenceId as parent } var user = m_resourceRepository.Load <User>(m_userId); var resourceText = m_resourceRepository.Load <Resource>(m_textId); var newComment = new TextComment { CreateTime = now, CreatedByUser = user, ParentComment = parentTextComment, ResourceText = resourceText, Text = m_newComment.Text, TextReferenceId = m_newComment.TextReferenceId }; var resultId = (long)m_resourceRepository.Create(newComment); return(resultId); }
public bool VisitParagraphCommand(ParagraphComment comment) { bool tag = false; foreach (var item in comment.Content.Where(c => c.Kind == DocumentationCommentKind.TextComment)) { TextComment com = (TextComment)item; if (Generators.Helpers.RegexTag.IsMatch(com.Text)) { tag = true; } else if (tag) { com.Text = com.Text.Substring(1); } if (com.Text.StartsWith("<", StringComparison.Ordinal)) { com.Text = $"{com.Text}{">"}"; } else if (com.Text.StartsWith(">", StringComparison.Ordinal)) { com.Text = com.Text.Substring(1); } } return(true); }
private void Bcontinu_Click(object sender, EventArgs e) { TextComment.Hide(); AlerteFaux.Hide(); Lcomment.Hide(); TexteExplication.Hide(); Suivant(); }
private void DeleteCommentsHierarchy(TextComment dbComment) { foreach (var dbSubcomment in dbComment.TextComments) { DeleteCommentsHierarchy(dbSubcomment); } m_resourceRepository.Delete(dbComment); }
private IList <TextComment> GetAllCommentsForText(long textId) { TextComment subcommentAlias = null; return(GetSession().QueryOver <TextComment>() .JoinAlias(x => x.TextComments, () => subcommentAlias, JoinType.LeftOuterJoin) .OrderBy(x => x.CreateTime).Asc .OrderBy(() => subcommentAlias.CreateTime).Asc .Where(x => x.ResourceText.Id == textId) .Fetch(SelectMode.Fetch, x => x.CreatedByUser) .Fetch(SelectMode.Fetch, x => x.TextComments) .TransformUsing(Transformers.DistinctRootEntity) .List()); }
private void Bvalidate_Click(object sender, EventArgs e) { XmlReader doc = XmlReader.Create("../../listeQuestions.xml"); bool valide = false; while (doc.Read()) { if (doc.GetAttribute("id") == "" + index) { if (Verifier(doc, Rep1)) { if (Verifier(doc, Rep2)) { if (Verifier(doc, Rep3)) { if (Verifier(doc, Rep4)) { valide = true; points = CalculPoint(); } } } } } } if (valide) { Suivant(); } else { AlerteFaux.Show(); Bvalidate.Hide(); TextComment.Show(); Lcomment.Show(); TexteExplication.Show(); Bcontinu.Show(); } }
public bool VisitParagraphCommand(ParagraphComment comment) { for (int i = 0; i < comment.Content.Count; i++) { if (comment.Content[i].Kind == DocumentationCommentKind.InlineCommandComment) { if (i + 1 < comment.Content.Count && comment.Content[i + 1].Kind == DocumentationCommentKind.TextComment) { TextComment com = (TextComment)comment.Content[i + 1]; com.Text = Helpers.RegexCommentCommandLeftover.Replace(com.Text, string.Empty); } } } bool tag = false; foreach (var item in comment.Content.Where(c => c.Kind == DocumentationCommentKind.TextComment)) { TextComment com = (TextComment)item; if (Helpers.RegexTag.IsMatch(com.Text)) { tag = true; } else if (tag) { com.Text = com.Text.Substring(1); } if (com.Text.StartsWith("<", StringComparison.Ordinal)) { com.Text = $"{com.Text}{">"}"; } else if (com.Text.StartsWith(">", StringComparison.Ordinal)) { com.Text = com.Text.Substring(1); } } return(true); }
protected TextComment(TextComment.Internal* native, bool skipVTables = false) : base((CppSharp.Parser.AST.InlineContentComment.Internal*) null) { __PointerAdjustment = 0; if (native == null) return; __Instance = new global::System.IntPtr(native); }
private TextComment(TextComment.Internal native, bool skipVTables = false) : this(__CopyValue(native), skipVTables) { __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; }
public static TextComment __CreateInstance(TextComment.Internal native, bool skipVTables = false) { return new TextComment(native, skipVTables); }
private static void* __CopyValue(TextComment.__Internal native) { var ret = Marshal.AllocHGlobal(32); global::CppSharp.Parser.AST.TextComment.__Internal.cctor_2(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); }
private TextComment(TextComment.Internal native) : this(__CopyValue(native)) { __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; }
private OperationReturn LoadComment(SessionInfo session, ScoreItem scoreItem) { OperationReturn optReturn = new OperationReturn(); optReturn.Result = true; optReturn.Code = 0; try { string rentToken = session.RentInfo.Token; ScoreSheet scoreSheet = scoreItem.ScoreSheet; if (scoreSheet == null) { optReturn.Result = false; optReturn.Code = Defines.RET_OBJECT_NULL; optReturn.Message = string.Format("ScoreSheet is null"); return(optReturn); } string strSql; DataSet objDataSet; switch (session.DBType) { case 2: strSql = string.Format( "SELECT * FROM T_31_004_{0} WHERE C002 = {1} AND C003 = {2}", rentToken, scoreItem.ID, scoreSheet.ID); optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql); if (!optReturn.Result) { return(optReturn); } objDataSet = optReturn.Data as DataSet; break; case 3: strSql = string.Format( "SELECT * FROM T_31_004_{0} WHERE C002 = {1} AND C003 = {2}", rentToken, scoreItem.ID, scoreSheet.ID); optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql); if (!optReturn.Result) { return(optReturn); } objDataSet = optReturn.Data as DataSet; break; default: optReturn.Result = false; optReturn.Code = Defines.RET_PARAM_INVALID; optReturn.Message = string.Format("DBType invalid"); return(optReturn); } if (objDataSet == null || objDataSet.Tables.Count <= 0) { optReturn.Result = false; optReturn.Code = Defines.RET_OBJECT_NULL; optReturn.Message = string.Format("DataSet is null or DataTables empty"); return(optReturn); } List <Comment> listComments = new List <Comment>(); for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++) { DataRow dr = objDataSet.Tables[0].Rows[i]; Comment comment; int intCommentStyle = Convert.ToInt32(dr["C008"]); switch (intCommentStyle) { case (int)CommentStyle.Text: TextComment textComment = new TextComment(); textComment.Type = ScoreObjectType.TextComment; textComment.DefaultText = dr["C005"].ToString(); comment = textComment; break; case (int)CommentStyle.Item: ItemComment itemComment = new ItemComment(); itemComment.Type = ScoreObjectType.ItemComment; comment = itemComment; break; default: optReturn.Result = false; optReturn.Code = Defines.RET_NOT_EXIST; optReturn.Message = string.Format("CommentStyle not exist"); return(optReturn); } comment.Style = (CommentStyle)intCommentStyle; comment.ID = Convert.ToInt64(dr["C001"]); comment.ScoreItem = scoreItem; comment.ScoreSheet = scoreSheet; comment.OrderID = Convert.ToInt32(dr["C004"]); comment.Title = dr["C009"].ToString(); #region 样式 OperationReturn styleReturn; styleReturn = LoadVisualStyle(session, comment, "T"); if (!styleReturn.Result) { if (styleReturn.Code != Defines.RET_NOT_EXIST) { return(styleReturn); } comment.TitleStyle = null; } else { VisualStyle style = styleReturn.Data as VisualStyle; if (style != null) { style.ScoreSheet = scoreSheet; comment.TitleStyle = style; } } styleReturn = LoadVisualStyle(session, comment, "P"); if (!styleReturn.Result) { if (styleReturn.Code != Defines.RET_NOT_EXIST) { return(styleReturn); } comment.PanelStyle = null; } else { VisualStyle style = styleReturn.Data as VisualStyle; if (style != null) { style.ScoreSheet = scoreSheet; comment.PanelStyle = style; } } #endregion #region 子项 var temp = comment as ItemComment; if (temp != null) { OperationReturn commentItemReturn; commentItemReturn = LoadCommentItem(session, temp); if (!commentItemReturn.Result) { return(commentItemReturn); } List <CommentItem> listItems = commentItemReturn.Data as List <CommentItem>; if (listItems == null) { commentItemReturn.Result = false; commentItemReturn.Code = Defines.RET_OBJECT_NULL; commentItemReturn.Message = string.Format("ListCommentItems is null"); return(commentItemReturn); } for (int j = 0; j < listItems.Count; j++) { temp.ValueItems.Add(listItems[j]); } temp.ValueItems = temp.ValueItems.OrderBy(j => j.OrderID).ToList(); } #endregion listComments.Add(comment); } optReturn.Data = listComments; } catch (Exception ex) { optReturn.Result = false; optReturn.Code = Defines.RET_FAIL; optReturn.Message = ex.Message; } return(optReturn); }
private void ToClearText_Click(object sender, RoutedEventArgs e) { TextComment.Clear(); }
public bool VisitText(TextComment comment) => true;
public static TextComment __CreateInstance(TextComment.Internal native) { return new TextComment(native); }
private static TextComment.Internal* __CopyValue(TextComment.Internal native) { var ret = Marshal.AllocHGlobal(32); CppSharp.Parser.AST.TextComment.Internal.cctor_2(ret, new global::System.IntPtr(&native)); return (TextComment.Internal*) ret; }
public bool VisitText(TextComment comment) { return(true); }
protected TextComment(TextComment.Internal* native, bool isInternalImpl = false) : base((CppSharp.Parser.AST.InlineContentComment.Internal*) native) { }
public override bool VisitDeclaration(CppSharp.AST.Declaration declaration) { if (AlreadyVisited(declaration)) { return(false); } if (declaration is Function && !(declaration is Method)) { var s = (TranslationUnit)declaration.OriginalNamespace; if (!_headerFiles.ContainsKey(s.FilePath)) { _headerFiles.Add(s.FilePath, File.ReadAllLines(s.FilePath)); } var commentLines = new Stack <string>(); for (int i = declaration.LineNumberStart - 2; i >= 0; i--) { commentLines.Push(_headerFiles[s.FilePath][i]); if (_headerFiles[s.FilePath][i].StartsWith("// Function: ")) { break; } if (string.IsNullOrWhiteSpace(_headerFiles[s.FilePath][i])) { break; } } var comments = commentLines.ToArray(); var content = new List <InlineContentComment>(); TextComment lastComment = null; CommentSection commentSection = CommentSection.Unset; foreach (var comment in comments) { var writeComment = comment; if (string.IsNullOrEmpty(comment)) { continue; } if (writeComment.StartsWith("// ") || writeComment.StartsWith(" * ") || writeComment.StartsWith(" */")) { writeComment = comment.Substring(3); } else if (writeComment.StartsWith("//") || writeComment.StartsWith(" *") || writeComment.StartsWith("* ") || writeComment.StartsWith("/*") || writeComment.StartsWith("*/")) { writeComment = comment.Substring(2); } // See if this is a new section if (writeComment.Length > 0 && !char.IsWhiteSpace(writeComment[0])) { if (writeComment.Trim() == "Function:") { commentSection = CommentSection.Function; } else if (writeComment.Trim() == "Parameters:") { commentSection = CommentSection.Parameters; } else if (writeComment.Trim() == "Return value:") { commentSection = CommentSection.ReturnValue; } else if (writeComment.Trim() == "Comments:") { commentSection = CommentSection.Comments; } } if (commentSection == CommentSection.Parameters) { if (writeComment.StartsWith(" ") && lastComment != null) { lastComment.Text += " " + writeComment.TrimStart(); continue; } } else if (commentSection == CommentSection.Comments) { if (writeComment.StartsWith(" ") && lastComment != null) { lastComment.Text += " " + writeComment.TrimStart(); continue; } } else { if (string.IsNullOrWhiteSpace(writeComment)) { continue; } } lastComment = new TextComment() { Text = writeComment, HasTrailingNewline = true }; content.Add(lastComment); } declaration.Comment = new RawComment() { FullComment = new FullComment { Blocks = new List <BlockContentComment>() { new ParagraphComment { Content = content } }, } }; } return(true); /* * if (declaration.Comment != null) * { * var fullComment = declaration.Comment.FullComment; * fullComment.Blocks.Clear(); * * var summaryPara = new ParagraphComment(); * * if (declaration.LogicalOriginalName.Contains("FPDFBitmap")) * { * * } * * summaryPara.Content.Add(new TextComment() * { * * Text = "" * }); * fullComment.Blocks.Add(summaryPara); * * /* * var remarksElement = xRoot.Element("remarks"); * if (remarksElement != null) * { * foreach (var remarksLine in remarksElement.Value.Split('\n')) * { * var remarksPara = new ParagraphComment(); * remarksPara.Content.Add(new TextComment * { * Text = remarksLine.ReplaceLineBreaks("").Trim() * }); * fullComment.Blocks.Add(remarksPara); * } * } * * var paramElements = xRoot.Elements("param"); * foreach (var paramElement in paramElements) * { * var paramComment = new ParamCommandComment(); * paramComment.Arguments.Add(new BlockCommandComment.Argument * { * Text = paramElement.Attribute("name").Value * }); * paramComment.ParagraphComment = new ParagraphComment(); * StringBuilder paramTextCommentBuilder = new StringBuilder(); * foreach (var paramLine in paramElement.Value.Split('\n')) * { * paramTextCommentBuilder.Append(paramLine.ReplaceLineBreaks("").Trim() + " "); * } * paramComment.ParagraphComment.Content.Add(new TextComment * { * Text = paramTextCommentBuilder.ToString() * }); * fullComment.Blocks.Add(paramComment); * } * } * /* * //Fix Enum comments * if (declaration is Enumeration enumDecl) * { * foreach (var item in enumDecl.Items.Where(i => i.Comment != null)) * { * item.Comment.BriefText = item.Comment.BriefText.Replace("<summary>", "").Replace("</summary>", "").Trim(); * } * }*/ }