Пример #1
0
        public static List <Note> GetNotes(int projectID, List <int> attributeIDs)
        {
            MySqlCommand com      = new MySqlCommand();
            List <Note>  noteList = new List <Note>();
            string       query    = @"SELECT DISTINCT a.*, c.*
                                FROM notes AS a
                                LEFT JOIN attributetonote AS b ON a.noteID = b.noteID
                                LEFT JOIN attributes AS c ON b.attributeID = c.attributeID
                                WHERE a.projectID = @projectID ";

            if (attributeIDs != null && attributeIDs.Count > 0)
            {
                StringBuilder attributeIDArraySb = new StringBuilder();
                foreach (int i in attributeIDs)
                {
                    attributeIDArraySb.Append(i + ",");
                }
                string arrayStr = attributeIDArraySb.ToString().TrimEnd(',');
                query += "AND b.attributeID IN (" + arrayStr + ")";
            }
            com.CommandText = query;
            com.CommandType = System.Data.CommandType.Text;
            com.Parameters.AddWithValue("@projectID", projectID);
            DataTable dt = RunNotesQuery(com);

            foreach (DataRow r in dt.Rows)
            {
                Note note = new Note();
                note.noteID      = Convert.ToInt32(r[0].ToString());
                note.projectID   = Convert.ToInt32(r[1].ToString());
                note.noteText    = r[2].ToString();
                note.noteCreated = Convert.ToDateTime(r[3].ToString());
                note.lastEdit    = Convert.ToDateTime(r[4].ToString());
                NoteAttribute noteAttribute = new NoteAttribute();
                try
                {
                    noteAttribute.attributeID   = Convert.ToInt32(r[5].ToString());
                    noteAttribute.attributeName = r[6].ToString();
                }
                catch { /*note without any attributes*/ }
                note.attributes = new List <NoteAttribute>()
                {
                    noteAttribute
                };
                List <Note> tempNoteList = noteList.Where(n => n.noteID == note.noteID).ToList();

                if (tempNoteList.Count > 0)
                {
                    tempNoteList[0].attributes.Add(noteAttribute);
                }
                else
                {
                    noteList.Add(note);
                }
            }

            return(noteList);
        }
Пример #2
0
 private void EnsureNoteData()
 {
     if (_note == null)
     {
         _note   = attribute as NoteAttribute;
         _type   = (MessageType)(int)_note.Type;
         _height = EditorStyles.helpBox.CalcSize(new GUIContent(_note.Text)).y;
     }
 }
Пример #3
0
        public static string GetNote(IEnumerable <object> attributes)
        {
            NoteAttribute attribute = CustomAttributeHelpers.GetAttribute <NoteAttribute>(attributes);

            if (attribute == null)
            {
                return(null);
            }
            return(attribute.get_Text());
        }
        public TagGroupDocumentation(ResourceKeyStack messagePath, ITagGroup tagGroup, IList <Func <ITag, TagDocumentation, bool> > specials, Dictionary <int, TagDocumentation> tagDictionary)
        {
            _messagePath   = messagePath.BranchFor(tagGroup);
            _name          = tagGroup.Name;
            _specials      = specials;
            _tagDictionary = tagDictionary;
            _tags          = new List <int>();
            var tagGroupType = tagGroup.GetType();

            _description = DescriptionAttribute.Harvest(tagGroupType) ?? _messagePath.Description;

            _title = TitleAttribute.HarvestTagLibrary(tagGroupType);
            foreach (ITag _tag in tagGroup)
            {
                var hash = _tag.GetType().GetHashCode();
                if (!_tagDictionary.ContainsKey(hash))
                {
                    _tagDictionary[hash] = null;
                    var tagDoc = new TagDocumentation(_messagePath, _tag, _specials, _tagDictionary);
                    _tagDictionary[hash] = tagDoc;
                }
                _tags.Add(hash);
            }
            if (ExampleAttribute.Harvest(tagGroupType))
            {
                _examples.AddRange(ExampleAttribute.HarvestTags(tagGroupType));
            }
            if (HasExample.Has(tagGroupType))
            {
                _examples.Add(new ExampleAttribute(_messagePath.Example));
            }
            if (NoteAttribute.Harvest(tagGroupType))
            {
                _notes.AddRange(NoteAttribute.HarvestTags(tagGroupType));
            }
            if (HasNote.Has(tagGroupType))
            {
                _notes.Add(new NoteAttribute(_messagePath.Note));
            }
        }
Пример #5
0
        public TagDocumentation(ResourceKeyStack messagePath, ITag tag, IList <Func <ITag, TagDocumentation, bool> > specials, Dictionary <int, TagDocumentation> tagDictionary)
        {
            _tagDictionary = tagDictionary;
            _messagePath   = messagePath.BranchFor(tag);
            _name          = tag.TagName;

            var tagType = tag.GetType();

            _category = CategoryHelper.GetCategory(tagType);

            _list       = new List <PropertyDocumentation>();
            _nested     = new List <int>();
            _methods    = new List <FunctionDocumentation>();
            TagBodyMode = tag.TagBodyMode;

            foreach (var property in tagType.GetCustomAttributes <PropertyAttribute>())
            {
                _list.Add(new PropertyDocumentation(_messagePath, property));
            }

            foreach (var property in tagType.GetProperties(
                         BindingFlags.Instance |
                         BindingFlags.Public |
                         BindingFlags.SetProperty |
                         BindingFlags.FlattenHierarchy))
            {
                if (Equals(property.PropertyType, typeof(ITagAttribute)) &&
                    !IsInternal(property))
                {
                    _list.Add(new PropertyDocumentation(_messagePath, property));
                }
            }
            var extendingTag = tag as ITagExtendTagLib;

            if (extendingTag != null)
            {
                foreach (var nested in extendingTag.TagLibExtension)
                {
                    var hash = nested.GetType().GetHashCode();
                    if (!_tagDictionary.ContainsKey(hash))
                    {
                        _tagDictionary[hash] = null;
                        var tagDoc = new TagDocumentation(_messagePath, nested, specials, _tagDictionary);
                        _tagDictionary[hash] = tagDoc;
                    }
                    _nested.Add(hash);
                }
            }
            var instanceDocumentation = tag as IInstanceTagDocumentation;

            if (instanceDocumentation != null)
            {
                _description = instanceDocumentation.Description;
                _examples.AddRange(instanceDocumentation.Examples ?? new ExampleAttribute[] {});
                _notes.AddRange(instanceDocumentation.Notes ?? new NoteAttribute[] {});
            }
            else
            {
                _description = DescriptionAttribute.Harvest(tagType) ?? _messagePath.Description;

                if (ExampleAttribute.Harvest(tagType))
                {
                    _examples.AddRange(ExampleAttribute.HarvestTags(tagType));
                }
                if (HasExample.Has(tagType))
                {
                    _examples.Add(new ExampleAttribute(_messagePath.Example));
                }
                if (NoteAttribute.Harvest(tagType))
                {
                    _notes.AddRange(NoteAttribute.HarvestTags(tagType));
                }
                if (HasNote.Has(tagType))
                {
                    _notes.Add(new NoteAttribute(_messagePath.Note));
                }
            }
        }