예제 #1
0
        public static IDbConnection GetConnection(DSRefNavigator navigator, out string type)
        {
            type = null;
            try
            {
                if (navigator != null)
                {
                    IVsDataExplorerConnectionManager dataConnectionsService =
                        (IVsDataExplorerConnectionManager)Package.GetGlobalService(typeof(IVsDataExplorerConnectionManager));

                    string itemName = navigator.GetConnectionName();

                    if (itemName != null)
                    {
                        var connection = dataConnectionsService.Connections[itemName];

                        return((IDbConnection)connection.Connection.GetLockedProviderObject());

                        //int iConn; // = dataConnectionsService.GetConnectionIndex(itemName);
                        //DataViewHierarchyAccessor dataViewHierarchy = null;

                        //for(iConn = 0; iConn < dataConnectionsService.Connections.Count; iConn++)
                        //{
                        //    DataViewHierarchyAccessor hierarchyAccessor =
                        //        new DataViewHierarchyAccessor((IVsUIHierarchy) dataConnectionsService.GetConnectionHierarchy(iConn));
                        //    try
                        //    {
                        //        if (hierarchyAccessor.Connection.DisplayConnectionString == itemName)
                        //        {
                        //            dataViewHierarchy = hierarchyAccessor;
                        //            break;
                        //        }
                        //    }
                        //    catch
                        //    {
                        //    }
                        //}
                        //if (dataViewHierarchy != null)
                        //{
                        //    DataConnection connection = dataViewHierarchy.Connection;
                        //    if (connection != null && connection.ConnectionSupport.ProviderObject != null)
                        //    {
                        //        type = connection.ConnectionSupport.ProviderObject.GetType().FullName;
                        //        return (IDbConnection) connection.ConnectionSupport.ProviderObject;
                        //    }
                        //}
                    }
                }
            }
            catch
            {
            }

            return(null);
        }
예제 #2
0
		public static IDbConnection GetConnection(DSRefNavigator navigator, out string type)
		{
			type = null;
			try
			{
				if (navigator != null)
				{
					IVsDataExplorerConnectionManager dataConnectionsService =
						(IVsDataExplorerConnectionManager) Package.GetGlobalService(typeof(IVsDataExplorerConnectionManager));

					string itemName = navigator.GetConnectionName();

					if (itemName != null)
					{
						var connection = dataConnectionsService.Connections[itemName];

						return (IDbConnection) connection.Connection.GetLockedProviderObject();

						//int iConn; // = dataConnectionsService.GetConnectionIndex(itemName);
						//DataViewHierarchyAccessor dataViewHierarchy = null;

						//for(iConn = 0; iConn < dataConnectionsService.Connections.Count; iConn++)
						//{
						//    DataViewHierarchyAccessor hierarchyAccessor =
						//        new DataViewHierarchyAccessor((IVsUIHierarchy) dataConnectionsService.GetConnectionHierarchy(iConn));
						//    try
						//    {
						//        if (hierarchyAccessor.Connection.DisplayConnectionString == itemName)
						//        {
						//            dataViewHierarchy = hierarchyAccessor;
						//            break;
						//        }
						//    }
						//    catch
						//    {
						//    }
						//}
						//if (dataViewHierarchy != null)
						//{
						//    DataConnection connection = dataViewHierarchy.Connection;
						//    if (connection != null && connection.ConnectionSupport.ProviderObject != null)
						//    {
						//        type = connection.ConnectionSupport.ProviderObject.GetType().FullName;
						//        return (IDbConnection) connection.ConnectionSupport.ProviderObject;
						//    }
						//}
					}
				}
			}
			catch
			{
			}

			return null;
		}
예제 #3
0
 public DSRefNode(IntPtr pointer, DSRefNavigator navigator)
 {
     _pointer   = pointer;
     _navigator = navigator;
 }
예제 #4
0
 public DSRefNode(IntPtr pointer, DSRefNavigator navigator)
 {
     _pointer = pointer;
     _navigator = navigator;
 }