Class: CapicuaGen::Gaspar::CSDBConnectionProviderFeature
- Inherits:
-
Feature
- Object
- Feature
- CapicuaGen::Gaspar::CSDBConnectionProviderFeature
- Includes:
- CapicuaGen, CapicuaGen::Gaspar
- Defined in:
- lib/CapicuaGenGaspar/DataAccess/CSConnectionProvider/Source/cs_db_connection_provider_feature.rb
Overview
para configurar una cadena de conexion dentro del codigo generado
Instance Method Summary collapse
-
#generate ⇒ Object
Modifica el archivo App.Config para que contenga la cadena de conexión a la base de datos.
- #get_db_connection_name_method ⇒ Object
-
#get_db_connection_provider_method ⇒ Object
Devuelve el metodo que genera el proveedor de conexion.
-
#get_db_connection_string_method ⇒ Object
Devuelve la cadena de conexión.
-
#initialize(values = {}) ⇒ CSDBConnectionProviderFeature
constructor
Inicializa la caracteristica.
Methods included from CapicuaGen::Gaspar
#get_about_class_full_name, #get_about_class_name, #get_app_config_file, #get_entity_by_catalog_name, #get_entity_catalogs_full_name, #get_entity_catalogs_name, #get_entity_data_access_full_name, #get_entity_data_access_name, #get_entity_full_name, #get_entity_interface_full_name, #get_entity_interface_name, #get_entity_name, #get_main_form_class_full_name, #get_main_form_class_name, #get_namespaces, #get_namespaces_text, #get_splash_class_full_name, #get_splash_class_name
Constructor Details
#initialize(values = {}) ⇒ CSDBConnectionProviderFeature
Inicializa la caracteristica
40 41 42 43 44 45 46 |
# File 'lib/CapicuaGenGaspar/DataAccess/CSConnectionProvider/Source/cs_db_connection_provider_feature.rb', line 40 def initialize(values= {}) super(values) # Configuro los tipos si estos no han sido configurados previamente self.types= [:data_connection_provider, :transformer] if self.types.blank? end |
Instance Method Details
#generate ⇒ Object
Modifica el archivo App.Config para que contenga la cadena de conexión a la base de datos
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/CapicuaGenGaspar/DataAccess/CSConnectionProvider/Source/cs_db_connection_provider_feature.rb', line 64 def generate # Ruta para conseguir el archivo app.config xml= Nokogiri::XML(File.read(get_app_config_file)) xpath= "connectionStrings/add[@name= '#{generation_attributes[:app_config_db_connection_name]}']" # Recupero el nodo node= XMLHelper.get_node_from_xml_document(xml, xpath) # Configuro el nodo node['name']= generation_attributes[:app_config_db_connection_name] node['connectionString']= generation_attributes[:app_config_db_connection_string] node['providerName']= generation_attributes[:app_config_db_connection_provider] # Formateo el texto formatted_xml= XMLHelper.format(xml.to_xml) # Guardo el resultado File.write(get_app_config_file,formatted_xml) end |
#get_db_connection_name_method ⇒ Object
54 55 56 |
# File 'lib/CapicuaGenGaspar/DataAccess/CSConnectionProvider/Source/cs_db_connection_provider_feature.rb', line 54 def get_db_connection_name_method return "\"#{generation_attributes[:app_config_db_connection_name]}\"" end |
#get_db_connection_provider_method ⇒ Object
Devuelve el metodo que genera el proveedor de conexion
50 51 52 |
# File 'lib/CapicuaGenGaspar/DataAccess/CSConnectionProvider/Source/cs_db_connection_provider_feature.rb', line 50 def get_db_connection_provider_method return "DbProviderFactories.GetFactory(ConfigurationManager.ConnectionStrings[\"#{generation_attributes[:app_config_db_connection_name]}\"].ProviderName)" end |
#get_db_connection_string_method ⇒ Object
Devuelve la cadena de conexión
59 60 61 |
# File 'lib/CapicuaGenGaspar/DataAccess/CSConnectionProvider/Source/cs_db_connection_provider_feature.rb', line 59 def get_db_connection_string_method return "ConfigurationManager.ConnectionStrings[\"#{generation_attributes[:app_config_db_connection_name]}\"].ConnectionString" end |