示例#1
0
        public static bool Execute(OpenedFileManager openedFileManager)
        {
            var accessor = new ObjectAccessor();
            var objects  = accessor.GetObjects();

            var strToUrn = new Dictionary <string, Urn>();
            var items    = new List <Common.ChooseItem.Item>();

            foreach (var obj in objects)
            {
                strToUrn[obj.fullName] = obj.urn;
                var searchTerms = CreateSearchTerms(obj);
                items.Add(new Common.ChooseItem.Item(obj.fullName, obj.type, searchTerms));
            }

            string title  = "Choose object on " + accessor.ServerName();
            var    choose = new Common.ChooseItem(items.ToArray(), title);

            if (choose.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return(false);
            }

            string result    = choose.Result();
            Urn    resultUrn = strToUrn[result];
            string body      = accessor.GetObjectText(resultUrn);

            openedFileManager.Open(accessor.ServerName(), result, resultUrn, body);
            return(true);
        }
示例#2
0
        static public bool Execute(DTE2 application, OpenedFileManager openedFileManager)
        {
            Document doc = application.ActiveDocument;

            if (doc == null)
            {
                return(false);
            }
            TextDocument textDoc = doc.Object("TextDocument") as TextDocument;

            if (textDoc == null)
            {
                return(false);
            }

            var    editPoint = textDoc.StartPoint.CreateEditPoint();
            string text      = editPoint.GetText(textDoc.EndPoint);

            text = text.Replace(Environment.NewLine, "\n");

            int from = textDoc.Selection.ActivePoint.AbsoluteCharOffset - 1;

            while (from > 0 && IsId(text[from - 1]))
            {
                from -= 1;
            }
            int to = from;

            while (to < text.Length && IsId(text[to]))
            {
                to += 1;
            }
            if (from == to)
            {
                return(false);
            }
            string name = text.Substring(from, to - from);

            string database = Common.Connection.GetActiveDatabase(text, from);

            var accessor = new ObjectAccessor();

            ObjectAccessor.ObjectInfo info = accessor.FindObject(name, database);
            if (info == null)
            {
                return(false);
            }

            string body = accessor.GetObjectText(info.urn);

            openedFileManager.Open(accessor.ServerName(), info.fullName, info.urn, body);
            return(true);
        }