コード例 #1
0
ファイル: View.cs プロジェクト: Qorpent/Npgsql2
        internal View(string viewName, DbConnection connection, ViewDesignerDoc parent)
        {
            _owner = parent;
              _name = viewName;
              _oldname = viewName;
              _catalog = connection.Database;
              _connection = connection;
              _owner.Name = _name;

              if (String.IsNullOrEmpty(viewName) == false)
              {
            using (DataTable tbl = connection.GetSchema("Views", new string[] { Catalog, null, Name }))
            {
              if (tbl.Rows.Count > 0)
              {
            _sql = tbl.Rows[0]["VIEW_DEFINITION"].ToString();

            StringBuilder builder = new StringBuilder();
            builder.Append(_sql);
            builder.AppendLine(";");

            _triggers.Clear();
            _oldtriggers.Clear();

            using (DataTable ttbl = _connection.GetSchema("Triggers", new string[] { Catalog, null, Name }))
            {
              foreach (DataRow row in ttbl.Rows)
              {
                ViewTrigger t = new ViewTrigger(this, row);
                _triggers.Add(t);
                _oldtriggers.Add(((ICloneable)t).Clone() as ViewTrigger);

                builder.AppendFormat("{0};\r\n", t.OriginalSql);
              }
            }
            _oldsql = builder.ToString();
              }
              else
              {
            _oldname = null;
              }
            }
              }
        }
コード例 #2
0
        private void DesignView(int itemId, string viewName)
        {
            Microsoft.VisualStudio.OLE.Interop.IServiceProvider provider = DataViewHierarchyAccessor.ServiceProvider as Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
              IVsUIShell shell = DataViewHierarchyAccessor.ServiceProvider.GetService(typeof(IVsUIShell)) as IVsUIShell;
              IVsUIHierarchy hier = DataViewHierarchyAccessor.Hierarchy;
              IVsWindowFrame frame;

              if (shell != null)
              {
            ViewDesignerDoc form = new ViewDesignerDoc(itemId, DataViewHierarchyAccessor, viewName);
            IntPtr formptr = System.Runtime.InteropServices.Marshal.GetIUnknownForObject(form);
            Guid empty = Guid.Empty;
            FakeHierarchy fake = new FakeHierarchy(form, hier);

            int code = shell.CreateDocumentWindow(
              0, // (uint)(__VSCREATEDOCWIN.CDW_fCreateNewWindow | __VSCREATEDOCWIN.CDW_RDTFLAGS_MASK) | (uint)(_VSRDTFLAGS.RDT_CanBuildFromMemory | _VSRDTFLAGS.RDT_NonCreatable | _VSRDTFLAGS.RDT_VirtualDocument | _VSRDTFLAGS.RDT_DontAddToMRU),
              form.Name, fake, (uint)itemId, formptr, formptr, ref empty, null, ref guidViewDesignContext, provider, "", form.Caption, null, out frame);

            if (frame != null)
            {
              object ret;
              int prop = (int)__VSFPROPID.VSFPROPID_Caption;

              code = frame.GetProperty(prop, out ret);

              code = frame.Show();
            }
              }
        }