diff --git a/src/Microsoft.SqlTools.Hosting/Hosting/IHostedService.cs b/src/Microsoft.SqlTools.Hosting/Hosting/IHostedService.cs index 66d63fdc..25443404 100644 --- a/src/Microsoft.SqlTools.Hosting/Hosting/IHostedService.cs +++ b/src/Microsoft.SqlTools.Hosting/Hosting/IHostedService.cs @@ -52,7 +52,7 @@ namespace Microsoft.SqlTools.Hosting protected IMultiServiceProvider ServiceProvider { get; private set; } - public void SetServiceProvider(IMultiServiceProvider provider) + public virtual void SetServiceProvider(IMultiServiceProvider provider) { ServiceProvider = provider; } diff --git a/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs b/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs index 9901952b..cf48aba0 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs @@ -176,7 +176,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection /// /// Open a connection with the specified ConnectParams /// - public async Task Connect(ConnectParams connectionParams) + public virtual async Task Connect(ConnectParams connectionParams) { // Validate parameters ConnectionCompleteParams validationResults = ValidateConnectParams(connectionParams); diff --git a/src/Microsoft.SqlTools.ServiceLayer/HostLoader.cs b/src/Microsoft.SqlTools.ServiceLayer/HostLoader.cs index aa6fac63..a69eec00 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/HostLoader.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/HostLoader.cs @@ -11,6 +11,7 @@ using Microsoft.SqlTools.ServiceLayer.EditData; using Microsoft.SqlTools.ServiceLayer.Hosting; using Microsoft.SqlTools.ServiceLayer.LanguageServices; using Microsoft.SqlTools.ServiceLayer.Metadata; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; using Microsoft.SqlTools.ServiceLayer.QueryExecution; using Microsoft.SqlTools.ServiceLayer.Scripting; using Microsoft.SqlTools.ServiceLayer.SqlContext; @@ -85,6 +86,7 @@ namespace Microsoft.SqlTools.ServiceLayer serviceProvider.RegisterSingleService(ScriptingService.Instance); InitializeHostedServices(serviceProvider, serviceHost); + serviceHost.ServiceProvider = serviceProvider; serviceHost.InitializeRequestHandlers(); } diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs index 049a67af..c8ee4d09 100755 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs @@ -853,6 +853,1310 @@ namespace Microsoft.SqlTools.ServiceLayer } } + public static string TreeNodeError + { + get + { + return Keys.GetString(Keys.TreeNodeError); + } + } + + public static string ServerNodeConnectionError + { + get + { + return Keys.GetString(Keys.ServerNodeConnectionError); + } + } + + public static string SchemaHierarchy_Aggregates + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Aggregates); + } + } + + public static string SchemaHierarchy_ServerRoles + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerRoles); + } + } + + public static string SchemaHierarchy_ApplicationRoles + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ApplicationRoles); + } + } + + public static string SchemaHierarchy_Assemblies + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Assemblies); + } + } + + public static string SchemaHierarchy_AssemblyFiles + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_AssemblyFiles); + } + } + + public static string SchemaHierarchy_AsymmetricKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_AsymmetricKeys); + } + } + + public static string SchemaHierarchy_DatabaseAsymmetricKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DatabaseAsymmetricKeys); + } + } + + public static string SchemaHierarchy_DataCompressionOptions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DataCompressionOptions); + } + } + + public static string SchemaHierarchy_Certificates + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Certificates); + } + } + + public static string SchemaHierarchy_FileTables + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_FileTables); + } + } + + public static string SchemaHierarchy_DatabaseCertificates + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DatabaseCertificates); + } + } + + public static string SchemaHierarchy_CheckConstraints + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_CheckConstraints); + } + } + + public static string SchemaHierarchy_Columns + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Columns); + } + } + + public static string SchemaHierarchy_Constraints + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Constraints); + } + } + + public static string SchemaHierarchy_Contracts + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Contracts); + } + } + + public static string SchemaHierarchy_Credentials + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Credentials); + } + } + + public static string SchemaHierarchy_ErrorMessages + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ErrorMessages); + } + } + + public static string SchemaHierarchy_ServerRoleMembership + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerRoleMembership); + } + } + + public static string SchemaHierarchy_DatabaseOptions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DatabaseOptions); + } + } + + public static string SchemaHierarchy_DatabaseRoles + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DatabaseRoles); + } + } + + public static string SchemaHierarchy_RoleMemberships + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_RoleMemberships); + } + } + + public static string SchemaHierarchy_DatabaseTriggers + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DatabaseTriggers); + } + } + + public static string SchemaHierarchy_DefaultConstraints + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DefaultConstraints); + } + } + + public static string SchemaHierarchy_Defaults + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Defaults); + } + } + + public static string SchemaHierarchy_Sequences + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Sequences); + } + } + + public static string SchemaHierarchy_Endpoints + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Endpoints); + } + } + + public static string SchemaHierarchy_EventNotifications + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_EventNotifications); + } + } + + public static string SchemaHierarchy_ServerEventNotifications + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerEventNotifications); + } + } + + public static string SchemaHierarchy_ExtendedProperties + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ExtendedProperties); + } + } + + public static string SchemaHierarchy_FileGroups + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_FileGroups); + } + } + + public static string SchemaHierarchy_ForeignKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ForeignKeys); + } + } + + public static string SchemaHierarchy_FullTextCatalogs + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_FullTextCatalogs); + } + } + + public static string SchemaHierarchy_FullTextIndexes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_FullTextIndexes); + } + } + + public static string SchemaHierarchy_Functions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Functions); + } + } + + public static string SchemaHierarchy_Indexes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Indexes); + } + } + + public static string SchemaHierarchy_InlineFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_InlineFunctions); + } + } + + public static string SchemaHierarchy_Keys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Keys); + } + } + + public static string SchemaHierarchy_LinkedServers + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_LinkedServers); + } + } + + public static string SchemaHierarchy_LinkedServerLogins + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_LinkedServerLogins); + } + } + + public static string SchemaHierarchy_Logins + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Logins); + } + } + + public static string SchemaHierarchy_MasterKey + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_MasterKey); + } + } + + public static string SchemaHierarchy_MasterKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_MasterKeys); + } + } + + public static string SchemaHierarchy_MessageTypes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_MessageTypes); + } + } + + public static string SchemaHierarchy_MultiSelectFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_MultiSelectFunctions); + } + } + + public static string SchemaHierarchy_Parameters + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Parameters); + } + } + + public static string SchemaHierarchy_PartitionFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_PartitionFunctions); + } + } + + public static string SchemaHierarchy_PartitionSchemes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_PartitionSchemes); + } + } + + public static string SchemaHierarchy_Permissions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Permissions); + } + } + + public static string SchemaHierarchy_PrimaryKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_PrimaryKeys); + } + } + + public static string SchemaHierarchy_Programmability + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Programmability); + } + } + + public static string SchemaHierarchy_Queues + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Queues); + } + } + + public static string SchemaHierarchy_RemoteServiceBindings + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_RemoteServiceBindings); + } + } + + public static string SchemaHierarchy_ReturnedColumns + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ReturnedColumns); + } + } + + public static string SchemaHierarchy_Roles + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Roles); + } + } + + public static string SchemaHierarchy_Routes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Routes); + } + } + + public static string SchemaHierarchy_Rules + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Rules); + } + } + + public static string SchemaHierarchy_Schemas + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Schemas); + } + } + + public static string SchemaHierarchy_Security + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Security); + } + } + + public static string SchemaHierarchy_ServerObjects + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerObjects); + } + } + + public static string SchemaHierarchy_Management + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Management); + } + } + + public static string SchemaHierarchy_ServerTriggers + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerTriggers); + } + } + + public static string SchemaHierarchy_ServiceBroker + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServiceBroker); + } + } + + public static string SchemaHierarchy_Services + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Services); + } + } + + public static string SchemaHierarchy_Signatures + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Signatures); + } + } + + public static string SchemaHierarchy_LogFiles + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_LogFiles); + } + } + + public static string SchemaHierarchy_Statistics + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Statistics); + } + } + + public static string SchemaHierarchy_Storage + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Storage); + } + } + + public static string SchemaHierarchy_StoredProcedures + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_StoredProcedures); + } + } + + public static string SchemaHierarchy_SymmetricKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SymmetricKeys); + } + } + + public static string SchemaHierarchy_Synonyms + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Synonyms); + } + } + + public static string SchemaHierarchy_Tables + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Tables); + } + } + + public static string SchemaHierarchy_Triggers + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Triggers); + } + } + + public static string SchemaHierarchy_Types + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Types); + } + } + + public static string SchemaHierarchy_UniqueKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_UniqueKeys); + } + } + + public static string SchemaHierarchy_UserDefinedDataTypes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_UserDefinedDataTypes); + } + } + + public static string SchemaHierarchy_UserDefinedTypes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_UserDefinedTypes); + } + } + + public static string SchemaHierarchy_Users + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Users); + } + } + + public static string SchemaHierarchy_Views + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Views); + } + } + + public static string SchemaHierarchy_XmlIndexes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_XmlIndexes); + } + } + + public static string SchemaHierarchy_XMLSchemaCollections + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_XMLSchemaCollections); + } + } + + public static string SchemaHierarchy_UserDefinedTableTypes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_UserDefinedTableTypes); + } + } + + public static string SchemaHierarchy_FilegroupFiles + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_FilegroupFiles); + } + } + + public static string MissingCaption + { + get + { + return Keys.GetString(Keys.MissingCaption); + } + } + + public static string SchemaHierarchy_BrokerPriorities + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_BrokerPriorities); + } + } + + public static string SchemaHierarchy_CryptographicProviders + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_CryptographicProviders); + } + } + + public static string SchemaHierarchy_DatabaseAuditSpecifications + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DatabaseAuditSpecifications); + } + } + + public static string SchemaHierarchy_DatabaseEncryptionKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DatabaseEncryptionKeys); + } + } + + public static string SchemaHierarchy_EventSessions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_EventSessions); + } + } + + public static string SchemaHierarchy_FullTextStopLists + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_FullTextStopLists); + } + } + + public static string SchemaHierarchy_ResourcePools + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ResourcePools); + } + } + + public static string SchemaHierarchy_ServerAudits + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerAudits); + } + } + + public static string SchemaHierarchy_ServerAuditSpecifications + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerAuditSpecifications); + } + } + + public static string SchemaHierarchy_SpatialIndexes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SpatialIndexes); + } + } + + public static string SchemaHierarchy_WorkloadGroups + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_WorkloadGroups); + } + } + + public static string SchemaHierarchy_SqlFiles + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SqlFiles); + } + } + + public static string SchemaHierarchy_ServerFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerFunctions); + } + } + + public static string SchemaHierarchy_SqlType + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SqlType); + } + } + + public static string SchemaHierarchy_ServerOptions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerOptions); + } + } + + public static string SchemaHierarchy_DatabaseDiagrams + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DatabaseDiagrams); + } + } + + public static string SchemaHierarchy_SystemTables + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemTables); + } + } + + public static string SchemaHierarchy_Databases + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_Databases); + } + } + + public static string SchemaHierarchy_SystemContracts + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemContracts); + } + } + + public static string SchemaHierarchy_SystemDatabases + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemDatabases); + } + } + + public static string SchemaHierarchy_SystemMessageTypes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemMessageTypes); + } + } + + public static string SchemaHierarchy_SystemQueues + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemQueues); + } + } + + public static string SchemaHierarchy_SystemServices + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemServices); + } + } + + public static string SchemaHierarchy_SystemStoredProcedures + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemStoredProcedures); + } + } + + public static string SchemaHierarchy_SystemViews + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemViews); + } + } + + public static string SchemaHierarchy_DataTierApplications + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DataTierApplications); + } + } + + public static string SchemaHierarchy_ExtendedStoredProcedures + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ExtendedStoredProcedures); + } + } + + public static string SchemaHierarchy_SystemAggregateFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemAggregateFunctions); + } + } + + public static string SchemaHierarchy_SystemApproximateNumerics + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemApproximateNumerics); + } + } + + public static string SchemaHierarchy_SystemBinaryStrings + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemBinaryStrings); + } + } + + public static string SchemaHierarchy_SystemCharacterStrings + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemCharacterStrings); + } + } + + public static string SchemaHierarchy_SystemCLRDataTypes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemCLRDataTypes); + } + } + + public static string SchemaHierarchy_SystemConfigurationFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemConfigurationFunctions); + } + } + + public static string SchemaHierarchy_SystemCursorFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemCursorFunctions); + } + } + + public static string SchemaHierarchy_SystemDataTypes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemDataTypes); + } + } + + public static string SchemaHierarchy_SystemDateAndTime + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemDateAndTime); + } + } + + public static string SchemaHierarchy_SystemDateAndTimeFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemDateAndTimeFunctions); + } + } + + public static string SchemaHierarchy_SystemExactNumerics + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemExactNumerics); + } + } + + public static string SchemaHierarchy_SystemFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemFunctions); + } + } + + public static string SchemaHierarchy_SystemHierarchyIdFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemHierarchyIdFunctions); + } + } + + public static string SchemaHierarchy_SystemMathematicalFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemMathematicalFunctions); + } + } + + public static string SchemaHierarchy_SystemMetadataFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemMetadataFunctions); + } + } + + public static string SchemaHierarchy_SystemOtherDataTypes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemOtherDataTypes); + } + } + + public static string SchemaHierarchy_SystemOtherFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemOtherFunctions); + } + } + + public static string SchemaHierarchy_SystemRowsetFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemRowsetFunctions); + } + } + + public static string SchemaHierarchy_SystemSecurityFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemSecurityFunctions); + } + } + + public static string SchemaHierarchy_SystemSpatialDataTypes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemSpatialDataTypes); + } + } + + public static string SchemaHierarchy_SystemStringFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemStringFunctions); + } + } + + public static string SchemaHierarchy_SystemSystemStatisticalFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemSystemStatisticalFunctions); + } + } + + public static string SchemaHierarchy_SystemTextAndImageFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemTextAndImageFunctions); + } + } + + public static string SchemaHierarchy_SystemUnicodeCharacterStrings + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemUnicodeCharacterStrings); + } + } + + public static string SchemaHierarchy_AggregateFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_AggregateFunctions); + } + } + + public static string SchemaHierarchy_ScalarValuedFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ScalarValuedFunctions); + } + } + + public static string SchemaHierarchy_TableValuedFunctions + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_TableValuedFunctions); + } + } + + public static string SchemaHierarchy_SystemExtendedStoredProcedures + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SystemExtendedStoredProcedures); + } + } + + public static string SchemaHierarchy_BuiltInType + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_BuiltInType); + } + } + + public static string SchemaHierarchy_BuiltInServerRole + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_BuiltInServerRole); + } + } + + public static string SchemaHierarchy_UserWithPassword + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_UserWithPassword); + } + } + + public static string SchemaHierarchy_SearchPropertyList + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SearchPropertyList); + } + } + + public static string SchemaHierarchy_SecurityPolicies + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SecurityPolicies); + } + } + + public static string SchemaHierarchy_SecurityPredicates + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SecurityPredicates); + } + } + + public static string SchemaHierarchy_ServerRole + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerRole); + } + } + + public static string SchemaHierarchy_SearchPropertyLists + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SearchPropertyLists); + } + } + + public static string SchemaHierarchy_ColumnStoreIndexes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ColumnStoreIndexes); + } + } + + public static string SchemaHierarchy_TableTypeIndexes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_TableTypeIndexes); + } + } + + public static string SchemaHierarchy_ServerInstance + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ServerInstance); + } + } + + public static string SchemaHierarchy_SelectiveXmlIndexes + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SelectiveXmlIndexes); + } + } + + public static string SchemaHierarchy_XmlNamespaces + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_XmlNamespaces); + } + } + + public static string SchemaHierarchy_XmlTypedPromotedPaths + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_XmlTypedPromotedPaths); + } + } + + public static string SchemaHierarchy_SqlTypedPromotedPaths + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_SqlTypedPromotedPaths); + } + } + + public static string SchemaHierarchy_DatabaseScopedCredentials + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DatabaseScopedCredentials); + } + } + + public static string SchemaHierarchy_ExternalDataSources + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ExternalDataSources); + } + } + + public static string SchemaHierarchy_ExternalFileFormats + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ExternalFileFormats); + } + } + + public static string SchemaHierarchy_ExternalResources + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ExternalResources); + } + } + + public static string SchemaHierarchy_ExternalTables + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ExternalTables); + } + } + + public static string SchemaHierarchy_AlwaysEncryptedKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_AlwaysEncryptedKeys); + } + } + + public static string SchemaHierarchy_ColumnMasterKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ColumnMasterKeys); + } + } + + public static string SchemaHierarchy_ColumnEncryptionKeys + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_ColumnEncryptionKeys); + } + } + public static string ConnectionServiceListDbErrorNotConnected(string uri) { return Keys.GetString(Keys.ConnectionServiceListDbErrorNotConnected, uri); @@ -1282,6 +2586,495 @@ namespace Microsoft.SqlTools.ServiceLayer public const string SqlScriptFormatterDecimalMissingPrecision = "SqlScriptFormatterDecimalMissingPrecision"; + public const string TreeNodeError = "TreeNodeError"; + + + public const string ServerNodeConnectionError = "ServerNodeConnectionError"; + + + public const string SchemaHierarchy_Aggregates = "SchemaHierarchy_Aggregates"; + + + public const string SchemaHierarchy_ServerRoles = "SchemaHierarchy_ServerRoles"; + + + public const string SchemaHierarchy_ApplicationRoles = "SchemaHierarchy_ApplicationRoles"; + + + public const string SchemaHierarchy_Assemblies = "SchemaHierarchy_Assemblies"; + + + public const string SchemaHierarchy_AssemblyFiles = "SchemaHierarchy_AssemblyFiles"; + + + public const string SchemaHierarchy_AsymmetricKeys = "SchemaHierarchy_AsymmetricKeys"; + + + public const string SchemaHierarchy_DatabaseAsymmetricKeys = "SchemaHierarchy_DatabaseAsymmetricKeys"; + + + public const string SchemaHierarchy_DataCompressionOptions = "SchemaHierarchy_DataCompressionOptions"; + + + public const string SchemaHierarchy_Certificates = "SchemaHierarchy_Certificates"; + + + public const string SchemaHierarchy_FileTables = "SchemaHierarchy_FileTables"; + + + public const string SchemaHierarchy_DatabaseCertificates = "SchemaHierarchy_DatabaseCertificates"; + + + public const string SchemaHierarchy_CheckConstraints = "SchemaHierarchy_CheckConstraints"; + + + public const string SchemaHierarchy_Columns = "SchemaHierarchy_Columns"; + + + public const string SchemaHierarchy_Constraints = "SchemaHierarchy_Constraints"; + + + public const string SchemaHierarchy_Contracts = "SchemaHierarchy_Contracts"; + + + public const string SchemaHierarchy_Credentials = "SchemaHierarchy_Credentials"; + + + public const string SchemaHierarchy_ErrorMessages = "SchemaHierarchy_ErrorMessages"; + + + public const string SchemaHierarchy_ServerRoleMembership = "SchemaHierarchy_ServerRoleMembership"; + + + public const string SchemaHierarchy_DatabaseOptions = "SchemaHierarchy_DatabaseOptions"; + + + public const string SchemaHierarchy_DatabaseRoles = "SchemaHierarchy_DatabaseRoles"; + + + public const string SchemaHierarchy_RoleMemberships = "SchemaHierarchy_RoleMemberships"; + + + public const string SchemaHierarchy_DatabaseTriggers = "SchemaHierarchy_DatabaseTriggers"; + + + public const string SchemaHierarchy_DefaultConstraints = "SchemaHierarchy_DefaultConstraints"; + + + public const string SchemaHierarchy_Defaults = "SchemaHierarchy_Defaults"; + + + public const string SchemaHierarchy_Sequences = "SchemaHierarchy_Sequences"; + + + public const string SchemaHierarchy_Endpoints = "SchemaHierarchy_Endpoints"; + + + public const string SchemaHierarchy_EventNotifications = "SchemaHierarchy_EventNotifications"; + + + public const string SchemaHierarchy_ServerEventNotifications = "SchemaHierarchy_ServerEventNotifications"; + + + public const string SchemaHierarchy_ExtendedProperties = "SchemaHierarchy_ExtendedProperties"; + + + public const string SchemaHierarchy_FileGroups = "SchemaHierarchy_FileGroups"; + + + public const string SchemaHierarchy_ForeignKeys = "SchemaHierarchy_ForeignKeys"; + + + public const string SchemaHierarchy_FullTextCatalogs = "SchemaHierarchy_FullTextCatalogs"; + + + public const string SchemaHierarchy_FullTextIndexes = "SchemaHierarchy_FullTextIndexes"; + + + public const string SchemaHierarchy_Functions = "SchemaHierarchy_Functions"; + + + public const string SchemaHierarchy_Indexes = "SchemaHierarchy_Indexes"; + + + public const string SchemaHierarchy_InlineFunctions = "SchemaHierarchy_InlineFunctions"; + + + public const string SchemaHierarchy_Keys = "SchemaHierarchy_Keys"; + + + public const string SchemaHierarchy_LinkedServers = "SchemaHierarchy_LinkedServers"; + + + public const string SchemaHierarchy_LinkedServerLogins = "SchemaHierarchy_LinkedServerLogins"; + + + public const string SchemaHierarchy_Logins = "SchemaHierarchy_Logins"; + + + public const string SchemaHierarchy_MasterKey = "SchemaHierarchy_MasterKey"; + + + public const string SchemaHierarchy_MasterKeys = "SchemaHierarchy_MasterKeys"; + + + public const string SchemaHierarchy_MessageTypes = "SchemaHierarchy_MessageTypes"; + + + public const string SchemaHierarchy_MultiSelectFunctions = "SchemaHierarchy_MultiSelectFunctions"; + + + public const string SchemaHierarchy_Parameters = "SchemaHierarchy_Parameters"; + + + public const string SchemaHierarchy_PartitionFunctions = "SchemaHierarchy_PartitionFunctions"; + + + public const string SchemaHierarchy_PartitionSchemes = "SchemaHierarchy_PartitionSchemes"; + + + public const string SchemaHierarchy_Permissions = "SchemaHierarchy_Permissions"; + + + public const string SchemaHierarchy_PrimaryKeys = "SchemaHierarchy_PrimaryKeys"; + + + public const string SchemaHierarchy_Programmability = "SchemaHierarchy_Programmability"; + + + public const string SchemaHierarchy_Queues = "SchemaHierarchy_Queues"; + + + public const string SchemaHierarchy_RemoteServiceBindings = "SchemaHierarchy_RemoteServiceBindings"; + + + public const string SchemaHierarchy_ReturnedColumns = "SchemaHierarchy_ReturnedColumns"; + + + public const string SchemaHierarchy_Roles = "SchemaHierarchy_Roles"; + + + public const string SchemaHierarchy_Routes = "SchemaHierarchy_Routes"; + + + public const string SchemaHierarchy_Rules = "SchemaHierarchy_Rules"; + + + public const string SchemaHierarchy_Schemas = "SchemaHierarchy_Schemas"; + + + public const string SchemaHierarchy_Security = "SchemaHierarchy_Security"; + + + public const string SchemaHierarchy_ServerObjects = "SchemaHierarchy_ServerObjects"; + + + public const string SchemaHierarchy_Management = "SchemaHierarchy_Management"; + + + public const string SchemaHierarchy_ServerTriggers = "SchemaHierarchy_ServerTriggers"; + + + public const string SchemaHierarchy_ServiceBroker = "SchemaHierarchy_ServiceBroker"; + + + public const string SchemaHierarchy_Services = "SchemaHierarchy_Services"; + + + public const string SchemaHierarchy_Signatures = "SchemaHierarchy_Signatures"; + + + public const string SchemaHierarchy_LogFiles = "SchemaHierarchy_LogFiles"; + + + public const string SchemaHierarchy_Statistics = "SchemaHierarchy_Statistics"; + + + public const string SchemaHierarchy_Storage = "SchemaHierarchy_Storage"; + + + public const string SchemaHierarchy_StoredProcedures = "SchemaHierarchy_StoredProcedures"; + + + public const string SchemaHierarchy_SymmetricKeys = "SchemaHierarchy_SymmetricKeys"; + + + public const string SchemaHierarchy_Synonyms = "SchemaHierarchy_Synonyms"; + + + public const string SchemaHierarchy_Tables = "SchemaHierarchy_Tables"; + + + public const string SchemaHierarchy_Triggers = "SchemaHierarchy_Triggers"; + + + public const string SchemaHierarchy_Types = "SchemaHierarchy_Types"; + + + public const string SchemaHierarchy_UniqueKeys = "SchemaHierarchy_UniqueKeys"; + + + public const string SchemaHierarchy_UserDefinedDataTypes = "SchemaHierarchy_UserDefinedDataTypes"; + + + public const string SchemaHierarchy_UserDefinedTypes = "SchemaHierarchy_UserDefinedTypes"; + + + public const string SchemaHierarchy_Users = "SchemaHierarchy_Users"; + + + public const string SchemaHierarchy_Views = "SchemaHierarchy_Views"; + + + public const string SchemaHierarchy_XmlIndexes = "SchemaHierarchy_XmlIndexes"; + + + public const string SchemaHierarchy_XMLSchemaCollections = "SchemaHierarchy_XMLSchemaCollections"; + + + public const string SchemaHierarchy_UserDefinedTableTypes = "SchemaHierarchy_UserDefinedTableTypes"; + + + public const string SchemaHierarchy_FilegroupFiles = "SchemaHierarchy_FilegroupFiles"; + + + public const string MissingCaption = "MissingCaption"; + + + public const string SchemaHierarchy_BrokerPriorities = "SchemaHierarchy_BrokerPriorities"; + + + public const string SchemaHierarchy_CryptographicProviders = "SchemaHierarchy_CryptographicProviders"; + + + public const string SchemaHierarchy_DatabaseAuditSpecifications = "SchemaHierarchy_DatabaseAuditSpecifications"; + + + public const string SchemaHierarchy_DatabaseEncryptionKeys = "SchemaHierarchy_DatabaseEncryptionKeys"; + + + public const string SchemaHierarchy_EventSessions = "SchemaHierarchy_EventSessions"; + + + public const string SchemaHierarchy_FullTextStopLists = "SchemaHierarchy_FullTextStopLists"; + + + public const string SchemaHierarchy_ResourcePools = "SchemaHierarchy_ResourcePools"; + + + public const string SchemaHierarchy_ServerAudits = "SchemaHierarchy_ServerAudits"; + + + public const string SchemaHierarchy_ServerAuditSpecifications = "SchemaHierarchy_ServerAuditSpecifications"; + + + public const string SchemaHierarchy_SpatialIndexes = "SchemaHierarchy_SpatialIndexes"; + + + public const string SchemaHierarchy_WorkloadGroups = "SchemaHierarchy_WorkloadGroups"; + + + public const string SchemaHierarchy_SqlFiles = "SchemaHierarchy_SqlFiles"; + + + public const string SchemaHierarchy_ServerFunctions = "SchemaHierarchy_ServerFunctions"; + + + public const string SchemaHierarchy_SqlType = "SchemaHierarchy_SqlType"; + + + public const string SchemaHierarchy_ServerOptions = "SchemaHierarchy_ServerOptions"; + + + public const string SchemaHierarchy_DatabaseDiagrams = "SchemaHierarchy_DatabaseDiagrams"; + + + public const string SchemaHierarchy_SystemTables = "SchemaHierarchy_SystemTables"; + + + public const string SchemaHierarchy_Databases = "SchemaHierarchy_Databases"; + + + public const string SchemaHierarchy_SystemContracts = "SchemaHierarchy_SystemContracts"; + + + public const string SchemaHierarchy_SystemDatabases = "SchemaHierarchy_SystemDatabases"; + + + public const string SchemaHierarchy_SystemMessageTypes = "SchemaHierarchy_SystemMessageTypes"; + + + public const string SchemaHierarchy_SystemQueues = "SchemaHierarchy_SystemQueues"; + + + public const string SchemaHierarchy_SystemServices = "SchemaHierarchy_SystemServices"; + + + public const string SchemaHierarchy_SystemStoredProcedures = "SchemaHierarchy_SystemStoredProcedures"; + + + public const string SchemaHierarchy_SystemViews = "SchemaHierarchy_SystemViews"; + + + public const string SchemaHierarchy_DataTierApplications = "SchemaHierarchy_DataTierApplications"; + + + public const string SchemaHierarchy_ExtendedStoredProcedures = "SchemaHierarchy_ExtendedStoredProcedures"; + + + public const string SchemaHierarchy_SystemAggregateFunctions = "SchemaHierarchy_SystemAggregateFunctions"; + + + public const string SchemaHierarchy_SystemApproximateNumerics = "SchemaHierarchy_SystemApproximateNumerics"; + + + public const string SchemaHierarchy_SystemBinaryStrings = "SchemaHierarchy_SystemBinaryStrings"; + + + public const string SchemaHierarchy_SystemCharacterStrings = "SchemaHierarchy_SystemCharacterStrings"; + + + public const string SchemaHierarchy_SystemCLRDataTypes = "SchemaHierarchy_SystemCLRDataTypes"; + + + public const string SchemaHierarchy_SystemConfigurationFunctions = "SchemaHierarchy_SystemConfigurationFunctions"; + + + public const string SchemaHierarchy_SystemCursorFunctions = "SchemaHierarchy_SystemCursorFunctions"; + + + public const string SchemaHierarchy_SystemDataTypes = "SchemaHierarchy_SystemDataTypes"; + + + public const string SchemaHierarchy_SystemDateAndTime = "SchemaHierarchy_SystemDateAndTime"; + + + public const string SchemaHierarchy_SystemDateAndTimeFunctions = "SchemaHierarchy_SystemDateAndTimeFunctions"; + + + public const string SchemaHierarchy_SystemExactNumerics = "SchemaHierarchy_SystemExactNumerics"; + + + public const string SchemaHierarchy_SystemFunctions = "SchemaHierarchy_SystemFunctions"; + + + public const string SchemaHierarchy_SystemHierarchyIdFunctions = "SchemaHierarchy_SystemHierarchyIdFunctions"; + + + public const string SchemaHierarchy_SystemMathematicalFunctions = "SchemaHierarchy_SystemMathematicalFunctions"; + + + public const string SchemaHierarchy_SystemMetadataFunctions = "SchemaHierarchy_SystemMetadataFunctions"; + + + public const string SchemaHierarchy_SystemOtherDataTypes = "SchemaHierarchy_SystemOtherDataTypes"; + + + public const string SchemaHierarchy_SystemOtherFunctions = "SchemaHierarchy_SystemOtherFunctions"; + + + public const string SchemaHierarchy_SystemRowsetFunctions = "SchemaHierarchy_SystemRowsetFunctions"; + + + public const string SchemaHierarchy_SystemSecurityFunctions = "SchemaHierarchy_SystemSecurityFunctions"; + + + public const string SchemaHierarchy_SystemSpatialDataTypes = "SchemaHierarchy_SystemSpatialDataTypes"; + + + public const string SchemaHierarchy_SystemStringFunctions = "SchemaHierarchy_SystemStringFunctions"; + + + public const string SchemaHierarchy_SystemSystemStatisticalFunctions = "SchemaHierarchy_SystemSystemStatisticalFunctions"; + + + public const string SchemaHierarchy_SystemTextAndImageFunctions = "SchemaHierarchy_SystemTextAndImageFunctions"; + + + public const string SchemaHierarchy_SystemUnicodeCharacterStrings = "SchemaHierarchy_SystemUnicodeCharacterStrings"; + + + public const string SchemaHierarchy_AggregateFunctions = "SchemaHierarchy_AggregateFunctions"; + + + public const string SchemaHierarchy_ScalarValuedFunctions = "SchemaHierarchy_ScalarValuedFunctions"; + + + public const string SchemaHierarchy_TableValuedFunctions = "SchemaHierarchy_TableValuedFunctions"; + + + public const string SchemaHierarchy_SystemExtendedStoredProcedures = "SchemaHierarchy_SystemExtendedStoredProcedures"; + + + public const string SchemaHierarchy_BuiltInType = "SchemaHierarchy_BuiltInType"; + + + public const string SchemaHierarchy_BuiltInServerRole = "SchemaHierarchy_BuiltInServerRole"; + + + public const string SchemaHierarchy_UserWithPassword = "SchemaHierarchy_UserWithPassword"; + + + public const string SchemaHierarchy_SearchPropertyList = "SchemaHierarchy_SearchPropertyList"; + + + public const string SchemaHierarchy_SecurityPolicies = "SchemaHierarchy_SecurityPolicies"; + + + public const string SchemaHierarchy_SecurityPredicates = "SchemaHierarchy_SecurityPredicates"; + + + public const string SchemaHierarchy_ServerRole = "SchemaHierarchy_ServerRole"; + + + public const string SchemaHierarchy_SearchPropertyLists = "SchemaHierarchy_SearchPropertyLists"; + + + public const string SchemaHierarchy_ColumnStoreIndexes = "SchemaHierarchy_ColumnStoreIndexes"; + + + public const string SchemaHierarchy_TableTypeIndexes = "SchemaHierarchy_TableTypeIndexes"; + + + public const string SchemaHierarchy_ServerInstance = "SchemaHierarchy_ServerInstance"; + + + public const string SchemaHierarchy_SelectiveXmlIndexes = "SchemaHierarchy_SelectiveXmlIndexes"; + + + public const string SchemaHierarchy_XmlNamespaces = "SchemaHierarchy_XmlNamespaces"; + + + public const string SchemaHierarchy_XmlTypedPromotedPaths = "SchemaHierarchy_XmlTypedPromotedPaths"; + + + public const string SchemaHierarchy_SqlTypedPromotedPaths = "SchemaHierarchy_SqlTypedPromotedPaths"; + + + public const string SchemaHierarchy_DatabaseScopedCredentials = "SchemaHierarchy_DatabaseScopedCredentials"; + + + public const string SchemaHierarchy_ExternalDataSources = "SchemaHierarchy_ExternalDataSources"; + + + public const string SchemaHierarchy_ExternalFileFormats = "SchemaHierarchy_ExternalFileFormats"; + + + public const string SchemaHierarchy_ExternalResources = "SchemaHierarchy_ExternalResources"; + + + public const string SchemaHierarchy_ExternalTables = "SchemaHierarchy_ExternalTables"; + + + public const string SchemaHierarchy_AlwaysEncryptedKeys = "SchemaHierarchy_AlwaysEncryptedKeys"; + + + public const string SchemaHierarchy_ColumnMasterKeys = "SchemaHierarchy_ColumnMasterKeys"; + + + public const string SchemaHierarchy_ColumnEncryptionKeys = "SchemaHierarchy_ColumnEncryptionKeys"; + + private Keys() { } diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.es.resx b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.es.resx index c8490030..04bafe16 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.es.resx +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.es.resx @@ -1,426 +1,426 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Los parámetros de conexión no pueden ser nulos - - - OwnerUri no puede ser nulo ni estar vacío - - - SpecifiedUri '{0}' no tiene una conexión existente - - - El valor '{0}' no es válido para AuthenticationType. Los valores válidos son 'Integrated' y 'SqlLogin'. - - - El valor '{0}' no es válido para ApplicationIntent. Los valores válidos son 'ReadWrite' y 'ReadOnly'. - - - Conexión cancelada - - - OwnerUri no puede ser nulo ni estar vacío - - - El objeto de detalles de conexión no puede ser nulo - - - ServerName no puede ser nulo ni estar vacío - - - {0} no puede ser nulo ni estar vacío cuando se utiliza autenticación SqlLogin - - - Ya se ha completado la consulta, no se puede cancelar - - - La consulta fue cancelada con éxito, pero no se ha podido desechar. No se encontró el URI del propietario. - - - Consulta cancelada por el usuario - - - El lote aún no ha finalizado, - - - Índice de lote no puede ser menor que 0 o mayor que el número de lotes - - - Índice del conjunto de resultados no puede ser menor que 0 o mayor que el número de conjuntos de resultados - - - El número máximo de bytes a devolver debe ser mayor que cero - - - El número máximo de caracteres a devolver debe ser mayor que cero - - - El número máximo de bytes XML a devolver debe ser mayor que cero - - - El método de acceso no puede ser de sólo escritura - - - FileStreamWrapper debe inicializarse antes de realizar operaciones - - - Este FileStreamWrapper no se puede utilizar para escritura. - - - (1 fila afectada) - - - ({0} filas afectadas) - - - Comandos finalizados correctamente. - - - Msg {0}, nivel {1} estado {2}, línea {3} {4} {5} - - - Error en la consulta: {0} - - - (Ningún nombre de columna) - - - La consulta solicitada no existe - - - Este editor no está conectado a una base de datos - - - Una consulta ya está en curso para esta sesión de editor. Por favor, cancelar esta consulta o esperar su finalización. - - - Remitente de eventos de OnInfoMessage debe ser un objeto SqlConnection - - - Lector no puede ser nulo - - - No se puede guardar el resultado hasta que haya finalizado la ejecución de la consulta - - - Error interno al iniciar el guardado de la tarea - - - Una operacion de guardado en la misma ruta se encuentra en curso - - - Error al guardar {0}: {1} - - - No se puede leer el subconjunto, a menos que los resultados se han leído desde el servidor - - - Fila de inicio no puede ser menor que 0 o mayor que el número de filas en el conjunto de resultados - - - La cantidad de filas debe ser un entero positivo - - - No se pudo recuperar el esquema de columna para el conjunto de resultados - - - No se pudo recuperar un plan de ejecución del conjunto de resultados - - - Esta característica actualmente no se admite en la base de datos de SQL Azure y almacén de datos: {0} - - - Se ha producido un error inesperado durante la ejecución de la definición de Peek: {0} - - - No se encontraron resultados. - - - No se pudo obtener ningún objeto asociado a la base de datos. - - - Conéctese a un servidor. - - - Tiempo de espera agotado para esta operación. - - - Esta característica no admite actualmente este tipo de objeto. - - - Posición está fuera del intervalo de la línea de archivo - - - Posición está fuera del intervalo de la columna de la línea {0} - - - Posición de inicio ({0}, {1}) debe preceder o ser igual a la posición final ({2}, {3}) - - - Msg {0}, {1}, nivel de estado {2}, línea {3} - - - Msj {0}, {1}, nivel de estado {2}, procedimiento {3}, línea {4} - - - Msg {0}, nivel {1}, {2} de estado - - - Se produjo un error al procesar el lote. Mensaje de error: {0} - - - ({0} filas afectadas) - - - La ejecución anterior aún no está completa. - - - Se ha producido un error de secuencias de comandos. - - - Se encontró sintaxis incorrecta mientras se estaba analizando {0}. - - - Se ha producido un error grave. - - - La ejecución completó {0} veces... - - - Se canceló la consulta. - - - Se produjo un error mientras se ejecutaba el lote. - - - Se produjo un error mientras se ejecutaba el lote, pero se ha omitido el error. - - - Iniciando bucle de ejecución de {0} veces... - - - No se admite el comando {0}. - - - La variable {0} no se encontró. - - - Error de ejecución de SQL: {0} - - - Ejecución de contenedor del analizador por lotes: {0} se encuentra... en la línea {1}: {2} Descripción: {3} - - - Lote analizador contenedor ejecución motor lote mensaje recibido: mensaje: {0} mensaje detallado: {1} - - - Motor de ejecución de analizador contenedor lote ResultSet procesamiento por lotes: DataReader.FieldCount: {0} DataReader.RecordsAffected: {1} - - - Finalizó el elemento ResultSet analizador contenedor ejecución motor los lotes. - - - Cancelando la ejecución por lotes del contenedor del analizador por lotes. - - - Advertencia de scripting. - - - Para obtener más información acerca de este error, vea los temas de solución de problemas en la documentación del producto. - - - El archivo '{0}' se incluyó recursivamente. - - - Falta la marca de final de comentario ' * /'. - - - Sin comilla de cierre después de la cadena de caracteres. - - - Se encontró sintaxis incorrecta al analizar '{0}'. - - - La variable {0} no está definida. - - - prueba - - - No se puede convertir el SqlCodeObject del Tipo {0} al Tipo {1} - - - Sustitución de una cadena vacía por una cadena vacía. - - - Sesión de edición no existe, - - - La consulta no ha finalizado. - - - La consulta no generó un único set de resultados - - - Falló al agregar una nueva fila a la caché de actualización - - - El ID de la fila ingresado, se encuentra fuera del rango de filas de la caché de edición - - - Una actualización está pendiente para esta fila y debe de revertirse primero - - - El ID de la fila ingresado no tiene actualizaciones pendientes - - - La metadata de la tabla o vista no pudo ser encontrada - - - Formato inválido para columna binaria - - - Columnas del tipo boolean deben de ser numéricos 1 o 0, o tipo string true o false - - - Falta un valor requerido de la celda - - - Existe una eliminación pendiente para esta fila, una actualización de celda no puede ser realizada. - - - El ID de la columna debe de estar en el rango de columnas de la consulta. - - - La columna no puede ser editada - - - No se encontró ninguna columna clave - - - Proporcione un nombre de archivo de salida - - - Objeto de base de datos {0} no puede ser usado para modificación. - - - SpecifiedUri '{0}' no tiene alguna conexión por defecto - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Los parámetros de conexión no pueden ser nulos + + + OwnerUri no puede ser nulo ni estar vacío + + + SpecifiedUri '{0}' no tiene una conexión existente + + + El valor '{0}' no es válido para AuthenticationType. Los valores válidos son 'Integrated' y 'SqlLogin'. + + + El valor '{0}' no es válido para ApplicationIntent. Los valores válidos son 'ReadWrite' y 'ReadOnly'. + + + Conexión cancelada + + + OwnerUri no puede ser nulo ni estar vacío + + + El objeto de detalles de conexión no puede ser nulo + + + ServerName no puede ser nulo ni estar vacío + + + {0} no puede ser nulo ni estar vacío cuando se utiliza autenticación SqlLogin + + + Ya se ha completado la consulta, no se puede cancelar + + + La consulta fue cancelada con éxito, pero no se ha podido desechar. No se encontró el URI del propietario. + + + Consulta cancelada por el usuario + + + El lote aún no ha finalizado, + + + Índice de lote no puede ser menor que 0 o mayor que el número de lotes + + + Índice del conjunto de resultados no puede ser menor que 0 o mayor que el número de conjuntos de resultados + + + El número máximo de bytes a devolver debe ser mayor que cero + + + El número máximo de caracteres a devolver debe ser mayor que cero + + + El número máximo de bytes XML a devolver debe ser mayor que cero + + + El método de acceso no puede ser de sólo escritura + + + FileStreamWrapper debe inicializarse antes de realizar operaciones + + + Este FileStreamWrapper no se puede utilizar para escritura. + + + (1 fila afectada) + + + ({0} filas afectadas) + + + Comandos finalizados correctamente. + + + Msg {0}, nivel {1} estado {2}, línea {3} {4} {5} + + + Error en la consulta: {0} + + + (Ningún nombre de columna) + + + La consulta solicitada no existe + + + Este editor no está conectado a una base de datos + + + Una consulta ya está en curso para esta sesión de editor. Por favor, cancelar esta consulta o esperar su finalización. + + + Remitente de eventos de OnInfoMessage debe ser un objeto SqlConnection + + + Lector no puede ser nulo + + + No se puede guardar el resultado hasta que haya finalizado la ejecución de la consulta + + + Error interno al iniciar el guardado de la tarea + + + Una operacion de guardado en la misma ruta se encuentra en curso + + + Error al guardar {0}: {1} + + + No se puede leer el subconjunto, a menos que los resultados se han leído desde el servidor + + + Fila de inicio no puede ser menor que 0 o mayor que el número de filas en el conjunto de resultados + + + La cantidad de filas debe ser un entero positivo + + + No se pudo recuperar el esquema de columna para el conjunto de resultados + + + No se pudo recuperar un plan de ejecución del conjunto de resultados + + + Esta característica actualmente no se admite en la base de datos de SQL Azure y almacén de datos: {0} + + + Se ha producido un error inesperado durante la ejecución de la definición de Peek: {0} + + + No se encontraron resultados. + + + No se pudo obtener ningún objeto asociado a la base de datos. + + + Conéctese a un servidor. + + + Tiempo de espera agotado para esta operación. + + + Esta característica no admite actualmente este tipo de objeto. + + + Posición está fuera del intervalo de la línea de archivo + + + Posición está fuera del intervalo de la columna de la línea {0} + + + Posición de inicio ({0}, {1}) debe preceder o ser igual a la posición final ({2}, {3}) + + + Msg {0}, {1}, nivel de estado {2}, línea {3} + + + Msj {0}, {1}, nivel de estado {2}, procedimiento {3}, línea {4} + + + Msg {0}, nivel {1}, {2} de estado + + + Se produjo un error al procesar el lote. Mensaje de error: {0} + + + ({0} filas afectadas) + + + La ejecución anterior aún no está completa. + + + Se ha producido un error de secuencias de comandos. + + + Se encontró sintaxis incorrecta mientras se estaba analizando {0}. + + + Se ha producido un error grave. + + + La ejecución completó {0} veces... + + + Se canceló la consulta. + + + Se produjo un error mientras se ejecutaba el lote. + + + Se produjo un error mientras se ejecutaba el lote, pero se ha omitido el error. + + + Iniciando bucle de ejecución de {0} veces... + + + No se admite el comando {0}. + + + La variable {0} no se encontró. + + + Error de ejecución de SQL: {0} + + + Ejecución de contenedor del analizador por lotes: {0} se encuentra... en la línea {1}: {2} Descripción: {3} + + + Lote analizador contenedor ejecución motor lote mensaje recibido: mensaje: {0} mensaje detallado: {1} + + + Motor de ejecución de analizador contenedor lote ResultSet procesamiento por lotes: DataReader.FieldCount: {0} DataReader.RecordsAffected: {1} + + + Finalizó el elemento ResultSet analizador contenedor ejecución motor los lotes. + + + Cancelando la ejecución por lotes del contenedor del analizador por lotes. + + + Advertencia de scripting. + + + Para obtener más información acerca de este error, vea los temas de solución de problemas en la documentación del producto. + + + El archivo '{0}' se incluyó recursivamente. + + + Falta la marca de final de comentario ' * /'. + + + Sin comilla de cierre después de la cadena de caracteres. + + + Se encontró sintaxis incorrecta al analizar '{0}'. + + + La variable {0} no está definida. + + + prueba + + + No se puede convertir el SqlCodeObject del Tipo {0} al Tipo {1} + + + Sustitución de una cadena vacía por una cadena vacía. + + + Sesión de edición no existe, + + + La consulta no ha finalizado. + + + La consulta no generó un único set de resultados + + + Falló al agregar una nueva fila a la caché de actualización + + + El ID de la fila ingresado, se encuentra fuera del rango de filas de la caché de edición + + + Una actualización está pendiente para esta fila y debe de revertirse primero + + + El ID de la fila ingresado no tiene actualizaciones pendientes + + + La metadata de la tabla o vista no pudo ser encontrada + + + Formato inválido para columna binaria + + + Columnas del tipo boolean deben de ser numéricos 1 o 0, o tipo string true o false + + + Falta un valor requerido de la celda + + + Existe una eliminación pendiente para esta fila, una actualización de celda no puede ser realizada. + + + El ID de la columna debe de estar en el rango de columnas de la consulta. + + + La columna no puede ser editada + + + No se encontró ninguna columna clave + + + Proporcione un nombre de archivo de salida + + + Objeto de base de datos {0} no puede ser usado para modificación. + + + SpecifiedUri '{0}' no tiene alguna conexión por defecto + \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx index f7ee389e..76ad3db3 100755 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx @@ -599,4 +599,656 @@ Decimal column is missing numeric precision or numeric scale + + Error expanding: {0} + + + + Error connecting to {0} + + + + Aggregates + + + + Server Roles + + + + Application Roles + + + + Assemblies + + + + Assembly Files + + + + Asymmetric Keys + + + + Asymmetric Keys + + + + Data Compression Options + + + + Certificates + + + + FileTables + + + + Certificates + + + + Check Constraints + + + + Columns + + + + Constraints + + + + Contracts + + + + Credentials + + + + Error Messages + + + + Server Role Membership + + + + Database Options + + + + Database Roles + + + + Role Memberships + + + + Database Triggers + + + + Default Constraints + + + + Defaults + + + + Sequences + + + + Endpoints + + + + Event Notifications + + + + Server Event Notifications + + + + Extended Properties + + + + Filegroups + + + + Foreign Keys + + + + Full-Text Catalogs + + + + Full-Text Indexes + + + + Functions + + + + Indexes + + + + Inline Functions + + + + Keys + + + + Linked Servers + + + + Linked Server Logins + + + + Logins + + + + Master Key + + + + Master Keys + + + + Message Types + + + + Table-Valued Functions + + + + Parameters + + + + Partition Functions + + + + Partition Schemes + + + + Permissions + + + + Primary Keys + + + + Programmability + + + + Queues + + + + Remote Service Bindings + + + + Returned Columns + + + + Roles + + + + Routes + + + + Rules + + + + Schemas + + + + Security + + + + Server Objects + + + + Management + + + + Triggers + + + + Service Broker + + + + Services + + + + Signatures + + + + Log Files + + + + Statistics + + + + Storage + + + + Stored Procedures + + + + Symmetric Keys + + + + Synonyms + + + + Tables + + + + Triggers + + + + Types + + + + Unique Keys + + + + User-Defined Data Types + + + + User-Defined Types (CLR) + + + + Users + + + + Views + + + + XML Indexes + + + + XML Schema Collections + + + + User-Defined Table Types + + + + Files + + + + Missing Caption + + + + Broker Priorities + + + + Cryptographic Providers + + + + Database Audit Specifications + + + + Database Encryption Keys + + + + Event Sessions + + + + Full Text Stoplists + + + + Resource Pools + + + + Audits + + + + Server Audit Specifications + + + + Spatial Indexes + + + + Workload Groups + + + + SQL Files + + + + Server Functions + + + + SQL Type + + + + Server Options + + + + Database Diagrams + + + + System Tables + + + + Databases + + + + System Contracts + + + + System Databases + + + + System Message Types + + + + System Queues + + + + System Services + + + + System Stored Procedures + + + + System Views + + + + Data-tier Applications + + + + Extended Stored Procedures + + + + Aggregate Functions + + + + Approximate Numerics + + + + Binary Strings + + + + Character Strings + + + + CLR Data Types + + + + Configuration Functions + + + + Cursor Functions + + + + System Data Types + + + + Date and Time + + + + Date and Time Functions + + + + Exact Numerics + + + + System Functions + + + + Hierarchy Id Functions + + + + Mathematical Functions + + + + Metadata Functions + + + + Other Data Types + + + + Other Functions + + + + Rowset Functions + + + + Security Functions + + + + Spatial Data Types + + + + String Functions + + + + System Statistical Functions + + + + Text and Image Functions + + + + Unicode Character Strings + + + + Aggregate Functions + + + + Scalar-valued Functions + + + + Table-valued Functions + + + + System Extended Stored Procedures + + + + Built-in Types + + + + Built-in Server Roles + + + + User with Password + + + + Search Property List + + + + Security Policies + + + + Security Predicates + + + + Server Role + + + + Search Property Lists + + + + Column Store Indexes + + + + Table Type Indexes + + + + ServerInstance + + + + Selective XML Indexes + + + + XML Namespaces + + + + XML Typed Promoted Paths + + + + T-SQL Typed Promoted Paths + + + + Database Scoped Credentials + + + + External Data Sources + + + + External File Formats + + + + External Resources + + + + External Tables + + + + Always Encrypted Keys + + + + Column Master Keys + + + + Column Encryption Keys + + diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings index d4917c6b..0bb0b741 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings @@ -293,3 +293,333 @@ TestLocalizationConstant = test # Utilities SqlScriptFormatterDecimalMissingPrecision = Decimal column is missing numeric precision or numeric scale + +############################################################################ +# Object Explorer Service + +TreeNodeError = Error expanding: {0} + +ServerNodeConnectionError = Error connecting to {0} + +SchemaHierarchy_Aggregates = Aggregates + +SchemaHierarchy_ServerRoles = Server Roles + +SchemaHierarchy_ApplicationRoles = Application Roles + +SchemaHierarchy_Assemblies = Assemblies + +SchemaHierarchy_AssemblyFiles = Assembly Files + +SchemaHierarchy_AsymmetricKeys = Asymmetric Keys + +SchemaHierarchy_DatabaseAsymmetricKeys = Asymmetric Keys + +SchemaHierarchy_DataCompressionOptions = Data Compression Options + +SchemaHierarchy_Certificates = Certificates + +SchemaHierarchy_FileTables = FileTables + +SchemaHierarchy_DatabaseCertificates = Certificates + +SchemaHierarchy_CheckConstraints = Check Constraints + +SchemaHierarchy_Columns = Columns + +SchemaHierarchy_Constraints = Constraints + +SchemaHierarchy_Contracts = Contracts + +SchemaHierarchy_Credentials = Credentials + +SchemaHierarchy_ErrorMessages = Error Messages + +SchemaHierarchy_ServerRoleMembership = Server Role Membership + +SchemaHierarchy_DatabaseOptions = Database Options + +SchemaHierarchy_DatabaseRoles = Database Roles + +SchemaHierarchy_RoleMemberships = Role Memberships + +SchemaHierarchy_DatabaseTriggers = Database Triggers + +SchemaHierarchy_DefaultConstraints = Default Constraints + +SchemaHierarchy_Defaults = Defaults + +SchemaHierarchy_Sequences = Sequences + +SchemaHierarchy_Endpoints = Endpoints + +SchemaHierarchy_EventNotifications = Event Notifications + +SchemaHierarchy_ServerEventNotifications = Server Event Notifications + +SchemaHierarchy_ExtendedProperties = Extended Properties + +SchemaHierarchy_FileGroups = Filegroups + +SchemaHierarchy_ForeignKeys = Foreign Keys + +SchemaHierarchy_FullTextCatalogs = Full-Text Catalogs + +SchemaHierarchy_FullTextIndexes = Full-Text Indexes + +SchemaHierarchy_Functions = Functions + +SchemaHierarchy_Indexes = Indexes + +SchemaHierarchy_InlineFunctions = Inline Functions + +SchemaHierarchy_Keys = Keys + +SchemaHierarchy_LinkedServers = Linked Servers + +SchemaHierarchy_LinkedServerLogins = Linked Server Logins + +SchemaHierarchy_Logins = Logins + +SchemaHierarchy_MasterKey = Master Key + +SchemaHierarchy_MasterKeys = Master Keys + +SchemaHierarchy_MessageTypes = Message Types + +SchemaHierarchy_MultiSelectFunctions = Table-Valued Functions + +SchemaHierarchy_Parameters = Parameters + +SchemaHierarchy_PartitionFunctions = Partition Functions + +SchemaHierarchy_PartitionSchemes = Partition Schemes + +SchemaHierarchy_Permissions = Permissions + +SchemaHierarchy_PrimaryKeys = Primary Keys + +SchemaHierarchy_Programmability = Programmability + +SchemaHierarchy_Queues = Queues + +SchemaHierarchy_RemoteServiceBindings = Remote Service Bindings + +SchemaHierarchy_ReturnedColumns = Returned Columns + +SchemaHierarchy_Roles = Roles + +SchemaHierarchy_Routes = Routes + +SchemaHierarchy_Rules = Rules + +SchemaHierarchy_Schemas = Schemas + +SchemaHierarchy_Security = Security + +SchemaHierarchy_ServerObjects = Server Objects + +SchemaHierarchy_Management = Management + +SchemaHierarchy_ServerTriggers = Triggers + +SchemaHierarchy_ServiceBroker = Service Broker + +SchemaHierarchy_Services = Services + +SchemaHierarchy_Signatures = Signatures + +SchemaHierarchy_LogFiles = Log Files + +SchemaHierarchy_Statistics = Statistics + +SchemaHierarchy_Storage = Storage + +SchemaHierarchy_StoredProcedures = Stored Procedures + +SchemaHierarchy_SymmetricKeys = Symmetric Keys + +SchemaHierarchy_Synonyms = Synonyms + +SchemaHierarchy_Tables = Tables + +SchemaHierarchy_Triggers = Triggers + +SchemaHierarchy_Types = Types + +SchemaHierarchy_UniqueKeys = Unique Keys + +SchemaHierarchy_UserDefinedDataTypes = User-Defined Data Types + +SchemaHierarchy_UserDefinedTypes = User-Defined Types (CLR) + +SchemaHierarchy_Users = Users + +SchemaHierarchy_Views = Views + +SchemaHierarchy_XmlIndexes = XML Indexes + +SchemaHierarchy_XMLSchemaCollections = XML Schema Collections + +SchemaHierarchy_UserDefinedTableTypes = User-Defined Table Types + +SchemaHierarchy_FilegroupFiles = Files + +MissingCaption = Missing Caption + +SchemaHierarchy_BrokerPriorities = Broker Priorities + +SchemaHierarchy_CryptographicProviders = Cryptographic Providers + +SchemaHierarchy_DatabaseAuditSpecifications = Database Audit Specifications + +SchemaHierarchy_DatabaseEncryptionKeys = Database Encryption Keys + +SchemaHierarchy_EventSessions = Event Sessions + +SchemaHierarchy_FullTextStopLists = Full Text Stoplists + +SchemaHierarchy_ResourcePools = Resource Pools + +SchemaHierarchy_ServerAudits = Audits + +SchemaHierarchy_ServerAuditSpecifications = Server Audit Specifications + +SchemaHierarchy_SpatialIndexes = Spatial Indexes + +SchemaHierarchy_WorkloadGroups = Workload Groups + +SchemaHierarchy_SqlFiles = SQL Files + +SchemaHierarchy_ServerFunctions = Server Functions + +SchemaHierarchy_SqlType = SQL Type + +SchemaHierarchy_ServerOptions = Server Options + +SchemaHierarchy_DatabaseDiagrams = Database Diagrams + +SchemaHierarchy_SystemTables = System Tables + +SchemaHierarchy_Databases = Databases + +SchemaHierarchy_SystemContracts = System Contracts + +SchemaHierarchy_SystemDatabases = System Databases + +SchemaHierarchy_SystemMessageTypes = System Message Types + +SchemaHierarchy_SystemQueues = System Queues + +SchemaHierarchy_SystemServices = System Services + +SchemaHierarchy_SystemStoredProcedures = System Stored Procedures + +SchemaHierarchy_SystemViews = System Views + +SchemaHierarchy_DataTierApplications = Data-tier Applications + +SchemaHierarchy_ExtendedStoredProcedures = Extended Stored Procedures + +SchemaHierarchy_SystemAggregateFunctions = Aggregate Functions + +SchemaHierarchy_SystemApproximateNumerics = Approximate Numerics + +SchemaHierarchy_SystemBinaryStrings = Binary Strings + +SchemaHierarchy_SystemCharacterStrings = Character Strings + +SchemaHierarchy_SystemCLRDataTypes = CLR Data Types + +SchemaHierarchy_SystemConfigurationFunctions = Configuration Functions + +SchemaHierarchy_SystemCursorFunctions = Cursor Functions + +SchemaHierarchy_SystemDataTypes = System Data Types + +SchemaHierarchy_SystemDateAndTime = Date and Time + +SchemaHierarchy_SystemDateAndTimeFunctions = Date and Time Functions + +SchemaHierarchy_SystemExactNumerics = Exact Numerics + +SchemaHierarchy_SystemFunctions = System Functions + +SchemaHierarchy_SystemHierarchyIdFunctions = Hierarchy Id Functions + +SchemaHierarchy_SystemMathematicalFunctions = Mathematical Functions + +SchemaHierarchy_SystemMetadataFunctions = Metadata Functions + +SchemaHierarchy_SystemOtherDataTypes = Other Data Types + +SchemaHierarchy_SystemOtherFunctions = Other Functions + +SchemaHierarchy_SystemRowsetFunctions = Rowset Functions + +SchemaHierarchy_SystemSecurityFunctions = Security Functions + +SchemaHierarchy_SystemSpatialDataTypes = Spatial Data Types + +SchemaHierarchy_SystemStringFunctions = String Functions + +SchemaHierarchy_SystemSystemStatisticalFunctions = System Statistical Functions + +SchemaHierarchy_SystemTextAndImageFunctions = Text and Image Functions + +SchemaHierarchy_SystemUnicodeCharacterStrings = Unicode Character Strings + +SchemaHierarchy_AggregateFunctions = Aggregate Functions + +SchemaHierarchy_ScalarValuedFunctions = Scalar-valued Functions + +SchemaHierarchy_TableValuedFunctions = Table-valued Functions + +SchemaHierarchy_SystemExtendedStoredProcedures = System Extended Stored Procedures + +SchemaHierarchy_BuiltInType = Built-in Types + +SchemaHierarchy_BuiltInServerRole = Built-in Server Roles + +SchemaHierarchy_UserWithPassword = User with Password + +SchemaHierarchy_SearchPropertyList = Search Property List + +SchemaHierarchy_SecurityPolicies = Security Policies + +SchemaHierarchy_SecurityPredicates = Security Predicates + +SchemaHierarchy_ServerRole = Server Role + +SchemaHierarchy_SearchPropertyLists = Search Property Lists + +SchemaHierarchy_ColumnStoreIndexes = Column Store Indexes + +SchemaHierarchy_TableTypeIndexes = Table Type Indexes + +SchemaHierarchy_ServerInstance = ServerInstance + +SchemaHierarchy_SelectiveXmlIndexes = Selective XML Indexes + +SchemaHierarchy_XmlNamespaces = XML Namespaces + +SchemaHierarchy_XmlTypedPromotedPaths = XML Typed Promoted Paths + +SchemaHierarchy_SqlTypedPromotedPaths = T-SQL Typed Promoted Paths + +SchemaHierarchy_DatabaseScopedCredentials = Database Scoped Credentials + +SchemaHierarchy_ExternalDataSources = External Data Sources + +SchemaHierarchy_ExternalFileFormats = External File Formats + +SchemaHierarchy_ExternalResources = External Resources + +SchemaHierarchy_ExternalTables = External Tables + +SchemaHierarchy_AlwaysEncryptedKeys = Always Encrypted Keys + +SchemaHierarchy_ColumnMasterKeys = Column Master Keys + +SchemaHierarchy_ColumnEncryptionKeys = Column Encryption Keys + diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf index 0936f7a7..de85581c 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf @@ -1,606 +1,1421 @@ - - - - - - Connection parameters cannot be null - Connection parameters cannot be null - - - - OwnerUri cannot be null or empty - OwnerUri cannot be null or empty - - - - SpecifiedUri '{0}' does not have existing connection - SpecifiedUri '{0}' does not have existing connection - . - Parameters: 0 - uri (string) - - - Invalid value '{0}' for AuthenticationType. Valid values are 'Integrated' and 'SqlLogin'. - Invalid value '{0}' for AuthenticationType. Valid values are 'Integrated' and 'SqlLogin'. - . - Parameters: 0 - authType (string) - - - Invalid value '{0}' for ApplicationIntent. Valid values are 'ReadWrite' and 'ReadOnly'. - Invalid value '{0}' for ApplicationIntent. Valid values are 'ReadWrite' and 'ReadOnly'. - . - Parameters: 0 - intent (string) - - - Connection canceled - Connection canceled - - - - OwnerUri cannot be null or empty - OwnerUri cannot be null or empty - - - - Connection details object cannot be null - Connection details object cannot be null - - - - ServerName cannot be null or empty - ServerName cannot be null or empty - - - - {0} cannot be null or empty when using SqlLogin authentication - {0} cannot be null or empty when using SqlLogin authentication - . - Parameters: 0 - component (string) - - - The query has already completed, it cannot be cancelled - The query has already completed, it cannot be cancelled - - - - Query successfully cancelled, failed to dispose query. Owner URI not found. - Query successfully cancelled, failed to dispose query. Owner URI not found. - - - - Query was canceled by user - Query was canceled by user - - - - The batch has not completed, yet - The batch has not completed, yet - - - - Batch index cannot be less than 0 or greater than the number of batches - Batch index cannot be less than 0 or greater than the number of batches - - - - Result set index cannot be less than 0 or greater than the number of result sets - Result set index cannot be less than 0 or greater than the number of result sets - - - - Maximum number of bytes to return must be greater than zero - Maximum number of bytes to return must be greater than zero - - - - Maximum number of chars to return must be greater than zero - Maximum number of chars to return must be greater than zero - - - - Maximum number of XML bytes to return must be greater than zero - Maximum number of XML bytes to return must be greater than zero - - - - Access method cannot be write-only - Access method cannot be write-only - - - - FileStreamWrapper must be initialized before performing operations - FileStreamWrapper must be initialized before performing operations - - - - This FileStreamWrapper cannot be used for writing - This FileStreamWrapper cannot be used for writing - - - - (1 row affected) - (1 row affected) - - - - ({0} rows affected) - ({0} rows affected) - . - Parameters: 0 - rows (long) - - - Commands completed successfully. - Commands completed successfully. - - - - Msg {0}, Level {1}, State {2}, Line {3}{4}{5} - Msg {0}, Level {1}, State {2}, Line {3}{4}{5} - . - Parameters: 0 - msg (int), 1 - lvl (int), 2 - state (int), 3 - line (int), 4 - newLine (string), 5 - message (string) - - - Query failed: {0} - Query failed: {0} - . - Parameters: 0 - message (string) - - - (No column name) - (No column name) - - - - The requested query does not exist - The requested query does not exist - - - - This editor is not connected to a database - This editor is not connected to a database - - - - A query is already in progress for this editor session. Please cancel this query or wait for its completion. - A query is already in progress for this editor session. Please cancel this query or wait for its completion. - - - - Sender for OnInfoMessage event must be a SqlConnection - Sender for OnInfoMessage event must be a SqlConnection - - - - Result cannot be saved until query execution has completed - Result cannot be saved until query execution has completed - - - - Internal error occurred while starting save task - Internal error occurred while starting save task - - - - A save request to the same path is in progress - A save request to the same path is in progress - - - - Failed to save {0}: {1} - Failed to save {0}: {1} - . - Parameters: 0 - fileName (string), 1 - message (string) - - - Cannot read subset unless the results have been read from the server - Cannot read subset unless the results have been read from the server - - - - Start row cannot be less than 0 or greater than the number of rows in the result set - Start row cannot be less than 0 or greater than the number of rows in the result set - - - - Row count must be a positive integer - Row count must be a positive integer - - - - Could not retrieve column schema for result set - Could not retrieve column schema for result set - - - - Could not retrieve an execution plan from the result set - Could not retrieve an execution plan from the result set - - - - This feature is currently not supported on Azure SQL DB and Data Warehouse: {0} - This feature is currently not supported on Azure SQL DB and Data Warehouse: {0} - . - Parameters: 0 - errorMessage (string) - - - An unexpected error occurred during Peek Definition execution: {0} - An unexpected error occurred during Peek Definition execution: {0} - . - Parameters: 0 - errorMessage (string) - - - No results were found. - No results were found. - - - - No database object was retrieved. - No database object was retrieved. - - - - Please connect to a server. - Please connect to a server. - - - - Operation timed out. - Operation timed out. - - - - This object type is currently not supported by this feature. - This object type is currently not supported by this feature. - - - - Position is outside of file line range - Position is outside of file line range - - - - Position is outside of column range for line {0} - Position is outside of column range for line {0} - . - Parameters: 0 - line (int) - - - Start position ({0}, {1}) must come before or be equal to the end position ({2}, {3}) - Start position ({0}, {1}) must come before or be equal to the end position ({2}, {3}) - . - Parameters: 0 - sLine (int), 1 - sCol (int), 2 - eLine (int), 3 - eCol (int) - - - Msg {0}, Level {1}, State {2}, Line {3} - Msg {0}, Level {1}, State {2}, Line {3} - - - - Msg {0}, Level {1}, State {2}, Procedure {3}, Line {4} - Msg {0}, Level {1}, State {2}, Procedure {3}, Line {4} - - - - Msg {0}, Level {1}, State {2} - Msg {0}, Level {1}, State {2} - - - - An error occurred while the batch was being processed. The error message is: {0} - An error occurred while the batch was being processed. The error message is: {0} - - - - ({0} row(s) affected) - ({0} row(s) affected) - - - - The previous execution is not yet complete. - The previous execution is not yet complete. - - - - A scripting error occurred. - A scripting error occurred. - - - - Incorrect syntax was encountered while {0} was being parsed. - Incorrect syntax was encountered while {0} was being parsed. - - - - A fatal error occurred. - A fatal error occurred. - - - - Execution completed {0} times... - Execution completed {0} times... - - - - You cancelled the query. - You cancelled the query. - - - - An error occurred while the batch was being executed. - An error occurred while the batch was being executed. - - - - An error occurred while the batch was being executed, but the error has been ignored. - An error occurred while the batch was being executed, but the error has been ignored. - - - - Starting execution loop of {0} times... - Starting execution loop of {0} times... - - - - Command {0} is not supported. - Command {0} is not supported. - - - - The variable {0} could not be found. - The variable {0} could not be found. - - - - SQL Execution error: {0} - SQL Execution error: {0} - - - - Batch parser wrapper execution: {0} found... at line {1}: {2} Description: {3} - Batch parser wrapper execution: {0} found... at line {1}: {2} Description: {3} - - - - Batch parser wrapper execution engine batch message received: Message: {0} Detailed message: {1} - Batch parser wrapper execution engine batch message received: Message: {0} Detailed message: {1} - - - - Batch parser wrapper execution engine batch ResultSet processing: DataReader.FieldCount: {0} DataReader.RecordsAffected: {1} - Batch parser wrapper execution engine batch ResultSet processing: DataReader.FieldCount: {0} DataReader.RecordsAffected: {1} - - - - Batch parser wrapper execution engine batch ResultSet finished. - Batch parser wrapper execution engine batch ResultSet finished. - - - - Canceling batch parser wrapper batch execution. - Canceling batch parser wrapper batch execution. - - - - Scripting warning. - Scripting warning. - - - - For more information about this error, see the troubleshooting topics in the product documentation. - For more information about this error, see the troubleshooting topics in the product documentation. - - - - File '{0}' recursively included. - File '{0}' recursively included. - - - - Missing end comment mark '*/'. - Missing end comment mark '*/'. - - - - Unclosed quotation mark after the character string. - Unclosed quotation mark after the character string. - - - - Incorrect syntax was encountered while parsing '{0}'. - Incorrect syntax was encountered while parsing '{0}'. - - - - Variable {0} is not defined. - Variable {0} is not defined. - - - - test - EN_LOCALIZATION - - - - Replacement of an empty string by an empty string. - Replacement of an empty string by an empty string. - - - - Edit session does not exist. - Edit session does not exist. - - - - Query has not completed execution - Query has not completed execution - - - - Query did not generate exactly one result set - Query did not generate exactly one result set - - - - Failed to add new row to update cache - Failed to add new row to update cache - - - - Given row ID is outside the range of rows in the edit cache - Given row ID is outside the range of rows in the edit cache - - - - An update is already pending for this row and must be reverted first - An update is already pending for this row and must be reverted first - - - - Given row ID does not have pending update - Given row ID does not have pending updated - - - - Table or view metadata could not be found - Table or view metadata could not be found - - - - Invalid format for binary column - Invalid format for binary column - - - - Allowed values for boolean columns are 0, 1, "true", or "false" - Boolean columns must be numeric 1 or 0, or string true or false - - - - A required cell value is missing - A required cell value is missing - - - - A delete is pending for this row, a cell update cannot be applied. - A delete is pending for this row, a cell update cannot be applied. - - - - Column ID must be in the range of columns for the query - Column ID must be in the range of columns for the query - - - - Column cannot be edited - Column cannot be edited - - - - No key columns were found - No key columns were found - - - - An output filename must be provided - An output filename must be provided - - - - Database object {0} cannot be used for editing. - Database object {0} cannot be used for editing. - . - Parameters: 0 - typeName (string) - - - Specified URI '{0}' does not have a default connection - Specified URI '{0}' does not have a default connection - . - Parameters: 0 - uri (string) - - - A commit task is in progress. Please wait for completion. - A commit task is in progress. Please wait for completion. - - - - Decimal column is missing numeric precision or numeric scale - Decimal column is missing numeric precision or numeric scale - - - - <TBD> - <TBD> - - - - Cannot add row to result buffer, data reader does not contain rows - Cannot add row to result buffer, data reader does not contain rows - - - - TIME column values must be between 00:00:00.0000000 and 23:59:59.9999999 - TIME column values must be between 00:00:00.0000000 and 23:59:59.9999999 - - - - NULL is not allowed for this column - NULL is not allowed for this column - - - - Edit session already exists. - Edit session already exists. - - - - Edit session has not been initialized - Edit session has not been initialized - - - - Edit session has already been initialized - Edit session has already been initialized - - - - Edit session has already been initialized or is in the process of initializing - Edit session has already been initialized or is in the process of initializing - - - - Query execution failed, see messages for details - Query execution failed, see messages for details - - - - Result limit cannot be negative - Result limit cannot be negative - - - - NULL - NULL - - - - A object name must be provided - A object name must be provided - - - - Explicitly specifying server or database is not supported - Explicitly specifying server or database is not supported - - - - Table metadata does not have extended properties - Table metadata does not have extended properties - - - - Table or view requested for edit could not be found - Table or view requested for edit could not be found - - - - + + + + + + Connection parameters cannot be null + Connection parameters cannot be null + + + + OwnerUri cannot be null or empty + OwnerUri cannot be null or empty + + + + SpecifiedUri '{0}' does not have existing connection + SpecifiedUri '{0}' does not have existing connection + . + Parameters: 0 - uri (string) + + + Invalid value '{0}' for AuthenticationType. Valid values are 'Integrated' and 'SqlLogin'. + Invalid value '{0}' for AuthenticationType. Valid values are 'Integrated' and 'SqlLogin'. + . + Parameters: 0 - authType (string) + + + Invalid value '{0}' for ApplicationIntent. Valid values are 'ReadWrite' and 'ReadOnly'. + Invalid value '{0}' for ApplicationIntent. Valid values are 'ReadWrite' and 'ReadOnly'. + . + Parameters: 0 - intent (string) + + + Connection canceled + Connection canceled + + + + OwnerUri cannot be null or empty + OwnerUri cannot be null or empty + + + + Connection details object cannot be null + Connection details object cannot be null + + + + ServerName cannot be null or empty + ServerName cannot be null or empty + + + + {0} cannot be null or empty when using SqlLogin authentication + {0} cannot be null or empty when using SqlLogin authentication + . + Parameters: 0 - component (string) + + + The query has already completed, it cannot be cancelled + The query has already completed, it cannot be cancelled + + + + Query successfully cancelled, failed to dispose query. Owner URI not found. + Query successfully cancelled, failed to dispose query. Owner URI not found. + + + + Query was canceled by user + Query was canceled by user + + + + The batch has not completed, yet + The batch has not completed, yet + + + + Batch index cannot be less than 0 or greater than the number of batches + Batch index cannot be less than 0 or greater than the number of batches + + + + Result set index cannot be less than 0 or greater than the number of result sets + Result set index cannot be less than 0 or greater than the number of result sets + + + + Maximum number of bytes to return must be greater than zero + Maximum number of bytes to return must be greater than zero + + + + Maximum number of chars to return must be greater than zero + Maximum number of chars to return must be greater than zero + + + + Maximum number of XML bytes to return must be greater than zero + Maximum number of XML bytes to return must be greater than zero + + + + Access method cannot be write-only + Access method cannot be write-only + + + + FileStreamWrapper must be initialized before performing operations + FileStreamWrapper must be initialized before performing operations + + + + This FileStreamWrapper cannot be used for writing + This FileStreamWrapper cannot be used for writing + + + + (1 row affected) + (1 row affected) + + + + ({0} rows affected) + ({0} rows affected) + . + Parameters: 0 - rows (long) + + + Commands completed successfully. + Commands completed successfully. + + + + Msg {0}, Level {1}, State {2}, Line {3}{4}{5} + Msg {0}, Level {1}, State {2}, Line {3}{4}{5} + . + Parameters: 0 - msg (int), 1 - lvl (int), 2 - state (int), 3 - line (int), 4 - newLine (string), 5 - message (string) + + + Query failed: {0} + Query failed: {0} + . + Parameters: 0 - message (string) + + + (No column name) + (No column name) + + + + The requested query does not exist + The requested query does not exist + + + + This editor is not connected to a database + This editor is not connected to a database + + + + A query is already in progress for this editor session. Please cancel this query or wait for its completion. + A query is already in progress for this editor session. Please cancel this query or wait for its completion. + + + + Sender for OnInfoMessage event must be a SqlConnection + Sender for OnInfoMessage event must be a SqlConnection + + + + Result cannot be saved until query execution has completed + Result cannot be saved until query execution has completed + + + + Internal error occurred while starting save task + Internal error occurred while starting save task + + + + A save request to the same path is in progress + A save request to the same path is in progress + + + + Failed to save {0}: {1} + Failed to save {0}: {1} + . + Parameters: 0 - fileName (string), 1 - message (string) + + + Cannot read subset unless the results have been read from the server + Cannot read subset unless the results have been read from the server + + + + Start row cannot be less than 0 or greater than the number of rows in the result set + Start row cannot be less than 0 or greater than the number of rows in the result set + + + + Row count must be a positive integer + Row count must be a positive integer + + + + Could not retrieve column schema for result set + Could not retrieve column schema for result set + + + + Could not retrieve an execution plan from the result set + Could not retrieve an execution plan from the result set + + + + This feature is currently not supported on Azure SQL DB and Data Warehouse: {0} + This feature is currently not supported on Azure SQL DB and Data Warehouse: {0} + . + Parameters: 0 - errorMessage (string) + + + An unexpected error occurred during Peek Definition execution: {0} + An unexpected error occurred during Peek Definition execution: {0} + . + Parameters: 0 - errorMessage (string) + + + No results were found. + No results were found. + + + + No database object was retrieved. + No database object was retrieved. + + + + Please connect to a server. + Please connect to a server. + + + + Operation timed out. + Operation timed out. + + + + This object type is currently not supported by this feature. + This object type is currently not supported by this feature. + + + + Position is outside of file line range + Position is outside of file line range + + + + Position is outside of column range for line {0} + Position is outside of column range for line {0} + . + Parameters: 0 - line (int) + + + Start position ({0}, {1}) must come before or be equal to the end position ({2}, {3}) + Start position ({0}, {1}) must come before or be equal to the end position ({2}, {3}) + . + Parameters: 0 - sLine (int), 1 - sCol (int), 2 - eLine (int), 3 - eCol (int) + + + Msg {0}, Level {1}, State {2}, Line {3} + Msg {0}, Level {1}, State {2}, Line {3} + + + + Msg {0}, Level {1}, State {2}, Procedure {3}, Line {4} + Msg {0}, Level {1}, State {2}, Procedure {3}, Line {4} + + + + Msg {0}, Level {1}, State {2} + Msg {0}, Level {1}, State {2} + + + + An error occurred while the batch was being processed. The error message is: {0} + An error occurred while the batch was being processed. The error message is: {0} + + + + ({0} row(s) affected) + ({0} row(s) affected) + + + + The previous execution is not yet complete. + The previous execution is not yet complete. + + + + A scripting error occurred. + A scripting error occurred. + + + + Incorrect syntax was encountered while {0} was being parsed. + Incorrect syntax was encountered while {0} was being parsed. + + + + A fatal error occurred. + A fatal error occurred. + + + + Execution completed {0} times... + Execution completed {0} times... + + + + You cancelled the query. + You cancelled the query. + + + + An error occurred while the batch was being executed. + An error occurred while the batch was being executed. + + + + An error occurred while the batch was being executed, but the error has been ignored. + An error occurred while the batch was being executed, but the error has been ignored. + + + + Starting execution loop of {0} times... + Starting execution loop of {0} times... + + + + Command {0} is not supported. + Command {0} is not supported. + + + + The variable {0} could not be found. + The variable {0} could not be found. + + + + SQL Execution error: {0} + SQL Execution error: {0} + + + + Batch parser wrapper execution: {0} found... at line {1}: {2} Description: {3} + Batch parser wrapper execution: {0} found... at line {1}: {2} Description: {3} + + + + Batch parser wrapper execution engine batch message received: Message: {0} Detailed message: {1} + Batch parser wrapper execution engine batch message received: Message: {0} Detailed message: {1} + + + + Batch parser wrapper execution engine batch ResultSet processing: DataReader.FieldCount: {0} DataReader.RecordsAffected: {1} + Batch parser wrapper execution engine batch ResultSet processing: DataReader.FieldCount: {0} DataReader.RecordsAffected: {1} + + + + Batch parser wrapper execution engine batch ResultSet finished. + Batch parser wrapper execution engine batch ResultSet finished. + + + + Canceling batch parser wrapper batch execution. + Canceling batch parser wrapper batch execution. + + + + Scripting warning. + Scripting warning. + + + + For more information about this error, see the troubleshooting topics in the product documentation. + For more information about this error, see the troubleshooting topics in the product documentation. + + + + File '{0}' recursively included. + File '{0}' recursively included. + + + + Missing end comment mark '*/'. + Missing end comment mark '*/'. + + + + Unclosed quotation mark after the character string. + Unclosed quotation mark after the character string. + + + + Incorrect syntax was encountered while parsing '{0}'. + Incorrect syntax was encountered while parsing '{0}'. + + + + Variable {0} is not defined. + Variable {0} is not defined. + + + + test + EN_LOCALIZATION + + + + Replacement of an empty string by an empty string. + Replacement of an empty string by an empty string. + + + + Edit session does not exist. + Edit session does not exist. + + + + Query has not completed execution + Query has not completed execution + + + + Query did not generate exactly one result set + Query did not generate exactly one result set + + + + Failed to add new row to update cache + Failed to add new row to update cache + + + + Given row ID is outside the range of rows in the edit cache + Given row ID is outside the range of rows in the edit cache + + + + An update is already pending for this row and must be reverted first + An update is already pending for this row and must be reverted first + + + + Given row ID does not have pending update + Given row ID does not have pending updated + + + + Table or view metadata could not be found + Table or view metadata could not be found + + + + Invalid format for binary column + Invalid format for binary column + + + + Allowed values for boolean columns are 0, 1, "true", or "false" + Boolean columns must be numeric 1 or 0, or string true or false + + + + A required cell value is missing + A required cell value is missing + + + + A delete is pending for this row, a cell update cannot be applied. + A delete is pending for this row, a cell update cannot be applied. + + + + Column ID must be in the range of columns for the query + Column ID must be in the range of columns for the query + + + + Column cannot be edited + Column cannot be edited + + + + No key columns were found + No key columns were found + + + + An output filename must be provided + An output filename must be provided + + + + Database object {0} cannot be used for editing. + Database object {0} cannot be used for editing. + . + Parameters: 0 - typeName (string) + + + Specified URI '{0}' does not have a default connection + Specified URI '{0}' does not have a default connection + . + Parameters: 0 - uri (string) + + + A commit task is in progress. Please wait for completion. + A commit task is in progress. Please wait for completion. + + + + Decimal column is missing numeric precision or numeric scale + Decimal column is missing numeric precision or numeric scale + + + + <TBD> + <TBD> + + + + Cannot add row to result buffer, data reader does not contain rows + Cannot add row to result buffer, data reader does not contain rows + + + + TIME column values must be between 00:00:00.0000000 and 23:59:59.9999999 + TIME column values must be between 00:00:00.0000000 and 23:59:59.9999999 + + + + NULL is not allowed for this column + NULL is not allowed for this column + + + + Edit session already exists. + Edit session already exists. + + + + Edit session has not been initialized + Edit session has not been initialized + + + + Edit session has already been initialized + Edit session has already been initialized + + + + Edit session has already been initialized or is in the process of initializing + Edit session has already been initialized or is in the process of initializing + + + + Query execution failed, see messages for details + Query execution failed, see messages for details + + + + Result limit cannot be negative + Result limit cannot be negative + + + + NULL + NULL + + + + A object name must be provided + A object name must be provided + + + + Explicitly specifying server or database is not supported + Explicitly specifying server or database is not supported + + + + Table metadata does not have extended properties + Table metadata does not have extended properties + + + + Table or view requested for edit could not be found + Table or view requested for edit could not be found + + + + Error expanding: {0} + Error expanding: {0} + + + + Error connecting to {0} + Error connecting to {0} + + + + Aggregates + Aggregates + + + + Server Roles + Server Roles + + + + Application Roles + Application Roles + + + + Assemblies + Assemblies + + + + Assembly Files + Assembly Files + + + + Asymmetric Keys + Asymmetric Keys + + + + Asymmetric Keys + Asymmetric Keys + + + + Data Compression Options + Data Compression Options + + + + Certificates + Certificates + + + + FileTables + FileTables + + + + Certificates + Certificates + + + + Check Constraints + Check Constraints + + + + Columns + Columns + + + + Constraints + Constraints + + + + Contracts + Contracts + + + + Credentials + Credentials + + + + Error Messages + Error Messages + + + + Server Role Membership + Server Role Membership + + + + Database Options + Database Options + + + + Database Roles + Database Roles + + + + Role Memberships + Role Memberships + + + + Database Triggers + Database Triggers + + + + Default Constraints + Default Constraints + + + + Defaults + Defaults + + + + Sequences + Sequences + + + + Endpoints + Endpoints + + + + Event Notifications + Event Notifications + + + + Server Event Notifications + Server Event Notifications + + + + Extended Properties + Extended Properties + + + + Filegroups + Filegroups + + + + Foreign Keys + Foreign Keys + + + + Full-Text Catalogs + Full-Text Catalogs + + + + Full-Text Indexes + Full-Text Indexes + + + + Functions + Functions + + + + Indexes + Indexes + + + + Inline Functions + Inline Functions + + + + Keys + Keys + + + + Linked Servers + Linked Servers + + + + Linked Server Logins + Linked Server Logins + + + + Logins + Logins + + + + Master Key + Master Key + + + + Master Keys + Master Keys + + + + Message Types + Message Types + + + + Table-Valued Functions + Table-Valued Functions + + + + Parameters + Parameters + + + + Partition Functions + Partition Functions + + + + Partition Schemes + Partition Schemes + + + + Permissions + Permissions + + + + Primary Keys + Primary Keys + + + + Programmability + Programmability + + + + Queues + Queues + + + + Remote Service Bindings + Remote Service Bindings + + + + Returned Columns + Returned Columns + + + + Roles + Roles + + + + Routes + Routes + + + + Rules + Rules + + + + Schemas + Schemas + + + + Security + Security + + + + Server Objects + Server Objects + + + + Management + Management + + + + Triggers + Triggers + + + + Service Broker + Service Broker + + + + Services + Services + + + + Signatures + Signatures + + + + Log Files + Log Files + + + + Statistics + Statistics + + + + Storage + Storage + + + + Stored Procedures + Stored Procedures + + + + Symmetric Keys + Symmetric Keys + + + + Synonyms + Synonyms + + + + Tables + Tables + + + + Triggers + Triggers + + + + Types + Types + + + + Unique Keys + Unique Keys + + + + User-Defined Data Types + User-Defined Data Types + + + + User-Defined Types (CLR) + User-Defined Types (CLR) + + + + Users + Users + + + + Views + Views + + + + XML Indexes + XML Indexes + + + + XML Schema Collections + XML Schema Collections + + + + User-Defined Table Types + User-Defined Table Types + + + + Files + Files + + + + Missing Caption + Missing Caption + + + + Broker Priorities + Broker Priorities + + + + Cryptographic Providers + Cryptographic Providers + + + + Database Audit Specifications + Database Audit Specifications + + + + Database Encryption Keys + Database Encryption Keys + + + + Event Sessions + Event Sessions + + + + Full Text Stoplists + Full Text Stoplists + + + + Resource Pools + Resource Pools + + + + Audits + Audits + + + + Server Audit Specifications + Server Audit Specifications + + + + Spatial Indexes + Spatial Indexes + + + + Workload Groups + Workload Groups + + + + SQL Files + SQL Files + + + + Server Functions + Server Functions + + + + SQL Type + SQL Type + + + + Server Options + Server Options + + + + Database Diagrams + Database Diagrams + + + + System Tables + System Tables + + + + Databases + Databases + + + + System Contracts + System Contracts + + + + System Databases + System Databases + + + + System Message Types + System Message Types + + + + System Queues + System Queues + + + + System Services + System Services + + + + System Stored Procedures + System Stored Procedures + + + + System Views + System Views + + + + Data-tier Applications + Data-tier Applications + + + + Extended Stored Procedures + Extended Stored Procedures + + + + Aggregate Functions + Aggregate Functions + + + + Approximate Numerics + Approximate Numerics + + + + Binary Strings + Binary Strings + + + + Character Strings + Character Strings + + + + CLR Data Types + CLR Data Types + + + + Configuration Functions + Configuration Functions + + + + Cursor Functions + Cursor Functions + + + + System Data Types + System Data Types + + + + Date and Time + Date and Time + + + + Date and Time Functions + Date and Time Functions + + + + Exact Numerics + Exact Numerics + + + + System Functions + System Functions + + + + Hierarchy Id Functions + Hierarchy Id Functions + + + + Mathematical Functions + Mathematical Functions + + + + Metadata Functions + Metadata Functions + + + + Other Data Types + Other Data Types + + + + Other Functions + Other Functions + + + + Rowset Functions + Rowset Functions + + + + Security Functions + Security Functions + + + + Spatial Data Types + Spatial Data Types + + + + String Functions + String Functions + + + + System Statistical Functions + System Statistical Functions + + + + Text and Image Functions + Text and Image Functions + + + + Unicode Character Strings + Unicode Character Strings + + + + Aggregate Functions + Aggregate Functions + + + + Scalar-valued Functions + Scalar-valued Functions + + + + Table-valued Functions + Table-valued Functions + + + + System Extended Stored Procedures + System Extended Stored Procedures + + + + Built-in Types + Built-in Types + + + + Built-in Server Roles + Built-in Server Roles + + + + User with Password + User with Password + + + + Search Property List + Search Property List + + + + Security Policies + Security Policies + + + + Security Predicates + Security Predicates + + + + Server Role + Server Role + + + + Search Property Lists + Search Property Lists + + + + Column Store Indexes + Column Store Indexes + + + + Table Type Indexes + Table Type Indexes + + + + ServerInstance + ServerInstance + + + + Selective XML Indexes + Selective XML Indexes + + + + XML Namespaces + XML Namespaces + + + + XML Typed Promoted Paths + XML Typed Promoted Paths + + + + T-SQL Typed Promoted Paths + T-SQL Typed Promoted Paths + + + + Database Scoped Credentials + Database Scoped Credentials + + + + External Data Sources + External Data Sources + + + + External File Formats + External File Formats + + + + External Resources + External Resources + + + + External Tables + External Tables + + + + Always Encrypted Keys + Always Encrypted Keys + + + + Column Master Keys + Column Master Keys + + + + Column Encryption Keys + Column Encryption Keys + + + + \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.xproj b/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.xproj index 358bb7c3..fa75a6cd 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.xproj +++ b/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.xproj @@ -1,19 +1,22 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - {0D61DC2B-DA66-441D-B9D0-F76C98F780F9} - Microsoft.SqlTools.ServiceLayer - .\obj - .\bin\ - v4.5.2 - - - 2.0 - - + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + {0D61DC2B-DA66-441D-B9D0-F76C98F780F9} + Microsoft.SqlTools.ServiceLayer + .\obj + .\bin\ + v4.5.2 + + + 2.0 + + + + + \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/CreateSessionRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/CreateSessionRequest.cs new file mode 100644 index 00000000..51226097 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/CreateSessionRequest.cs @@ -0,0 +1,45 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using Microsoft.SqlTools.Hosting.Protocol.Contracts; +using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts +{ + /// + /// Information returned from a . + /// Contains success information, a to be used when + /// requesting expansion of nodes, and a root node to display for this area. + /// + public class CreateSessionResponse + { + /// + /// Boolean indicating if the connection was successful + /// + public bool Success { get; set; } + + /// + /// Unique ID to use when sending any requests for objects in the + /// tree under the node + /// + public string SessionId { get; set; } + + /// + /// Information describing the base node in the tree + /// + public NodeInfo RootNode { get; set; } + } + /// + /// Establishes an Object Explorer tree session for a specific connection. + /// This will create a connection to a specific server or database, register + /// it for use in the + /// + public class CreateSessionRequest + { + public static readonly + RequestType Type = + RequestType.Create("objectexplorer/createsession"); + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/ExpandRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/ExpandRequest.cs new file mode 100644 index 00000000..a004d172 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/ExpandRequest.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using Microsoft.SqlTools.Hosting.Protocol.Contracts; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts +{ + /// + /// Information returned from a . + /// + public class ExpandResponse + { + /// + /// Unique ID to use when sending any requests for objects in the + /// tree under the node + /// + public string SessionId { get; set; } + + /// + /// Information describing the expanded nodes in the tree + /// + public NodeInfo[] Nodes { get; set; } + } + + /// + /// Parameters to the . + /// + public class ExpandParams + { + /// + /// The Id returned from a . This + /// is used to disambiguate between different trees. + /// + public string SessionId { get; set; } + + /// + /// Path identifying the node to expand. See for details + /// + public string NodePath { get; set; } + } + + /// + /// A request to expand a + /// + public class ExpandRequest + { + /// + /// Returns children of a given node as a array. + /// + public static readonly + RequestType Type = + RequestType.Create("objectexplorer/expand"); + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/NodeInfo.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/NodeInfo.cs new file mode 100644 index 00000000..b97f647d --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/NodeInfo.cs @@ -0,0 +1,40 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts +{ + /// + /// Information describing a Node in the Object Explorer tree. + /// Contains information required to display the Node to the user and + /// to know whether actions such as expanding children is possible + /// the node + /// + public class NodeInfo + { + /// + /// Path identifying this node: for example a table will be at ["server", "database", "tables", "tableName"]. + /// This enables rapid navigation of the tree without the need for a global registry of elements. + /// The path functions as a unique ID and is used to disambiguate the node when sending requests for expansion. + /// A common ID is needed since processes do not share address space and need a unique identifier + /// + public string NodePath { get; set; } + + /// + /// The type of the node - for example Server, Database, Folder, Table + /// + public string NodeType { get; set; } + + /// + /// Label to display to the user, describing this node. + /// + public string Label { get; set; } + + /// + /// Is this a leaf node (in which case no children can be generated) or + /// is it expandable? + /// + public bool IsLeaf { get; set; } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/RefreshRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/RefreshRequest.cs new file mode 100644 index 00000000..74cfc8ed --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/RefreshRequest.cs @@ -0,0 +1,39 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using Microsoft.SqlTools.Hosting.Protocol.Contracts; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts +{ + /// + /// Parameters to the . + /// + public class RefreshParams + { + /// + /// The Id returned from a . This + /// is used to disambiguate between different trees. + /// + public string SessionId { get; set; } + + /// + /// Path identifying the node to expand. See for details + /// + public string[] NodePath { get; set; } + } + + /// + /// A request to expand a + /// + public class RefreshRequest + { + /// + /// Returns children of a given node as a array. + /// + public static readonly + RequestType Type = + RequestType.Create("objectexplorer/refresh"); + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ChildFactory.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ChildFactory.cs new file mode 100644 index 00000000..cb412d79 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ChildFactory.cs @@ -0,0 +1,39 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System.Collections.Generic; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes +{ + /// + /// A supports creation of children + /// for a class of objects in the tree. The + /// + public abstract class ChildFactory + { + /// + /// The set of applicable parents for which the factory can create children. + /// + /// + /// the string names for each that + /// this factory can create children for + /// + public abstract IEnumerable ApplicableParents(); + + /// + /// Expands an element in the + /// + /// + /// + public abstract IEnumerable Expand(TreeNode parent); + + public abstract bool CanCreateChild(TreeNode parent, object context); + public abstract TreeNode CreateChild(TreeNode parent, object context); + + // TODO Consider whether Remove operations need to be supported + //public abstract bool CanRemoveChild(TreeNode parent, object context); + //public abstract int GetChildIndexToRemove(TreeNode parent, object context); + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeObservableCollection.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeObservableCollection.cs new file mode 100644 index 00000000..b7d8fad5 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeObservableCollection.cs @@ -0,0 +1,177 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes +{ + /// + /// A collection class for + /// + public sealed class NodeObservableCollection : ObservableCollection + { + public event EventHandler Initialized; + private int? numInits; + private static int cleanupBlocker; + + public bool IsInitialized + { + get { return numInits.HasValue && numInits == 0; } + } + + public bool IsPopulating + { + get { return numInits.HasValue && numInits != 0; } + } + + public void BeginInit() + { + if (!numInits.HasValue) + { + numInits = 1; + } + else + { + numInits = numInits + 1; + } + } + + public void EndInit() + { + IList empty = null; + EndInit(null, ref empty); + } + + public void EndInit(TreeNode parent, ref IList deferredChildren) + { + if (numInits.HasValue && + numInits.Value == 1) + { + try + { + DoSort(); + + if (deferredChildren != null) + { + // Set the parents so the children know how to sort themselves + foreach (var item in deferredChildren) + { + item.Parent = parent; + } + + deferredChildren = deferredChildren.OrderBy(x => x).ToList(); + + // Add the deferredChildren + foreach (var item in deferredChildren) + { + this.Add(item); + } + } + } + finally + { + if (deferredChildren != null) + { + deferredChildren.Clear(); + } + numInits = numInits - 1; + } + + Initialized?.Invoke(this, EventArgs.Empty); + } + else + { + numInits = numInits - 1; + } + } + + + /// + /// Repositions this child in the list + /// + public void ReSortChild(TreeNode child) + { + if (child == null) + return; + + List sorted = this.OrderBy(x => x).ToList(); + + // Remove without cleanup + try + { + cleanupBlocker++; + Remove(child); + } + finally + { + cleanupBlocker--; + } + + // Then insert + for (int i = 0; i < sorted.Count; i++) + { + if (sorted[i] == child) + { + Insert(i, child); + return; + } + } + } + + protected override void RemoveItem(int index) + { + // Cleanup all the children + Cleanup(this[index]); + + base.RemoveItem(index); + } + + protected override void ClearItems() + { + // Cleanup all the children + foreach (var child in this) + { + Cleanup(child); + } + + base.ClearItems(); + } + + private static void Cleanup(TreeNode parent) + { + if (cleanupBlocker > 0 || + parent.Parent == null) + return; + + // TODO implement cleanup policy / pattern + //ICleanupPattern parentAsCleanup = parent as ICleanupPattern; + //if (parentAsCleanup != null) + // parentAsCleanup.DoCleanup(); + + //foreach (var child in parent.Children) + //{ + // Cleanup(child); + //} + + parent.Parent = null; + } + + private void DoSort() + { + List sorted = this.OrderBy(x => x).ToList(); + for (int i = 0; i < sorted.Count(); i++) + { + int index = IndexOf(sorted[i]); + if (index != i) + { + Move(IndexOf(sorted[i]), i); + } + } + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs new file mode 100644 index 00000000..2305cb7f --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs @@ -0,0 +1,141 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes +{ + /// + /// Enum listing possible node types in the object explorer tree + /// + // TODO Consider replacing this with an auto-gen'd version + public enum NodeTypes + { + None, + SqlServersRoot, + DatabaseInstance, + DacInstance, + ServerInstance, + ScalarValuedFunctionInstance, + TableValuedFunctionInstance, + AggregateFunctionInstance, + FileGroupInstance, + StoredProcedureInstance, + UserDefinedTableTypeInstance, + ViewInstance, + TableInstance, + HistoryTableInstance, + Databases, + ExternalResources, + ServerLevelSecurity, + ServerLevelServerObjects, + ServerLevelManagement, + SystemDatabases, + ServerLevelLinkedServerLogins, + ServerLevelServerAudits, + ServerLevelCryptographicProviders, + ServerLevelCredentials, + ServerLevelServerRoles, + ServerLevelLogins, + ServerLevelEventSessions, + ServerLevelServerAuditSpecifications, + ServerLevelEventNotifications, + ServerLevelErrorMessages, + ServerLevelServerTriggers, + ServerLevelLinkedServers, + ServerLevelEndpoints, + DacInstancesFolder, + Tables, + Views, + Synonyms, + Programmability, + ServiceBroker, + Storage, + Security, + SystemTables, + FileTables, + SystemViews, + StoredProcedures, + Functions, + ExtendedStoredProcedures, + DatabaseTriggers, + Defaults, + Rules, + Types, + Assemblies, + MessageTypes, + Contracts, + Queues, + Services, + Routes, + DatabaseAndQueueEventNotifications, + RemoteServiceBindings, + BrokerPriorities, + FileGroups, + FullTextCatalogs, + FullTextStopLists, + SqlLogFiles, + PartitionFunctions, + PartitionSchemes, + SearchPropertyLists, + Users, + Roles, + Schemas, + AsymmetricKeys, + Certificates, + SymmetricKeys, + DatabaseEncryptionKeys, + MasterKeys, + Signatures, + DatabaseAuditSpecifications, + Columns, + Keys, + Constraints, + Triggers, + Indexes, + Statistics, + TableValuedFunctions, + ScalarValuedFunctions, + AggregateFunctions, + SystemDataTypes, + UserDefinedDataTypes, + UserDefinedTableTypes, + UserDefinedTypes, + XmlSchemaCollections, + SystemExactNumerics, + SystemApproximateNumerics, + SystemDateAndTimes, + SystemCharacterStrings, + SystemUnicodeCharacterStrings, + SystemBinaryStrings, + SystemOtherDataTypes, + SystemClrDataTypes, + SystemSpatialDataTypes, + UserDefinedTableTypeColumns, + UserDefinedTableTypeKeys, + UserDefinedTableTypeConstraints, + SystemStoredProcedures, + StoredProcedureParameters, + TableValuedFunctionParameters, + ScalarValuedFunctionParameters, + AggregateFunctionParameters, + DatabaseRoles, + ApplicationRoles, + FileGroupFiles, + SystemMessageTypes, + SystemContracts, + SystemServices, + SystemQueues, + Sequences, + SecurityPolicies, + DatabaseScopedCredentials, + ExternalTables, + ExternalResourceInstance, + ExternalDataSources, + ExternalFileFormats, + ExternalTableInstance, + AlwaysEncryptedKeys, + ColumnMasterKeys, + ColumnEncryptionKeys + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs new file mode 100644 index 00000000..11b5e74b --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs @@ -0,0 +1,329 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; +using Microsoft.SqlTools.Utility; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes +{ + /// + /// Base class for elements in the object explorer tree. Provides common methods for tree navigation + /// and other core functionality + /// + public class TreeNode : IComparable + { + private NodeObservableCollection children = new NodeObservableCollection(); + private TreeNode parent; + private string nodePath; + private string label; + private ObjectExplorerService objectExplorerService; + public const char PathPartSeperator = '/'; + + /// + /// Constructor with no required inputs + /// + public TreeNode() + { + + } + + /// + /// Constructor that accepts a label to identify the node + /// + /// Label identifying the node + public TreeNode(string value) + { + // We intentionally do not valid this being null or empty since + // some nodes may need to set it + NodeValue = value; + } + + /// + /// Value describing this node + /// + public string NodeValue { get; set; } + + /// + /// The type of the node - for example Server, Database, Folder, Table + /// + public string NodeType { get; set; } + + /// + /// Enum defining the type of the node - for example Server, Database, Folder, Table + /// + public NodeTypes NodeTypeId { get; set; } + + /// + /// Label to display to the user, describing this node. + /// If not explicitly set this will fall back to the but + /// for many nodes such as the server, the display label will be different + /// to the value. + /// + public string Label { + get + { + if(label == null) + { + return NodeValue; + } + return label; + } + set + { + label = value; + } + } + + /// + /// Is this a leaf node (in which case no children can be generated) or + /// is it expandable? + /// + public bool IsAlwaysLeaf { get; set; } + + /// + /// Message to show if this Node is in an error state. This indicates + /// that children could be retrieved + /// + public string ErrorStateMessage { get; set; } + + /// + /// Parent of this node + /// + public TreeNode Parent + { + get + { + return parent; + } + set + { + parent = value; + // Reset the node path since it's no longer valid + nodePath = null; + } + } + + /// + /// Path identifying this node: for example a table will be at ["server", "database", "tables", "tableName"]. + /// This enables rapid navigation of the tree without the need for a global registry of elements. + /// The path functions as a unique ID and is used to disambiguate the node when sending requests for expansion. + /// A common ID is needed since processes do not share address space and need a unique identifier + /// + public string GetNodePath() + { + if (nodePath == null) + { + GenerateNodePath(); + } + return nodePath; + } + + private void GenerateNodePath() + { + string path = ""; + ObjectExplorerUtils.VisitChildAndParents(this, node => + { + if (string.IsNullOrEmpty(node.NodeValue)) + { + // Hit a node with no NodeValue. This indicates we need to stop traversing + return false; + } + // Otherwise add this value to the beginning of the path and keep iterating up + path = string.Format(CultureInfo.InvariantCulture, + "{0}{1}{2}", node.NodeValue, string.IsNullOrEmpty(path) ? "" : PathPartSeperator.ToString(), path); + return true; + }); + nodePath = path; + } + + public TreeNode FindNodeByPath(string path) + { + TreeNode nodeForPath = ObjectExplorerUtils.FindNode(this, node => + { + return node.GetNodePath() == path; + }, nodeToFilter => + { + return path.StartsWith(nodeToFilter.GetNodePath()); + }); + + return nodeForPath; + } + + /// + /// Converts to a object for serialization with just the relevant properties + /// needed to identify the node + /// + /// + public NodeInfo ToNodeInfo() + { + return new NodeInfo() + { + IsLeaf = this.IsAlwaysLeaf, + Label = this.Label, + NodePath = this.GetNodePath(), + NodeType = this.NodeType + }; + } + + /// + /// Expands this node and returns its children + /// + /// Children as an IList. This is the raw children collection, not a copy + public IList Expand() + { + // TODO consider why solution explorer has separate Children and Items options + if (children.IsInitialized) + { + return children; + } + PopulateChildren(); + return children; + } + + /// + /// Gets a readonly view of the currently defined children for this node. + /// This does not expand the node at all + /// Since the tree needs to keep track of parent relationships, directly + /// adding to the list is not supported. + /// + /// containing all children for this node + public IList GetChildren() + { + return new ReadOnlyCollection(children); + } + + /// + /// Adds a child to the list of children under this node + /// + /// + public void AddChild(TreeNode newChild) + { + Validate.IsNotNull(nameof(newChild), newChild); + children.Add(newChild); + newChild.Parent = this; + } + + /// + /// Optional context to help with lookup of children + /// + public virtual object GetContext() + { + return null; + } + + /// + /// Helper method to convert context to expected format + /// + /// Type to convert to + /// context as expected type of null if it doesn't match + public T GetContextAs() + where T : class + { + return GetContext() as T; + } + + public T ParentAs() + where T : TreeNode + { + return Parent as T; + } + + protected void PopulateChildren() + { + Debug.Assert(IsAlwaysLeaf == false); + + SmoQueryContext context = this.GetContextAs(); + + if (children.IsPopulating || context == null) + return; + + children.Clear(); + BeginChildrenInit(); + + try + { + IEnumerable childFactories = context.GetObjectExplorerService().GetApplicableChildFactories(this); + if (childFactories != null) + { + foreach (var factory in childFactories) + { + IEnumerable items = factory.Expand(this); + if (items != null) + { + foreach (TreeNode item in items) + { + children.Add(item); + item.Parent = this; + + } + } + } + } + } + finally + { + EndChildrenInit(); + } + } + + public void BeginChildrenInit() + { + children.BeginInit(); + } + + public void EndChildrenInit() + { + children.EndInit(); + // TODO consider use of deferred children and if it's necessary + // children.EndInit(this, ref deferredChildren); + } + + + /// + /// Sort Priority to help when ordering elements in the tree + /// + public int? SortPriority { get; set; } + + protected virtual int CompareSamePriorities(TreeNode thisItem, TreeNode otherItem) + { + return string.Compare(thisItem.NodeValue, otherItem.NodeValue, StringComparison.OrdinalIgnoreCase); + } + + public int CompareTo(TreeNode other) + { + + if (!this.SortPriority.HasValue && + !other.SortPriority.HasValue) + { + return CompareSamePriorities(this, other); + } + + if (this.SortPriority.HasValue && + !other.SortPriority.HasValue) + { + return -1; // this is above other + } + if (!this.SortPriority.HasValue) + { + return 1; // this is below other + } + + // Both have sort priority + int priDiff = this.SortPriority.Value - other.SortPriority.Value; + if (priDiff < 0) + return -1; // this is below other + if (priDiff == 0) + return 0; + return 1; + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNodeWithContext.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNodeWithContext.cs new file mode 100644 index 00000000..0ff80faa --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNodeWithContext.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes +{ + public class TreeNodeWithContext + { + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ValidForFlag.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ValidForFlag.cs new file mode 100644 index 00000000..8b10051b --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ValidForFlag.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes +{ + /// + /// Indicates which type of server a given node type is valid for + /// + [Flags] + public enum ValidForFlag + { + Sql2005 = 0x01, + Sql2008 = 0x02, + Sql2012 = 0x04, + Sql2014 = 0x08, + Azure = 0x10, + NotDebugInstance = 0x20, + NotContainedUser = 0x40, + AzureV12 = 0x80, + Sql2016 = 0x100, + CanConnectToMaster = 0x200, + CanViewSecurity = 0x400, + SqlvNext = 0x800, + All = Sql2005 | Sql2008 | Sql2012 | Sql2014 | Sql2016 | SqlvNext | Azure | AzureV12 + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs new file mode 100644 index 00000000..bedad392 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs @@ -0,0 +1,344 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.SqlTools.Extensibility; +using Microsoft.SqlTools.Hosting; +using Microsoft.SqlTools.Hosting.Protocol; +using Microsoft.SqlTools.ServiceLayer.Connection; +using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; +using Microsoft.SqlTools.Utility; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer +{ + /// + /// A Service to support querying server and database information as an Object Explorer tree. + /// The APIs used for this are modeled closely on the VSCode TreeExplorerNodeProvider API. + /// + public class ObjectExplorerService : HostedService, IComposableService + { + internal const string uriPrefix = "objectexplorer://"; + + // Instance of the connection service, used to get the connection info for a given owner URI + private ConnectionService connectionService; + private IProtocolEndpoint serviceHost; + private Dictionary sessionMap; + private readonly Lazy>> applicableNodeChildFactories; + private IMultiServiceProvider serviceProvider; + + /// + /// Singleton constructor + /// + public ObjectExplorerService() + { + sessionMap = new Dictionary(); + applicableNodeChildFactories = new Lazy>>(() => PopulateFactories()); + } + + /// + /// Internal for testing only + /// + internal ObjectExplorerService(ExtensionServiceProvider serviceProvider) + : this() + { + SetServiceProvider(serviceProvider); + } + + private Dictionary> ApplicableNodeChildFactories + { + get + { + return applicableNodeChildFactories.Value; + } + } + + /// + /// As an , this will be set whenever the service is initialized + /// via an + /// + /// + public override void SetServiceProvider(IMultiServiceProvider provider) + { + Validate.IsNotNull(nameof(provider), provider); + serviceProvider = provider; + connectionService = provider.GetService(); + } + + /// + /// Initializes the service with the service host and registers request handlers. + /// + /// The service host instance to register with + public override void InitializeService(IProtocolEndpoint serviceHost) + { + this.serviceHost = serviceHost; + // Register handlers for requests + serviceHost.SetRequestHandler(CreateSessionRequest.Type, HandleCreateSessionRequest); + serviceHost.SetRequestHandler(ExpandRequest.Type, HandleExpandRequest); + } + + internal async Task HandleCreateSessionRequest(ConnectionDetails connectionDetails, RequestContext context) + { + Logger.Write(LogLevel.Verbose, "HandleCreateSessionRequest"); + Func> doCreateSession = async () => + { + Validate.IsNotNull(nameof(connectionDetails), connectionDetails); + Validate.IsNotNull(nameof(context), context); + + string uri = GenerateUri(connectionDetails); + + ObjectExplorerSession session; + if (!sessionMap.TryGetValue(uri, out session)) + { + // Establish a connection to the specified server/database + session = await DoCreateSession(connectionDetails, uri); + } + + CreateSessionResponse response; + if (session == null) + { + response = new CreateSessionResponse() { Success = false }; + } + else + { + // Else we have a session available, response with existing session information + response = new CreateSessionResponse() + { + Success = true, + RootNode = session.Root.ToNodeInfo(), + SessionId = session.Uri + }; + } + return response; + }; + + await HandleRequestAsync(doCreateSession, context, "HandleCreateSessionRequest"); + } + + internal async Task ExpandNode(ObjectExplorerSession session, string nodePath) + { + return await Task.Factory.StartNew(() => + { + NodeInfo[] nodes = null; + TreeNode node = session.Root.FindNodeByPath(nodePath); + if(node != null) + { + nodes = node.Expand().Select(x => x.ToNodeInfo()).ToArray(); + } + return nodes; + }); + } + + /// + /// Establishes a new session and stores its information + /// + /// object if successful, null if unsuccessful + internal async Task DoCreateSession(ConnectionDetails connectionDetails, string uri) + { + ObjectExplorerSession session; + + ConnectParams connectParams = new ConnectParams() { OwnerUri = uri, Connection = connectionDetails }; + + ConnectionCompleteParams connectionResult = await Connect(connectParams); + if (connectionResult == null) + { + return null; + } + + session = ObjectExplorerSession.CreateSession(connectionResult, serviceProvider); + sessionMap[uri] = session; + return session; + } + + + private async Task Connect(ConnectParams connectParams) + { + try + { + // open connection based on request details + ConnectionCompleteParams result = await connectionService.Connect(connectParams); + return result; + } + catch (Exception ex) + { + // Send a connection failed error message in this case. + ConnectionCompleteParams result = new ConnectionCompleteParams() + { + Messages = ex.ToString() + }; + await serviceHost.SendEvent(ConnectionCompleteNotification.Type, result); + return null; + } + } + + internal async Task HandleExpandRequest(ExpandParams expandParams, RequestContext context) + { + Logger.Write(LogLevel.Verbose, "HandleExpandRequest"); + Func> expandNode = async () => + { + Validate.IsNotNull(nameof(expandParams), expandParams); + Validate.IsNotNull(nameof(context), context); + + string uri = expandParams.SessionId; + ObjectExplorerSession session = null; + NodeInfo[] nodes = null; + if (sessionMap.ContainsKey(uri)) + { + session = sessionMap[uri]; + } + else + { + //TODO: error + } + + + if (session != null) + { + // Establish a connection to the specified server/database + nodes = await ExpandNode(session, expandParams.NodePath); + } + + ExpandResponse response; + response = new ExpandResponse() { Nodes = nodes, SessionId = uri }; + return response; + }; + + await HandleRequestAsync(expandNode, context, "HandleExpandRequest"); + } + + private async Task HandleRequestAsync(Func> handler, RequestContext requestContext, string requestType) + { + Logger.Write(LogLevel.Verbose, requestType); + + try + { + T result = await handler(); + await requestContext.SendResult(result); + } + catch (Exception ex) + { + await requestContext.SendError(ex.ToString()); + } + } + + /// + /// Generates a URI for object explorer using a similar pattern to Mongo DB (which has URI-based database definition) + /// as this should ensure uniqueness + /// + /// + /// string representing a URI + /// Internal for testing purposes only + internal static string GenerateUri(ConnectionDetails details) + { + Validate.IsNotNull("details", details); + string uri = string.Format(CultureInfo.InvariantCulture, "{0}{1}", uriPrefix, Uri.EscapeUriString(details.ServerName)); + uri = AppendIfExists(uri, "databaseName", details.DatabaseName); + uri = AppendIfExists(uri, "user", details.UserName); + return uri; + } + + private static string AppendIfExists(string uri, string propertyName, string propertyValue) + { + if (!string.IsNullOrEmpty(propertyValue)) + { + uri += string.Format(CultureInfo.InvariantCulture, ";{0}={1}", propertyName, Uri.EscapeUriString(propertyValue)); + } + return uri; + } + + public IEnumerable GetApplicableChildFactories(TreeNode item) + { + if (ApplicableNodeChildFactories != null) + { + HashSet applicableFactories; + if (ApplicableNodeChildFactories.TryGetValue(item.NodeTypeId.ToString(), out applicableFactories)) + { + return applicableFactories; + } + } + return null; + } + + internal Dictionary> PopulateFactories() + { + VerifyServicesInitialized(); + + var childFactories = new Dictionary>(); + // Create our list of all NodeType to ChildFactory objects so we can expand appropriately + foreach (var factory in serviceProvider.GetServices()) + { + var parents = factory.ApplicableParents(); + if (parents != null) + { + foreach (var parent in parents) + { + AddToApplicableChildFactories(childFactories, factory, parent); + } + } + } + return childFactories; + } + + private void VerifyServicesInitialized() + { + if (serviceProvider == null) + { + throw new InvalidOperationException(SqlTools.Hosting.Localization.sr.ServiceProviderNotSet); + } + if (connectionService == null) + { + throw new InvalidOperationException(SqlTools.Hosting.Localization.sr.ServiceProviderNotSet); + } + } + + private static void AddToApplicableChildFactories(Dictionary> childFactories, ChildFactory factory, string parent) + { + HashSet applicableFactories; + if (!childFactories.TryGetValue(parent, out applicableFactories)) + { + applicableFactories = new HashSet(); + childFactories[parent] = applicableFactories; + } + applicableFactories.Add(factory); + } + + internal class ObjectExplorerSession + { + private ConnectionService connectionService; + private IMultiServiceProvider serviceProvider; + + // TODO decide whether a cache is needed to handle lookups in elements with a large # children + //private const int Cachesize = 10000; + //private Cache cache; + + public ObjectExplorerSession(string uri, TreeNode root, IMultiServiceProvider serviceProvider, ConnectionService connectionService) + { + Validate.IsNotNullOrEmptyString("uri", uri); + Validate.IsNotNull("root", root); + Uri = uri; + Root = root; + this.serviceProvider = serviceProvider; + this.connectionService = connectionService; + } + + public string Uri { get; private set; } + public TreeNode Root { get; private set; } + + public static ObjectExplorerSession CreateSession(ConnectionCompleteParams response, IMultiServiceProvider serviceProvider) + { + TreeNode serverNode = new ServerNode(response, serviceProvider); + return new ObjectExplorerSession(response.OwnerUri, serverNode, serviceProvider, serviceProvider.GetService()); + } + + } + } + +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerUtils.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerUtils.cs new file mode 100644 index 00000000..443c93a3 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerUtils.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer +{ + /// + /// Utility class for Object Explorer related operations + /// + public static class ObjectExplorerUtils + { + /// + /// Visitor that walks all nodes from the child to the root node, unless the + /// function indicates that this should stop traversing + /// + /// node to start traversing at + /// Predicate function that accesses the tree and + /// determines whether to stop going further up the tree + /// + /// boolean - true to continue navigating up the tree, false to end the loop + /// and return early + /// + public static bool VisitChildAndParents(TreeNode child, Predicate visitor) + { + if (child == null) + { + // End case: all nodes have been visited + return true; + } + + // Visit the child first, then go up the parents + if (!visitor(child)) + { + return false; + } + return VisitChildAndParents(child.Parent, visitor); + } + + /// + /// Finds a node by traversing the tree starting from the given node through all the children + /// + /// node to start traversing at + /// Predicate function that accesses the tree and + /// determines whether to stop going further up the tree + /// Predicate function to filter the children when traversing + /// A Tree Node that matches the condition + public static TreeNode FindNode(TreeNode node, Predicate condition, Predicate filter) + { + if(node == null) + { + return null; + } + + if (condition(node)) + { + return node; + } + foreach (var child in node.GetChildren()) + { + if (filter != null && filter(child)) + { + TreeNode childNode = FindNode(child, condition, filter); + if (childNode != null) + { + return childNode; + } + } + } + return null; + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/DatabaseInstanceTreeNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/DatabaseInstanceTreeNode.cs new file mode 100644 index 00000000..cf375376 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/DatabaseInstanceTreeNode.cs @@ -0,0 +1,30 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + + +using Microsoft.SqlServer.Management.Smo; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + internal partial class DatabaseInstanceTreeNode + { + + /// + /// Initializes the context and ensures that + /// + protected override void EnsureContextInitialized() + { + if (context == null) + { + base.EnsureContextInitialized(); + Database db = SmoObject as Database; + if (context != null && db != null) + { + context.Database = db; + } + } + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/FolderNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/FolderNode.cs new file mode 100644 index 00000000..1ee4f221 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/FolderNode.cs @@ -0,0 +1,33 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using Microsoft.SqlServer.Management.Smo; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + /// + /// Represents a folder node in the tree + /// + public class FolderNode : SmoTreeNode + { + /// + /// For folders, this copies the context of its parent if available + /// + /// + public override object GetContext() + { + return Parent?.GetContext(); + } + + /// + /// For folders, searches for its parent's SMO object rather than copying for itself + /// + /// from this parent's parent, or null if not found + public override NamedSmoObject GetParentSmoObject() + { + return ParentAs()?.GetParentSmoObject(); + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/ServerNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/ServerNode.cs new file mode 100644 index 00000000..3703f7b7 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/ServerNode.cs @@ -0,0 +1,192 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Data.Common; +using System.Data.SqlClient; +using System.Globalization; +using System.Linq; +using Microsoft.SqlServer.Management.Common; +using Microsoft.SqlServer.Management.Smo; +using Microsoft.SqlTools.Extensibility; +using Microsoft.SqlTools.ServiceLayer.Connection; +using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; +using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; +using Microsoft.SqlTools.ServiceLayer.Utility; +using Microsoft.SqlTools.Utility; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + /// + /// Server node implementation + /// + public class ServerNode : TreeNode + { + private ConnectionSummary connectionSummary; + private ServerInfo serverInfo; + private string connectionUri; + private Lazy context; + private ConnectionService connectionService; + private SmoServerCreator serverCreator; + + public ServerNode(ConnectionCompleteParams connInfo, IMultiServiceProvider serviceProvider) + : base() + { + Validate.IsNotNull(nameof(connInfo), connInfo); + Validate.IsNotNull("connInfo.ConnectionSummary", connInfo.ConnectionSummary); + Validate.IsNotNull(nameof(serviceProvider), serviceProvider); + + this.connectionSummary = connInfo.ConnectionSummary; + this.serverInfo = connInfo.ServerInfo; + this.connectionUri = connInfo.OwnerUri; + + this.connectionService = serviceProvider.GetService(); + + this.context = new Lazy(() => CreateContext(serviceProvider)); + + NodeValue = connectionSummary.ServerName; + IsAlwaysLeaf = false; + NodeType = NodeTypes.ServerInstance.ToString(); + NodeTypeId = NodeTypes.ServerInstance; + Label = GetConnectionLabel(); + } + + internal SmoServerCreator ServerCreator + { + get + { + if (serverCreator == null) + { + ServerCreator = new SmoServerCreator(); + } + return serverCreator; + } + set + { + this.serverCreator = value; + } + } + + /// + /// Returns the label to display to the user. + /// + internal string GetConnectionLabel() + { + string userName = connectionSummary.UserName; + + // TODO Domain and username is not yet supported on .Net Core. + // Consider passing as an input from the extension where this can be queried + //if (string.IsNullOrWhiteSpace(userName)) + //{ + // userName = Environment.UserDomainName + @"\" + Environment.UserName; + //} + + // TODO Consider adding IsAuthenticatingDatabaseMaster check in the code and + // referencing result here + if (!string.IsNullOrWhiteSpace(connectionSummary.DatabaseName) && + string.Compare(connectionSummary.DatabaseName, CommonConstants.MasterDatabaseName, StringComparison.OrdinalIgnoreCase) != 0 && + (serverInfo.IsCloud /* || !ci.IsAuthenticatingDatabaseMaster */)) + { + // We either have an azure with a database specified or a Denali database using a contained user + userName += ", " + connectionSummary.DatabaseName; + } + + string label; + if (string.IsNullOrWhiteSpace(userName)) + { + label = string.Format( + CultureInfo.InvariantCulture, + "{0} ({1} {2})", + connectionSummary.ServerName, + "SQL Server", + serverInfo.ServerVersion); + } + else + { + label = string.Format( + CultureInfo.InvariantCulture, + "{0} ({1} {2} - {3})", + connectionSummary.ServerName, + "SQL Server", + serverInfo.ServerVersion, + userName); + } + + return label; + } + + private SmoQueryContext CreateContext(IMultiServiceProvider serviceProvider) + { + string exceptionMessage; + ConnectionInfo connectionInfo; + SqlConnection connection = null; + // Get server object from connection + if (!connectionService.TryFindConnection(this.connectionUri, out connectionInfo) || + connectionInfo.AllConnections == null || connectionInfo.AllConnections.Count == 0) + { + ErrorStateMessage = string.Format(CultureInfo.CurrentCulture, + SR.ServerNodeConnectionError, connectionSummary.ServerName); + return null; + } + //TODO: figure out how to use existing connections + DbConnection dbConnection = connectionInfo.AllConnections.First(); + ReliableSqlConnection reliableSqlConnection = dbConnection as ReliableSqlConnection; + SqlConnection sqlConnection = dbConnection as SqlConnection; + if (reliableSqlConnection != null) + { + connection = reliableSqlConnection.GetUnderlyingConnection(); + } + else if (sqlConnection != null) + { + connection = sqlConnection; + } + else + { + ErrorStateMessage = string.Format(CultureInfo.CurrentCulture, + SR.ServerNodeConnectionError, connectionSummary.ServerName); + return null; + } + + try + { + Server server = ServerCreator.Create(connection); + return new SmoQueryContext(server, serviceProvider) + { + Parent = server + }; + } + catch (ConnectionFailureException cfe) + { + exceptionMessage = cfe.Message; + } + catch (Exception ex) + { + exceptionMessage = ex.Message; + } + + Logger.Write(LogLevel.Error, "Exception at ServerNode.CreateContext() : " + exceptionMessage); + this.ErrorStateMessage = string.Format(SR.TreeNodeError, exceptionMessage); + return null; + } + + public override object GetContext() + { + return context.Value; + } + } + + /// + /// Internal for testing purposes only + /// + internal class SmoServerCreator + { + public virtual Server Create(SqlConnection connection) + { + ServerConnection serverConn = new ServerConnection(connection); + return new Server(serverConn); + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs new file mode 100644 index 00000000..6aa7a072 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs @@ -0,0 +1,161 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using Microsoft.SqlServer.Management.Smo; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; +using Microsoft.SqlTools.ServiceLayer.Utility; +using Microsoft.SqlTools.Utility; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + public class SmoChildFactoryBase : ChildFactory + { + public override IEnumerable ApplicableParents() + { + return null; + } + + public override IEnumerable Expand(TreeNode parent) + { + //parent.BeginChildrenInit(); + try + { + List allChildren = new List(); + OnExpandPopulateFolders(allChildren, parent); + RemoveFoldersFromInvalidSqlServerVersions(allChildren, parent); + OnExpandPopulateNonFolders(allChildren, parent); + OnBeginAsyncOperations(parent); + return allChildren; + } + finally + { + //parent.EndChildrenInit(); + } + } + + /// + /// Populates any folders for a given parent node + /// + /// List to which nodes should be added + /// Parent the nodes are being added to + protected virtual void OnExpandPopulateFolders(IList allChildren, TreeNode parent) + { + } + + /// + /// Populates any non-folder nodes such as specific items in the tree. + /// + /// List to which nodes should be added + /// Parent the nodes are being added to + protected virtual void OnExpandPopulateNonFolders(IList allChildren, TreeNode parent) + { + if (ChildQuerierTypes == null) + { + // This node does not support non-folder children + return; + } + SmoQueryContext context = parent.GetContextAs(); + Validate.IsNotNull(nameof(context), context); + IEnumerable queriers = context.ServiceProvider.GetServices(q => IsCompatibleQuerier(q)); + foreach (var querier in queriers) + { + foreach(var smoObject in querier.Query(context)) + { + if (smoObject == null) + { + Console.WriteLine("smoObject should not be null"); + } + TreeNode childNode = CreateChild(parent, smoObject); + if (childNode != null) + { + allChildren.Add(childNode); + } + } + } + } + + private bool IsCompatibleQuerier(SmoQuerier querier) + { + if (ChildQuerierTypes == null) + { + return false; + } + + Type actualType = querier.GetType(); + foreach (Type childType in ChildQuerierTypes) + { + // We will accept any querier that is compatible with the listed querier type + if (childType.IsAssignableFrom(actualType)) + { + return true; + } + } + return false; + + } + + /// + /// Filters out invalid folders if they cannot be displayed for the current server version + /// + /// List to which nodes should be added + /// Parent the nodes are being added to + protected virtual void RemoveFoldersFromInvalidSqlServerVersions(IList allChildren, TreeNode parent) + { + } + + // TODO Assess whether async operations node is required + protected virtual void OnBeginAsyncOperations(TreeNode parent) + { + } + + public override bool CanCreateChild(TreeNode parent, object context) + { + return false; + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + throw new NotImplementedException(); + } + + protected virtual void InitializeChild(TreeNode child, object context) + { + NamedSmoObject smoObj = context as NamedSmoObject; + if (smoObj == null) + { + Debug.WriteLine("context is not a NamedSmoObject. type: " + context.GetType()); + } + else + { + SmoTreeNode childAsMeItem = (SmoTreeNode)child; + childAsMeItem.CacheInfoFromModel(smoObj); + } + } + + internal virtual Type[] ChildQuerierTypes { + get + { + return null; + } + } + + /// + /// Returns true if any final validation of the object to be added passes, and false + /// if validation fails. This provides a chance to filter specific items out of a list + /// + /// + /// + /// boolean + public virtual bool PassesFinalFilters(TreeNode parent, object context) + { + return true; + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoCollectionWrapper.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoCollectionWrapper.cs new file mode 100644 index 00000000..13122300 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoCollectionWrapper.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Collections; +using System.Collections.Generic; +using Microsoft.SqlServer.Management.Smo; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + /// + /// Wrapper to convert non-generic Smo enumerables to generic enumerable types for easier use in + /// + /// + public class SmoCollectionWrapper : IEnumerable + where T : SqlSmoObject + { + private SmoCollectionBase collection; + + /// + /// Constructor which accepts a containing the objects + /// to wrap + /// + /// or null if none were set + public SmoCollectionWrapper(SmoCollectionBase collection) + { + this.collection = collection; + } + + /// + /// + /// + /// + public IEnumerator GetEnumerator() + { + if (collection == null) + { + yield break; + } + foreach(Object obj in collection) + { + yield return (T)obj; + } + } + + /// + /// + /// + /// + IEnumerator IEnumerable.GetEnumerator() + { + return collection?.GetEnumerator(); + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs new file mode 100644 index 00000000..87373258 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs @@ -0,0 +1,42 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Collections.Generic; +using Microsoft.SqlServer.Management.Smo; +using Microsoft.SqlTools.Extensibility; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + /// + /// A handles SMO queries for one or more SMO object types. + /// The property defines which types can be queried. + /// + /// To query multiple + /// + public abstract class SmoQuerier : IComposableService + { + public abstract Type[] SupportedObjectTypes { get; } + + /// + /// Queries SMO for a collection of objects using the + /// + /// + /// + public abstract IEnumerable Query(SmoQueryContext context); + + internal IMultiServiceProvider ServiceProvider + { + get; + private set; + } + + public void SetServiceProvider(IMultiServiceProvider provider) + { + ServiceProvider = provider; + } + } + +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryContext.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryContext.cs new file mode 100644 index 00000000..d933c5f9 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryContext.cs @@ -0,0 +1,102 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using Microsoft.SqlServer.Management.Smo; +using Microsoft.SqlTools.Extensibility; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + /// + /// Context object containing key properties needed to query for SMO objects + /// + public class SmoQueryContext + { + /// + /// Creates a context object with a server to use as the basis for any queries + /// + /// + public SmoQueryContext(Server server, IMultiServiceProvider serviceProvider) + { + Server = server; + ServiceProvider = serviceProvider; + } + + /// + /// The server SMO will query against + /// + public Server Server { get; private set; } + + /// + /// Optional Database context object to query against + /// + public Database Database { get; set; } + + /// + /// Parent of a give node to use for queries + /// + public SmoObjectBase Parent { get; set; } + + /// + /// A query loader that can be used to find objects + /// for specific SMO types + /// + public IMultiServiceProvider ServiceProvider { get; private set; } + + /// + /// Helper method to cast a parent to a specific type + /// + /// + /// + public T ParentAs() + where T : TreeNode + { + return Parent as T; + } + + /// + /// Gets the if available, by looking it up + /// from the + /// + /// + /// + /// Thrown if the is not set or the + /// isn't available from that provider + /// + public ObjectExplorerService GetObjectExplorerService() + { + if (ServiceProvider == null) + { + throw new InvalidOperationException(SqlTools.Hosting.Localization.sr.ServiceProviderNotSet); + } + ObjectExplorerService service = ServiceProvider.GetService(); + if (service == null) + { + throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, + SqlTools.Hosting.Localization.sr.ServiceNotFound, nameof(ObjectExplorerService))); + } + + return service; + } + /// + /// Copies the context for use by another node + /// + /// New Parent to set + /// new with all fields except the same + public SmoQueryContext CopyWithParent(SmoObjectBase parent) + { + SmoQueryContext context = new SmoQueryContext(this.Server, this.ServiceProvider) + { + Database = this.Database, + Parent = parent + }; + return context; + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs new file mode 100644 index 00000000..a87a1dc4 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs @@ -0,0 +1,1583 @@ + + + + + + + + + +// This file was generated by a T4 Template. Do not modify directly, instead update the SmoQueryModelDefinition.xml file +// and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool", +// or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen". + +using System; +using System.Collections.Generic; +using System.Composition; +using System.Linq; +using Microsoft.SqlServer.Management.Smo; +using Microsoft.SqlServer.Management.Smo.Broker; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + + [Export(typeof(SmoQuerier))] + internal partial class SqlDatabaseQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Database) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.Databases; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlLinkedServerLoginQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(LinkedServer) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.LinkedServers; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlLoginQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Login) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.Logins; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlServerRoleQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ServerRole) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.Roles; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlCredentialQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Credential) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.Credentials; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlCryptographicProviderQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(CryptographicProvider) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.CryptographicProviders; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlServerAuditQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Audit) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.Audits; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlServerAuditSpecificationQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ServerAuditSpecification) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.ServerAuditSpecifications; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlEndpointQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Endpoint) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.Endpoints; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlLinkedServerQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(LinkedServer) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.LinkedServers; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlServerDdlTriggerQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ServerDdlTrigger) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.Triggers; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlErrorMessageQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(UserDefinedMessage) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.UserDefinedMessages; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlTableQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Table) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Tables; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlViewQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(View) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Views; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlSynonymQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Synonym) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Synonyms; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlColumnQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Column) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + TableViewTableTypeBase parentTableViewTableTypeBase = context.Parent as TableViewTableTypeBase; + if (parentTableViewTableTypeBase != null) + { + var retValue = parentTableViewTableTypeBase.Columns; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlIndexQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Index) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + TableViewTableTypeBase parentTableViewTableTypeBase = context.Parent as TableViewTableTypeBase; + if (parentTableViewTableTypeBase != null) + { + var retValue = parentTableViewTableTypeBase.Indexes; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlCheckQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Check) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Table parentTable = context.Parent as Table; + if (parentTable != null) + { + var retValue = parentTable.Checks; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlForeignKeyConstraintQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ForeignKey) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Table parentTable = context.Parent as Table; + if (parentTable != null) + { + var retValue = parentTable.ForeignKeys; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlDefaultConstraintQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(DefaultConstraint) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Column parentColumn = context.Parent as Column; + if (parentColumn != null) + { + var retValue = parentColumn.DefaultConstraint; + if(retValue != null) + { + return new SqlSmoObject[] { retValue }; + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlDmlTriggerQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Trigger) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Table parentTable = context.Parent as Table; + if (parentTable != null) + { + var retValue = parentTable.Triggers; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlFullTextIndexQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(FullTextIndex) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Table parentTable = context.Parent as Table; + if (parentTable != null) + { + var retValue = parentTable.FullTextIndex; + if(retValue != null) + { + return new SqlSmoObject[] { retValue }; + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlStatisticQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Statistic) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + TableViewBase parentTableViewBase = context.Parent as TableViewBase; + if (parentTableViewBase != null) + { + var retValue = parentTableViewBase.Statistics; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlDatabaseDdlTriggerQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Trigger) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Triggers; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlAssemblyQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(SqlAssembly) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Assemblies; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlRuleQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Rule) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Rules; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlDefaultQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Default) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Defaults; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlSequenceQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Sequence) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Sequences; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlSystemDataTypeQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(SystemDataType) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.SystemDataTypes; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlUserDefinedDataTypeQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(UserDefinedDataType) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.UserDefinedDataTypes; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlUserDefinedTableTypeQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(UserDefinedTableType) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.UserDefinedTableTypes; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlXmlSchemaCollectionQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(XmlSchemaCollection) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.XmlSchemaCollections; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlUserDefinedTypeQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(UserDefinedType) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.UserDefinedTypes; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlUserDefinedFunctionQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(UserDefinedFunction) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.UserDefinedFunctions; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlUserDefinedAggregateQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(UserDefinedAggregate) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.UserDefinedAggregates; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlFileGroupQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(FileGroup) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.FileGroups; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlFileQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(DataFile) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + FileGroup parentFileGroup = context.Parent as FileGroup; + if (parentFileGroup != null) + { + var retValue = parentFileGroup.Files; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlFullTextCatalogQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(FullTextCatalog) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.FullTextCatalogs; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlFullTextStopListQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(FullTextStopList) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.FullTextStopLists; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlPartitionFunctionQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(PartitionFunction) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.PartitionFunctions; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlPartitionSchemeQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(PartitionScheme) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.PartitionSchemes; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlSearchPropertyListQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(SearchPropertyList) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.SearchPropertyLists; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlUserQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(User) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Users; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlSchemaQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Schema) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Schemas; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlAsymmetricKeyQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(AsymmetricKey) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.AsymmetricKeys; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlCertificateQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Certificate) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Certificates; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlSymmetricKeyQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(SymmetricKey) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.SymmetricKeys; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlDatabaseEncryptionKeyQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(DatabaseEncryptionKey) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.DatabaseEncryptionKey; + if(retValue != null) + { + return new SqlSmoObject[] { retValue }; + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlMasterKeyQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(MasterKey) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.MasterKey; + if(retValue != null) + { + return new SqlSmoObject[] { retValue }; + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlDatabaseAuditSpecificationQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(DatabaseAuditSpecification) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.DatabaseAuditSpecifications; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlSecurityPolicyQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(SecurityPolicy) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.SecurityPolicies; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlDatabaseCredentialQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(DatabaseScopedCredential) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.DatabaseScopedCredentials; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlRoleQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(DatabaseRole) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.Roles; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlApplicationRoleQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ApplicationRole) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.ApplicationRoles; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlColumnMasterKeyQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ColumnMasterKey) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.ColumnMasterKeys; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlColumnEncryptionKeyQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ColumnEncryptionKey) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.ColumnEncryptionKeys; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlServiceBrokerQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ServiceBroker) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.ServiceBroker; + if(retValue != null) + { + return new SqlSmoObject[] { retValue }; + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlServiceQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(BrokerService) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + ServiceBroker parentServiceBroker = context.Parent as ServiceBroker; + if (parentServiceBroker != null) + { + var retValue = parentServiceBroker.Services; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlContractQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ServiceContract) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + ServiceBroker parentServiceBroker = context.Parent as ServiceBroker; + if (parentServiceBroker != null) + { + var retValue = parentServiceBroker.ServiceContracts; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlQueueQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ServiceQueue) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + ServiceBroker parentServiceBroker = context.Parent as ServiceBroker; + if (parentServiceBroker != null) + { + var retValue = parentServiceBroker.Queues; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlRemoteServiceBindingQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(RemoteServiceBinding) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + ServiceBroker parentServiceBroker = context.Parent as ServiceBroker; + if (parentServiceBroker != null) + { + var retValue = parentServiceBroker.RemoteServiceBindings; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlBrokerPriorityQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(BrokerPriority) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + ServiceBroker parentServiceBroker = context.Parent as ServiceBroker; + if (parentServiceBroker != null) + { + var retValue = parentServiceBroker.Priorities; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlMessageTypeQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(MessageType) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + ServiceBroker parentServiceBroker = context.Parent as ServiceBroker; + if (parentServiceBroker != null) + { + var retValue = parentServiceBroker.MessageTypes; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlExternalDataSourceQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ExternalDataSource) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.ExternalDataSources; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlExternalFileFormatQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ExternalFileFormat) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.ExternalFileFormats; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlProcedureQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(StoredProcedure) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.StoredProcedures; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlExtendedStoredProcedureQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(ExtendedStoredProcedure) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Database parentDatabase = context.Parent as Database; + if (parentDatabase != null) + { + var retValue = parentDatabase.ExtendedStoredProcedures; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlSubroutineParameterQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(Parameter) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + StoredProcedure parentStoredProcedure = context.Parent as StoredProcedure; + if (parentStoredProcedure != null) + { + var retValue = parentStoredProcedure.Parameters; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + UserDefinedAggregate parentUserDefinedAggregate = context.Parent as UserDefinedAggregate; + if (parentUserDefinedAggregate != null) + { + var retValue = parentUserDefinedAggregate.Parameters; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + UserDefinedFunction parentUserDefinedFunction = context.Parent as UserDefinedFunction; + if (parentUserDefinedFunction != null) + { + var retValue = parentUserDefinedFunction.Parameters; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlPartitionFunctionParameterQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(PartitionFunctionParameter) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + PartitionFunction parentPartitionFunction = context.Parent as PartitionFunction; + if (parentPartitionFunction != null) + { + var retValue = parentPartitionFunction.PartitionFunctionParameters; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + + [Export(typeof(SmoQuerier))] + internal partial class SqlBuiltInTypeQuerier: SmoQuerier + { + Type[] supportedTypes = new Type[] { typeof(SystemDataType) }; + + public override Type[] SupportedObjectTypes { get { return supportedTypes; } } + + public override IEnumerable Query(SmoQueryContext context) + { + Server parentServer = context.Parent as Server; + if (parentServer != null) + { + var retValue = parentServer.SystemDataTypes; + if(retValue != null) + { + return new SmoCollectionWrapper(retValue); + } + } + return Enumerable.Empty(); + } + } + +} + diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt new file mode 100644 index 00000000..99fe3fcd --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt @@ -0,0 +1,215 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ output extension=".cs" #> +<#@ assembly name="System.Xml.dll" #> +<#@ import namespace="System" #> +<#@ import namespace="System.Globalization" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Xml" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +// This file was generated by a T4 Template. Do not modify directly, instead update the SmoQueryModelDefinition.xml file +// and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool", +// or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen". + +using System; +using System.Collections.Generic; +using System.Composition; +using System.Linq; +using Microsoft.SqlServer.Management.Smo; +using Microsoft.SqlServer.Management.Smo.Broker; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ +<# + var directory = Path.GetDirectoryName(Host.TemplateFile); + string xmlFile = Path.Combine(directory, "SmoQueryModelDefinition.xml"); + + ///////// + // Now generate all the Query methods + ///////// + var allNodes = GetNodes(xmlFile); + var indent = " "; + foreach (var nodeName in allNodes) + { + XmlElement nodeElement = GetNodeElement(xmlFile, nodeName); + IList parents = GetParents(nodeElement, xmlFile, nodeName); + string nodeType = GetNodeType(nodeElement, nodeName); + + string queryBaseClass = "SmoQuerier"; + PushIndent(indent); + WriteLine(""); + WriteLine(string.Format("[Export(typeof({0}))]", queryBaseClass)); + WriteLine(string.Format("internal partial class {0}Querier: {1}", nodeName, queryBaseClass)); + WriteLine("{"); + PushIndent(indent); + + // Supported Types + WriteLine("Type[] supportedTypes = new Type[] { typeof("+ nodeType + ") };"); + WriteLine(""); + WriteLine("public override Type[] SupportedObjectTypes { get { return supportedTypes; } }"); + WriteLine(""); + + // Query impl + WriteLine("public override IEnumerable Query(SmoQueryContext context)"); + WriteLine("{"); + PushIndent(indent); + + // TODO Allow override of the navigation path + foreach(var parentType in parents) + { + string parentVar = string.Format("parent{0}", parentType); + WriteLine(string.Format("{0} {1} = context.Parent as {0};", parentType, parentVar)); + WriteLine(string.Format("if ({0} != null)", parentVar)); + WriteLine("{"); + PushIndent(indent); + + string navigationPath = GetNavigationPath(nodeElement, xmlFile, nodeName, parentType); + WriteLine(string.Format("var retValue = {0}.{1};", parentVar, navigationPath)); + WriteLine("if(retValue != null)"); + WriteLine("{"); + PushIndent(indent); + if (IsCollection(nodeElement)) + { + WriteLine(string.Format("return new SmoCollectionWrapper<{0}>(retValue);", nodeType)); + } + else + { + WriteLine("return new SqlSmoObject[] { retValue };"); + } + PopIndent(); + WriteLine("}"); + PopIndent(); + WriteLine("}"); // close If + } + + WriteLine("return Enumerable.Empty();"); + + PopIndent(); + WriteLine("}"); // close Query method + PopIndent(); + WriteLine("}"); // close Class + PopIndent(); + } +#> +} + +<#+ + + public static string[] GetNodes(string xmlFile) + { + List typesList = new List(); + XmlDocument doc = new XmlDocument(); + doc.Load(xmlFile); + XmlNodeList treeTypes = doc.SelectNodes("/SmoQueryModel/Node"); + if (treeTypes != null) + { + foreach (var type in treeTypes) + { + XmlElement element = type as XmlElement; + if (element != null) + { + typesList.Add(element.GetAttribute("Name")); + } + } + } + return typesList.ToArray(); + } + + public static XmlElement GetNodeElement(string xmlFile, string nodeName) + { + XmlDocument doc = new XmlDocument(); + doc.Load(xmlFile); + return (XmlElement)doc.SelectSingleNode(string.Format("/SmoQueryModel/Node[@Name='{0}']", nodeName)); + } + + public static string GetNavPathField(string xmlFile, string nodeName, string parent) + { + XmlDocument doc = new XmlDocument(); + doc.Load(xmlFile); + XmlElement navPathElement = (XmlElement)doc.SelectSingleNode(string.Format("/SmoQueryModel/Node[@Name='{0}']/NavigationPath[@Parent='{1}']", nodeName, parent)); + + return navPathElement?.GetAttribute("Field"); + } + + public static string GetNavigationPath(XmlElement nodeElement, string xmlFile, string nodeName, string parentName) + { + string navPathField = GetNavPathField(xmlFile, nodeName, parentName); + if (!string.IsNullOrEmpty(navPathField)) + { + return navPathField; + } + // else use pluralized type as this is the most common scenario + string nodeType = GetNodeType(nodeElement, nodeName); + + string nodeTypeAccessor = IsCollection(nodeElement) ? string.Format("{0}s", nodeType) : nodeType; + return nodeTypeAccessor; + } + + public static string GetNodeType(XmlElement nodeElement, string nodeName) + { + var type = nodeElement.GetAttribute("Type"); + if (!string.IsNullOrEmpty(type)) + { + return type; + } + // Otherwise assume the type is the node name without "Sql" at the start + var prefix = "Sql"; + return nodeName.IndexOf(prefix) == 0 ? nodeName.Substring(prefix.Length) : nodeName; + } + + public static bool IsCollection(XmlElement nodeElement) + { + var collection = nodeElement.GetAttribute("Collection"); + bool result; + if (bool.TryParse(collection, out result)) + { + return result; + } + // Default is true + return true; + } + + public static IList GetParents(XmlElement nodeElement, string xmlFile, string parentName) + { + var parentAttr = nodeElement.GetAttribute("Parent"); + if (!string.IsNullOrEmpty(parentAttr)) + { + return new string[] { parentAttr }; + } + + var parentNodes = GetChildren(xmlFile, parentName, "Parent"); + if (parentNodes != null && parentNodes.Count > 0) + { + List parents = new List(); + int i = 0; + foreach(var node in parentNodes) + { + parents.Add(node.InnerText); + } + return parents; + } + + // default to assuming a type is under Database + return new string[] { "Database" }; + } + + public static List GetChildren(string xmlFile, string parentName, string childNode) + { + XmlElement nodeElement = GetNodeElement(xmlFile, parentName); + XmlDocument doc = new XmlDocument(); + doc.Load(xmlFile); + + List retElements = new List(); + XmlNodeList nodeList = doc.SelectNodes(string.Format("/SmoQueryModel/Node[@Name='{0}']/{1}", parentName, childNode)); + foreach (var item in nodeList) + { + XmlElement itemAsElement = item as XmlElement; + if (itemAsElement != null) + { + retElements.Add(itemAsElement); + } + } + return retElements; + } + +#> \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModelDefinition.xml b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModelDefinition.xml new file mode 100644 index 00000000..fd1a5960 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModelDefinition.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + StoredProcedure + UserDefinedAggregate + UserDefinedFunction + + + + + + + + + + diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNode.cs new file mode 100644 index 00000000..d732cd47 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNode.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using Microsoft.SqlServer.Management.Smo; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + /// + /// A Node in the tree representing a SMO-based object + /// + public class SmoTreeNode : TreeNode + { + public static int FolderSortPriority = 0; + private static int _nextSortPriority = FolderSortPriority + 1; // 0 is reserved for folders + + protected SmoQueryContext context; + + public SmoTreeNode() : base() + { + } + + protected virtual void OnInitialize() + { + // TODO setup initialization + } + + /// + /// Is this a system (MSShipped) object? + /// + public bool IsMsShippedOwned { get; set; } + + /// + /// Indicates which platforms a node is valid for + /// + public ValidForFlag ValidFor { get; set; } + + /// + /// Gets an incrementing sort priority value to assist in automatically sorting + /// elements in a tree + /// + public static int NextSortPriority + { + get + { + return System.Threading.Interlocked.Increment(ref _nextSortPriority); + } + } + + public NamedSmoObject SmoObject { get; private set; } + + public virtual void CacheInfoFromModel(NamedSmoObject smoObject) + { + SmoObject = smoObject; + NodeValue = smoObject.Name; + } + + public virtual NamedSmoObject GetParentSmoObject() + { + if (SmoObject != null) + { + return SmoObject; + } + // Return the parent's object, or null if it's not set / not a SmoTreeNode + return ParentAs()?.GetParentSmoObject(); + } + + public override object GetContext() + { + EnsureContextInitialized(); + return context; + } + + protected virtual void EnsureContextInitialized() + { + if (context == null) + { + SmoObjectBase smoParent = GetParentSmoObject(); + SmoQueryContext parentContext = Parent?.GetContextAs(); + if (smoParent != null && parentContext != null) + { + context = parentContext.CopyWithParent(smoParent); + } + } + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SystemDataTypeChildFactories.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SystemDataTypeChildFactories.cs new file mode 100644 index 00000000..5f860c40 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SystemDataTypeChildFactories.cs @@ -0,0 +1,208 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System.Collections.Generic; +using Microsoft.SqlServer.Management.Smo; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + internal partial class SystemExactNumericsChildFactory + { + private static readonly HashSet _exactNumerics = new HashSet{ + "bit", + "tinyint", + "smallint", + "int", + "bigint", + "numeric", + "decimal", + "smallmoney", + "money" + }; + public override bool PassesFinalFilters(TreeNode parent, object contextObject) + { + NamedSmoObject smoObject = contextObject as NamedSmoObject; + if (smoObject != null) + { + string name = smoObject.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + return _exactNumerics.Contains(name); + } + } + return false; + } + } + internal partial class SystemApproximateNumericsChildFactory + { + private static readonly HashSet _approxNumerics = new HashSet{ + "float", + "real" + }; + public override bool PassesFinalFilters(TreeNode parent, object contextObject) + { + NamedSmoObject smoObject = contextObject as NamedSmoObject; + if (smoObject != null) + { + string name = smoObject.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + return _approxNumerics.Contains(name); + } + } + return false; + } + } + internal partial class SystemDateAndTimesChildFactory + { + private static readonly HashSet _dateAndTime = new HashSet{ + "datetime", + "smalldatetime", + "date", + "time", + "datetimeoffset", + "datetime2", + }; + public override bool PassesFinalFilters(TreeNode parent, object contextObject) + { + NamedSmoObject smoObject = contextObject as NamedSmoObject; + if (smoObject != null) + { + string name = smoObject.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + return _dateAndTime.Contains(name); + } + } + return false; + } + } + internal partial class SystemCharacterStringsChildFactory + { + private static readonly HashSet _characterStrings = new HashSet{ + "char", + "varchar", + "text", + }; + public override bool PassesFinalFilters(TreeNode parent, object contextObject) + { + NamedSmoObject smoObject = contextObject as NamedSmoObject; + if (smoObject != null) + { + string name = smoObject.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + return _characterStrings.Contains(name); + } + } + return false; + } + } + internal partial class SystemUnicodeCharacterStringsChildFactory + { + private static readonly HashSet _unicodeCharacterStrings = new HashSet + { + "nchar", + "nvarchar", + "ntext", + }; + public override bool PassesFinalFilters(TreeNode parent, object contextObject) + { + NamedSmoObject smoObject = contextObject as NamedSmoObject; + if (smoObject != null) + { + string name = smoObject.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + return _unicodeCharacterStrings.Contains(name); + } + } + return false; + } + } + internal partial class SystemBinaryStringsChildFactory + { + private static readonly HashSet _binaryStrings = new HashSet{ + "binary", + "varbinary", + "image", + }; + public override bool PassesFinalFilters(TreeNode parent, object contextObject) + { + NamedSmoObject smoObject = contextObject as NamedSmoObject; + if (smoObject != null) + { + string name = smoObject.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + return _binaryStrings.Contains(name); + } + } + return false; + } + } + internal partial class SystemOtherDataTypesChildFactory + { + private static readonly HashSet _otherDataTypes = new HashSet{ + "sql_variant", + "timestamp", + "uniqueidentifier", + "xml", + }; + public override bool PassesFinalFilters(TreeNode parent, object contextObject) + { + NamedSmoObject smoObject = contextObject as NamedSmoObject; + if (smoObject != null) + { + string name = smoObject.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + return _otherDataTypes.Contains(name); + } + } + return false; + } + } + internal partial class SystemClrDataTypesChildFactory + { + private static readonly HashSet _clrDataTypes = new HashSet{ + "hierarchyid", + }; + public override bool PassesFinalFilters(TreeNode parent, object contextObject) + { + NamedSmoObject smoObject = contextObject as NamedSmoObject; + if (smoObject != null) + { + string name = smoObject.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + return _clrDataTypes.Contains(name); + } + } + return false; + } + } + internal partial class SystemSpatialDataTypesChildFactory + { + private static readonly HashSet _spatialDataTypes = new HashSet{ + "geometry", + "geography", + }; + public override bool PassesFinalFilters(TreeNode parent, object contextObject) + { + NamedSmoObject smoObject = contextObject as NamedSmoObject; + if (smoObject != null) + { + string name = smoObject.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + return _spatialDataTypes.Contains(name); + } + } + return false; + } + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml new file mode 100644 index 00000000..ea347cb9 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml @@ -0,0 +1,396 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TemporalTableType.None + TemporalTableType.SystemVersioned + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TemporalTableType.History + + + + + + + + + + + + + + + + + + + + + + + + + + + + IndexKeyType.DriPrimaryKey + IndexKeyType.DriUniqueKey + + + + + + + + + IndexKeyType.None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IndexKeyType.DriPrimaryKey + IndexKeyType.DriUniqueKey + + + + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + UserDefinedFunctionType.Table + + + + + + + + + + + + UserDefinedFunctionType.Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs new file mode 100644 index 00000000..fc994563 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs @@ -0,0 +1,3466 @@ + + + + + + + + + +using System; +using System.Collections.Generic; +using System.Composition; +using Microsoft.SqlTools.ServiceLayer; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + + internal sealed partial class DatabaseInstanceTreeNode : SmoTreeNode + { + public DatabaseInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "DatabaseInstance"; + this.NodeTypeId = NodeTypes.DatabaseInstance; + OnInitialize(); + } + } + + internal sealed partial class TableInstanceTreeNode : SmoTreeNode + { + public TableInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "TableInstance"; + this.NodeTypeId = NodeTypes.TableInstance; + OnInitialize(); + } + } + + internal sealed partial class ViewInstanceTreeNode : SmoTreeNode + { + public ViewInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "ViewInstance"; + this.NodeTypeId = NodeTypes.ViewInstance; + OnInitialize(); + } + } + + internal sealed partial class UserDefinedTableTypeInstanceTreeNode : SmoTreeNode + { + public UserDefinedTableTypeInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "UserDefinedTableTypeInstance"; + this.NodeTypeId = NodeTypes.UserDefinedTableTypeInstance; + OnInitialize(); + } + } + + internal sealed partial class StoredProcedureInstanceTreeNode : SmoTreeNode + { + public StoredProcedureInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "StoredProcedureInstance"; + this.NodeTypeId = NodeTypes.StoredProcedureInstance; + OnInitialize(); + } + } + + internal sealed partial class TableValuedFunctionInstanceTreeNode : SmoTreeNode + { + public TableValuedFunctionInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "TableValuedFunctionInstance"; + this.NodeTypeId = NodeTypes.TableValuedFunctionInstance; + OnInitialize(); + } + } + + internal sealed partial class ScalarValuedFunctionInstanceTreeNode : SmoTreeNode + { + public ScalarValuedFunctionInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "ScalarValuedFunctionInstance"; + this.NodeTypeId = NodeTypes.ScalarValuedFunctionInstance; + OnInitialize(); + } + } + + internal sealed partial class AggregateFunctionInstanceTreeNode : SmoTreeNode + { + public AggregateFunctionInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "AggregateFunctionInstance"; + this.NodeTypeId = NodeTypes.AggregateFunctionInstance; + OnInitialize(); + } + } + + internal sealed partial class FileGroupInstanceTreeNode : SmoTreeNode + { + public FileGroupInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "FileGroupInstance"; + this.NodeTypeId = NodeTypes.FileGroupInstance; + OnInitialize(); + } + } + + internal sealed partial class ExternalTableInstanceTreeNode : SmoTreeNode + { + public ExternalTableInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "ExternalTableInstance"; + this.NodeTypeId = NodeTypes.ExternalTableInstance; + OnInitialize(); + } + } + + internal sealed partial class ExternalResourceInstanceTreeNode : SmoTreeNode + { + public ExternalResourceInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "ExternalResourceInstance"; + this.NodeTypeId = NodeTypes.ExternalResourceInstance; + OnInitialize(); + } + } + + internal sealed partial class HistoryTableInstanceTreeNode : SmoTreeNode + { + public HistoryTableInstanceTreeNode() : base() + { + NodeValue = string.Empty; + this.NodeType = "HistoryTableInstance"; + this.NodeTypeId = NodeTypes.HistoryTableInstance; + OnInitialize(); + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Databases, + NodeType = "Folder", + NodeTypeId = NodeTypes.Databases, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Security, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelSecurity, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12|ValidForFlag.NotContainedUser|ValidForFlag.CanViewSecurity, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ServerObjects, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelServerObjects, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.NotContainedUser, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class DatabasesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Databases" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemDatabases, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemDatabases, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12|ValidForFlag.NotContainedUser|ValidForFlag.CanConnectToMaster, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlDatabaseQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new DatabaseInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelSecurityChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelSecurity" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_LinkedServerLogins, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelLinkedServerLogins, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Logins, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelLogins, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ServerRoles, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelServerRoles, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Credentials, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelCredentials, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_CryptographicProviders, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelCryptographicProviders, + ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.NotDebugInstance, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ServerAudits, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelServerAudits, + ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ServerAuditSpecifications, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelServerAuditSpecifications, + ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelServerObjectsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelServerObjects" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Endpoints, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelEndpoints, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_LinkedServers, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelLinkedServers, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ServerTriggers, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelServerTriggers, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ErrorMessages, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServerLevelErrorMessages, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemDatabasesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemDatabases" }; } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelLinkedServerLoginsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelLinkedServerLogins" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlLinkedServerLoginQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelLoginsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelLogins" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlLoginQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelServerRolesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelServerRoles" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlServerRoleQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelCredentialsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelCredentials" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlCredentialQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelCryptographicProvidersChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelCryptographicProviders" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlCryptographicProviderQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelServerAuditsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelServerAudits" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlServerAuditQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelServerAuditSpecificationsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelServerAuditSpecifications" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlServerAuditSpecificationQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelEndpointsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelEndpoints" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlEndpointQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelLinkedServersChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelLinkedServers" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlLinkedServerQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelServerTriggersChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelServerTriggers" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlServerDdlTriggerQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServerLevelErrorMessagesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServerLevelErrorMessages" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlErrorMessageQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class DatabaseInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "DatabaseInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Tables, + NodeType = "Folder", + NodeTypeId = NodeTypes.Tables, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Views, + NodeType = "Folder", + NodeTypeId = NodeTypes.Views, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Synonyms, + NodeType = "Folder", + NodeTypeId = NodeTypes.Synonyms, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Programmability, + NodeType = "Folder", + NodeTypeId = NodeTypes.Programmability, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ExternalResources, + NodeType = "Folder", + NodeTypeId = NodeTypes.ExternalResources, + ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ServiceBroker, + NodeType = "Folder", + NodeTypeId = NodeTypes.ServiceBroker, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Storage, + NodeType = "Folder", + NodeTypeId = NodeTypes.Storage, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Security, + NodeType = "Folder", + NodeTypeId = NodeTypes.Security, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new Type[0]; } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class TablesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Tables" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemTables, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemTables, + IsMsShippedOwned = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_FileTables, + NodeType = "Folder", + NodeTypeId = NodeTypes.FileTables, + ValidFor = ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.NotDebugInstance, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ExternalTables, + NodeType = "Folder", + NodeTypeId = NodeTypes.ExternalTables, + ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlTableQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new TableInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ViewsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Views" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemViews, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemViews, + IsMsShippedOwned = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlViewQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new ViewInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SynonymsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Synonyms" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlSynonymQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ProgrammabilityChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Programmability" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_StoredProcedures, + NodeType = "Folder", + NodeTypeId = NodeTypes.StoredProcedures, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Functions, + NodeType = "Folder", + NodeTypeId = NodeTypes.Functions, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_DatabaseTriggers, + NodeType = "Folder", + NodeTypeId = NodeTypes.DatabaseTriggers, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Assemblies, + NodeType = "Folder", + NodeTypeId = NodeTypes.Assemblies, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Types, + NodeType = "Folder", + NodeTypeId = NodeTypes.Types, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Rules, + NodeType = "Folder", + NodeTypeId = NodeTypes.Rules, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Defaults, + NodeType = "Folder", + NodeTypeId = NodeTypes.Defaults, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Sequences, + NodeType = "Folder", + NodeTypeId = NodeTypes.Sequences, + ValidFor = ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ExternalResourcesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ExternalResources" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ExternalDataSources, + NodeType = "Folder", + NodeTypeId = NodeTypes.ExternalDataSources, + ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ExternalFileFormats, + NodeType = "Folder", + NodeTypeId = NodeTypes.ExternalFileFormats, + ValidFor = ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServiceBrokerChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ServiceBroker" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_MessageTypes, + NodeType = "Folder", + NodeTypeId = NodeTypes.MessageTypes, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Contracts, + NodeType = "Folder", + NodeTypeId = NodeTypes.Contracts, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Queues, + NodeType = "Folder", + NodeTypeId = NodeTypes.Queues, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Services, + NodeType = "Folder", + NodeTypeId = NodeTypes.Services, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_RemoteServiceBindings, + NodeType = "Folder", + NodeTypeId = NodeTypes.RemoteServiceBindings, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_BrokerPriorities, + NodeType = "Folder", + NodeTypeId = NodeTypes.BrokerPriorities, + ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class StorageChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Storage" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_FileGroups, + NodeType = "Folder", + NodeTypeId = NodeTypes.FileGroups, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_FullTextCatalogs, + NodeType = "Folder", + NodeTypeId = NodeTypes.FullTextCatalogs, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_FullTextStopLists, + NodeType = "Folder", + NodeTypeId = NodeTypes.FullTextStopLists, + ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_LogFiles, + NodeType = "Folder", + NodeTypeId = NodeTypes.SqlLogFiles, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_PartitionFunctions, + NodeType = "Folder", + NodeTypeId = NodeTypes.PartitionFunctions, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_PartitionSchemes, + NodeType = "Folder", + NodeTypeId = NodeTypes.PartitionSchemes, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SearchPropertyLists, + NodeType = "Folder", + NodeTypeId = NodeTypes.SearchPropertyLists, + ValidFor = ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SecurityChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Security" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Users, + NodeType = "Folder", + NodeTypeId = NodeTypes.Users, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Roles, + NodeType = "Folder", + NodeTypeId = NodeTypes.Roles, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Schemas, + NodeType = "Folder", + NodeTypeId = NodeTypes.Schemas, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_AsymmetricKeys, + NodeType = "Folder", + NodeTypeId = NodeTypes.AsymmetricKeys, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Certificates, + NodeType = "Folder", + NodeTypeId = NodeTypes.Certificates, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SymmetricKeys, + NodeType = "Folder", + NodeTypeId = NodeTypes.SymmetricKeys, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_DatabaseScopedCredentials, + NodeType = "Folder", + NodeTypeId = NodeTypes.DatabaseScopedCredentials, + ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_DatabaseEncryptionKeys, + NodeType = "Folder", + NodeTypeId = NodeTypes.DatabaseEncryptionKeys, + ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_MasterKeys, + NodeType = "Folder", + NodeTypeId = NodeTypes.MasterKeys, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_DatabaseAuditSpecifications, + NodeType = "Folder", + NodeTypeId = NodeTypes.DatabaseAuditSpecifications, + ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SecurityPolicies, + NodeType = "Folder", + NodeTypeId = NodeTypes.SecurityPolicies, + ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_AlwaysEncryptedKeys, + NodeType = "Folder", + NodeTypeId = NodeTypes.AlwaysEncryptedKeys, + ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemTablesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemTables" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlTableQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new TableInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class FileTablesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "FileTables" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlTableQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new TableInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ExternalTablesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ExternalTables" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlTableQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new ExternalTableInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class TableInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "TableInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Columns, + NodeType = "Folder", + NodeTypeId = NodeTypes.Columns, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Keys, + NodeType = "Folder", + NodeTypeId = NodeTypes.Keys, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Constraints, + NodeType = "Folder", + NodeTypeId = NodeTypes.Constraints, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Triggers, + NodeType = "Folder", + NodeTypeId = NodeTypes.Triggers, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Indexes, + NodeType = "Folder", + NodeTypeId = NodeTypes.Indexes, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Statistics, + NodeType = "Folder", + NodeTypeId = NodeTypes.Statistics, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlTableQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new HistoryTableInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class HistoryTableInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "HistoryTableInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Columns, + NodeType = "Folder", + NodeTypeId = NodeTypes.Columns, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Indexes, + NodeType = "Folder", + NodeTypeId = NodeTypes.Indexes, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Statistics, + NodeType = "Folder", + NodeTypeId = NodeTypes.Statistics, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlTableQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ExternalTableInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ExternalTableInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Columns, + NodeType = "Folder", + NodeTypeId = NodeTypes.Columns, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Statistics, + NodeType = "Folder", + NodeTypeId = NodeTypes.Statistics, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlTableQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ColumnsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Columns" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlColumnQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + child.SortPriority = SmoTreeNode.NextSortPriority; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class KeysChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Keys" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlIndexQuerier), typeof(SqlForeignKeyConstraintQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ConstraintsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Constraints" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlDefaultConstraintQuerier), typeof(SqlCheckQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class TriggersChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Triggers" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlDmlTriggerQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class IndexesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Indexes" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlIndexQuerier), typeof(SqlFullTextIndexQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class StatisticsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Statistics" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlStatisticQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemViewsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemViews" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlViewQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new ViewInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ViewInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ViewInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Columns, + NodeType = "Folder", + NodeTypeId = NodeTypes.Columns, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Triggers, + NodeType = "Folder", + NodeTypeId = NodeTypes.Triggers, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Indexes, + NodeType = "Folder", + NodeTypeId = NodeTypes.Indexes, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Statistics, + NodeType = "Folder", + NodeTypeId = NodeTypes.Statistics, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new Type[0]; } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class FunctionsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Functions" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_TableValuedFunctions, + NodeType = "Folder", + NodeTypeId = NodeTypes.TableValuedFunctions, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ScalarValuedFunctions, + NodeType = "Folder", + NodeTypeId = NodeTypes.ScalarValuedFunctions, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_AggregateFunctions, + NodeType = "Folder", + NodeTypeId = NodeTypes.AggregateFunctions, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class DatabaseTriggersChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "DatabaseTriggers" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlDatabaseDdlTriggerQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class AssembliesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Assemblies" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlAssemblyQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class TypesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Types" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemDataTypes, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemDataTypes, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_UserDefinedDataTypes, + NodeType = "Folder", + NodeTypeId = NodeTypes.UserDefinedDataTypes, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_UserDefinedTableTypes, + NodeType = "Folder", + NodeTypeId = NodeTypes.UserDefinedTableTypes, + ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_UserDefinedTypes, + NodeType = "Folder", + NodeTypeId = NodeTypes.UserDefinedTypes, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_XMLSchemaCollections, + NodeType = "Folder", + NodeTypeId = NodeTypes.XmlSchemaCollections, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class RulesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Rules" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlRuleQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class DefaultsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Defaults" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlDefaultQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SequencesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Sequences" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlSequenceQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemDataTypesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemDataTypes" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemExactNumerics, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemExactNumerics, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemApproximateNumerics, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemApproximateNumerics, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemDateAndTime, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemDateAndTimes, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemCharacterStrings, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemCharacterStrings, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemUnicodeCharacterStrings, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemUnicodeCharacterStrings, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemBinaryStrings, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemBinaryStrings, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemOtherDataTypes, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemOtherDataTypes, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemCLRDataTypes, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemClrDataTypes, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemSpatialDataTypes, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemSpatialDataTypes, + ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class UserDefinedDataTypesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "UserDefinedDataTypes" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserDefinedDataTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class UserDefinedTableTypesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "UserDefinedTableTypes" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserDefinedTableTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new UserDefinedTableTypeInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class UserDefinedTypesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "UserDefinedTypes" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserDefinedTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class XmlSchemaCollectionsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "XmlSchemaCollections" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlXmlSchemaCollectionQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class UserDefinedTableTypeInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "UserDefinedTableTypeInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Columns, + NodeType = "Folder", + NodeTypeId = NodeTypes.UserDefinedTableTypeColumns, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Keys, + NodeType = "Folder", + NodeTypeId = NodeTypes.UserDefinedTableTypeKeys, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Constraints, + NodeType = "Folder", + NodeTypeId = NodeTypes.UserDefinedTableTypeConstraints, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new Type[0]; } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class UserDefinedTableTypeColumnsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "UserDefinedTableTypeColumns" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlColumnQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + child.SortPriority = SmoTreeNode.NextSortPriority; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class UserDefinedTableTypeKeysChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "UserDefinedTableTypeKeys" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlIndexQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class UserDefinedTableTypeConstraintsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "UserDefinedTableTypeConstraints" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlDefaultConstraintQuerier), typeof(SqlCheckQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemExactNumericsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemExactNumerics" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlBuiltInTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemApproximateNumericsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemApproximateNumerics" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlBuiltInTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemDateAndTimesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemDateAndTimes" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlBuiltInTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemCharacterStringsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemCharacterStrings" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlBuiltInTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemUnicodeCharacterStringsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemUnicodeCharacterStrings" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlBuiltInTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemBinaryStringsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemBinaryStrings" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlBuiltInTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemOtherDataTypesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemOtherDataTypes" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlBuiltInTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemClrDataTypesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemClrDataTypes" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserDefinedTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemSpatialDataTypesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemSpatialDataTypes" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserDefinedTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ExternalDataSourcesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ExternalDataSources" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlExternalDataSourceQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ExternalFileFormatsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ExternalFileFormats" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlExternalFileFormatQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class StoredProceduresChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "StoredProcedures" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemStoredProcedures, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemStoredProcedures, + IsMsShippedOwned = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlProcedureQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new StoredProcedureInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemStoredProceduresChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemStoredProcedures" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlProcedureQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new StoredProcedureInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class StoredProcedureInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "StoredProcedureInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Parameters, + NodeType = "Folder", + NodeTypeId = NodeTypes.StoredProcedureParameters, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new Type[0]; } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class StoredProcedureParametersChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "StoredProcedureParameters" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlSubroutineParameterQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + child.SortPriority = SmoTreeNode.NextSortPriority; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class TableValuedFunctionsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "TableValuedFunctions" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserDefinedFunctionQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new TableValuedFunctionInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class TableValuedFunctionInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "TableValuedFunctionInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Parameters, + NodeType = "Folder", + NodeTypeId = NodeTypes.TableValuedFunctionParameters, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new Type[0]; } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class TableValuedFunctionParametersChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "TableValuedFunctionParameters" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlSubroutineParameterQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + child.SortPriority = SmoTreeNode.NextSortPriority; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ScalarValuedFunctionsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ScalarValuedFunctions" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserDefinedFunctionQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new ScalarValuedFunctionInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ScalarValuedFunctionInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ScalarValuedFunctionInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Parameters, + NodeType = "Folder", + NodeTypeId = NodeTypes.ScalarValuedFunctionParameters, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new Type[0]; } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ScalarValuedFunctionParametersChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ScalarValuedFunctionParameters" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlSubroutineParameterQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + child.SortPriority = SmoTreeNode.NextSortPriority; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class AggregateFunctionsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "AggregateFunctions" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserDefinedAggregateQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new AggregateFunctionInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class AggregateFunctionInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "AggregateFunctionInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_Parameters, + NodeType = "Folder", + NodeTypeId = NodeTypes.AggregateFunctionParameters, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new Type[0]; } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class AggregateFunctionParametersChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "AggregateFunctionParameters" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlSubroutineParameterQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + child.SortPriority = SmoTreeNode.NextSortPriority; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class RemoteServiceBindingsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "RemoteServiceBindings" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlRemoteServiceBindingQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class BrokerPrioritiesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "BrokerPriorities" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlBrokerPriorityQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class FileGroupsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "FileGroups" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlFileGroupQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new FileGroupInstanceTreeNode(); + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class FullTextCatalogsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "FullTextCatalogs" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlFullTextCatalogQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class FullTextStopListsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "FullTextStopLists" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlFullTextStopListQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SqlLogFilesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SqlLogFiles" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlFileQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class PartitionFunctionsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "PartitionFunctions" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlPartitionFunctionQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class PartitionSchemesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "PartitionSchemes" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlPartitionSchemeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SearchPropertyListsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SearchPropertyLists" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlSearchPropertyListQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class FileGroupInstanceChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "FileGroupInstance" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_FilegroupFiles, + NodeType = "Folder", + NodeTypeId = NodeTypes.FileGroupFiles, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class FileGroupFilesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "FileGroupFiles" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlFileQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class UsersChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Users" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class RolesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Roles" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_DatabaseRoles, + NodeType = "Folder", + NodeTypeId = NodeTypes.DatabaseRoles, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ApplicationRoles, + NodeType = "Folder", + NodeTypeId = NodeTypes.ApplicationRoles, + ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SchemasChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Schemas" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlSchemaQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class AsymmetricKeysChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "AsymmetricKeys" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlAsymmetricKeyQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class CertificatesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Certificates" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlCertificateQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SymmetricKeysChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SymmetricKeys" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlSymmetricKeyQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class DatabaseEncryptionKeysChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "DatabaseEncryptionKeys" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlDatabaseEncryptionKeyQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class MasterKeysChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "MasterKeys" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlMasterKeyQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class DatabaseAuditSpecificationsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "DatabaseAuditSpecifications" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlDatabaseAuditSpecificationQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SecurityPoliciesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SecurityPolicies" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlSecurityPolicyQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class DatabaseScopedCredentialsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "DatabaseScopedCredentials" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlDatabaseCredentialQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class AlwaysEncryptedKeysChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "AlwaysEncryptedKeys" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ColumnMasterKeys, + NodeType = "Folder", + NodeTypeId = NodeTypes.ColumnMasterKeys, + ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ColumnEncryptionKeys, + NodeType = "Folder", + NodeTypeId = NodeTypes.ColumnEncryptionKeys, + ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes { get {return null;} } + + + public override TreeNode CreateChild(TreeNode parent, object context) + { + return null; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class DatabaseRolesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "DatabaseRoles" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlRoleQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ApplicationRolesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ApplicationRoles" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlApplicationRoleQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ColumnMasterKeysChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ColumnMasterKeys" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlColumnMasterKeyQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ColumnEncryptionKeysChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "ColumnEncryptionKeys" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlColumnEncryptionKeyQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class MessageTypesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "MessageTypes" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemMessageTypes, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemMessageTypes, + IsMsShippedOwned = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlMessageTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemMessageTypesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemMessageTypes" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlMessageTypeQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ContractsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Contracts" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemContracts, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemContracts, + IsMsShippedOwned = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlContractQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemContractsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemContracts" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlContractQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class QueuesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Queues" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemQueues, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemQueues, + IsMsShippedOwned = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlQueueQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemQueuesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemQueues" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlQueueQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class ServicesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "Services" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemServices, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemServices, + IsMsShippedOwned = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlServiceQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemServicesChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemServices" }; } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlServiceQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new SmoTreeNode(); + child.IsAlwaysLeaf = true; + InitializeChild(child, context); + return child; + } + } + + +} + diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt new file mode 100644 index 00000000..f51dc887 --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt @@ -0,0 +1,387 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ output extension=".cs" #> +<#@ assembly name="System.Xml.dll" #> +<#@ import namespace="System" #> +<#@ import namespace="System.Globalization" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Xml" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +using System; +using System.Collections.Generic; +using System.Composition; +using Microsoft.SqlTools.ServiceLayer; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; + +namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel +{ + +<# + var directory = Path.GetDirectoryName(Host.TemplateFile); + string xmlFile = Path.Combine(directory, "TreeNodeDefinition.xml"); + + ///////// + // TODO - is Generate all the ReverseDependencies needed? + ///////// + // var allReverseDependencies = GetReverseDependencies(xmlFile); + // WriteLine(" internal static class TreeNodeRules"); + // WriteLine(" {"); + // WriteLine(" internal static Dictionary> TypeReverseDependencyMap = new Dictionary>()"); + // WriteLine(" {"); + // foreach (var reverseDependencyKey in allReverseDependencies.Keys) + // { + // bool isFirstDependentType = true; + // StringBuilder dependentListBuilder = new StringBuilder("{"); + // foreach (var dependentType in allReverseDependencies[reverseDependencyKey]) + // { + // if (isFirstDependentType) + // { + // isFirstDependentType = false; + // } + // else + // { + // dependentListBuilder.Append(","); + // } + // + // dependentListBuilder.Append(string.Format(CultureInfo.InvariantCulture, " typeof({0})", dependentType)); + // } + // dependentListBuilder.Append(" }"); + // + // WriteLine(string.Format(CultureInfo.InvariantCulture, " {{ typeof({0}), new List {1} }}", reverseDependencyKey, dependentListBuilder.ToString())); + // } + // WriteLine(" };"); + // WriteLine(" }"); + // WriteLine(""); + + ///////// + // First generate all the TreeNodes + ///////// + var allTreeNodes = GetUniqueTreeNodes(xmlFile); + foreach (var TreeNode in allTreeNodes) + { + var name = TreeNode.GetAttribute("Name"); + WriteLine(string.Format(" internal sealed partial class {0} : SmoTreeNode", name)); + WriteLine(" {"); + WriteLine(string.Format(" public {0}() : base()", name)); + WriteLine(" {"); + WriteLine(" NodeValue = string.Empty;"); + WriteLine(string.Format(" this.NodeType = \"{0}\";", name.Replace("TreeNode", string.Empty))); + WriteLine(string.Format(" this.NodeTypeId = NodeTypes.{0};", name.Replace("TreeNode", string.Empty))); + WriteLine(" OnInitialize();"); + WriteLine(" }"); + WriteLine(" }"); + WriteLine(""); + } + + ///////// + // Now generate all the ChildFactories + ///////// + var allNodes = GetNodes(xmlFile); + foreach (var type in allNodes) + { + XmlElement nodeElement = GetNodeElement(xmlFile, type); + var imageAttr = nodeElement.GetAttribute("Image"); + var isAlwaysLeaf = nodeElement.GetAttributeNode("IsAlwaysLeaf"); + var baseClass = nodeElement.GetAttribute("BaseClass"); + var strategy = nodeElement.GetAttribute("Strategy"); + var ChildQuerierTypes = nodeElement.GetAttribute("ChildQuerierTypes"); + var TreeNode = nodeElement.GetAttribute("TreeNode"); + var isAsync = nodeElement.GetAttributeNode("IsAsyncLoad"); + var disableSort = nodeElement.GetAttributeNode("DisableSort"); + + string childFactoryBaseClass = "SmoChildFactoryBase"; + + // TODO Will we need alternative child factories? If so, add code here to support this + + if (isAlwaysLeaf == null) + { + WriteLine(" [Export(typeof(ChildFactory))]"); + WriteLine(" [Shared]"); + + WriteLine(string.Format(" internal partial class {0}ChildFactory : {1}", type, childFactoryBaseClass)); + + WriteLine(" {"); + WriteLine(string.Format(" public override IEnumerable ApplicableParents() {{ return new[] {{ \"{0}\" }}; }}", type)); + + List children = GetChildren(xmlFile, type); + if (children.Count > 0) + { + WriteLine(""); + WriteLine(" protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent)"); + WriteLine(" {"); + foreach (var child in children) + { + XmlElement childAsXmlElement = GetNodeElement(xmlFile, child.GetAttribute("Name")); + if (childAsXmlElement == null) + { + // TODO SHould we error with clear message that this needs to be fixed? + continue; + } + string childImage = childAsXmlElement.GetAttribute("Image"); + var msShippedOwned = childAsXmlElement.GetAttributeNode("IsMsShippedOwned"); + var validFor = childAsXmlElement.GetAttribute("ValidFor"); + + if (TreeNodeExists(xmlFile, child.GetAttribute("Name") + "TreeNode")) + { + WriteLine(string.Format(" currentChildren.Add(new {0}TreeNode {{ SortPriority = SmoTreeNode.NextSortPriority }} );", child.GetAttribute("Name"))); + } + else + { + WriteLine(" currentChildren.Add(new FolderNode {"); + WriteLine(string.Format(" NodeValue = {0},", childAsXmlElement.GetAttribute("LocLabel"))); + WriteLine(string.Format(" NodeType = \"{0}\",", "Folder")); + WriteLine(string.Format(" NodeTypeId = NodeTypes.{0},", child.GetAttribute("Name"))); + + if (msShippedOwned != null) + { + WriteLine(" IsMsShippedOwned = true,"); + } + if (!string.IsNullOrWhiteSpace(validFor)) + { + WriteLine(string.Format(" ValidFor = {0},", GetValidForFlags(validFor))); + } + WriteLine(" SortPriority = SmoTreeNode.NextSortPriority,"); + WriteLine(" });"); + } + } + WriteLine(" }"); + } + + if (!string.IsNullOrWhiteSpace(strategy)) + { + string[] allTypes = ChildQuerierTypes.Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries); + WriteLine(""); + WriteLine(" internal override Type[] ChildQuerierTypes"); + WriteLine(" {"); + WriteLine(" get"); + WriteLine(" {"); + if (!string.IsNullOrWhiteSpace(ChildQuerierTypes)) + { + Write(" return new [] {"); + foreach (var typeToRe in allTypes) + { + Write(string.Format(" typeof({0}Querier),", typeToRe)); + } + WriteLine(" };"); + } + else + { + Write(" return new Type[0];"); + } + WriteLine(" }"); + WriteLine(" }"); + + WriteLine(""); + + WriteLine(" public override TreeNode CreateChild(TreeNode parent, object context)"); + WriteLine(" {"); + if (string.IsNullOrWhiteSpace(TreeNode)) + { + WriteLine(" var child = new SmoTreeNode();"); + WriteLine(" child.IsAlwaysLeaf = true;"); + } + else + { + var modelNodeChildren = GetNodeElement(xmlFile, TreeNode.Replace("TreeNode",string.Empty)); + WriteLine(string.Format(" var child = new {0}();", TreeNode)); + if (modelNodeChildren.ChildNodes.Count == 0) + { + WriteLine(" child.IsAlwaysLeaf = true;"); + } + } + if (disableSort != null) + { + WriteLine(" child.SortPriority = SmoTreeNode.NextSortPriority;"); + } + WriteLine(" InitializeChild(child, context);"); + WriteLine(" return child;"); + WriteLine(" }"); + } + else if (baseClass == "ModelBased") + { + WriteLine(""); + WriteLine(" internal override Type[] ChildQuerierTypes { get {return null;} }"); + WriteLine(""); + // TODO Is reverse engineering strategy every needed? + // WriteLine(" protected override ReverseEngineeringStrategy Strategy { get {return ReverseEngineeringStrategy.None;} }"); + WriteLine(""); + WriteLine(" public override TreeNode CreateChild(TreeNode parent, object context)"); + WriteLine(" {"); + WriteLine(" return null;"); + WriteLine(" }"); + } + + WriteLine(" }"); + WriteLine(""); + } + } +#> +} + +<#+ + public static string GetValidForFlags(string validForStr) + { + List flags = new List(); + if (validForStr.Contains("Sql2005")) + { + flags.Add("ValidForFlag.Sql2005"); + } + + if (validForStr.Contains("Sql2008")) + { + flags.Add("ValidForFlag.Sql2008"); + } + + if (validForStr.Contains("Sql2012")) + { + flags.Add("ValidForFlag.Sql2012"); + } + + if (validForStr.Contains("Sql2014")) + { + flags.Add("ValidForFlag.Sql2014"); + } + + if (validForStr.Contains("Sql2016")) + { + flags.Add("ValidForFlag.Sql2016"); + } + + if (validForStr.Contains("AzureV11")) + { + flags.Add("ValidForFlag.Azure"); + } + + if (validForStr.Contains("AzureV12")) + { + flags.Add("ValidForFlag.AzureV12"); + } + + if (validForStr.Contains("NotDebugInstance")) + { + flags.Add("ValidForFlag.NotDebugInstance"); + } + + if (validForStr.Contains("NotContainedUser")) + { + flags.Add("ValidForFlag.NotContainedUser"); + } + + if (validForStr.Contains("CanConnectToMaster")) + { + flags.Add("ValidForFlag.CanConnectToMaster"); + } + + if (validForStr.Contains("CanViewSecurity")) + { + flags.Add("ValidForFlag.CanViewSecurity"); + } + + return string.Join("|", flags); + } + public static string[] GetNodes(string xmlFile) + { + List typesList = new List(); + XmlDocument doc = new XmlDocument(); + doc.Load(xmlFile); + XmlNodeList treeTypes = doc.SelectNodes("/ServerExplorerTree/Node"); + if (treeTypes != null) + { + foreach (var type in treeTypes) + { + XmlElement element = type as XmlElement; + if (element != null) + { + typesList.Add(element.GetAttribute("Name")); + } + } + } + return typesList.ToArray(); + } + + public static Dictionary> GetReverseDependencies(string xmlFile) + { + Dictionary> dependencyMap = new Dictionary>(); + XmlDocument doc = new XmlDocument(); + doc.Load(xmlFile); + XmlNodeList treeTypes = doc.SelectNodes("/ServerExplorerTree/ReverseDependencyList/ReverseDependency"); + if (treeTypes != null) + { + foreach (var type in treeTypes) + { + XmlElement element = type as XmlElement; + if (element != null) + { + string typeName = element.GetAttribute("Type"); + string dependency = element.GetAttribute("DependsOn"); + List dependenciesForType; + if (dependencyMap.TryGetValue(typeName, out dependenciesForType)) + { + dependenciesForType.Add(dependency); + } + else + { + string[] allDepedencies = dependency.Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries); + dependenciesForType = new List(); + dependenciesForType.AddRange(allDepedencies); + dependencyMap.Add(typeName, dependenciesForType); + } + } + } + } + return dependencyMap; + } + + public static XmlElement GetNodeElement(string xmlFile, string nodeName) + { + XmlDocument doc = new XmlDocument(); + doc.Load(xmlFile); + return (XmlElement)doc.SelectSingleNode(string.Format("/ServerExplorerTree/Node[@Name='{0}']", nodeName)); + } + + public static bool TreeNodeExists(string xmlFile, string TreeNode) + { + XmlDocument doc = new XmlDocument(); + doc.Load(xmlFile); + var found = (XmlElement)doc.SelectSingleNode(string.Format("/ServerExplorerTree/CodeGenOptions/UniqueTreeNode[@Name='{0}']", TreeNode)); + + return (found != null); + } + + public static List GetUniqueTreeNodes(string xmlFile) + { + XmlDocument doc = new XmlDocument(); + doc.Load(xmlFile); + + List retElements = new List(); + XmlNodeList nodeList = doc.SelectNodes("/ServerExplorerTree/CodeGenOptions/UniqueTreeNode"); + foreach (var item in nodeList) + { + XmlElement itemAsElement = item as XmlElement; + if (itemAsElement != null) + { + retElements.Add(itemAsElement); + } + } + return retElements; + } + + public static List GetChildren(string xmlFile, string parentName) + { + XmlElement nodeElement = GetNodeElement(xmlFile, parentName); + XmlDocument doc = new XmlDocument(); + doc.Load(xmlFile); + + List retElements = new List(); + XmlNodeList nodeList = doc.SelectNodes(string.Format("/ServerExplorerTree/Node[@Name='{0}']/Child", parentName)); + foreach (var item in nodeList) + { + XmlElement itemAsElement = item as XmlElement; + if (itemAsElement != null) + { + retElements.Add(itemAsElement); + } + } + return retElements; + } +#> \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/Properties/AssemblyInfo.cs b/src/Microsoft.SqlTools.ServiceLayer/Properties/AssemblyInfo.cs index 05de5fec..38a47f7c 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Properties/AssemblyInfo.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Properties/AssemblyInfo.cs @@ -44,3 +44,6 @@ using System.Runtime.InteropServices; [assembly: InternalsVisibleTo("Microsoft.SqlTools.ServiceLayer.UnitTests")] [assembly: InternalsVisibleTo("Microsoft.SqlTools.ServiceLayer.IntegrationTests")] [assembly: InternalsVisibleTo("Microsoft.SqlTools.ServiceLayer.Test.Common")] + +// Allowing internals visible access to Moq library to help testing +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/src/Microsoft.SqlTools.ServiceLayer/ServiceHost.cs b/src/Microsoft.SqlTools.ServiceLayer/ServiceHost.cs index bfe0fbb2..c042a023 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ServiceHost.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ServiceHost.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Threading.Tasks; +using Microsoft.SqlTools.Extensibility; using Microsoft.SqlTools.Hosting; using Microsoft.SqlTools.Hosting.Contracts; using Microsoft.SqlTools.Hosting.Protocol; @@ -29,6 +30,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting /// private const int ShutdownTimeoutInSeconds = 120; public static readonly string[] CompletionTriggerCharacters = new string[] { ".", "-", ":", "\\", "[", "\"" }; + private IMultiServiceProvider serviceProvider; #region Singleton Instance Code @@ -54,6 +56,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting // Initialize the shutdown activities shutdownCallbacks = new List(); initializeCallbacks = new List(); + } + + public IMultiServiceProvider ServiceProvider + { + get + { + return serviceProvider; + } + internal set + { + serviceProvider = value; + } } /// diff --git a/src/Microsoft.SqlTools.ServiceLayer/Utility/CommonConstants.cs b/src/Microsoft.SqlTools.ServiceLayer/Utility/CommonConstants.cs new file mode 100644 index 00000000..d98f75ee --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/Utility/CommonConstants.cs @@ -0,0 +1,19 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + + +namespace Microsoft.SqlTools.ServiceLayer.Utility +{ + /// + /// Common Constant values used across multiple services + /// + public static class CommonConstants + { + public const string MasterDatabaseName = "master"; + public const string MsdbDatabaseName = "msdb"; + public const string ModelDatabaseName = "model"; + public const string TempDbDatabaseName = "tempdb"; + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs new file mode 100644 index 00000000..fd288334 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs @@ -0,0 +1,215 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.SqlTools.ServiceLayer.Connection; +using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; +using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; +using Microsoft.SqlTools.ServiceLayer.Test.Common; +using Xunit; +using static Microsoft.SqlTools.ServiceLayer.ObjectExplorer.ObjectExplorerService; + +namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer +{ + public class ObjectExplorerServiceTests + { + private ObjectExplorerService _service = TestServiceProvider.Instance.ObjectExplorerService; + + [Fact] + public async void CreateSessionAndExpandOnTheServerShouldReturnTheDatabases() + { + var query = ""; + string uri = "CreateSessionAndExpand"; + string databaseName = null; + using (SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName, query, uri)) + { + var session = await CreateSession(testDb.DatabaseName, uri); + await CreateSessionAndDatabaseNode(testDb.DatabaseName, session); + CancelConnection(uri); + } + } + + private async Task CreateSession(string databaseName, string uri) + { + ConnectParams connectParams = TestServiceProvider.Instance.ConnectionProfileService.GetConnectionParameters(TestServerType.OnPrem, databaseName); + ConnectionDetails details = connectParams.Connection; + + return await _service.DoCreateSession(details, uri); + } + + private async Task CreateSessionAndDatabaseNode(string databaseName, ObjectExplorerSession session) + { + Assert.NotNull(session); + Assert.NotNull(session.Root); + NodeInfo nodeInfo = session.Root.ToNodeInfo(); + Assert.Equal(nodeInfo.IsLeaf, false); + Assert.Equal(nodeInfo.NodeType, NodeTypes.ServerInstance.ToString()); + var children = session.Root.Expand(); + + //All server children should be folder nodes + foreach (var item in children) + { + Assert.Equal(item.NodeType, "Folder"); + } + + var databasesRoot = children.FirstOrDefault(x => x.NodeTypeId == NodeTypes.Databases); + var databasesChildren = await _service.ExpandNode(session, databasesRoot.GetNodePath()); + var databases = databasesChildren.Where(x => x.NodeType == NodeTypes.DatabaseInstance.ToString()); + + //Verify the test databases is in the list + Assert.NotNull(databases); + var databaseNode = databases.FirstOrDefault(d => d.Label == databaseName); + Assert.NotNull(databaseNode); + return databaseNode; + } + + private void CancelConnection(string uri) + { + //ConnectionService.Instance.CancelConnect(new CancelConnectParams + //{ + // OwnerUri = uri, + // Type = ConnectionType.Default + //}); + } + + private async Task ExpandTree(NodeInfo node, ObjectExplorerSession session) + { + if(node != null && !node.IsLeaf) + { + var children = await _service.ExpandNode(session, node.NodePath); + Assert.NotNull(children); + if(children.Count() == 0 && !node.NodePath.Contains("System") && + !node.NodePath.Contains("FileTables") && !node.NodePath.Contains("External Tables")) + { + var labaleToUpper = node.Label.ToUpper(); + if (labaleToUpper.Contains("TABLE") || labaleToUpper.Contains("StoredProcedure") + || labaleToUpper.Contains("VIEW")) + { + //TOOD: Add a better validation. For now at least check tables not to be empty + //Assert.True(false, "The list of tables, procedure and views cannot be empty"); + } + } + foreach (var child in children) + { + //Console.WriteLine(child.Label); + await ExpandTree(child, session); + } + } + } + + [Fact] + public async void VerifyAdventureWorksDatabaseObjects() + { + var query = Scripts.AdventureWorksScript; + string uri = "VerifyAdventureWorksDatabaseObjects"; + string databaseName = null; + + using (SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName, query, uri)) + { + var session = await CreateSession(testDb.DatabaseName, uri); + var databaseNodeInfo = await CreateSessionAndDatabaseNode(testDb.DatabaseName, session); + await ExpandTree(databaseNodeInfo, session); + CancelConnection(uri); + } + } + + // [Fact] + public async void VerifySql2016Objects() + { + var query = LoadScript("Sql_2016_Additions.sql"); + string uri = "VerifySql2016Objects"; + string databaseName = null; + + using (SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName, query, uri)) + { + var session = await CreateSession(testDb.DatabaseName, uri); + var databaseNodeInfo = await CreateSessionAndDatabaseNode(testDb.DatabaseName, session); + await ExpandTree(databaseNodeInfo, session); + CancelConnection(uri); + } + } + + // [Fact] + public async void VerifySqlObjects() + { + var query = LoadScript("Sql_Additions.sql"); + string uri = "VerifySqlObjects"; + string databaseName = null; + + using (SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName, query, uri)) + { + var session = await CreateSession(testDb.DatabaseName, uri); + var databaseNodeInfo = await CreateSessionAndDatabaseNode(testDb.DatabaseName, session); + await ExpandTree(databaseNodeInfo, session); + CancelConnection(uri); + } + } + + // [Fact] + public async void VerifyFileTableTest() + { + var query = LoadScript("FileTableTest.sql"); + string uri = "VerifyFileTableTest"; + string databaseName = null; + + using (SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName, query, uri)) + { + var session = await CreateSession(testDb.DatabaseName, uri); + var databaseNodeInfo = await CreateSessionAndDatabaseNode(testDb.DatabaseName, session); + await ExpandTree(databaseNodeInfo, session); + CancelConnection(uri); + } + } + + //[Fact] + public async void VerifyColumnstoreindexSql16() + { + var query = LoadScript("ColumnstoreindexSql16.sql"); + string uri = "VerifyColumnstoreindexSql16"; + string databaseName = null; + + using (SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName, query, uri)) + { + var session = await CreateSession(testDb.DatabaseName, uri); + var databaseNodeInfo = await CreateSessionAndDatabaseNode(testDb.DatabaseName, session); + await ExpandTree(databaseNodeInfo, session); + CancelConnection(uri); + } + } + + private static string TestLocationDirectory + { + get + { + return Path.Combine(RunEnvironmentInfo.GetTestDataLocation(), "ObjectExplorer"); + } + } + + public DirectoryInfo InputFileDirectory + { + get + { + string d = Path.Combine(TestLocationDirectory, "TestScripts"); + return new DirectoryInfo(d); + } + } + + public FileInfo GetInputFile(string fileName) + { + return new FileInfo(Path.Combine(InputFileDirectory.FullName, fileName)); + } + + private string LoadScript(string fileName) + { + FileInfo inputFile = GetInputFile(fileName); + return TestUtilities.ReadTextAndNormalizeLineEndings(inputFile.FullName); + } + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Utility/LiveConnectionHelper.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Utility/LiveConnectionHelper.cs index c07b121d..c634c079 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Utility/LiveConnectionHelper.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Utility/LiveConnectionHelper.cs @@ -1,7 +1,10 @@ -using System.Data.SqlClient; +using System; +using System.Data.SqlClient; using System.Globalization; using System.IO; using System.Reflection; +using System.Threading; +using System.Threading.Tasks; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlTools.ServiceLayer.Connection; using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; @@ -27,11 +30,11 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility } - public static TestConnectionResult InitLiveConnectionInfo() + public static TestConnectionResult InitLiveConnectionInfo(string databaseName = null) { string sqlFilePath = GetTestSqlFile(); ScriptFile scriptFile = TestServiceProvider.Instance.WorkspaceService.Workspace.GetFile(sqlFilePath); - ConnectParams connectParams = TestServiceProvider.Instance.ConnectionProfileService.GetConnectionParameters(TestServerType.OnPrem); + ConnectParams connectParams = TestServiceProvider.Instance.ConnectionProfileService.GetConnectionParameters(TestServerType.OnPrem, databaseName); string ownerUri = scriptFile.ClientFilePath; var connectionService = GetLiveTestConnectionService(); @@ -50,6 +53,35 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility return new TestConnectionResult() { ConnectionInfo = connInfo, ScriptFile = scriptFile }; } + public static async Task InitLiveConnectionInfoAsync(string databaseName = null, string ownerUri = null) + { + ScriptFile scriptFile = null; + if (string.IsNullOrEmpty(ownerUri)) + { + string sqlFilePath = GetTestSqlFile(); + scriptFile = TestServiceProvider.Instance.WorkspaceService.Workspace.GetFile(sqlFilePath); + ownerUri = scriptFile.ClientFilePath; + } + ConnectParams connectParams = TestServiceProvider.Instance.ConnectionProfileService.GetConnectionParameters(TestServerType.OnPrem, databaseName); + + var connectionService = GetLiveTestConnectionService(); + var connectionResult = + await connectionService + .Connect(new ConnectParams + { + OwnerUri = ownerUri, + Connection = connectParams.Connection + }); + if (!string.IsNullOrEmpty(connectionResult.ErrorMessage)) + { + Console.WriteLine(connectionResult.ErrorMessage); + } + + ConnectionInfo connInfo = null; + connectionService.TryFindConnection(ownerUri, out connInfo); + return new TestConnectionResult() { ConnectionInfo = connInfo, ScriptFile = scriptFile }; + } + public static ConnectionInfo InitLiveConnectionInfoForDefinition(string databaseName = null) { ConnectParams connectParams = TestServiceProvider.Instance.ConnectionProfileService.GetConnectionParameters(TestServerType.OnPrem, databaseName); diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Scripts/AdventureWorks.sql b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Scripts/AdventureWorks.sql new file mode 100644 index 00000000..4697adc4 Binary files /dev/null and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Scripts/AdventureWorks.sql differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Scripts/Scripts.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Scripts/Scripts.cs index d5190bb1..b6b35797 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Scripts/Scripts.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Scripts/Scripts.cs @@ -43,7 +43,9 @@ END public static string CreateDatabaseQuery { get { return CreateDatabaseQueryInstance.Value; } } - public static string TestDbComplexSelectQueries { get { return TestDbSelectQueriesInstance.Value; } } + public static string TestDbComplexSelectQueries { get { return TestDbSelectQueriesInstance.Value; } } + + public static string AdventureWorksScript { get { return AdventureWorksScriptInstance.Value; } } private static readonly Lazy CreateDatabaseObjectsQueryInstance = new Lazy(() => { @@ -58,6 +60,11 @@ END private static readonly Lazy TestDbSelectQueriesInstance = new Lazy(() => { return GetScriptFileContent(ResourceNameRefix + "TestDbTableQueries.sql"); + }); + + private static readonly Lazy AdventureWorksScriptInstance = new Lazy(() => + { + return GetScriptFileContent(ResourceNameRefix + "AdventureWorks.sql"); }); private static string GetScriptFileContent(string fileName) diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/SqlTestDb.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/SqlTestDb.cs index 99d3df96..c20a1f08 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/SqlTestDb.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/SqlTestDb.cs @@ -27,13 +27,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common /// /// Create the test db if not already exists /// - public static SqlTestDb CreateNew(TestServerType serverType, bool doNotCleanupDb = false, string databaseName = null, string query = null) + public static SqlTestDb CreateNew( + TestServerType serverType, + bool doNotCleanupDb = false, + string databaseName = null, + string query = null, + string dbNamePrefix = null) { SqlTestDb testDb = new SqlTestDb(); using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) { - databaseName = databaseName ?? GetUniqueDBName(""); + databaseName = databaseName ?? GetUniqueDBName(dbNamePrefix); string createDatabaseQuery = Scripts.CreateDatabaseQuery.Replace("#DatabaseName#", databaseName); TestServiceProvider.Instance.RunQuery(serverType, MasterDatabaseName, createDatabaseQuery); Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Test database '{0}' is created", databaseName)); diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/ColumnstoreindexSql16.sql b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/ColumnstoreindexSql16.sql new file mode 100644 index 00000000..c8086c63 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/ColumnstoreindexSql16.sql @@ -0,0 +1,34 @@ +CREATE TABLE CS_Delay_Table1 +(ProductKey [int] NOT NULL, +OrderDateKey [int] NOT NULL, +DueDateKey [int] NOT NULL, +ShipDateKey [int] NOT NULL); +GO + +CREATE CLUSTERED COLUMNSTORE INDEX CSI_1 ON CS_Delay_Table1 +WITH (COMPRESSION_DELAY = 100 minutes); +GO + +CREATE TABLE CS_Delay_Table2 +(ProductKey [int] NOT NULL, +OrderDateKey [int] NOT NULL, +DueDateKey [int] NOT NULL, +ShipDateKey [int] NOT NULL); +GO + +CREATE CLUSTERED INDEX CI_Table2 ON CS_Delay_Table2 (ProductKey); +GO + +CREATE NONCLUSTERED COLUMNSTORE INDEX CSI_2 +ON CS_Delay_Table2 +(OrderDateKey, DueDateKey, ShipDateKey) +WITH (COMPRESSION_DELAY = 200); +GO + +CREATE TABLE CS_Delay_Table3 +(ProductKey [int] NOT NULL, +OrderDateKey [int] NOT NULL, +DueDateKey [int] NOT NULL, +ShipDateKey [int] NOT NULL, +INDEX CSI_3 CLUSTERED COLUMNSTORE WITH(COMPRESSION_DELAY = 50 minute)); +GO \ No newline at end of file diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/FileTableTest.sql b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/FileTableTest.sql new file mode 100644 index 00000000..2f689c79 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/FileTableTest.sql @@ -0,0 +1,103 @@ + +CREATE DATABASE [$(DatabaseName)] + +GO +ALTER DATABASE [$(DatabaseName)] SET TARGET_RECOVERY_TIME = 1 MINUTES +GO +USE [$(DatabaseName)] + +GO +ALTER DATABASE [$(DatabaseName)] +SET FILESTREAM( + NON_TRANSACTED_ACCESS = FULL, + DIRECTORY_NAME = N'$(DatabaseName)' + ) WITH NO_WAIT + +GO + +ALTER DATABASE $(DatabaseName) + ADD FILEGROUP [FileGroup1] + CONTAINS FILESTREAM + +GO + +ALTER DATABASE $(DatabaseName) +ADD FILE + (NAME = 'FileTableFile' + , FILENAME = '$(DefaultDataPath)$(DatabaseName)_FT' + ) +TO FILEGROUP [FileGroup1] + +GO + + + +CREATE TABLE [dbo].[FileTablePass] AS FILETABLE WITH( +FileTable_Directory = 'docs', +FILETABLE_PRIMARY_KEY_CONSTRAINT_NAME=MyPk, +FILETABLE_STREAMID_UNIQUE_CONSTRAINT_NAME=MyStreamUQ, +FILETABLE_FULLPATH_UNIQUE_CONSTRAINT_NAME=MyPathUQ) + +GO +ALTER TABLE [dbo].[FileTablePass] WITH CHECK ADD CONSTRAINT [MyCheck] CHECK ((stream_id IS NOT NULL)) +GO +ALTER TABLE [dbo].[FileTablePass] ADD CONSTRAINT [MyDefault] DEFAULT ((NULL)) FOR [name] +GO +ALTER TABLE [dbo].[FileTablePass] ADD CONSTRAINT [MyQU] UNIQUE NONCLUSTERED ([name] ASC) +GO +ALTER TABLE [dbo].[FileTablePass] WITH CHECK ADD CONSTRAINT [MyFk] FOREIGN KEY([parent_path_locator]) +REFERENCES [dbo].[FileTablePass] ([path_locator]) +GO +CREATE TABLE [dbo].[t2] ( + [c1] INT NOT NULL, + [c2] INT DEFAULT ((1)) NULL, + [c3] INT DEFAULT ((1)) NOT NULL, + [path_locator] hierarchyid, + PRIMARY KEY CLUSTERED ([c1] ASC), + UNIQUE NONCLUSTERED ([c2] ASC), + CHECK ([c2] > (0)) +); + +GO +CREATE STATISTICS stat1 + ON dbo.[FileTablePass](stream_id) +WITH SAMPLE 50 PERCENT; +GO +CREATE INDEX IX_FileTablePass_Stream_id + ON dbo.FileTablePass(stream_id); +GO + +CREATE TRIGGER FileTableTrigger +ON dbo.FileTablePass +AFTER INSERT +AS RAISERROR ('Block insert', 16, 10); +GO +CREATE INDEX IX_T2_C3 + ON [dbo].[t2](c3); + +GO + +CREATE TRIGGER reminder2 +ON dbo.t2 +AFTER INSERT, UPDATE, DELETE +AS +PRINT 'reminder trigger'; + +GO + +ALTER TABLE dbo.t2 +ADD CONSTRAINT FK_TO_FILETABLE FOREIGN KEY (path_locator) + REFERENCES FileTablePass (path_locator) ; +GO +exec sp_addextendedproperty 'prop_ex', 'FileTable', 'SCHEMA', 'dbo', 'TABLE', 'FileTablePass' +exec sp_addextendedproperty 'prop_ex', 'MyPk', 'SCHEMA', 'dbo', 'TABLE', 'FileTablePass', 'CONSTRAINT', 'MyPk' +exec sp_addextendedproperty 'prop_ex', 'MyStreamUQ', 'SCHEMA', 'dbo', 'TABLE', 'FileTablePass', 'CONSTRAINT', 'MyStreamUQ' +exec sp_addextendedproperty 'prop_ex', 'MyPathUQ', 'SCHEMA', 'dbo', 'TABLE', 'FileTablePass', 'CONSTRAINT', 'MyPathUQ' + +GO + +CREATE USER test_user WITHOUT LOGIN +GO + +GRANT SELECT ON dbo.FileTablePass TO test_user +GO \ No newline at end of file diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/NumberedProcedures.sql b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/NumberedProcedures.sql new file mode 100644 index 00000000..0c6f4534 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/NumberedProcedures.sql @@ -0,0 +1,62 @@ +CREATE PROCEDURE [dbo].[Encrypted_Additional_Numbered_Procedure] +( @param1 int) +WITH ENCRYPTION +AS +SELECT 1 AS Col1 + +GO + + +CREATE PROCEDURE [dbo].[Encrypted_Additional_Numbered_Procedure];2 +( @param1 int) +WITH ENCRYPTION +AS +SELECT 2 AS Col1 + + +GO + +CREATE PROCEDURE [dbo].[Encrypted_Additional_Numbered_Procedure];3 +( @param1 int) +WITH ENCRYPTION +AS +SELECT 3 AS Col1 + + +GO + +CREATE PROCEDURE [dbo].[Encrypted_Additional_Numbered_Procedure];4 +( @param1 int) +WITH ENCRYPTION +AS +SELECT 4 AS Col1 + +GO + +CREATE PROCEDURE [dbo].[Additional_Numbered_Procedure] +(@param1 int) +AS +SELECT 1 AS Col1 + +GO + +CREATE PROCEDURE [dbo].[Additional_Numbered_Procedure];2 +(@param1 int) +AS +SELECT 2 AS Col1 + +GO + +CREATE PROCEDURE [dbo].[Additional_Numbered_Procedure];3 +(@param1 int) +AS +SELECT 3 AS Col1 + +GO + +CREATE PROCEDURE [dbo].[Additional_Numbered_Procedure];4 +(@param1 int) +AS +SELECT 4 AS Col1 + + diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/Sql_2016_Additions.sql b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/Sql_2016_Additions.sql new file mode 100644 index 00000000..c68e4de7 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/Sql_2016_Additions.sql @@ -0,0 +1,275 @@ +ALTER DATABASE current SET COMPATIBILITY_LEVEL=130 +GO + +/* Dropping previous master key in master db that could have been created from other runs */ +IF ( EXISTS(SELECT name FROM sys.symmetric_keys WHERE name = '##MS_DatabaseMasterKey##')) DROP MASTER KEY + +CREATE MASTER KEY ENCRYPTION BY PASSWORD= 'Password01!'; + +OPEN MASTER KEY DECRYPTION BY PASSWORD = 'Password01!'; + + +CREATE DATABASE SCOPED CREDENTIAL AlterEgo WITH IDENTITY = 'RettigB', + SECRET = 'sdrlk8$40-dksli87nNN8'; + +GO + +-- Row-Level Security +CREATE TABLE [dbo].[Sales1] +( + OrderID INT, + SalesRep SYSNAME NOT NULL, + Product VARCHAR(10), + Qty INT +); + +GO + +CREATE TABLE [dbo].[Sales2] +( + OrderID INT, + SalesRep SYSNAME NOT NULL, + Product VARCHAR(10), + Qty INT +); + +GO + +CREATE FUNCTION [dbo].[fn_securitypredicate](@SalesRep AS SYSNAME) + RETURNS TABLE +WITH SCHEMABINDING +AS + RETURN SELECT 1 AS fn_securitypredicate_result +WHERE @SalesRep = USER_NAME() OR USER_NAME() = 'Manager'; + + +GO + +CREATE SECURITY POLICY [dbo].[SalesFilter] +ADD FILTER PREDICATE [dbo].[fn_securitypredicate]([SalesRep]) ON [dbo].[Sales1], +ADD FILTER PREDICATE [dbo].[fn_securitypredicate]([SalesRep]) ON [dbo].[Sales2], +ADD BLOCK PREDICATE [dbo].[fn_securitypredicate]([SalesRep]) ON [dbo].[Sales1], +ADD BLOCK PREDICATE [dbo].[fn_securitypredicate]([SalesRep]) ON [dbo].[Sales2] AFTER UPDATE +WITH (STATE = OFF) +NOT FOR REPLICATION + +GO + +CREATE COLUMN MASTER KEY CMK1 +WITH ( + KEY_STORE_PROVIDER_NAME = 'MSSQL_CERTIFICATE_STORE', + KEY_PATH = 'Current User/Personal/f2260f28d909d21c642a3d8e0b45a830e79a1420' + ); + +GO + +CREATE COLUMN MASTER KEY CMK2 +WITH ( + KEY_STORE_PROVIDER_NAME = 'MSSQL_CERTIFICATE_STORE', + KEY_PATH = 'Current User/Personal/f2260f28d909d21c642a3d8e0b45a830e79a1420' + ); + +GO + +CREATE COLUMN ENCRYPTION KEY TwoValueCEK +WITH VALUES +( + COLUMN_MASTER_KEY = CMK1, + ALGORITHM = 'RSA_OAEP', + ENCRYPTED_VALUE = 0x016E000001630075007200720065006E00740075007300650072002F006D0079002F0037006300380061003100310033003400320037003800620037003000630038003100390062003900630039003400360061006600340039006500610030003200650038006200650038003400340065006C33A82ECF04A7185824B4545457AC5244CD9C219E64067B9520C0081B8399B58C2863F7494ABE3694BD87D55FFD7576FFDC47C28F94ECC99577DF4FB8FA19AA95764FEF889CDE0F176DA5897B74382FBB22756CE2921050A09201A0EB6AF3D6091014C30146EA62635EE8CBF0A8074DEDFF125CEA80D1C0F5E8C58750A07D270E2A8BF824EE4C0C156366BF26D38CCE49EBDD5639A2DF029A7DBAE5A5D111F2F2FA3246DF8C2FA83C1E542C10570FADA98F6B29478DC58CE5CBDD407CCEFCDB97814525F6F32BECA266014AC346AC39C4F185C6C0F0A24FEC4DFA015649624692DE7865B9827BA22C3B574C9FD169F822B609F902288C5880EB25F14BD990D871B1BC4BA3A5B237AF76D26354773FA2A25CF4511AF58C911E601CFCB1905128C997844EED056C2AE7F0B48700AB41307E470FF9520997D0EB0D887DE11AFE574FFE845B7DC6C03FEEE8D467236368FC0CB2FDBD54DADC65B10B3DE6C80DF8B7B3F8F3CE5BE914713EE7B1FA5B7A578359592B8A5FDFDDE5FF9F392BC87C3CD02FBA94582AC063BBB9FFAC803FD489E16BEB28C4E3374A8478C737236A0B232F5A9DDE4D119573F1AEAE94B2192B81575AD6F57E670C1B2AB91045124DFDAEC2898F3F0112026DFC93BF9391D667D1AD7ED7D4E6BB119BBCEF1D1ADA589DD3E1082C3DAD13223BE438EB9574DA04E9D8A06320CAC6D3EC21D5D1C2A0AA484C7C +), +( + COLUMN_MASTER_KEY = CMK2, + ALGORITHM = 'RSA_OAEP', + ENCRYPTED_VALUE = 0x016E000001630075007200720065006E00740075007300650072002F006D0079002F0064006500650063006200660034006100340031003000380034006200350033003200360066003200630062006200350030003600380065003900620061003000320030003600610037003800310066001DDA6134C3B73A90D349C8905782DD819B428162CF5B051639BA46EC69A7C8C8F81591A92C395711493B25DCBCCC57836E5B9F17A0713E840721D098F3F8E023ABCDFE2F6D8CC4339FC8F88630ED9EBADA5CA8EEAFA84164C1095B12AE161EABC1DF778C07F07D413AF1ED900F578FC00894BEE705EAC60F4A5090BBE09885D2EFE1C915F7B4C581D9CE3FDAB78ACF4829F85752E9FC985DEB8773889EE4A1945BD554724803A6F5DC0A2CD5EFE001ABED8D61E8449E4FAA9E4DD392DA8D292ECC6EB149E843E395CDE0F98D04940A28C4B05F747149B34A0BAEC04FFF3E304C84AF1FF81225E615B5F94E334378A0A888EF88F4E79F66CB377E3C21964AACB5049C08435FE84EEEF39D20A665C17E04898914A85B3DE23D56575EBC682D154F4F15C37723E04974DB370180A9A579BC84F6BC9B5E7C223E5CBEE721E57EE07EFDCC0A3257BBEBF9ADFFB00DBF7EF682EC1C4C47451438F90B4CF8DA709940F72CFDC91C6EB4E37B4ED7E2385B1FF71B28A1D2669FBEB18EA89F9D391D2FDDEA0ED362E6A591AC64EF4AE31CA8766C259ECB77D01A7F5C36B8418F91C1BEADDD4491C80F0016B66421B4B788C55127135DA2FA625FB7FD195FB40D90A6C67328602ECAF3EC4F5894BFD84A99EB4753BE0D22E0D4DE6A0ADFEDC80EB1B556749B4A8AD00E73B329C95827AB91C0256347E85E3C5FD6726D0E1FE82C925D3DF4A9 +); + +GO + +CREATE TABLE Customers ( + CustName nvarchar(60), + SSN varchar(11) + COLLATE Latin1_General_BIN2 ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = TwoValueCEK, + ENCRYPTION_TYPE = DETERMINISTIC , + ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256'), + Age int NULL, + ACTNO varchar(11) + ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = TwoValueCEK, + ENCRYPTION_TYPE = RANDOMIZED, + ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256') +); + +GO + +USE [$(DatabaseName)] + +GO + +DBCC TRACEON(4631,-1) + +GO + +OPEN MASTER KEY DECRYPTION BY PASSWORD = 'Password01!'; + +CREATE DATABASE SCOPED CREDENTIAL cred1 WITH IDENTITY = 'test_user', SECRET = '$(Secret)'; + +CREATE EXTERNAL DATA SOURCE eds1 + WITH ( + TYPE = HADOOP, + LOCATION = '$(DataSourceLocation)', + CREDENTIAL = cred1 + ); + +CREATE EXTERNAL DATA SOURCE eds2 + WITH ( + TYPE = HADOOP, + LOCATION = '$(DataSourceLocation)' + ); + +CREATE EXTERNAL FILE FORMAT eff1 + WITH ( + FORMAT_TYPE = DELIMITEDTEXT + ); + +CREATE EXTERNAL FILE FORMAT eff2 + WITH ( + FORMAT_TYPE = ORC + ); + +CREATE EXTERNAL FILE FORMAT eff3 + WITH ( + FORMAT_TYPE = PARQUET + ); + +CREATE EXTERNAL FILE FORMAT eff4 + WITH ( + FORMAT_TYPE = RCFILE, + SERDE_METHOD = 'org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe' + ); + +CREATE EXTERNAL FILE FORMAT eff5 + WITH ( + FORMAT_TYPE = DELIMITEDTEXT, + FORMAT_OPTIONS (FIELD_TERMINATOR = '|', STRING_DELIMITER = ';', DATE_FORMAT = 'MM-dd-yyyy', USE_TYPE_DEFAULT = FALSE) + ); + +CREATE EXTERNAL FILE FORMAT eff6 + WITH ( + FORMAT_TYPE = DELIMITEDTEXT, + FORMAT_OPTIONS (FIELD_TERMINATOR = '|') + ); + +CREATE EXTERNAL FILE FORMAT eff7 + WITH ( + FORMAT_TYPE = DELIMITEDTEXT, + FORMAT_OPTIONS (DATE_FORMAT = 'MM-dd-yyyy', FIELD_TERMINATOR = '|') + ); + +CREATE EXTERNAL FILE FORMAT eff8 + WITH ( + FORMAT_TYPE = DELIMITEDTEXT, + FORMAT_OPTIONS (DATE_FORMAT = 'MM-dd-yyyy', FIELD_TERMINATOR = '|', STRING_DELIMITER = ';') + ); + +CREATE EXTERNAL FILE FORMAT eff9 + WITH ( + FORMAT_TYPE = DELIMITEDTEXT, + FORMAT_OPTIONS (DATE_FORMAT = 'MM-dd-yyyy', FIELD_TERMINATOR = '|', STRING_DELIMITER = ';'), + DATA_COMPRESSION = 'org.apache.hadoop.io.compress.GzipCodec' + ); + +CREATE EXTERNAL FILE FORMAT eff10 + WITH ( + FORMAT_TYPE = RCFILE, + SERDE_METHOD = 'org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe', + DATA_COMPRESSION = 'org.apache.hadoop.io.compress.DefaultCodec' + ); + +CREATE EXTERNAL FILE FORMAT eff11 + WITH ( + FORMAT_TYPE = ORC, + DATA_COMPRESSION = 'org.apache.hadoop.io.compress.SnappyCodec' + ); + +CREATE EXTERNAL FILE FORMAT eff12 + WITH ( + FORMAT_TYPE = PARQUET, + DATA_COMPRESSION = 'org.apache.hadoop.io.compress.SnappyCodec' + ); + +CREATE EXTERNAL TABLE bands1 +( + id INTEGER NOT NULL, + name VARCHAR(50) NOT NULL, + origin CHAR(3), + rate FLOAT, + experience SMALLINT + ) + WITH ( + LOCATION = '/bands.dat', + DATA_SOURCE = eds1, + FILE_FORMAT = eff1 + ); + +CREATE EXTERNAL TABLE bands2 +( + id INTEGER NOT NULL, + name VARCHAR(50) NOT NULL, + origin CHAR(3), + rate FLOAT, + experience SMALLINT + ) + WITH ( + LOCATION = '/bands.dat', + DATA_SOURCE = eds2, + FILE_FORMAT = eff1 + ); + +CREATE EXTERNAL TABLE bands3 +( + id INTEGER NOT NULL, + name VARCHAR(50) NOT NULL, + origin CHAR(3), + rate FLOAT, + experience SMALLINT + ) + WITH ( + LOCATION = '/bands.dat', + DATA_SOURCE = eds2, + FILE_FORMAT = eff1, + REJECT_TYPE = VALUE, + REJECT_VALUE = 0 + ); + +CREATE EXTERNAL TABLE bands4 +( + id INTEGER NOT NULL, + name VARCHAR(50) NOT NULL, + origin CHAR(3), + rate FLOAT, + experience SMALLINT + ) + WITH ( + LOCATION = '/bands.dat', + DATA_SOURCE = eds1, + FILE_FORMAT = eff1, + REJECT_TYPE = PERCENTAGE, + REJECT_VALUE = 30.5, + REJECT_SAMPLE_VALUE = 10 + ); + +CREATE EXTERNAL TABLE bands5 +( + id INTEGER NOT NULL, + name VARCHAR(50) NOT NULL, + origin CHAR(3), + rate FLOAT, + experience SMALLINT + ) + WITH ( + LOCATION = '/bands.dat', + DATA_SOURCE = eds1, + FILE_FORMAT = eff1, + REJECT_TYPE = VALUE, + REJECT_VALUE = 30 + ); \ No newline at end of file diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/Sql_Additions.sql b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/Sql_Additions.sql new file mode 100644 index 00000000..dea7fcbf --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/TestScripts/Sql_Additions.sql @@ -0,0 +1,298 @@ +-- create signature +ADD SIGNATURE TO [Procedure1] + BY CERTIFICATE [Certificate1] + WITH PASSWORD = 'pGFD4bb925DGvbd2439587y' ; +GO +--Create a queue to receive messages. +CREATE QUEUE NotifyQueue ; +GO +--Create a service on the queue that references +--the event notifications contract. +CREATE SERVICE NotifyService +ON QUEUE NotifyQueue +([http://schemas.microsoft.com/SQL/Notifications/PostEventNotification]); +GO +--Create the event notification on queue. +CREATE EVENT NOTIFICATION Notify_ALTER_T1 +ON QUEUE notifyqueue +FOR QUEUE_ACTIVATION +TO SERVICE 'NotifyService', +'8140a771-3c4b-4479-8ac0-81008ab17984'; +GO +--Create the event notification on database +CREATE EVENT NOTIFICATION Notify_ALTER_T1 +ON DATABASE +FOR ALTER_TABLE +TO SERVICE 'NotifyService', + '8140a771-3c4b-4479-8ac0-81008ab17984'; +GO + +CREATE FUNCTION [dbo].[TableFunctionWithComputedColumns] +( + -- Add the parameters for the function here + @p1 int = 2, + @p2 nchar(10) = NUll +) +RETURNS +@Table_Var TABLE +( + -- Add the column definitions for the TABLE variable here + c1 int, + c2 nchar(10), + c3 AS 1 * 3 +) +AS +BEGIN + -- Fill the table variable with the rows for your result set + INSERT INTO @Table_Var + SELECT a.column_1, a.column_2 + FROM Table_1 a + WHERE a.column_1 > 5 + + INSERT INTO @Table_Var + SELECT column_1, 'From 2' + FROM Table_2 + WHERE @p1 > column_1 + + RETURN +END +GO + +CREATE FUNCTION [dbo].[TableFunctionWithComputedColumnsEncrypted] +( + -- Add the parameters for the function here + @p1 int = 2, + @p2 nchar(10) +) +RETURNS +@Table_Var TABLE +( + -- Add the column definitions for the TABLE variable here + c1 int, + c2 nchar(10), + c3 AS 1 * 3 +) +WITH ENCRYPTION +AS +BEGIN + -- Fill the table variable with the rows for your result set + INSERT INTO @Table_Var + SELECT a.column_1, a.column_2 + FROM Table_1 a + WHERE a.column_1 > 5 + + INSERT INTO @Table_Var + SELECT column_1, 'From 2' + FROM Table_2 + WHERE @p1 > column_1 + + RETURN +END +GO + +Create table [dbo].[referenced_table] (C1 int, C2 int); + +GO + +CREATE PROCEDURE GetReferenedTable +AS +BEGIN +SELECT * from [dbo].[referenced_table]; +END +GO +exec sp_addextendedproperty N'microsoft_database_tools_support', 'GetReferenedTable', N'SCHEMA', 'dbo', N'PROCEDURE' ,'GetReferenedTable' +GO +DISABLE TRIGGER [Trigger_1] + ON DATABASE; +GO + +CREATE VIEW [dbo].[View_2] (c1) +AS +SELECT column_1 as c1 +FROM dbo.Table_1 + +GO + +exec sp_addextendedproperty 'prop_ex', 'Table_1', 'SCHEMA', 'dbo', 'TABLE', 'Table_1' + +GO + +exec sp_addextendedproperty 'prop_ex', 'column_1', 'SCHEMA', 'dbo', 'TABLE', 'Table_1', 'COLUMN', 'column_1' +GO + +CREATE TABLE dbo.MultipleIndexTable +( [c1] INT NOT NULL CHECK (c1 > 0), +[c2] int default 10 null, +PRIMARY KEY NONCLUSTERED (c1 ASC), +UNIQUE CLUSTERED (c1 ASC, c2 DESC) +) + +GO + +CREATE TRIGGER [Trigger_2] +ON DATABASE +FOR DROP_TABLE +AS + SELECT COUNT(column_1) from dbo.Table_1 + RAISERROR ('You must disable Trigger "Trigger_1" to drop synonyms!',10, 1) + ROLLBACK + +GO + +SET ANSI_NULLS OFF +GO + +SET QUOTED_IDENTIFIER OFF +GO + +DISABLE TRIGGER [Trigger_1] ON DATABASE +GO + +GO + +CREATE TABLE dbo.Table_3 +( + c1 int, + c2 int, +) ON PartitionScheme(c1) + +GO +CREATE TABLE [dbo].[Different_WithAppend_Table]( +[Id] [int] IDENTITY(1,1) NOT NULL, +[Col] [char](1) NULL +) ON [PRIMARY] + +GO + +CREATE FUNCTION [dbo].[EncryptedFunctionWithConstraints] +(@p1 INT) +RETURNS + @GeneratedTableName TABLE ( + [c0] INT NOT NULL PRIMARY KEY, + [c1] INT DEFAULT ((1)) NULL, + [c2] NCHAR (10) NULL, + [c3] INT UNIQUE , + CHECK ([c1]>(0))) +WITH ENCRYPTION +AS +BEGIN + insert into @GeneratedTableName values (1,1, 'abc',1); + RETURN +END +GO +CREATE TABLE [[] (c1 int) +GO +CREATE TABLE []]] (c1 int) +GO +CREATE TABLE [asdf'[] (c1 int) +GO +CREATE TABLE [噂構申表5] (c1 int) +GO +-- Casing of NULL is explicit 'NUll' +CREATE PROC CasingOnDefaultValue @param1 int = NUll, @param2 nvarchar(123) = N'abc' +AS +BEGIN + select 1 as a +END +-- permissions +GO +CREATE USER nologon4 without login +GO +GRANT VIEW DEFINITION ON CasingOnDefaultValue to nologon4 +GO +CREATE USER granter without login +GO +GRANT CONNECT TO granter WITH GRANT OPTION; +GO +DENY CONNECT TO nologon4 CASCADE AS granter; +GO +GRANT VIEW DEFINITION ON [噂構申表5] to nologon4 +GO +GRANT VIEW DEFINITION ON [[] TO nologon4 +GO +GRANT VIEW DEFINITION ON []]] TO nologon4 +GO +GRANT VIEW DEFINITION ON [asdf'[] TO nologon4 +GO +GRANT SELECT ON dbo.Table_1 to nologon4 +GO +GRANT SELECT ON dbo.Table_2 to nologon4 +GO +REVOKE SELECT ON dbo.Table_2(column_2) TO nologon4 +GO +GRANT SELECT ON dbo.View_1 to nologon4 +GO +GRANT SELECT ON dbo.EncryptedView(A) to nologon4 +GO +GRANT EXECUTE ON dbo.Procedure1 TO nologon4 +GO +GRANT EXECUTE ON dbo.CLR_SimpleResultsetProcedure TO nologon4 +GO +GRANT EXECUTE ON dbo.EncryptedProcedure TO nologon4 +GO +GRANT VIEW DEFINITION ON CERTIFICATE :: Certificate1 TO nologon4 +GO +GRANT EXECUTE ON dbo.ScalarFunction1 TO nologon4 +GO +GRANT EXECUTE ON dbo.EncryptedFunction TO nologon4 +GO +GRANT SELECT ON dbo.InlineFunction_1 TO nologon4 +GO +GRANT SELECT ON dbo.TableFunction1 TO nologon4 +GO +GRANT SELECT ON dbo.CLRTableValueFunction TO nologon4 +GO +GRANT VIEW DEFINITION ON TYPE::dbo.dataType To nologon4 +GO +GRANT VIEW DEFINITION ON FULLTEXT CATALOG ::FullTextCatalog1 To nologon4 +GO +GRANT VIEW DEFINITION ON XML SCHEMA COLLECTION :: dbo.XmlSchemaCollection To nologon4 +GO +GRANT VIEW DEFINITION ON ASSEMBLY :: [Geometry] To nologon4 +GO +GRANT VIEW DEFINITION ON TYPE:: dbo.Angle To nologon4 +GO +GRANT VIEW DEFINITION ON dbo.[Concat] To nologon4 +GO +GRANT VIEW DEFINITION ON dbo.Synonym_1 To nologon4 +GO +GRANT VIEW DEFINITION ON SCHEMA :: Schema1 To nologon4 +GO +GRANT VIEW DEFINITION ON SYMMETRIC KEY :: SymKey1 To nologon4 +GO +GRANT VIEW DEFINITION ON ASYMMETRIC KEY :: AsmKey1 To nologon4 +GO +GRANT VIEW DEFINITION ON dbo.Queue1 To nologon4 +GO +GRANT VIEW DEFINITION ON dbo.NotifyQueue To nologon4 +GO +GRANT VIEW DEFINITION ON SERVICE :: Service1 To nologon4 +GO +GRANT VIEW DEFINITION ON SERVICE :: NotifyService To nologon4 +GO +GRANT VIEW DEFINITION ON CONTRACT :: Contract1 To nologon4 +GO +GRANT VIEW DEFINITION ON MESSAGE TYPE :: MessageType1 To nologon4 +GO +GRANT VIEW DEFINITION ON ROUTE :: AutoCreatedLocal To nologon4 +GO +GRANT VIEW DEFINITION ON ROUTE :: Route1 To nologon4 +GO +GRANT VIEW DEFINITION ON REMOTE SERVICE BINDING :: ServiceBinding1 To nologon4 +GO +GRANT SELECT ON dbo.referenced_table To nologon4 +GO +GRANT SELECT ON dbo.TableFunctionWithComputedColumns To nologon4 +GO +GRANT SELECT ON dbo.TableFunctionWithComputedColumnsEncrypted To nologon4 +GO +GRANT SELECT ON dbo.View_2 TO nologon4 +GO +GRANT SELECT ON dbo.MultipleIndexTable TO nologon4 +GO +GRANT SELECT ON dbo.Table_3 TO nologon4 +GO +GRANT SELECT ON dbo.Different_WithAppend_Table TO nologon4 +GO +GRANT SELECT ON dbo.[EncryptedFunctionWithConstraints] TO nologon4 +GO \ No newline at end of file diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs index 00f3146b..1f8a7607 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs @@ -8,6 +8,7 @@ using Microsoft.SqlTools.Credentials; using Microsoft.SqlTools.ServiceLayer.Connection; using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; using Microsoft.SqlTools.ServiceLayer.Hosting; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; using Microsoft.SqlTools.ServiceLayer.QueryExecution; using Microsoft.SqlTools.ServiceLayer.SqlContext; using Microsoft.SqlTools.ServiceLayer.Workspace; @@ -43,6 +44,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common { return CredentialService.Instance; } + } + + public ObjectExplorerService ObjectExplorerService + { + get + { + var serviceProvider = ServiceHost.Instance.ServiceProvider; + return serviceProvider.GetService(); + } } public TestConnectionProfileService ConnectionProfileService diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/project.json b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/project.json index 1b200970..b3070af8 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/project.json +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/project.json @@ -6,7 +6,8 @@ "includeFiles": [ "Scripts/CreateTestDatabaseObjects.sql", "Scripts/CreateTestDatabase.sql", - "Scripts/TestDbTableQueries.sql" + "Scripts/TestDbTableQueries.sql", + "Scripts/AdventureWorks.sql" ] } }, diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs new file mode 100644 index 00000000..a37babf6 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs @@ -0,0 +1,369 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Globalization; +using Microsoft.SqlServer.Management.Common; +using Microsoft.SqlServer.Management.Smo; +using Microsoft.SqlTools.Extensibility; +using Microsoft.SqlTools.ServiceLayer.Connection; +using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; +using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility; +using Moq; +using Xunit; + +namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer +{ + /// + /// Tests covering basic operation of Node based classes + /// + public class NodeTests : ObjectExplorerTestBase + { + private string defaultOwnerUri = "objectexplorer://myserver"; + private ServerInfo defaultServerInfo; + private ConnectionDetails defaultConnectionDetails; + private ConnectionCompleteParams defaultConnParams; + private string fakeConnectionString = "Data Source=server;Initial Catalog=database;Integrated Security=False;User Id=user"; + + public NodeTests() + { + defaultServerInfo = TestObjects.GetTestServerInfo(); + + defaultConnectionDetails = new ConnectionDetails() + { + DatabaseName = "master", + ServerName = "localhost", + UserName = "serverAdmin", + Password = "..." + }; + defaultConnParams = new ConnectionCompleteParams() + { + ServerInfo = defaultServerInfo, + ConnectionSummary = defaultConnectionDetails, + OwnerUri = defaultOwnerUri + }; + + // TODO can all tests use the standard service provider? + ServiceProvider = ExtensionServiceProvider.CreateDefaultServiceProvider(); + } + + [Fact] + public void ServerNodeConstructorValidatesFields() + { + Assert.Throws(() => new ServerNode(null, ServiceProvider)); + Assert.Throws(() => new ServerNode(defaultConnParams, null)); + } + + [Fact] + public void ServerNodeConstructorShouldSetValuesCorrectly() + { + // Given a server node with valid inputs + ServerNode node = new ServerNode(defaultConnParams, ServiceProvider); + // Then expect all fields set correctly + Assert.False(node.IsAlwaysLeaf, "Server node should never be a leaf"); + Assert.Equal(defaultConnectionDetails.ServerName, node.NodeValue); + + string expectedLabel = defaultConnectionDetails.ServerName + " (SQL Server " + defaultServerInfo.ServerVersion + " - " + + defaultConnectionDetails.UserName + ")"; + Assert.Equal(expectedLabel, node.Label); + + Assert.Equal(NodeTypes.ServerInstance.ToString(), node.NodeType); + string[] nodePath = node.GetNodePath().Split(TreeNode.PathPartSeperator); + Assert.Equal(1, nodePath.Length); + Assert.Equal(defaultConnectionDetails.ServerName, nodePath[0]); + } + + [Fact] + public void ServerNodeLabelShouldIgnoreUserNameIfEmptyOrNull() + { + // Given no username set + ConnectionSummary integratedAuthSummary = new ConnectionSummary() + { + DatabaseName = defaultConnectionDetails.DatabaseName, + ServerName = defaultConnectionDetails.ServerName, + UserName = null + }; + ConnectionCompleteParams connParams = new ConnectionCompleteParams() + { + ConnectionSummary = integratedAuthSummary, + ServerInfo = defaultServerInfo, + OwnerUri = defaultOwnerUri + }; + // When querying label + string label = new ServerNode(connParams, ServiceProvider).Label; + // Then only server name and version shown + string expectedLabel = defaultConnectionDetails.ServerName + " (SQL Server " + defaultServerInfo.ServerVersion + ")"; + Assert.Equal(expectedLabel, label); + } + + [Fact] + public void ServerNodeConstructorShouldShowDbNameForCloud() + { + defaultServerInfo.IsCloud = true; + + // Given a server node for a cloud DB, with master name + ServerNode node = new ServerNode(defaultConnParams, ServiceProvider); + // Then expect label to not include db name + string expectedLabel = defaultConnectionDetails.ServerName + " (SQL Server " + defaultServerInfo.ServerVersion + " - " + + defaultConnectionDetails.UserName + ")"; + Assert.Equal(expectedLabel, node.Label); + + // But given a server node for a cloud DB that's not master + defaultConnectionDetails.DatabaseName = "NotMaster"; + node = new ServerNode(defaultConnParams, ServiceProvider); + + // Then expect label to include db name + expectedLabel = defaultConnectionDetails.ServerName + " (SQL Server " + defaultServerInfo.ServerVersion + " - " + + defaultConnectionDetails.UserName + ", " + defaultConnectionDetails.DatabaseName + ")"; + Assert.Equal(expectedLabel, node.Label); + } + + [Fact] + public void ToNodeInfoIncludeAllFields() + { + // Given a server connection + ServerNode node = new ServerNode(defaultConnParams, ServiceProvider); + // When converting to NodeInfo + NodeInfo info = node.ToNodeInfo(); + // Then all fields should match + Assert.Equal(node.IsAlwaysLeaf, info.IsLeaf); + Assert.Equal(node.Label, info.Label); + Assert.Equal(node.NodeType, info.NodeType); + string[] nodePath = node.GetNodePath().Split(TreeNode.PathPartSeperator); + string[] nodeInfoPathParts = info.NodePath.Split(TreeNode.PathPartSeperator); + Assert.Equal(nodePath.Length, nodeInfoPathParts.Length); + for (int i = 0; i < nodePath.Length; i++) + { + Assert.Equal(nodePath[i], nodeInfoPathParts[i]); + } + } + + [Fact] + public void AddChildShouldSetParent() + { + TreeNode parent = new TreeNode("parent"); + TreeNode child = new TreeNode("child"); + Assert.Null(child.Parent); + parent.AddChild(child); + Assert.Equal(parent, child.Parent); + } + + [Fact] + public void GetChildrenShouldReturnReadonlyList() + { + TreeNode node = new TreeNode("parent"); + IList children = node.GetChildren(); + Assert.Throws(() => children.Add(new TreeNode("child"))); + } + + [Fact] + public void GetChildrenShouldReturnAddedNodesInOrder() + { + TreeNode parent = new TreeNode("parent"); + TreeNode[] expectedKids = new TreeNode[] { new TreeNode("1"), new TreeNode("2") }; + foreach (TreeNode child in expectedKids) + { + parent.AddChild(child); + } + IList children = parent.GetChildren(); + Assert.Equal(expectedKids.Length, children.Count); + for (int i = 0; i < expectedKids.Length; i++) + { + Assert.Equal(expectedKids[i], children[i]); + } + } + + public void MultiLevelTreeShouldFormatPath() + { + TreeNode root = new TreeNode("root"); + Assert.Equal("/root" , root.GetNodePath()); + + TreeNode level1Child1 = new TreeNode("L1C1"); + TreeNode level1Child2 = new TreeNode("L1C2"); + root.AddChild(level1Child1); + root.AddChild(level1Child2); + Assert.Equal("/root/L1C1" , level1Child1.GetNodePath()); + Assert.Equal("/root/L1C2", level1Child2.GetNodePath()); + + TreeNode level2Child1 = new TreeNode("L2C2"); + level1Child1.AddChild(level2Child1); + Assert.Equal("/root/L1C1/L2C2", level2Child1.GetNodePath()); + } + + [Fact] + public void ServerNodeContextShouldIncludeServer() + { + // given a successful Server creation + SetupAndRegisterTestConnectionService(); + Server smoServer = new Server(new ServerConnection(new SqlConnection(fakeConnectionString))); + ServerNode node = SetupServerNodeWithServer(smoServer); + + // When I get the context for a ServerNode + var context = node.GetContextAs(); + + // Then I expect it to contain the server I created + Assert.NotNull(context); + Assert.Equal(smoServer, context.Server); + // And the server should be the parent + Assert.Equal(smoServer, context.Parent); + Assert.Null(context.Database); + } + + [Fact] + public void ServerNodeContextShouldSetErrorMessageIfSqlConnectionIsNull() + { + // given a connectionInfo with no SqlConnection to use for queries + ConnectionService connService = SetupAndRegisterTestConnectionService(); + connService.OwnerToConnectionMap.Remove(defaultOwnerUri); + + Server smoServer = new Server(new ServerConnection(new SqlConnection(fakeConnectionString))); + ServerNode node = SetupServerNodeWithServer(smoServer); + + // When I get the context for a ServerNode + var context = node.GetContextAs(); + + // Then I expect it to be in an error state + Assert.Null(context); + Assert.Equal( + string.Format(CultureInfo.CurrentCulture, SR.ServerNodeConnectionError, defaultConnectionDetails.ServerName), + node.ErrorStateMessage); + } + + [Fact] + public void ServerNodeContextShouldSetErrorMessageIfConnFailureExceptionThrown() + { + // given a connectionInfo with no SqlConnection to use for queries + SetupAndRegisterTestConnectionService(); + + Server smoServer = new Server(new ServerConnection(new SqlConnection(fakeConnectionString))); + string expectedMsg = "ConnFailed!"; + ServerNode node = SetupServerNodeWithExceptionCreator(new ConnectionFailureException(expectedMsg)); + + // When I get the context for a ServerNode + var context = node.GetContextAs(); + + // Then I expect it to be in an error state + Assert.Null(context); + Assert.Equal( + string.Format(CultureInfo.CurrentCulture, SR.TreeNodeError, expectedMsg), + node.ErrorStateMessage); + } + + [Fact] + public void ServerNodeContextShouldSetErrorMessageIfExceptionThrown() + { + // given a connectionInfo with no SqlConnection to use for queries + SetupAndRegisterTestConnectionService(); + + Server smoServer = new Server(new ServerConnection(new SqlConnection(fakeConnectionString))); + string expectedMsg = "Failed!"; + ServerNode node = SetupServerNodeWithExceptionCreator(new Exception(expectedMsg)); + + // When I get the context for a ServerNode + var context = node.GetContextAs(); + + // Then I expect it to be in an error state + Assert.Null(context); + Assert.Equal( + string.Format(CultureInfo.CurrentCulture, SR.TreeNodeError, expectedMsg), + node.ErrorStateMessage); + } + + private ConnectionService SetupAndRegisterTestConnectionService() + { + ConnectionService connService = TestObjects.GetTestConnectionService(); + ConnectionInfo connectionInfo = new ConnectionInfo(TestObjects.GetTestSqlConnectionFactory(), + defaultOwnerUri, defaultConnectionDetails); + connectionInfo.AddConnection("Default", new SqlConnection()); + + connService.OwnerToConnectionMap.Add(defaultOwnerUri, connectionInfo); + ServiceProvider.RegisterSingleService(connService); + return connService; + } + + private ServerNode SetupServerNodeWithServer(Server smoServer) + { + Mock creator = new Mock(); + creator.Setup(c => c.Create(It.IsAny())) + .Returns(() => smoServer); + ServerNode node = SetupServerNodeWithCreator(creator.Object); + return node; + } + + private ServerNode SetupServerNodeWithExceptionCreator(Exception ex) + { + Mock creator = new Mock(); + creator.Setup(c => c.Create(It.IsAny())) + .Throws(ex); + + ServerNode node = SetupServerNodeWithCreator(creator.Object); + return node; + } + + private ServerNode SetupServerNodeWithCreator(SmoServerCreator creator) + { + ServerNode node = new ServerNode(defaultConnParams, ServiceProvider); + node.ServerCreator = creator; + return node; + } + + [Fact] + public void ServerNodeChildrenShouldIncludeFoldersAndDatabases() + { + // Given a server with 1 database + SetupAndRegisterTestConnectionService(); + ServiceProvider.RegisterSingleService(new ObjectExplorerService()); + + string dbName = "DB1"; + Mock smoObjectMock = new Mock(); + smoObjectMock.SetupGet(s => s.Name).Returns(dbName); + + Mock querierMock = new Mock(); + querierMock.Setup(q => q.Query(It.IsAny())) + .Returns(smoObjectMock.Object.SingleItemAsEnumerable()); + + ServiceProvider.Register(() => new[] { querierMock.Object }); + + Server smoServer = new Server(new ServerConnection(new SqlConnection(fakeConnectionString))); + ServerNode node = SetupServerNodeWithServer(smoServer); + + // When I populate its children + IList children = node.Expand(); + + // Then I expect it to contain server-level folders + Assert.Equal(3, children.Count); + VerifyTreeNode(children[0], "Folder", SR.SchemaHierarchy_Databases); + VerifyTreeNode(children[1], "Folder", SR.SchemaHierarchy_Security); + VerifyTreeNode(children[2], "Folder", SR.SchemaHierarchy_ServerObjects); + // And the database is contained under it + TreeNode databases = children[0]; + IList dbChildren = databases.Expand(); + Assert.Equal(2, dbChildren.Count); + Assert.Equal("System Databases", dbChildren[0].NodeValue); + + TreeNode dbNode = dbChildren[1]; + Assert.Equal(dbName, dbNode.NodeValue); + Assert.Equal(dbName, dbNode.Label); + Assert.False(dbNode.IsAlwaysLeaf); + + // Note: would like to verify Database in the context, but cannot since it's a Sealed class and isn't easily mockable + } + + private void VerifyTreeNode(TreeNode node, string nodeType, string folderValue) + where T : TreeNode + { + T nodeAsT = node as T; + Assert.NotNull(nodeAsT); + Assert.Equal(nodeType, nodeAsT.NodeType); + Assert.Equal(folderValue, nodeAsT.NodeValue); + } + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs new file mode 100644 index 00000000..a357dfd3 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs @@ -0,0 +1,151 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Threading.Tasks; +using Microsoft.SqlTools.Hosting.Protocol; +using Microsoft.SqlTools.ServiceLayer.Connection; +using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes; +using Microsoft.SqlTools.ServiceLayer.Test.Common; +using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility; +using Moq; +using Xunit; + +namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer +{ + + public class ObjectExplorerServiceTests : ObjectExplorerTestBase + { + private ObjectExplorerService service; + private Mock connectionServiceMock; + private Mock serviceHostMock; + public ObjectExplorerServiceTests() + { + connectionServiceMock = new Mock(); + serviceHostMock = new Mock(); + service = CreateOEService(connectionServiceMock.Object); + service.InitializeService(serviceHostMock.Object); + } + + [Fact] + public async Task CreateSessionRequestErrorsIfConnectionDetailsIsNull() + { + object errorResponse = null; + var contextMock = RequestContextMocks.Create(null) + .AddErrorHandling((errorMessage, errorCode, obj) => errorResponse = errorMessage); + + await service.HandleCreateSessionRequest(null, contextMock.Object); + VerifyErrorSent(contextMock); + Assert.True(((string)errorResponse).Contains("ArgumentNullException")); + } + + [Fact] + public async Task CreateSessionRequestReturnsFalseOnConnectionFailure() + { + // Given the connection service fails to connect + ConnectionDetails details = TestObjects.GetTestConnectionDetails(); + ConnectionCompleteParams completeParams = null; + serviceHostMock.AddEventHandling(ConnectionCompleteNotification.Type, (et, p) => completeParams = p); + + string expectedExceptionText = "Error!!!"; + connectionServiceMock.Setup(c => c.Connect(It.IsAny())) + .Throws(new Exception(expectedExceptionText)); + + // when creating a new session + // then expect the create session request to return false + await RunAndVerify( + test: (requestContext) => service.HandleCreateSessionRequest(details, requestContext), + verify: (actual => + { + Assert.False(actual.Success); + Assert.Null(actual.SessionId); + Assert.Null(actual.RootNode); + })); + + // And expect error notification to be sent + serviceHostMock.Verify(x => x.SendEvent(ConnectionCompleteNotification.Type, It.IsAny()), Times.Once()); + Assert.NotNull(completeParams); + Assert.True(completeParams.Messages.Contains(expectedExceptionText)); + } + + + [Fact] + public async Task CreateSessionRequestReturnsSuccessAndNodeInfo() + { + // Given the connection service fails to connect + ConnectionDetails details = TestObjects.GetTestConnectionDetails(); + serviceHostMock.AddEventHandling(ConnectionCompleteNotification.Type, null); + + connectionServiceMock.Setup(c => c.Connect(It.IsAny())) + .Returns((ConnectParams connectParams) => Task.FromResult(GetCompleteParamsForConnection(connectParams.OwnerUri, details))); + + // when creating a new session + // then expect the create session request to return false + await RunAndVerify( + test: (requestContext) => service.HandleCreateSessionRequest(details, requestContext), + verify: (actual => + { + Assert.True(actual.Success); + Assert.NotNull(actual.SessionId); + VerifyServerNode(actual.RootNode, details); + })); + + // And expect no error notification to be sent + serviceHostMock.Verify(x => x.SendEvent(ConnectionCompleteNotification.Type, + It.IsAny()), Times.Never()); + } + + private void VerifyServerNode(NodeInfo serverNode, ConnectionDetails details) + { + Assert.NotNull(serverNode); + Assert.Equal(NodeTypes.ServerInstance.ToString(), serverNode.NodeType); + string[] pathParts = serverNode.NodePath.Split(TreeNode.PathPartSeperator); + Assert.Equal(1, pathParts.Length); + Assert.Equal(details.ServerName, pathParts[0]); + Assert.True(serverNode.Label.Contains(details.ServerName)); + Assert.False(serverNode.IsLeaf); + } + + private static ConnectionCompleteParams GetCompleteParamsForConnection(string uri, ConnectionDetails details) + { + return new ConnectionCompleteParams() + { + OwnerUri = uri, + ConnectionSummary = new ConnectionSummary() + { + ServerName = details.ServerName, + DatabaseName = details.DatabaseName, + UserName = details.UserName + }, + ServerInfo = TestObjects.GetTestServerInfo() + }; + } + + private async Task RunAndVerify(Func, Task> test, Action verify) + { + T result = default(T); + var contextMock = RequestContextMocks.Create(r => result = r).AddErrorHandling(null); + await test(contextMock.Object); + VerifyResult(contextMock, verify, result); + } + + private void VerifyResult(Mock> contextMock, Action verify, T actual) + { + contextMock.Verify(c => c.SendResult(It.IsAny()), Times.Once); + contextMock.Verify(c => c.SendError(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); + verify(actual); + } + + private void VerifyErrorSent(Mock> contextMock) + { + contextMock.Verify(c => c.SendResult(It.IsAny()), Times.Never); + contextMock.Verify(c => c.SendError(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + } + + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerTestBase.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerTestBase.cs new file mode 100644 index 00000000..2020ed7f --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerTestBase.cs @@ -0,0 +1,45 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using Microsoft.SqlTools.Extensibility; +using Microsoft.SqlTools.ServiceLayer.Connection; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer; + +namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer +{ + // Base class providing common test functionality for OE tests + public abstract class ObjectExplorerTestBase + { + protected RegisteredServiceProvider ServiceProvider + { + get; + set; + } + + protected RegisteredServiceProvider CreateServiceProviderWithMinServices() + { + return CreateProvider() + .RegisterSingleService(new ConnectionService()) + .RegisterSingleService(new ObjectExplorerService()); + } + + protected RegisteredServiceProvider CreateProvider() + { + ServiceProvider = new RegisteredServiceProvider(); + return ServiceProvider; + } + + protected ObjectExplorerService CreateOEService(ConnectionService connService) + { + CreateProvider() + .RegisterSingleService(connService) + .RegisterSingleService(new ObjectExplorerService()); + + // Create the service using the service provider, which will initialize dependencies + return ServiceProvider.GetService(); + } + + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/SmoQueryModelTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/SmoQueryModelTests.cs new file mode 100644 index 00000000..c6f46554 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/SmoQueryModelTests.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Linq; +using Microsoft.SqlServer.Management.Smo; +using Microsoft.SqlTools.Extensibility; +using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; +using Xunit; + +namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer +{ + public class SmoQueryModelTests + { + + [Fact] + public void ShouldFindDatabaseQuerierFromRealPath() + { + // Given the extension type loader is set to find SmoCollectionQuerier objects + IMultiServiceProvider serviceProvider = ExtensionServiceProvider.CreateDefaultServiceProvider(); + // When I request a database compatible querier + SmoQuerier querier = serviceProvider.GetService(q => q.SupportedObjectTypes.Contains(typeof(Database))); + // Then I expect to get back the SqlDatabaseQuerier + Assert.NotNull(querier); + Assert.Equal(typeof(SqlDatabaseQuerier), querier.GetType()); + + // And I expect the service provider to have been set by the extension code + Assert.NotNull(querier.ServiceProvider); + } + + [Fact] + public void ShouldFindQuerierIfInExtensionList() + { + VerifyQuerierLookup(typeof(Table), typeof(SqlTableQuerier), expectExists: true); + } + + [Fact] + public void ShouldNotFindQuerierIfNotInExtensionList() + { + VerifyQuerierLookup(typeof(Database), null, expectExists: false); + } + + private static void VerifyQuerierLookup(Type smoType, Type querierType, bool expectExists) + { + ExtensionServiceProvider serviceProvider = ExtensionServiceProvider.Create(new Type[] { + typeof(SqlTableQuerier), + typeof(SqlLinkedServerQuerier) + }); + SmoQuerier querier = serviceProvider.GetService(q => q.SupportedObjectTypes.Contains(smoType)); + if (expectExists) + { + Assert.NotNull(querier); + Assert.Equal(querierType, querier.GetType()); + Assert.NotNull(querier.ServiceProvider); + } + else + { + Assert.Null(querier); + } + } + + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ServiceHost/SrTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ServiceHost/SrTests.cs index 0b9a9aa4..9925e566 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ServiceHost/SrTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ServiceHost/SrTests.cs @@ -43,6 +43,169 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost var queryServiceErrorFormat = SR.QueryServiceErrorFormat(1, 1, 1, 1, "\n", ".."); var queryServiceQueryFailed = SR.QueryServiceQueryFailed(".."); var workspaceServiceBufferPositionOutOfOrder = SR.WorkspaceServiceBufferPositionOutOfOrder(1, 2, 3, 4); + var treeNodeError = SR.TreeNodeError; + var serverNodeConnectionError = SR.ServerNodeConnectionError; + var schemaHierarchyAggregates = SR.SchemaHierarchy_Aggregates; + var SchemaHierarchy_ServerRoles = SR.SchemaHierarchy_ServerRoles; + var SchemaHierarchy_ApplicationRoles = SR.SchemaHierarchy_ApplicationRoles; + var SchemaHierarchy_Assemblies = SR.SchemaHierarchy_Assemblies; + var SchemaHierarchy_AssemblyFiles = SR.SchemaHierarchy_AssemblyFiles; + var SchemaHierarchy_AsymmetricKeys = SR.SchemaHierarchy_AsymmetricKeys; + var SchemaHierarchy_DatabaseAsymmetricKeys = SR.SchemaHierarchy_DatabaseAsymmetricKeys; + var SchemaHierarchy_DataCompressionOptions = SR.SchemaHierarchy_DataCompressionOptions; + var SchemaHierarchy_Certificates = SR.SchemaHierarchy_Certificates; + var SchemaHierarchy_FileTables = SR.SchemaHierarchy_FileTables; + var SchemaHierarchy_DatabaseCertificates = SR.SchemaHierarchy_DatabaseCertificates; + var SchemaHierarchy_CheckConstraints = SR.SchemaHierarchy_CheckConstraints; + var SchemaHierarchy_Columns = SR.SchemaHierarchy_Columns; + var SchemaHierarchy_Constraints = SR.SchemaHierarchy_Constraints; + var SchemaHierarchy_Contracts = SR.SchemaHierarchy_Contracts; + var SchemaHierarchy_Credentials = SR.SchemaHierarchy_Credentials; + var SchemaHierarchy_ErrorMessages = SR.SchemaHierarchy_ErrorMessages; + var SchemaHierarchy_ServerRoleMembership = SR.SchemaHierarchy_ServerRoleMembership; + var SchemaHierarchy_DatabaseOptions = SR.SchemaHierarchy_DatabaseOptions; + var SchemaHierarchy_DatabaseRoles = SR.SchemaHierarchy_DatabaseRoles; + var SchemaHierarchy_RoleMemberships = SR.SchemaHierarchy_RoleMemberships; + var SchemaHierarchy_DatabaseTriggers = SR.SchemaHierarchy_DatabaseTriggers; + var SchemaHierarchy_DefaultConstraints = SR.SchemaHierarchy_DefaultConstraints; + var SchemaHierarchy_Defaults = SR.SchemaHierarchy_Defaults; + var SchemaHierarchy_Sequences = SR.SchemaHierarchy_Sequences; + var SchemaHierarchy_Endpoints = SR.SchemaHierarchy_Endpoints; + var SchemaHierarchy_EventNotifications = SR.SchemaHierarchy_EventNotifications; + var SchemaHierarchy_ServerEventNotifications = SR.SchemaHierarchy_ServerEventNotifications; + var SchemaHierarchy_ExtendedProperties = SR.SchemaHierarchy_ExtendedProperties; + var SchemaHierarchy_FileGroups = SR.SchemaHierarchy_FileGroups; + var SchemaHierarchy_ForeignKeys = SR.SchemaHierarchy_ForeignKeys; + var SchemaHierarchy_FullTextCatalogs = SR.SchemaHierarchy_FullTextCatalogs; + var SchemaHierarchy_FullTextIndexes = SR.SchemaHierarchy_FullTextIndexes; + var SchemaHierarchy_Functions = SR.SchemaHierarchy_Functions; + var SchemaHierarchy_Indexes = SR.SchemaHierarchy_Indexes; + var SchemaHierarchy_InlineFunctions = SR.SchemaHierarchy_InlineFunctions; + var SchemaHierarchy_Keys = SR.SchemaHierarchy_Keys; + var SchemaHierarchy_LinkedServers = SR.SchemaHierarchy_LinkedServers; + var SchemaHierarchy_LinkedServerLogins = SR.SchemaHierarchy_LinkedServerLogins; + var SchemaHierarchy_Logins = SR.SchemaHierarchy_Logins; + var SchemaHierarchy_MasterKey = SR.SchemaHierarchy_MasterKey; + var SchemaHierarchy_MasterKeys = SR.SchemaHierarchy_MasterKeys; + var SchemaHierarchy_MessageTypes = SR.SchemaHierarchy_MessageTypes; + var SchemaHierarchy_MultiSelectFunctions = SR.SchemaHierarchy_MultiSelectFunctions; + var SchemaHierarchy_Parameters = SR.SchemaHierarchy_Parameters; + var SchemaHierarchy_PartitionFunctions = SR.SchemaHierarchy_PartitionFunctions; + var SchemaHierarchy_PartitionSchemes = SR.SchemaHierarchy_PartitionSchemes; + var SchemaHierarchy_Permissions = SR.SchemaHierarchy_Permissions; + var SchemaHierarchy_PrimaryKeys = SR.SchemaHierarchy_PrimaryKeys; + var schemaHierarchyPrimaryKeys = SR.SchemaHierarchy_PrimaryKeys; + var schemaHierarchyProgrammability = SR.SchemaHierarchy_Programmability; + var schemaHierarchyQueues = SR.SchemaHierarchy_Queues; + var schemaHierarchyRemoteServiceBindings = SR.SchemaHierarchy_RemoteServiceBindings; + var schemaHierarchyReturnedColumns = SR.SchemaHierarchy_ReturnedColumns; + var schemaHierarchyRoles = SR.SchemaHierarchy_Roles; + var schemaHierarchyRoutes = SR.SchemaHierarchy_Routes; + var schemaHierarchyRules = SR.SchemaHierarchy_Rules; + var schemaHierarchySchemas = SR.SchemaHierarchy_Schemas; + var schemaHierarchySecurity = SR.SchemaHierarchy_Security; + var schemaHierarchyServerObjects = SR.SchemaHierarchy_ServerObjects; + var schemaHierarchyManagement = SR.SchemaHierarchy_Management; + var schemaHierarchyServerTriggers = SR.SchemaHierarchy_ServerTriggers; + var schemaHierarchyServiceBroker = SR.SchemaHierarchy_ServiceBroker; + var schemaHierarchyServices = SR.SchemaHierarchy_Services; + var schemaHierarchySignatures = SR.SchemaHierarchy_LogFiles; + var schemaHierarchyStatistics = SR.SchemaHierarchy_Statistics; + var schemaHierarchyStorage = SR.SchemaHierarchy_Storage; + var schemaHierarchyStoredProcedures = SR.SchemaHierarchy_StoredProcedures; + var schemaHierarchySymmetricKeys = SR.SchemaHierarchy_SymmetricKeys; + var schemaHierarchySynonyms = SR.SchemaHierarchy_Synonyms; + var schemaHierarchyTables = SR.SchemaHierarchy_Tables; + var schemaHierarchyTriggers = SR.SchemaHierarchy_Triggers; + var schemaHierarchyTypes = SR.SchemaHierarchy_Types; + var schemaHierarchyUniqueKeys = SR.SchemaHierarchy_UniqueKeys; + var schemaHierarchyUserDefinedDataTypes = SR.SchemaHierarchy_UserDefinedDataTypes; + var schemaHierarchyUserDefinedTypes = SR.SchemaHierarchy_UserDefinedTypes; + var schemaHierarchyUsers = SR.SchemaHierarchy_Users; + var schemaHierarchyViews = SR.SchemaHierarchy_Views; + var schemaHierarchyXmlIndexes = SR.SchemaHierarchy_XmlIndexes; + var schemaHierarchyXMLSchemaCollections = SR.SchemaHierarchy_XMLSchemaCollections; + var schemaHierarchyUserDefinedTableTypes = SR.SchemaHierarchy_UserDefinedTableTypes; + var schemaHierarchyFilegroupFiles = SR.SchemaHierarchy_FilegroupFiles; + var missingCaption = SR.MissingCaption; + var schemaHierarchyBrokerPriorities = SR.SchemaHierarchy_BrokerPriorities; + var schemaHierarchyCryptographicProviders = SR.SchemaHierarchy_CryptographicProviders; + var schemaHierarchyDatabaseAuditSpecifications = SR.SchemaHierarchy_DatabaseAuditSpecifications; + var schemaHierarchyDatabaseEncryptionKeys = SR.SchemaHierarchy_DatabaseEncryptionKeys; + var schemaHierarchyEventSessions = SR.SchemaHierarchy_EventSessions; + var schemaHierarchyFullTextStopLists = SR.SchemaHierarchy_FullTextStopLists; + var schemaHierarchyResourcePools = SR.SchemaHierarchy_ResourcePools; + var schemaHierarchyServerAudits = SR.SchemaHierarchy_ServerAudits; + var schemaHierarchyServerAuditSpecifications = SR.SchemaHierarchy_ServerAuditSpecifications; + var schemaHierarchySpatialIndexes = SR.SchemaHierarchy_SpatialIndexes; + var schemaHierarchyWorkloadGroups = SR.SchemaHierarchy_WorkloadGroups; + var schemaHierarchySqlFiles = SR.SchemaHierarchy_SqlFiles; + var schemaHierarchyServerFunctions = SR.SchemaHierarchy_ServerFunctions; + var schemaHierarchySqlType = SR.SchemaHierarchy_SqlType; + var schemaHierarchyServerOptions = SR.SchemaHierarchy_ServerOptions; + var schemaHierarchyDatabaseDiagrams = SR.SchemaHierarchy_DatabaseDiagrams; + var schemaHierarchySystemTables = SR.SchemaHierarchy_SystemTables; + var schemaHierarchyDatabases = SR.SchemaHierarchy_Databases; + var schemaHierarchySystemContracts = SR.SchemaHierarchy_SystemContracts; + var schemaHierarchySystemDatabases = SR.SchemaHierarchy_SystemDatabases; + var schemaHierarchySystemMessageTypes = SR.SchemaHierarchy_SystemMessageTypes; + var schemaHierarchySystemQueues = SR.SchemaHierarchy_SystemQueues; + var schemaHierarchySystemServices = SR.SchemaHierarchy_SystemServices; + var schemaHierarchySystemStoredProcedures = SR.SchemaHierarchy_SystemStoredProcedures; + var schemaHierarchySystemViews = SR.SchemaHierarchy_SystemViews; + var schemaHierarchyDataTierApplications = SR.SchemaHierarchy_DataTierApplications; + var schemaHierarchyExtendedStoredProcedures = SR.SchemaHierarchy_ExtendedStoredProcedures; + var schemaHierarchySystemAggregateFunctions = SR.SchemaHierarchy_SystemAggregateFunctions; + var schemaHierarchySystemApproximateNumerics = SR.SchemaHierarchy_SystemApproximateNumerics; + var schemaHierarchySystemBinaryStrings = SR.SchemaHierarchy_SystemBinaryStrings; + var schemaHierarchySystemCharacterStrings = SR.SchemaHierarchy_SystemCharacterStrings; + var schemaHierarchySystemCLRDataTypes = SR.SchemaHierarchy_SystemCLRDataTypes; + var schemaHierarchySystemConfigurationFunctions = SR.SchemaHierarchy_SystemConfigurationFunctions; + var schemaHierarchySystemCursorFunctions = SR.SchemaHierarchy_SystemCursorFunctions; + var schemaHierarchySystemDataTypes = SR.SchemaHierarchy_SystemDataTypes; + var schemaHierarchySystemDateAndTime = SR.SchemaHierarchy_SystemDateAndTime; + var schemaHierarchySystemDateAndTimeFunctions = SR.SchemaHierarchy_SystemDateAndTimeFunctions; + var schemaHierarchySystemExactNumerics = SR.SchemaHierarchy_SystemExactNumerics; + var schemaHierarchySystemFunctions = SR.SchemaHierarchy_SystemFunctions; + var schemaHierarchySystemHierarchyIdFunctions = SR.SchemaHierarchy_SystemHierarchyIdFunctions; + var schemaHierarchySystemMathematicalFunctions = SR.SchemaHierarchy_SystemMathematicalFunctions; + var schemaHierarchySystemMetadataFunctionions = SR.SchemaHierarchy_SystemMetadataFunctions; + var schemaHierarchySystemOtherDataTypes = SR.SchemaHierarchy_SystemOtherDataTypes; + var schemaHierarchySystemOtherFunctions = SR.SchemaHierarchy_SystemOtherFunctions; + var schemaHierarchySystemRowsetFunctions = SR.SchemaHierarchy_SystemRowsetFunctions; + var schemaHierarchySystemSecurityFunctions = SR.SchemaHierarchy_SystemSecurityFunctions; + var schemaHierarchySystemSpatialDataTypes = SR.SchemaHierarchy_SystemSpatialDataTypes; + var schemaHierarchySystemStringFunctions = SR.SchemaHierarchy_SystemStringFunctions; + var schemaHierarchySystemSystemStatisticalFunctions = SR.SchemaHierarchy_SystemSystemStatisticalFunctions; + var schemaHierarchySystemTextAndImageFunctions = SR.SchemaHierarchy_SystemTextAndImageFunctions; + var schemaHierarchySystemUnicodeCharacterStrings = SR.SchemaHierarchy_SystemUnicodeCharacterStrings; + var schemaHierarchyAggregateFunctions = SR.SchemaHierarchy_AggregateFunctions; + var schemaHierarchyScalarValuedFunctions = SR.SchemaHierarchy_ScalarValuedFunctions; + var schemaHierarchyTableValuedFunctions = SR.SchemaHierarchy_TableValuedFunctions; + var schemaHierarchySystemExtendedStoredProcedures = SR.SchemaHierarchy_SystemExtendedStoredProcedures; + var schemaHierarchyBuiltInType = SR.SchemaHierarchy_BuiltInType; + var schemaHierarchyBuiltInServerRole = SR.SchemaHierarchy_BuiltInServerRole; + var schemaHierarchyUserWithPassword = SR.SchemaHierarchy_UserWithPassword; + var schemaHierarchySearchPropertyList = SR.SchemaHierarchy_SearchPropertyList; + var schemaHierarchySecurityPolicies = SR.SchemaHierarchy_SecurityPolicies; + var schemaHierarchySecurityPredicates = SR.SchemaHierarchy_SecurityPredicates; + var schemaHierarchyServerRole = SR.SchemaHierarchy_ServerRole; + var schemaHierarchySearchPropertyLists = SR.SchemaHierarchy_SearchPropertyLists; + var schemaHierarchyColumnStoreIndexes = SR.SchemaHierarchy_ColumnStoreIndexes; + var schemaHierarchyTableTypeIndexes = SR.SchemaHierarchy_TableTypeIndexes; + var schemaHierarchyServerInstance = SR.SchemaHierarchy_ServerInstance; + var schemaHierarchySelectiveXmlIndexes = SR.SchemaHierarchy_SelectiveXmlIndexes; + var schemaHierarchyXmlNamespaces = SR.SchemaHierarchy_XmlNamespaces; + var schemaHierarchyXmlTypedPromotedPaths = SR.SchemaHierarchy_XmlTypedPromotedPaths; + var schemaHierarchySqlTypedPromotedPaths = SR.SchemaHierarchy_SqlTypedPromotedPaths; + var schemaHierarchyDatabaseScopedCredentials = SR.SchemaHierarchy_DatabaseScopedCredentials; + var schemaHierarchyExternalDataSources = SR.SchemaHierarchy_ExternalDataSources; + var schemaHierarchyExternalFileFormats = SR.SchemaHierarchy_ExternalFileFormats; + var schemaHierarchyExternalResources = SR.SchemaHierarchy_ExternalResources; + var schemaHierarchyExternalTables = SR.SchemaHierarchy_ExternalTables; + var schemaHierarchyAlwaysEncryptedKeys = SR.SchemaHierarchy_AlwaysEncryptedKeys; + var schemaHierarchyColumnMasterKeys = SR.SchemaHierarchy_ColumnMasterKeys; + var schemaHierarchyColumnEncryptionKeys = SR.SchemaHierarchy_ColumnEncryptionKeys; } [Fact] diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/ProtocolEndpointMocks.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/ProtocolEndpointMocks.cs new file mode 100644 index 00000000..eb8005c1 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/ProtocolEndpointMocks.cs @@ -0,0 +1,33 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Threading.Tasks; +using Microsoft.SqlTools.Hosting.Protocol; +using Microsoft.SqlTools.Hosting.Protocol.Contracts; +using Moq; + +namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility +{ + public static class ProtocolEndpointMocks + { + public static Mock AddEventHandling( + this Mock mock, + EventType expectedEvent, + Action, TParams> eventCallback) + { + var flow = mock.Setup(h => h.SendEvent( + It.Is>(m => m == expectedEvent), + It.IsAny())) + .Returns(Task.FromResult(0)); + if (eventCallback != null) + { + flow.Callback(eventCallback); + } + + return mock; + } + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/TestObjects.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/TestObjects.cs index a8d5b429..240877e2 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/TestObjects.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/TestObjects.cs @@ -53,6 +53,30 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility }; } + public static ServerInfo GetTestServerInfo() + { + return new ServerInfo() + { + ServerVersion = "14.0.1.0", + ServerMajorVersion = 14, + ServerMinorVersion = 0, + EngineEditionId = 3, + OsVersion = "Linux (Ubuntu 15.10)", + IsCloud = false, + ServerEdition = "Developer Edition", + ServerLevel = "" + }; + } + + /// + /// Creates a test sql connection factory instance + /// + public static ISqlConnectionFactory GetTestSqlConnectionFactory() + { + // use mock database connection + return new TestSqlConnectionFactory(); + } + /// /// Creates a test connection details object ///