Example #1
0
 public CommentNode(int col, int line, string value, CommentType type)
 {
     this.col = col;
     this.line = line;
     Value = value;
     Type = type;
 }
Example #2
0
        //主线程中在窗口打印日志信息
        private void LogCommentM(CommentType commentType, string comment)
        {
            string mark = null;
            ItemType itemType = ItemType.Error;
            if (commentType == CommentType.Info)
            {
                mark = "消息";
                itemType = ItemType.Info;
            }
            else if (commentType == CommentType.Warn)
            {
                mark = "警告";
                itemType = ItemType.Warn;
            }
            else if (commentType == CommentType.Error)
            {
                mark = "错误";
                itemType = ItemType.Error;
            }

            string message = String.Format("{0} [{1}] {2}", DateTime.Now.ToString(), mark, comment);
            SListBoxItem item = new SListBoxItem(message, itemType);

            //添加滚动效果,在添加记录前,先计算滚动条是否在底部,从而决定添加后是否自动滚动
            bool scoll = false;
            if (logsBox.TopIndex == logsBox.Items.Count - (int)(logsBox.Height / logsBox.ItemHeight))
                scoll = true;
            //添加记录
            logsBox.Items.Add(item);
            //滚动到底部
            if (scoll)
                logsBox.TopIndex = logsBox.Items.Count - (int)(logsBox.Height / logsBox.ItemHeight);
        }
Example #3
0
        public override CommentCollection GetLastestCommentsForSomeone(int targetUserID, CommentType type, int top)
        {
            using (SqlQuery query = new SqlQuery())
            {
                string getTargetNameSql = null;

                switch (type)
                {
                    case CommentType.Blog:
                        getTargetNameSql = "(SELECT [Subject] FROM [bx_BlogArticles] WHERE [ArticleID]=TargetID) AS [TargetName] ";
                        break;

                    case CommentType.Photo:
                        getTargetNameSql = "(SELECT [Name] FROM [bx_Photos] WHERE [PhotoID]=TargetID) AS [TargetName] ";
                        break;

                    default:
                        getTargetNameSql = string.Empty;
                        break;
                }

                query.CommandText = "SELECT TOP (@TopCount) *, " + getTargetNameSql + " FROM bx_Comments WHERE [TargetUserID]=@TargetUserID AND [Type]=@Type ORDER BY [CommentID] DESC";
                query.CommandType = CommandType.Text;

                query.CreateParameter<int>("@TargetUserID", targetUserID, SqlDbType.Int);
                query.CreateParameter<CommentType>("@Type", type, SqlDbType.TinyInt);

                query.CreateTopParameter("@TopCount", top);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    return new CommentCollection(reader);
                }
            }
        }
Example #4
0
		// used for comment tracking
		public void StartComment(CommentType commentType, bool commentStartsLine, Location startPosition)
		{
			this.currentCommentType = commentType;
			this.startPosition      = startPosition;
			this.sb.Length          = 0;
			this.commentStartsLine  = commentStartsLine;
		}
Example #5
0
		public Comment(CommentType commentType, string comment, bool commentStartsLine, Location startPosition, Location endPosition)
			: base(startPosition, endPosition)
		{
			this.CommentType   = commentType;
			this.CommentText       = comment;
			CommentStartsLine = commentStartsLine;
		}
		public async Task<List<Comment>> GetComments(string id, CommentType commentType)
		{
			var uri = "/" + id + "?commentType=" + commentType;
			List<Comment> comments = new List<Comment>();
			var recievedContent = "";
			try
			{
				var response = await httpClient.GetAsync(new Uri(App.serverUri + "message/comment" + uri));
				if (response.IsSuccessStatusCode) { 
					recievedContent = await response.Content.ReadAsStringAsync(); 
					comments = JsonConvert.DeserializeObject<List<Comment>>(recievedContent);
				}
				else
				{
					await App.coreView.displayAlertMessage("Connection Error", "Trouble Connecting To Server", "OK");
				}

			}
			catch (Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(@"				ERROR {0}", ex.Message);
				Comment comm = JsonConvert.DeserializeObject<Comment>(recievedContent);
				comments.Add(comm);
			}
			return comments;
		}
    private int GetObjectID(CommentType type, string WebID)
    {
        if (type == CommentType.Wall)
        {
            Member m = Member.GetMemberViaWebMemberID(WebID);
            return m.MemberID;
        }
        else if (type == CommentType.Video)
        {
            Video v = Video.GetVideoByWebVideoIDWithJoin(WebID);
            return v.VideoID;
        }
        else if (type == CommentType.AskAFriend)
        {
            AskAFriend aaf = AskAFriend.GetAskAFriendByWebAskAFriendID(WebID);
            return aaf.AskAFriendID;
        }
        else if (type == CommentType.Blog)
        {
            BlogEntry blog = BlogEntry.GetBlogEntryByWebBlogEntryID(WebID);
            return blog.BlogEntryID;
        }
        else if (type == CommentType.Photo)
        {
            Photo photo = Photo.GetPhotoByWebPhotoIDWithJoin(WebID);
            return photo.PhotoID;
        }
        else if (type == CommentType.PhotoGallery)
        {
            PhotoCollection photoColl = PhotoCollection.GetPhotoCollectionByWebPhotoCollectionID(WebID);
            return photoColl.PhotoCollectionID;
        }

        return -1;
    }
Example #8
0
 public Comment(Nemerle.Compiler.Comment comment, CommentType type, int textPosition)
 {
     Position = comment.Position;
       Length = comment.Length;
       IsDocument = comment.IsDocument;
       IsMultiline = comment.IsMultiline;
       Type = type;
       TextPosition = textPosition;
 }
 /// <summary>
 /// Creates a new comment instance from an XML element.
 /// </summary>
 /// <param name="xml">The XML element.</param>
 public CrawlerComment(XElement xml)
 {
     this.type = (CommentType)int.Parse(xml.Attribute("type").Value, CultureInfo.InvariantCulture);
     this.guid = Guid.Parse(xml.Attribute("guid").Value);
     this.time = DateTime.Parse(xml.Attribute("time").Value, CultureInfo.InvariantCulture);
     this.user = xml.Attribute("user").Value;
     this.item = xml.Attribute("item").Value;
     this.text = xml.Value;
     this.xml = xml;
 }
Example #10
0
        /// <summary>
        /// Initializes a new instance of the Comment class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The line text.</param>
        /// <param name="commentType">The type of the comment.</param>
        internal Comment(CsDocument document, string text, CommentType commentType)
            : base(document, (int)commentType)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(text, "text");
            Param.Ignore(commentType);

            this.Text = text;
            CsLanguageService.Debug.Assert(System.Enum.IsDefined(typeof(CommentType), this.CommentType), "The type is invalid.");
        }
        /// <summary>
        /// Returns the height of the given comment.
        /// </summary>
        public static int GetCommentHeight(string comment, CommentType commentType)
        {
            int minHeight = 38;
            if (commentType == CommentType.None) minHeight = 17;

            GUIStyle style = "HelpBox";
            return Math.Max(
                (int)style.CalcHeight(new GUIContent(comment), Screen.width),
                minHeight);
        }
Example #12
0
 /// <summary>
 /// 显示Comment
 /// </summary>
 /// <param name="type"></param>
 /// <param name="message"></param>
 /// <param name="arg"></param>
 public static void Comment(CommentType type, string message, params object[] arg)
 {
     if (LogEvent != null)
     {
         if (arg.Length == 0)
             LogEvent(type, message);
         else
             LogEvent(type, String.Format(message, arg));
     }
 }
Example #13
0
 public Comment(String memberID, String commentToID, String content,CommentType type)
 {
     this.MemberID = memberID;
     this.Creater = new BiZ.Creater.Creater(memberID);
     this.CommentToID = commentToID;
     this.Content = content;
     this.CreatedTime = DateTime.Now;
     this.UpdateTime = DateTime.Now;
     this.CommentType = type;
     this.DeleteFlag = Comm.DeletedFlag.No;
 }
 public static int GetResourseType(CommentType type)
 {
     switch (type)
     {
         case CommentType.AlbumComment:
             return 1;
         case CommentType.PhotoComment:
         default:
             return 2;
     }
 }
Example #15
0
 public static Int32 GetCloserOfPositionOfComment(String Code, Int32 SearchOffset, CommentType Type)
 {
     switch (Type)
     {
         case CommentType.SingleLine:
             return Code.IndexOf(CloserOfSingleLineComment, SearchOffset);
         case CommentType.MultiLine:
             return Code.IndexOf(CloserOfMultiLineComment, SearchOffset);
         default:
             return IndexNotFound;
     }
 }
        private async Task RequestShortComments()
        {
            if (_currCommentType == CommentType.Long)
            {
                _currCommentType = CommentType.Short;
            }
            var shortComment = await DataRequester.RequestShortComment(CurrentStoryId, _currCommentType == CommentType.Long ? null : LastCommentId);
            if (shortComment == null)
                return;

            CommentList.Last().AddRange(shortComment.comments);
        }
Example #17
0
        protected XElement FormatComments(Step step, CommentType type)
        {
            XElement comment = new XElement(this.xmlns + "span", new XAttribute("class", "comment"));

            foreach (var stepComment in step.Comments.Where(o => o.Type == type))
            {
                comment.Add(stepComment.Text.Trim());
                comment.Add(new XElement(this.xmlns + "br"));
            }
            comment.LastNode.Remove();

            return comment;
        }
        /// <summary>
        /// Comments list
        /// </summary>
        /// <param name="commentType">Comment type</param>
        /// <param name="take">Items to take</param>
        /// <param name="skip">Items to skip</param>
        /// <param name="filter">Filter expression</param>
        /// <param name="order">Sort order</param>
        /// <returns>List of comments</returns>
        public IEnumerable<CommentItem> GetComments(CommentType commentType = CommentType.All, int take = 10, int skip = 0, string filter = "", string order = "")
        {
            if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.ViewPublicComments))
                throw new System.UnauthorizedAccessException();

            if (string.IsNullOrEmpty(filter)) filter = "1==1";
            if (string.IsNullOrEmpty(order)) order = "DateCreated desc";

            var items = new List<Comment>();
            var query = items.AsQueryable().Where(filter);
            var comments = new List<CommentItem>();

            var all = Security.IsAuthorizedTo(BlogEngine.Core.Rights.EditOtherUsersPosts);

            foreach (var p in Post.Posts)
            {
                if (all || p.Author.ToLower() == Security.CurrentUser.Identity.Name.ToLower())
                {
                    switch (commentType)
                    {
                        case CommentType.Pending:
                            items.AddRange(p.NotApprovedComments);
                            break;
                        case CommentType.Pingback:
                            items.AddRange(p.Pingbacks);
                            break;
                        case CommentType.Spam:
                            items.AddRange(p.SpamComments);
                            break;
                        case CommentType.Approved:
                            items.AddRange(p.ApprovedComments);
                            break;
                        default:
                            items.AddRange(p.Comments);
                            break;
                    }
                }
            }

            // if take passed in as 0, return all
            if (take == 0) take = items.Count;        

            var itemList = query.OrderBy(order).Skip(skip).Take(take).ToList();

            foreach (var item in itemList)
            {
                comments.Add(CreateJsonCommentFromComment(item, itemList));               
            }

            return comments;
        }
        public bool CheckPossibilityOfChangingComment(string userId, int commentId, CommentType type)
        {
            switch (type)
            {
                case CommentType.AlbumComment:
                    var albumComment = _unitOfWork.AlbumComments.Get(commentId);
                    return albumComment != null && albumComment.TargetAlbum.UserId == userId;

                case CommentType.PhotoComment:
                default:
                    var photoComment = _unitOfWork.PhotoComments.Get(commentId);
                    return photoComment != null && photoComment.TargetPhoto.AuthorId == userId;
            }
        }
Example #20
0
        public HttpResponseMessage PostComment(CommentType c)
        {
            Log.InfoFormat("POST api/comments/{0}/    EventId={1}  Content={2}", c.id, c.id, c.content);
            var comment = c.content;

            var userId = User.Identity.GetUserName().ToLong(); // Pulling this from the IPrincipal.  It is actually the user id
            var profile = _profilesService.GetProfile(userId);

            var ev = _eventService.GetEvent(c.id);

            _eventService.AddShoutoutToEvent(profile, ev, c.content);
            Log.InfoFormat("Posted comment to event.   EventId={0} ", c.id);

            return Request.CreateResponse(HttpStatusCode.OK);
        }
 public void SaveComment(int elementid, int? parentid, string comment, CommentType commenttype, int userid)
 {
     DB.Comments.InsertOnSubmit(
         new Comment()
             {
                 UserId = userid,
                 ParentId = parentid,
                 ItemId = elementid,
                 Date = DateTime.Now,
                 CommentType = commenttype,
                 CommentText = comment
             }
         );
     DB.SubmitChanges();
 }
        /// <summary>
        /// Creates a comment instance.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="time">The time.</param>
        /// <param name="user">The user.</param>
        /// <param name="item">The item.</param>
        /// <param name="text">The text.</param>
        public CrawlerComment(CommentType type, DateTime time, string user, string item, string text)
        {
            this.type = type;
            this.guid = Guid.NewGuid();
            this.time = time;
            this.user = user;
            this.item = item;
            this.text = text;

            this.xml = new XElement("comment",
                new XAttribute("type", ((int)this.type).ToString(CultureInfo.InvariantCulture)),
                new XAttribute("guid", this.guid),
                new XAttribute("time", this.time.ToString(CultureInfo.InvariantCulture)),
                new XAttribute("item", this.item),
                new XAttribute("user", this.user),
                text);
        }
Example #23
0
        public static Comment[] GetCommentByObjectIDWithJoin(Int32 objectID, CommentType commentType)
        {
            var db = DatabaseFactory.CreateDatabase();
            var dbCommand = db.GetStoredProcCommand("HG_GetCommentByObjectIDWithJoin");
            db.AddInParameter(dbCommand, "ObjectID", DbType.Int32, objectID);
            db.AddInParameter(dbCommand, "CommentType", DbType.Int32, (Int32)commentType);

            List<Comment> comments = null;

            using (var dr = db.ExecuteReader(dbCommand))
            {
                comments = Comment.PopulateObject(dr);
                dr.Close();
            }

            return comments.ToArray();
        }
        public override void Parse(MemoryStream ms, ParseState state)
        {
            /* eat comment marker */
            byte commentType = (byte) ms.ReadByte();

            if (commentType == 36)
            {
                Type = CommentType.SLASH_STAR;
            }
            else if (commentType == 78)
            {
                //TODO: make a global string writer to use instead of each element making its own string builder
                Type = CommentType.SLASH_STAR_SAME_LINE;
            }
            else if (commentType == 85)
            {
                Type = CommentType.ANGLE_STAR;
            }
            else if (commentType == 109)
            {
                Type = CommentType.SLASH_PLUS;
            }
            if (Type == CommentType.SLASH_PLUS)
            {
                ms.Seek(-1, SeekOrigin.Current);
                PureStringElement commentText = new PureStringElement();
                commentText.Parse(ms, state);
                this.Value = "/+ " + commentText.Value + " +/";
            } else
            {
                byte[] bShort = new byte[2];
                bShort[0] = (byte)ms.ReadByte();
                bShort[1] = (byte)ms.ReadByte();

                int commentLength = BitConverter.ToInt16(bShort, 0);

                byte[] commentData = new byte[commentLength];
                ms.Read(commentData, 0, commentLength);

                string s = Encoding.Unicode.GetString(commentData);
                s = s.Replace("\r\n", "\n"); // CRLF to LF
                s = s.Replace("\n", "\r\n"); // LF to CRLF
                this.Value = s;
            }
        }
Example #25
0
 internal static char GetCommentChar (CommentType type)
 {
     switch (type) {
         case CommentType.Extracted:
             return '.';
         case CommentType.Reference:
             return ':';
         case CommentType.Flag:
             return ',';
         case CommentType.PreviousContext:
             return '|';
         case CommentType.ObsoleteMessage:
             return '~';
         case CommentType.Translator:
             return ' ';
         default:
             throw new Exception ("Invalid CommentType");
     }
 }
Example #26
0
		public async Task<Comment> PostAsync(CommentType commentType, int id, string text, int inReplyTo = 0)
		{
			var postData = new Dictionary<string, string>();

			postData.Add("id", id);
			postData.Add("text", text);
			postData.Add("type", commentType);

			if (inReplyTo != 0)
				postData.Add("in_reply_to", inReplyTo);

			var options = "?" + postData.ToQueryString();

			var response = await Post<RootComment>(PostUrl + options, null);

			ValidateResponse(response);

			return response.Comment;
		}
Example #27
0
        public static Int32[] GetCommentIDs(Int32 objectID, Int32 lastCommentID, CommentType commentType)
        {
            var db = DatabaseFactory.CreateDatabase();
            var dbCommand = db.GetStoredProcCommand("HG_GetCommentIDs");
            db.AddInParameter(dbCommand, "objectID", DbType.Int32, objectID);
            db.AddInParameter(dbCommand, "lastCommentID", DbType.Int32, lastCommentID);
            db.AddInParameter(dbCommand, "commentType", DbType.Int32, (Int32)commentType);

            var commentIDs = new List<Int32>();

            // Populate the datareader
            using (var dr = db.ExecuteReader(dbCommand))
            {
                while (dr.Read())
                    commentIDs.Add(Convert.ToInt32(dr["CommentID"]));
                dr.Close();
            }

            return commentIDs.ToArray();
        }
Example #28
0
		public async Task<IList<Comment>> GetAsync(CommentType commentType, int id, int numberOfCommentByPage, int sinceId = 0)
		{
			var postData = new Dictionary<string, string>();

			postData.Add("id", id);
			postData.Add("nbpp", numberOfCommentByPage);
			postData.Add("order", "desc");
			postData.Add("type", commentType);

			if (sinceId != 0)
				postData.Add("since_id", sinceId);

			var options = "?" + postData.ToQueryString();

			var response = await Get<CommentList>(GetUrl + options);

			ValidateResponse(response);

			return response.Comments;
		}
Example #29
0
        public bool TrackComment(string s, int index)
        {
            switch (_current)
            {
                case CommentType.None:
                    if (_definition.IsSingleLineCommentsSupported() && StartsWith(s, index, _definition.SINGLE_LINE))
                        _current = CommentType.SingleLine;
                    else if (_definition.IsMultiLineCommentsSupported() && StartsWith(s, index, _definition.MULTI_LINE_START))
                        _current = CommentType.MultiLine;
                    break;

                case CommentType.MultiLine:
                    if (EndsWith(s, index, _definition.MULTI_LINE_END))
                    {
                        _current = CommentType.None;
                        return true;
                    }
                    break;
            }

            return _current != CommentType.None;
        }
Example #30
0
        public Collection<Post> GetAllPosts(int categoryId, DateTime startDate, DateTime endDate, CommentType ctype, int numberOfPosts)
        {
            //// int numberOfPosts = 10;
            Collection<Post> posts = new Collection<Post>();

            using (SqlConnection connection = this.GetConnection())
            {
                connection.Open();

                SqlCommand sc = new SqlCommand();

                sc.CommandText = "GetAllPosts";

                sc.Parameters.AddWithValue("NumberOfPosts", numberOfPosts);
                sc.Parameters.AddWithValue("CategoryId", categoryId);
                sc.Parameters.AddWithValue("DateFrom", startDate);
                sc.Parameters.AddWithValue("DateTo", endDate);

                if (ctype != CommentType.All)
                {
                    sc.Parameters.AddWithValue("@ApprovedCommentsOnly", ctype == CommentType.Approved ? 1 : 0);
                }
                else
                {
                    sc.Parameters.AddWithValue("@ApprovedCommentsOnly", DBNull.Value);
                }

                sc.CommandType = CommandType.StoredProcedure;
                sc.Connection = connection;

                using (SqlDataReader reader = sc.ExecuteReader())
                {
                    posts = SqlDataMap.CreatePostsFromReader(reader);
                }
            }

            return posts;
        }
Example #31
0
 public InspectorCommentAttribute(CommentType type, string tooltip)
 {
 }
Example #32
0
 public abstract void WriteComment(CommentType commentType, string content);
Example #33
0
 public override void WriteComment(CommentType commentType, string content)
 {
     decoratedWriter.WriteComment(commentType, content);
 }
Example #34
0
 public Comment(CommentType commentType, TextLocation startLocation, TextLocation endLocation)
 {
     this.CommentType   = commentType;
     this.startLocation = startLocation;
     this.endLocation   = endLocation;
 }
Example #35
0
        /* Function: ScoreUsingInterpretation
         * A function used by <ScoreInterpretation()> to determine the C and S fields of the score for the passed interpretation
         * using only the using statements.  Only those fields and the trailing 1 will be set in the returned score.  If the interpretation
         * doesn't match using the using statements, it will return zero.
         */
        private long ScoreUsingInterpretation(Topic topic, Link link, SymbolString interpretation)
        {
            // --C----- -------- -------- -SSSSSSS SSS----- -------- -------- -------1
            // C - Whether the topic and link's capitalization match if it matters to the language.
            // S - How high on the scope list the symbol match is.

            IList <UsingString> usingStrings = link.Context.GetUsingStatements();

            if (usingStrings == null || usingStrings.Count == 0)
            {
                return(0);
            }

            Language    topicLanguage = EngineInstance.Languages.FromID(topic.LanguageID);
            CommentType commentType   = EngineInstance.CommentTypes.FromID(topic.CommentTypeID);


            // Values of C:
            //		Natural Docs links:
            //			1 - Topic is documentation, case matches
            //			1 - Topic is documentation, case differs
            //			1 - Topic is file, case matches
            //			1 - Topic is file, case differs
            //			1 - Topic is code, topic language is case sensitive, case matches
            //			0 - Topic is code, topic language is case sensitive, case differs
            //			1 - Topic is code, topic language is case insensitive, case matches
            //			1 - Topic is code, topic language is case insensitive, case differs
            //		Type/Class Parent links:
            //			Assuming they're the same language...
            //			X - Topic is documentation, case matches
            //			X - Topic is documentation, case differs
            //			X - Topic is file, case matches
            //			X - Topic is file, case differs
            //			1 - Topic is code, language is case sensitive, case matches
            //			X - Topic is code, language is case sensitive, case differs
            //			1 - Topic is code, language is case insensitive, case matches
            //			1 - Topic is code, language is case insensitive, case differs

            bool caseFlagged;
            bool caseRequired;

            if (link.Type == LinkType.NaturalDocs)
            {
                caseRequired = false;
                caseFlagged  = (commentType.Flags.Code && topicLanguage.CaseSensitive);
            }
            else
            {
                if (commentType.Flags.Code == false)
                {
                    return(0);
                }

                caseRequired = topicLanguage.CaseSensitive;
                caseFlagged  = false;
            }


            // Find the scope list index to start at, since the actual scopes come before the using statements.
            //    Scope list:
            //       0 - A.B.C.Link
            //       1 - A.B.Link
            //       2 - A.Link
            //       3 - Link
            //       4 - Link + first using statement
            // So if there's a scope, the starting index is the number of separators in the scope + 2.  Otherwise it's one.
            //    Scope list:
            //       0 - Link
            //       1 - Link + first using statement

            int scopeListIndex;

            if (link.Context.ScopeIsGlobal)
            {
                scopeListIndex = 1;
            }
            else
            {
                int scopeIndex, scopeLength;
                link.Context.GetRawTextScope(out scopeIndex, out scopeLength);

                scopeListIndex = link.Context.RawText.Count(SymbolString.SeparatorChar, scopeIndex, scopeLength) + 2;
            }


            // Go through each using statement looking for the best score.

            long bestScore = 0;

            foreach (var usingString in usingStrings)
            {
                SymbolString newInterpretation;
                bool         newInterpretationPossible;

                if (usingString.Type == UsingString.UsingType.AddPrefix)
                {
                    newInterpretation         = usingString.PrefixToAdd + interpretation;
                    newInterpretationPossible = true;
                }
                else if (usingString.Type == UsingString.UsingType.ReplacePrefix)
                {
                    SymbolString prefixToRemove       = usingString.PrefixToRemove;
                    string       prefixToRemoveString = prefixToRemove.ToString();
                    string       interpretationString = interpretation.ToString();

                    if (interpretationString.Length > prefixToRemoveString.Length &&
                        interpretation.StartsWith(prefixToRemove, !caseRequired))
                    {
                        newInterpretation         = usingString.PrefixToAdd + SymbolString.FromExportedString(interpretationString.Substring(prefixToRemoveString.Length + 1));
                        newInterpretationPossible = true;
                    }
                    else
                    {
                        newInterpretation         = new SymbolString();                  // to make the compiler shut up
                        newInterpretationPossible = false;
                    }
                }
                else
                {
                    throw new NotImplementedException();
                }


                if (newInterpretationPossible && string.Compare(newInterpretation, topic.Symbol, !caseRequired) == 0)
                {
                    // --C----- -------- -------- -SSSSSSS SSS----- -------- -------- -------1
                    // Our baseline.

                    long score = 0x0000000000000001;


                    // --C----- -------- -------- -SSSSSSS SSS----- -------- -------- -------=
                    // Encode the scope index.  We want lower indexes to have a higher score.

                    if (scopeListIndex > 1023)
                    {
                        scopeListIndex = 1023;
                    }

                    long scopeListBits = 1023 - scopeListIndex;
                    scopeListBits <<= 29;

                    score |= scopeListBits;


                    // --C----- -------- -------- -======= ===----- -------- -------- -------=
                    // Determine C.  If C is set we can quit early because it would be impossible for a later using statement to
                    // generate a higher score.

                    if (!caseFlagged || string.Compare(newInterpretation, topic.Symbol, false) == 0)
                    {
                        score    |= 0x2000000000000000;
                        bestScore = score;
                        break;
                    }
                    else
                    {
                        if (score > bestScore)
                        {
                            bestScore = score;
                        }
                    }
                }

                scopeListIndex++;
            }

            return(bestScore);
        }
Example #36
0
 /// <summary>
 /// List of comments based on type for a single page.
 /// </summary>
 /// <param name="commentType">
 /// The comment type.
 /// </param>
 /// <param name="page">
 /// The current page.
 /// </param>
 /// <returns>
 /// A list of JSON comments.
 /// </returns>
 public static List <JsonComment> GetComments(CommentType commentType, int page)
 {
     return(GetComments(commentType, BlogSettings.Instance.CommentsPerPage, page));
 }
Example #37
0
        /// <summary>
        /// List of comments based on type for a single page.
        /// </summary>
        /// <param name="commentType">
        /// The comment type.
        /// </param>
        /// <param name="pageSize">
        /// The number of comments per page.
        /// </param>
        /// <param name="page">
        /// The current page.
        /// </param>
        /// <returns>
        /// A list of JSON comments.
        /// </returns>
        public static List <JsonComment> GetComments(CommentType commentType, int pageSize, int page)
        {
            var cntTo   = page * pageSize;
            var cntFrom = cntTo - pageSize;
            var cnt     = 0;

            var allComments  = new List <Comment>();
            var pageComments = new List <JsonComment>();

            foreach (var p in Post.Posts)
            {
                switch (commentType)
                {
                case CommentType.Pending:
                    allComments.AddRange(p.NotApprovedComments);
                    break;

                case CommentType.Pingback:
                    allComments.AddRange(p.Pingbacks);
                    break;

                case CommentType.Spam:
                    allComments.AddRange(p.SpamComments);
                    break;

                default:
                    allComments.AddRange(p.ApprovedComments);
                    break;
                }
            }

            allComments.Sort((x, y) => DateTime.Compare(y.DateCreated, x.DateCreated));

            // TODO: find a way to better handle deleting last comment on the last page
            // below is not working properly; after moving to the next page and deleting
            // another comment there, things get nasty
            if (allComments.Count > 0 && allComments.Count == cntFrom && page > 1)
            {
                // removed last comment(s) on the page
                // need to shift one page back

                //var context = System.Web.HttpContext.Current;
                //if (context.Request.Cookies["CommentPagerCurrentPage"] != null)
                //    context.Request.Cookies["CommentPagerCurrentPage"].Value = (page - 1).ToString();

                //return GetComments(commentType, page - 1);
            }

            foreach (var c in allComments)
            {
                cnt++;
                if (cnt <= cntFrom || cnt > cntTo)
                {
                    continue;
                }

                pageComments.Add(CreateJsonCommentFromComment(c));
            }

            currentPage = page;
            commCnt     = cnt;

            return(pageComments);
        }
Example #38
0
        /* Function: ScoreScopeInterpretation
         * A function used by <ScoreInterpretation()> to determine the C and S fields of the score for the passed interpretation
         * using only the scope.  Only those fields and the trailing 1 will be set in the returned score.  If the interpretation doesn't
         * match using the scope, it will return zero.
         */
        private long ScoreScopeInterpretation(Topic topic, Link link, SymbolString interpretation)
        {
            // --C----- -------- -------- -SSSSSSS SSS----- -------- -------- -------1
            // C - Whether the topic and link's capitalization match if it matters to the language.
            // S - How high on the scope list the symbol match is.

            Language    topicLanguage = EngineInstance.Languages.FromID(topic.LanguageID);
            CommentType commentType   = EngineInstance.CommentTypes.FromID(topic.CommentTypeID);


            // Values of C:
            //		Natural Docs links:
            //			1 - Topic is documentation, case matches
            //			1 - Topic is documentation, case differs
            //			1 - Topic is file, case matches
            //			1 - Topic is file, case differs
            //			1 - Topic is code, topic language is case sensitive, case matches
            //			0 - Topic is code, topic language is case sensitive, case differs
            //			1 - Topic is code, topic language is case insensitive, case matches
            //			1 - Topic is code, topic language is case insensitive, case differs
            //		Type/Class Parent links:
            //			Assuming they're the same language...
            //			X - Topic is documentation, case matches
            //			X - Topic is documentation, case differs
            //			X - Topic is file, case matches
            //			X - Topic is file, case differs
            //			1 - Topic is code, language is case sensitive, case matches
            //			X - Topic is code, language is case sensitive, case differs
            //			1 - Topic is code, language is case insensitive, case matches
            //			1 - Topic is code, language is case insensitive, case differs

            bool caseFlagged;
            bool caseRequired;

            if (link.Type == LinkType.NaturalDocs)
            {
                caseRequired = false;
                caseFlagged  = (commentType.Flags.Code && topicLanguage.CaseSensitive);
            }
            else
            {
                if (commentType.Flags.Code == false)
                {
                    return(0);
                }

                caseRequired = topicLanguage.CaseSensitive;
                caseFlagged  = false;
            }


            // --C----- -------- -------- -SSSSSSS SSS----- -------- -------- -------1
            // Our baseline.

            long score = 0x0000000000000001;

            int scopeListIndex;


            // If we match as a global symbol...

            if (string.Compare(topic.Symbol, interpretation, !caseRequired) == 0)
            {
                if (link.Context.ScopeIsGlobal)
                {
                    scopeListIndex = 0;
                }
                else
                {
                    // Conceptually, we had to walk down the entire hierachy to get to global:
                    //    Scope A.B.C = A.B.C.Name, A.B.Name, A.Name, Name = Index 3
                    // so the scope list index is the number of dividers in the scope plus one.

                    int linkScopeIndex, linkScopeLength;
                    link.Context.GetRawTextScope(out linkScopeIndex, out linkScopeLength);

                    int dividers = link.Context.RawText.Count(SymbolString.SeparatorChar, linkScopeIndex, linkScopeLength);
                    scopeListIndex = dividers + 1;
                }

                // --C----- -------- -------- -SSSSSSS SSS----- -------- -------- -------=
                // Apply C
                if (!caseFlagged || string.Compare(topic.Symbol, interpretation, false) == 0)
                {
                    score |= 0x2000000000000000;
                }
            }


            // If the topic ends with the interepretation, such as "A.B.C.Name" and "Name"...

            else if (topic.Symbol.EndsWith(interpretation, !caseRequired))
            {
                string topicSymbolString = topic.Symbol.ToString();
                int    topicScopeIndex   = 0;
                int    topicScopeLength  = topicSymbolString.Length - interpretation.ToString().Length - 1;

                // See if the link's scope can completely encompass the remaining scope:
                //    Topic A.B.C.Name + Link Name + Link Scope A.B.C = yes
                //    Topic A.B.C.Name + Link Name + Link Scope A.B = no
                //    Topic A.B.C.Name + Link Name + Link Scope A.B.C.D = yes, it can walk up the hierarchy
                //    Topic A.B.C.Name + Link Name + Link Scope A.B.CC = no, can't split a word
                //    Topic A.B.C.Name + Link Name + Link Scope X.Y.Z = no

                string linkContextString = link.Context.RawText;
                int    linkScopeIndex, linkScopeLength;
                link.Context.GetRawTextScope(out linkScopeIndex, out linkScopeLength);

                // If the remaining topic scope is a substring or equal to the link scope...
                if (topicScopeLength <= linkScopeLength &&
                    string.Compare(linkContextString, linkScopeIndex, topicSymbolString, topicScopeIndex, topicScopeLength, !caseRequired) == 0)
                {
                    if (topicScopeLength == linkScopeLength)
                    {
                        // If it's an exact match, this is considered the first entry on our conceptual scope list.
                        scopeListIndex = 0;
                    }

                    else                     // topicScopeLength < linkScopeLength
                    {
                        // If the scope was a substring, the next character needs to be a separator so we don't split a word.
                        if (linkContextString[topicScopeLength] != SymbolString.SeparatorChar)
                        {
                            return(0);
                        }

                        // The scope list index is the number of separators we trimmed off:
                        //    Link scope: A.B.C.D
                        //    Remaining topic scope: A.B
                        //    Scope list:
                        //       0 - A.B.C.D
                        //       1 - A.B.C
                        //       2 - A.B
                        //       3 - A
                        //       4 - global
                        scopeListIndex = linkContextString.Count(SymbolString.SeparatorChar, linkScopeIndex + topicScopeLength,
                                                                 linkScopeLength - topicScopeLength);
                    }

                    // --C----- -------- -------- -SSSSSSS SSS----- -------- -------- -------=
                    // Apply C
                    if (!caseFlagged ||
                        (topicSymbolString.EndsWith(interpretation) == true &&
                         string.Compare(linkContextString, linkScopeIndex, topicSymbolString, topicScopeIndex, topicScopeLength, false) == 0))
                    {
                        score |= 0x2000000000000000;
                    }
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0);
            }


            // --=----- -------- -------- -SSSSSSS SSS----- -------- -------- -------=
            // Encode the scope index.  We want lower indexes to have a higher score.

            if (scopeListIndex > 1023)
            {
                scopeListIndex = 1023;
            }

            long scopeListBits = 1023 - scopeListIndex;

            scopeListBits <<= 29;

            score |= scopeListBits;

            return(score);
        }
Example #39
0
 public static string GetCommentGroupName(CommentType type, string count)
 {
     return(count + GetString("CommentItem") + (type == CommentType.Long ? GetString("LongComment") : GetString("ShortComment")));
 }
Example #40
0
 public static void TypeLabel(CommentType value)
 {
     GUIUtils.ColoredLabel(value.ToString(), GetTypeColor(value));
 }
Example #41
0
 /// <summary>
 /// Создает экземляр класса <name>DisciplineChoiceApplication</name>
 /// </summary>
 /// <param name="electivesBlock">Элективный блок</param>
 /// <param name="discipline">Дисциплина</param>
 /// <param name="student">Студент</param>
 /// <param name="priority">Приоритет, присвоенный дисциплине</param>
 /// <param name="status">Статус заявления</param>
 public DisciplineChoiceApplication(ElectivesBlock electivesBlock, Discipline discipline,
                                    Student student, int priority, Status status, CommentType comment)
 {
     ElectivesBlock = electivesBlock;
     Discipline     = discipline;
     Student        = student;
     Priority       = priority;
     Status         = status;
     Comment        = comment;
 }
Example #42
0
 public Comment(string content, CommentType type = CommentType.SingleLine)
 {
     this.CommentType = type;
     this.Content     = content;
 }