private void mnuConnect_Click(object sender, EventArgs e) { try { using (frmChooseDatasource frmChooseDatasource = new frmChooseDatasource()) { if (frmChooseDatasource.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IDataSourceProviderEditor provEditor = DataSourceProviderManager.CreateProviderEditor(frmChooseDatasource.SelectedProvider); Form frmEditor = (Form)provEditor; if (frmEditor.ShowDialog() == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; m_dsProvider = (DataSourceProvider)provEditor.CreateProvider(new NullProgressIndicator()); UpdateControls(); UpdateDataGridView(m_dsProvider.Information); UpdateMessage("Data source of type '" + frmChooseDatasource.SelectedProvider + "' was successfully connected."); this.Cursor = Cursors.Default; } } } } catch (Exception ex) { this.Cursor = Cursors.Default; UpdateMessage("Exception: " + ex.Message); MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal Repository(IDataSourceProvider dataSourceProvider) { if (dataSourceProvider == null) { throw new ArgumentNullException("dataSourceProvider"); } _dataSourceProvider = dataSourceProvider; }
public void AddDataSourceProvider(string invariantName, IDataSourceProvider provider) { if (_providers.ContainsKey(invariantName)) { return; } _providers.Add(invariantName, provider); }
/// <summary> /// Creates a new instance of the <see cref="AdoNetConnection"/> class. /// </summary> /// <param name="dataSourceProvider">The data source provider.</param> /// <param name="connectionStringName">Name of the connection string.</param> /// <exception cref="System.ArgumentException">Connection string name '{0}' could not be found in configuration.WithValues(connectionString)</exception> public AdoNetConnection(IDataSourceProvider dataSourceProvider, string connectionStringName) { var connectionEntry = ConfigurationManager.ConnectionStrings[connectionStringName]; if (connectionEntry == null) { throw new ArgumentException("Connection string name '{0}' could not be found in configuration".WithValues(connectionStringName)); } this.dataSourceProvider = dataSourceProvider; this.connectionString = connectionEntry.ConnectionString; }
public IList <string> GetDatabases(SqlConnectionString connectionString) { var dbProvider = connectionString.DbProvider?.InvariantName; if (string.IsNullOrWhiteSpace(dbProvider)) { return(new List <string>()); } IDataSourceProvider provider = null; _providers.TryGetValue(dbProvider, out provider); if (provider == null) { return(new List <string>()); } var factory = DbProviderFactories.GetFactory(dbProvider); var databases = new List <string>(); using (var sqlConnection = factory.CreateConnection()) { if (sqlConnection == null) { return(new List <string>()); } sqlConnection.ConnectionString = connectionString.ToString(); sqlConnection.Open(); using (var command = factory.CreateCommand()) { if (command == null) { return(new List <string>()); } command.Connection = sqlConnection; command.CommandText = provider.DataBasesQuery; command.CommandType = CommandType.Text; using (IDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { databases.Add(dataReader[0].ToString()); } } } } return(databases); }
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { string[] array = null; if (context != null) { IComponent instance = context.Instance as IComponent; if (instance != null) { ISite site = instance.Site; if (site != null) { IDesignerHost service = (IDesignerHost)site.GetService(typeof(IDesignerHost)); if (service != null) { IDesigner dataBoundControlDesigner = service.GetDesigner(instance); DesignerDataSourceView view = this.GetView(dataBoundControlDesigner); if (view != null) { IDataSourceDesigner dataSourceDesigner = view.DataSourceDesigner; if (dataSourceDesigner != null) { string[] viewNames = dataSourceDesigner.GetViewNames(); if (viewNames != null) { array = new string[viewNames.Length]; viewNames.CopyTo(array, 0); } } } if (((array == null) && (dataBoundControlDesigner != null)) && (dataBoundControlDesigner is IDataSourceProvider)) { IDataSourceProvider provider = dataBoundControlDesigner as IDataSourceProvider; object dataSource = null; if (provider != null) { dataSource = provider.GetSelectedDataSource(); } if (dataSource != null) { array = DesignTimeData.GetDataMembers(dataSource); } } } } } if (array == null) { array = new string[0]; } Array.Sort(array, Comparer.Default); } return(new TypeConverter.StandardValuesCollection(array)); }
public QueryBuilder( IDataQueryExecutor executor, IDslParser parser, IDataQueryExpressionTranslator translator, IQueryEntityNameTranslator nameTranslator, IDataSourceProvider dataSourceProvider) { _executor = executor; _parser = parser; _translator = translator; _nameTranslator = nameTranslator; _dataSourceProvider = dataSourceProvider; }
public IList <string> GetDataSources(SqlConnectionString connectionString) { var dbProvider = connectionString.DbProvider?.InvariantName; if (string.IsNullOrWhiteSpace(dbProvider)) { return(new List <string>()); } IDataSourceProvider provider = null; _providers.TryGetValue(dbProvider, out provider); return(provider != null?provider.GetDataSources() : new List <string>()); }
private void mnuDiconnect_Click(object sender, EventArgs e) { if (m_dsProvider != null) { m_dsProvider.Close(); m_dsProvider.Dispose(); m_dsProvider = null; UpdateControls(); UpdateDataGridView(null); UpdateMessage("Data source has been disconnected"); } }
private void ExtractFields(IDataSourceProvider dataSourceProvider, ArrayList fields) { IEnumerable resolvedSelectedDataSource = dataSourceProvider.GetResolvedSelectedDataSource(); if (resolvedSelectedDataSource != null) { PropertyDescriptorCollection dataFields = DesignTimeData.GetDataFields(resolvedSelectedDataSource); if ((dataFields != null) && (dataFields.Count != 0)) { foreach (PropertyDescriptor descriptor in dataFields) { fields.Add(new FieldItem(descriptor.Name, descriptor.PropertyType)); } } } }
protected Repository(string connectionName) { if (string.IsNullOrWhiteSpace(connectionName)) { throw new ArgumentNullException("connectionName"); } _connectionName = connectionName; var dataSourceProvider = GetDataSourceProvider(); if (dataSourceProvider == null) { throw new ArgumentNullException("dataSourceProvider"); } _dataSourceProvider = dataSourceProvider; }
/// <summary> /// If sourceInstance is null attempt to create a SourceInstance from SourceLocation /// </summary> /// <exception cref="ResourceStaticAnalysisException">Thrown when data source instance could not be initialized properly. This could happen - for example - if a file comprising the datasource does not exist.</exception> public void Initialize(IDataSourceProvider provider) { if (this._sourceInstance == null) { lock (this) { try { this._sourceInstance = provider.CreateDataSourceInstance(SourceLocation); } catch (FileNotFoundException e) { throw new ResourceStaticAnalysisException(string.Format(CultureInfo.InvariantCulture, "File '{1}' that is part of a datasource of type {0} cannot be found.", provider.DataSourceType, e.FileName), e); } catch (Exception e) { throw new ResourceStaticAnalysisException(String.Format(CultureInfo.InvariantCulture, "Creating datasource instance of type {0} from source location {1} failed.", provider.DataSourceType, SourceLocation), e); } } } }
public StringCollection GetStandardValues(Component component) { StringCollection fields = new StringCollection(); if (component != null) { ISite site1 = component.Site; if (site1 != null) { IDesignerHost host1 = (IDesignerHost)site1.GetService(typeof(IDesignerHost)); if (host1 != null) { IDesigner designer1 = host1.GetDesigner(component); DesignerDataSourceView view1 = ((DataBoundControlDesigner)designer1).DesignerView; if (view1 != null) { IDataSourceViewSchema schema1 = null; try { schema1 = view1.Schema; } catch (Exception exception1) { IComponentDesignerDebugService service1 = (IComponentDesignerDebugService)site1.GetService(typeof(IComponentDesignerDebugService)); if (service1 != null) { service1.Fail("DataSource DebugService FailedCall\r\n" + exception1.ToString()); } } if (schema1 != null) { IDataSourceFieldSchema[] schemaArray1 = schema1.GetFields(); if (schemaArray1 != null) { for (int num1 = 0; num1 < schemaArray1.Length; num1++) { fields.Add(schemaArray1[num1].Name); } } } } if (((fields.Count == 0) && (designer1 != null)) && (designer1 is IDataSourceProvider)) { IDataSourceProvider provider1 = designer1 as IDataSourceProvider; IEnumerable enumerable1 = null; if (provider1 != null) { enumerable1 = provider1.GetResolvedSelectedDataSource(); } if (enumerable1 != null) { PropertyDescriptorCollection collection1 = DesignTimeData.GetDataFields(enumerable1); if (collection1 != null) { foreach (PropertyDescriptor descriptor1 in collection1) { fields.Add(descriptor1.Name); } } } } } } } return(fields); }
public async Task <GeneratedTemplateInfos> GenerateTemplateExecute(string template, IDataSourceProvider dataSourceProvider) { if (template == null) { return(null); } var parsingOptions = new ParserOptions(template, () => new MemoryStream(), Encoding.Default, _templateServiceProvider.ParserOptions.MaxSize, _templateServiceProvider.ParserOptions.DisableContentEscaping); parsingOptions.Timeout = _templateServiceProvider.ParserOptions.Timeout; parsingOptions.Null = _templateServiceProvider.ParserOptions.NullSubstitute; parsingOptions.StackOverflowBehavior = _templateServiceProvider.ParserOptions.PartialStackOverflowBehavior; parsingOptions.PartialStackSize = _templateServiceProvider.ParserOptions.PartialStackSize; parsingOptions.ValueResolver = new JObjectResolver(); //if (_templateServiceProvider.ParserOptions.EnableExtendedMissingPathOutput) //{ // parsingOptions.UnresolvedPath += ParsingOptionsOnUnresolvedPath; //} //var formatterService = new MorestachioFormatterService(); //var formatters = _templateServiceProvider.ObtainFormatters(); //foreach (var formatter in formatters) //{ // var morestachioFormatterModel = formatter.CreateFormatter(); // formatterService.Add(morestachioFormatterModel.Function, morestachioFormatterModel); //} MorestachioDocumentInfo extendedParseInformation; try { extendedParseInformation = Parser.ParseWithOptions(parsingOptions); } catch (Exception e) { return(new GeneratedTemplateInfos() { Errors = new IMorestachioError[] { new MorestachioSyntaxError(new CharacterLocationExtended(), "Error ", "", "", e.Message), } }); } if (extendedParseInformation.Errors.Any()) { var generatedTemplateInfos = new GeneratedTemplateInfos() { InferredTemplateModel = extendedParseInformation.Document, Errors = extendedParseInformation.Errors.ToArray() }; _templateServiceProvider.OnTemplateCreated(generatedTemplateInfos); return(generatedTemplateInfos); } var result = await dataSourceProvider.Fetch(); if (result == null) { return(null); } var generateTemplateExecute = new GeneratedTemplateInfos() { Result = await extendedParseInformation.CreateAndStringifyAsync(result), InferredTemplateModel = extendedParseInformation.Document }; _templateServiceProvider.OnTemplateCreated(generateTemplateExecute); return(generateTemplateExecute); }
public Repository(IConfiguration configuration) { DbContext = new DbProvider <T>(configuration); }
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { object[] objArray1 = null; if (context != null) { IComponent component1 = context.Instance as IComponent; if (component1 != null) { ISite site1 = component1.Site; if (site1 != null) { IDesignerHost host1 = (IDesignerHost)site1.GetService(typeof(IDesignerHost)); if (host1 != null) { IDesigner designer1 = host1.GetDesigner(component1); DesignerDataSourceView view1 = this.GetView(designer1); if (view1 != null) { IDataSourceViewSchema schema1 = null; try { schema1 = view1.Schema; } catch (Exception exception1) { IComponentDesignerDebugService service1 = (IComponentDesignerDebugService)site1.GetService(typeof(IComponentDesignerDebugService)); if (service1 != null) { service1.Fail("DataSource DebugService FailedCall\r\n" + exception1.ToString()); } } if (schema1 != null) { IDataSourceFieldSchema[] schemaArray1 = schema1.GetFields(); if (schemaArray1 != null) { objArray1 = new object[schemaArray1.Length]; for (int num1 = 0; num1 < schemaArray1.Length; num1++) { objArray1[num1] = schemaArray1[num1].Name; } } } } if (((objArray1 == null) && (designer1 != null)) && (designer1 is IDataSourceProvider)) { IDataSourceProvider provider1 = designer1 as IDataSourceProvider; IEnumerable enumerable1 = null; if (provider1 != null) { enumerable1 = provider1.GetResolvedSelectedDataSource(); } if (enumerable1 != null) { PropertyDescriptorCollection collection1 = DesignTimeData.GetDataFields(enumerable1); if (collection1 != null) { ArrayList list1 = new ArrayList(); foreach (PropertyDescriptor descriptor1 in collection1) { list1.Add(descriptor1.Name); } objArray1 = list1.ToArray(); } } } } } } } return(new TypeConverter.StandardValuesCollection(objArray1)); }
public async Task <GeneratedTemplateInfos> GenerateTemplateExecute(string template, IDataSourceProvider dataSourceProvider) { if (template == null) { return(null); } var parsingOptions = new ParserOptions(template, () => new MemoryStream(), Encoding.Default, false, true); parsingOptions.ValueResolver = new JObjectResolver(); //var formatterService = new MorestachioFormatterService(); //var formatters = _templateServiceProvider.ObtainFormatters(); //foreach (var formatter in formatters) //{ // var morestachioFormatterModel = formatter.CreateFormatter(); // formatterService.Add(morestachioFormatterModel.Function, morestachioFormatterModel); //} MorestachioDocumentInfo extendedParseInformation; try { extendedParseInformation = Parser.ParseWithOptions(parsingOptions); } catch (Exception e) { return(new GeneratedTemplateInfos() { Errors = new IMorestachioError[] { new MorestachioSyntaxError(new CharacterLocationExtended(), "Error ", "", "", e.Message), } }); } if (extendedParseInformation.Errors.Any()) { return(new GeneratedTemplateInfos() { InferredTemplateModel = extendedParseInformation.Document, Errors = extendedParseInformation.Errors.ToArray() }); } var result = await dataSourceProvider.Fetch(); if (result == null) { return(null); } return(new GeneratedTemplateInfos() { Result = extendedParseInformation.Create(result).Stream.Stringify(true, Encoding.Default), InferredTemplateModel = extendedParseInformation.Document }); }
public TrackerProvider(string connectionName) { _connectionName = connectionName; _dataSourceProvider = DataSourceProviderFactory.Create(_connectionName); RegisterEvents(); }
public DataSourceProviderViewModel(IDataSourceProvider provider) { this.provider = provider; this.DataSources = this.provider.DataSources.Select(o => new DataSourceViewModel(o)); }
public CustomerTabSubWindowContainer(TabControl tabControl, IDataSourceProvider <Core.Model.Customer> dataSourceProvider) : base(tabControl, dataSourceProvider) { }
private DummyMultiplexer() { _source = new DataSource("Local", "Provider=OLEDB;Data Source=localhost;Initial Catalog=db;Integrated Security=SSPI", "Dummy"); _provider = new DummySourceProvider(_source); _selector = new DummySourceSelector(_source); }
/// <summary> /// Prevent from uncontroled creation. /// </summary> private DynamicDataSourceProvider(IDataSourceProvider provider) { this.provider = provider; }
public AppInfo(IDataSourceProvider dataSourceProvider, IAppDrive appDrive) { _dataSourceProvider = dataSourceProvider; _appDrive = appDrive; }
public LogProvider(IDataSourceProvider <Log> dataSourceProvider) { _dataSourceProvider = dataSourceProvider; }
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { object[] values = null; if (context != null) { IComponent instance = context.Instance as IComponent; if (instance != null) { ISite site = instance.Site; if (site != null) { IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); if (host != null) { IDesigner dataBoundControlDesigner = host.GetDesigner(instance); DesignerDataSourceView view = this.GetView(dataBoundControlDesigner); if (view != null) { IDataSourceViewSchema schema = null; try { schema = view.Schema; } catch (Exception exception) { IComponentDesignerDebugService service = (IComponentDesignerDebugService)site.GetService(typeof(IComponentDesignerDebugService)); if (service != null) { service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.Schema", exception.Message })); } } if (schema != null) { IDataSourceFieldSchema[] fields = schema.GetFields(); if (fields != null) { values = new object[fields.Length]; for (int i = 0; i < fields.Length; i++) { values[i] = fields[i].Name; } } } } if (((values == null) && (dataBoundControlDesigner != null)) && (dataBoundControlDesigner is IDataSourceProvider)) { IDataSourceProvider provider = dataBoundControlDesigner as IDataSourceProvider; IEnumerable dataSource = null; if (provider != null) { dataSource = provider.GetResolvedSelectedDataSource(); } if (dataSource != null) { PropertyDescriptorCollection dataFields = DesignTimeData.GetDataFields(dataSource); if (dataFields != null) { ArrayList list = new ArrayList(); foreach (PropertyDescriptor descriptor in dataFields) { list.Add(descriptor.Name); } values = list.ToArray(); } } } } } } } return(new TypeConverter.StandardValuesCollection(values)); }
public PlayersController(IMediator mediator, IDataSourceProvider dataSource) { this._mediator = mediator; this._dataSourceProvider = dataSource; }
public MyODataRoutingMatcherPolicy(IODataTemplateTranslator translator, IDataSourceProvider provider) { _translator = translator; _provider = provider; }
private async Task <bool> InitSqlStructure(ISqlFactory factory, IDataSourceProvider dataSourceProvider) { var executor = new InitialSqlScriptsExecutor(factory); return(await executor.ExecuteScripts(useDb : dataSourceProvider.UseDb)); }
private DynamicDataSourceProvider(IDataSourceProvider provider) { this.provider = provider; }
public PersonalLoanProvider(IDataSourceProvider <PersonalLoan> dataSourceProvider) { _dataSourceProvider = dataSourceProvider; }
private void mnuConnect_Click(object sender, EventArgs e) { try { using (frmChooseDatasource frmChooseDatasource = new frmChooseDatasource()) { if (frmChooseDatasource.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IDataSourceProviderEditor provEditor = DataSourceProviderManager.CreateProviderEditor(frmChooseDatasource.SelectedProvider); Form frmEditor = (Form)provEditor; if (frmEditor.ShowDialog() == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; m_dsProvider = (DataSourceProvider)provEditor.CreateProvider(); UpdateControls(); UpdateDataGridView(m_dsProvider.Information); UpdateMessage("Data source of type '" + frmChooseDatasource.SelectedProvider + "' was successfully connected."); this.Cursor = Cursors.Default; } } } } catch(Exception ex) { this.Cursor = Cursors.Default; UpdateMessage("Exception: " + ex.Message); MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public DataSourceController(IDataSourceProvider dataSource) { this._dataSourceProvider = dataSource; }
public virtual void OnDataProviderChanged(IDataSourceProvider e) { LastProvider = e; DataProviderChanged?.Invoke(this, e); }
public HandleAllController(IDataSourceProvider provider) { _provider = provider; }