protected override void OnInit(EventArgs e) { base.OnInit(e); try { foreach (var provider in DataSourceProvider.GetProviderList()) { if (!string.IsNullOrEmpty(provider.Configurator)) { var ctrl = this.Page.LoadControl(provider.Configurator); DataSourceConfigurator conf = ctrl as DataSourceConfigurator; if (conf != null) { conf.PortalId = PortalId; conf.LocalResourceFile = LocalResourceFile; conf.ID = provider.FriendlyName; phConfigurator.Controls.Add(ctrl); } } } } catch (Exception ex) { DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, TemplateFileName + "/" + ex.Message, ModuleMessage.ModuleMessageType.RedError); } }
public ObservableSourceProvider(DataSourceProvider dsp, string pathElement, PathConnectorTypeEnum pathConnectorType, string binderName) : this(pathElement, pathConnectorType, binderName) { Data = dsp; Type = null; SourceKind = SourceKindEnum.DataSourceProvider; }
public static ODataRoute CustomMapODataServiceRoute(this HttpConfiguration configuration, string routeName, string routePrefix) { ODataRoute route = configuration.MapODataServiceRoute(routeName, routePrefix, builder => { // Get the model from the datasource of the current request: model-per-request. builder.AddService(ServiceLifetime.Scoped, sp => { IHttpRequestMessageProvider requestMessageProvider = sp.GetRequiredService <IHttpRequestMessageProvider>(); string dataSource = requestMessageProvider.Request.Properties[Constants.ODataDataSource] as string; IEdmModel model = DataSourceProvider.GetEdmModel(dataSource); return(model); }); // Create a request provider for every request. This is a workaround for the missing HttpContext of a self-hosted webapi. builder.AddService <IHttpRequestMessageProvider>(ServiceLifetime.Scoped, sp => new HttpRequestMessageProvider()); // The routing conventions are registered as singleton. builder.AddService(ServiceLifetime.Singleton, sp => { IList <IODataRoutingConvention> routingConventions = ODataRoutingConventions.CreateDefault(); routingConventions.Insert(0, new MatchAllRoutingConvention()); return(routingConventions.ToList().AsEnumerable()); }); }); CustomODataRoute odataRoute = new CustomODataRoute(route.RoutePrefix, new CustomODataPathRouteConstraint(routeName)); configuration.Routes.Remove(routeName); configuration.Routes.Add(routeName, odataRoute); return(odataRoute); }
public override string Execute(Dictionary <string, string> parameters) { string path = parameters["templatepath"]; if (string.IsNullOrEmpty(path)) { return(""); } string filename = parameters["templatefile"]; if (string.IsNullOrEmpty(filename)) { return(""); } try { string ModelProvider = parameters["dataprovider"]; string ModelConstructor = parameters["datasource"]; var ModelParameters = new Dictionary <string, string>(parameters); ModelParameters.Remove("templatepath"); ModelParameters.Remove("templatefile"); ModelParameters.Remove("dataprovider"); ModelParameters.Remove("datasource"); var Model = DataSourceProvider.Instance(ModelProvider).Invoke(ModelConstructor, ModelParameters); return(TemplateProvider.FindProviderAndExecute(path, filename, Dump(Model))); } catch (Exception ex) { return("Error : " + path + filename + " " + ex.Message); } }
private void HookDataContextEvents(object newValue) { // hook any new event object newContext = null; DataSourceProvider provider = newValue as DataSourceProvider; if (provider == null) { newContext = newValue; } else { provider.DataChanged += DataProvider_DataChanged; newContext = provider.Data; } HookChildChanged(newContext as Csla.Core.INotifyChildChanged); HookPropertyChanged(newContext as INotifyPropertyChanged); INotifyCollectionChanged observable = newContext as INotifyCollectionChanged; if (observable != null) { HookObservableListChanged(observable); } else { HookBindingListChanged(newContext as IBindingList); } }
public IActionResult GetName(string key) { if (!IsCurrentUserAuthorized()) { return(Unauthorized()); } // Get entity type from path. ODataPath path = Request.ODataFeature().Path; if (path.PathTemplate != "~/entityset/key/property") { return(BadRequest("Not the correct property access request!")); } dynamic property = path.Segments.Last(); IEdmEntityType entityType = property.Property.DeclaringType as IEdmEntityType; // Create an untyped entity object with the entity type. EdmEntityObject entity = new EdmEntityObject(entityType); var dataSource = GetDataSource(); var value = new DataSourceProvider(dataSource).GetProperty("Name", entity); if (value == null) { return(NotFound()); } string strValue = value as string; return(Ok(strValue)); }
public IActionResult GetName(string key) { // Get entity type from path. ODataPath path = Request.ODataFeature().Path; if (path.PathTemplate != "~/entityset/key/property") { return(BadRequest("Not the correct property access request!")); } PropertySegment property = path.Segments.Last() as PropertySegment; IEdmEntityType entityType = property.Property.DeclaringType as IEdmEntityType; // Create an untyped entity object with the entity type. EdmEntityObject entity = new EdmEntityObject(entityType); string sourceString = Request.GetDataSource(); DataSourceProvider.Get(sourceString, key, entity); object value = DataSourceProvider.GetProperty(sourceString, "Name", entity); if (value == null) { return(NotFound()); } string strValue = value as string; return(Ok(strValue)); }
private ICollectionView GetView(string resourceName) { DataSourceProvider provider = (DataSourceProvider)FindResource(resourceName); PersonCollection persons = (PersonCollection)provider.Data; return(CollectionViewSource.GetDefaultView(persons)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseAuthorization(); app.UseODataBatching(); app.UseEndpoints(endpoints => { endpoints.Select().Expand().Filter().OrderBy().MaxTop(100).Count(); var routeBuilder = endpoints.MapODataRoute("odataPrefix", "odata/{dataSource}", containerBuilder => { containerBuilder.AddService(Microsoft.OData.ServiceLifetime.Scoped, typeof(IEdmModel), sp => { var serviceScope = sp.GetRequiredService <HttpRequestScope>(); IEdmModel model = DataSourceProvider.GetEdmModel(serviceScope.HttpRequest); return(model); }); containerBuilder.AddService(Microsoft.OData.ServiceLifetime.Scoped, typeof(IEnumerable <IODataRoutingConvention>), sp => { IList <IODataRoutingConvention> routingConventions = ODataRoutingConventions.CreateDefault(); routingConventions.Insert(0, new MatchAllRoutingConvention()); return(routingConventions.ToList().AsEnumerable()); }); }); }); }
private void UnHookDataContextEvents(object oldValue) { // unhook any old event handling object oldContext = null; DataSourceProvider provider = oldValue as DataSourceProvider; if (provider == null) { oldContext = oldValue; } else { provider.DataChanged -= new EventHandler(DataProvider_DataChanged); oldContext = provider.Data; } UnHookChildChanged(oldContext as Csla.Core.INotifyChildChanged); UnHookPropertyChanged(oldContext as INotifyPropertyChanged); INotifyCollectionChanged observable = oldContext as INotifyCollectionChanged; if (observable != null) { UnHookObservableListChanged(observable); } else { UnHookBindingListChanged(oldContext as IBindingList); } }
ICollectionView GetFamilyView() { DataSourceProvider provider = (DataSourceProvider)this.FindResource("Family"); return(CollectionViewSource.GetDefaultView(provider.Data)); }
public DbContext ProduceDbContextInstance(string connStrName = null, bool isConnStr = false, DataSourceProvider provider = DataSourceProvider.EfInMemory) { return(new MapHiveIdSrvConfigurationDbContext( ((DbContextOptionsBuilder <ConfigurationDbContext>) new DbContextOptionsBuilder <ConfigurationDbContext>().ConfigureIdSrvDbProvider(connStrName, isConnStr, provider)).Options, new ConfigurationStoreOptions().ConfigureConfiguratonStoreOptions() )); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { DataSourceProvider.SetDbPath(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData)); global::Xamarin.Forms.Forms.Init(); LoadApplication(new App(new AppDrive())); return(base.FinishedLaunching(app, options)); }
public NativeListViewPage() { InitializeComponent(); StartLabel.Text = Device.OnPlatform("Custom UITableView+UICell", "Custom ListView+Cell", "Custom renderer todo"); DataSourceProvider sourceProvider = new DataSourceProvider(); //NativeList.Items = new VirtualizingCollection<DataSource>(sourceProvider); NativeList.Items = DataSource.GetDataSourcesList(); }
public void SetUp() { _unityContainer = new UnityContainer(); _unityContainer.RegisterType <IDataSource <TestObject>, TestDataSource>(ReuseScope.Container); _unityContainer.RegisterType <IDataSource, TestDataSource>(typeof(TestObject).Name, ReuseScope.Container); _target = new DataSourceProvider(_unityContainer); }
public ObservableSource(DataSourceProvider dsp, string pathElement, PathConnectorTypeEnum pathConnectorType, string binderName) : this(pathElement, pathConnectorType, true, binderName) { SourceKind = SourceKindEnum.DataSourceProvider; Container = dsp; Data = null; Type = null; WeakEventManager <DataSourceProvider, EventArgs> .AddHandler(dsp, "DataChanged", OnDataSourceProvider_DataChanged); Status = ObservableSourceStatusEnum.Undetermined; }
/// <summary> /// configures a data provider for given builder /// </summary> /// <param name="builder"></param> /// <param name="provider"></param> /// <param name="connStr"></param> /// <returns></returns> public static DbContextOptionsBuilder ConfigureProvider(this DbContextOptionsBuilder builder, DataSourceProvider provider, string connStr) { if (!ProvidersConfiguration.ContainsKey(provider) || ProvidersConfiguration[provider] == null) { throw new ArgumentException($"Db provider not configured: {provider}"); } ProvidersConfiguration[provider](builder, connStr); return(builder); }
// Get entityset(key) public IEdmEntityObject Get(string key) { // Get entity type from path. ODataPath path = Request.ODataProperties().Path; IEdmEntityType entityType = (IEdmEntityType)path.EdmType; // Create an untyped entity object with the entity type. EdmEntityObject entity = new EdmEntityObject(entityType); DataSourceProvider.Get((string)Request.Properties[Constants.ODataDataSource], key, entity); return(entity); }
public EditorApplication(IServiceProvider managerCollection, DataSourceProvider dataSources) { logger = managerCollection.GetService <ILogger>(); settings = managerCollection.GetService <SettingsMan>(); dataProvider = managerCollection.GetService <IModelsProvider>(); workspaceMan = managerCollection.GetService <IWorkspaceMan>(); dialogProvider = new Lazy <IDialogProvider>(() => managerCollection.GetService <IDialogProvider>()); //DialogProvider = managerCollection.GetManager<IDialogProvider>(); settings.Restore(); this.managerCollection = managerCollection; this.dataSources = dataSources; }
private object GetDataObject(object dataContext) { DataSourceProvider provider = dataContext as DataSourceProvider; if (provider != null) { return(provider.Data); } else { return(dataContext); } }
private static Func <HttpRequestMessage, IEdmModel> GetModelFuncFromRequest() { return(request => { string odataPath = request.Properties[Constants.CustomODataPath] as string ?? string.Empty; string[] segments = odataPath.Split('/'); string dataSource = segments[0]; request.Properties[Constants.ODataDataSource] = dataSource; IEdmModel model = DataSourceProvider.GetEdmModel(dataSource); request.Properties[Constants.CustomODataPath] = string.Join("/", segments, 1, segments.Length - 1); return model; }); }
private bool TryGetPBCollectionDataProvider(DataSourceProvider dsp, out PBCollectionDSP pbCollectionDSP) { if (dsp is PBCollectionDSP pbDSP) { pbCollectionDSP = pbDSP; return(true); } else { pbCollectionDSP = null; return(false); } }
/** * This is a sample function that will check to see if the user is accessing the salary node in our customCallback database. * If they are, then it throws a new DataSourceException. It also does other things for the sake of being a sample, too. * If you modify this, make sure to keep the method name the same. * * @param select The select statement * @param provider The datasource provider. * @param xmlTag The xmlTag * @return * @throws DataSourceException */ public static Object ApproveSelect(String select, DataSourceProvider provider, BaseTag xmlTag) { if (select.Equals("$$THIS_IS_INCORRECTLY_FORMATTED$$")) //In a custom callback, you can modify the select tag. { return("$$THIS_IS_CORRECTLY_FORMMATED$$"); } //We can also prevent people from accessing unwanted data, such as, perhaps, the salary node of a database if (select.ToLower().Contains("salary")) { throw new DataSourceException("Select for this tag was denied by custom callback because we don't want someone seeing our salary", 0); } return(select); }
public static void RunExample() { Config config = LoadConfig(3); var dataProviders = new List <IDataProvider>(); dataProviders.Add(new BogusDataProvider(config.DataGeneration)); dataProviders.Add(new SqlDataProvider(new System.Data.SqlClient.SqlConnection(config.DataSource.Config.connectionString.ToString()))); //create a data masker IDataMasker dataMasker = new DataMasker(dataProviders); //grab our dataSource from the config, note: you could just ignore the config.DataSource.Type //and initialize your own instance IDataSource dataSource = DataSourceProvider.Provide(config.DataSource.Type, config.DataSource); //enumerate all our tables foreach (TableConfig tableConfig in config.Tables) { //load data IEnumerable <IDictionary <string, object> > rows = dataSource.GetData(tableConfig); //get row coun var rowCount = dataSource.GetCount(tableConfig); //here you have two options, you can update all rows in one go, or one at a time. #region update all rows //update all rows var masked = rows.Select(row => { //mask the data return(dataMasker.Mask(row, tableConfig)); }); dataSource.UpdateRows(masked, rowCount, tableConfig); #endregion //OR #region update row by row foreach (var row in rows) { //mask the data var maskedRow = dataMasker.Mask(row, tableConfig); dataSource.UpdateRow(maskedRow, tableConfig); } #endregion } }
private static void Execute( Config config) { WriteLine("Masking Data"); UpdateProgress(ProgressType.Overall, 0, config.Tables.Count, "Overall Progress"); var dataProviders = new List <IDataProvider>(); dataProviders.Add(new BogusDataProvider(config.DataGeneration)); dataProviders.Add(new SqlDataProvider(new System.Data.SqlClient.SqlConnection(config.DataSource.Config.connectionString.ToString()))); //create a data masker IDataMasker dataMasker = new DataMasker(dataProviders); //grab our dataSource from the config, note: you could just ignore the config.DataSource.Type //and initialize your own instance IDataSource dataSource = DataSourceProvider.Provide(config.DataSource.Type, config.DataSource); for (int i = 0; i < config.Tables.Count; i++) { TableConfig tableConfig = config.Tables[i]; var rowCount = dataSource.GetCount(tableConfig); UpdateProgress(ProgressType.Masking, 0, (int)rowCount, "Masking Progress"); UpdateProgress(ProgressType.Updating, 0, (int)rowCount, "Update Progress"); IEnumerable <IDictionary <string, object> > rows = dataSource.GetData(tableConfig); int rowIndex = 0; var maskedRows = rows.Select(row => { rowIndex++; //update per row, or see below, //dataSource.UpdateRow(row, tableConfig); UpdateProgress(ProgressType.Masking, rowIndex); return(dataMasker.Mask(row, tableConfig)); }); //update all rows dataSource.UpdateRows(maskedRows, rowCount, tableConfig, totalUpdated => UpdateProgress(ProgressType.Updating, totalUpdated)); UpdateProgress(ProgressType.Overall, i + 1); } WriteLine("Done"); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Request.QueryString["template"] != null) { TemplateFileName = Request.QueryString["template"]; } if (!Page.IsPostBack) { try { foreach (var item in DataSourceProvider.GetProviderList()) { if (item.Configurator != null) { ddlDataSource.Items.Add(new ListItem(item.FriendlyName)); } } string realfilename = HostingEnvironment.MapPath(TemplateFileName); Hashtable settings = new Hashtable(); string dsFileName = Path.ChangeExtension(realfilename, ".datasource"); //string token = ""; if (File.Exists(dsFileName)) { string[] lines = File.ReadAllLines(dsFileName); foreach (var item in lines) { string[] par = item.Split(new char[] { '=' }, 2); settings.Add(par[0], par[1]); } ddlDataSource.SelectedValue = (string)settings["dataprovider"]; } foreach (DataSourceConfigurator conf in phConfigurator.Controls) { conf.Visible = ddlDataSource.SelectedValue == conf.ID; conf.LoadSettings(settings); //conf.setToken(token); } } catch (Exception ex) { DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, TemplateFileName + "/" + ex.Message, ModuleMessage.ModuleMessageType.RedError); } } }
// Get entityset(key) public IEdmEntityObject Get(string key) { // Get entity type from path. ODataPath path = Request.ODataFeature().Path; IEdmEntityType entityType = (IEdmEntityType)path.EdmType; // Create an untyped entity object with the entity type. EdmEntityObject entity = new EdmEntityObject(entityType); string sourceString = Request.GetDataSource(); DataSourceProvider.Get(sourceString, key, entity); return(entity); }
// Get entityset public EdmEntityObjectCollection Get() { // Get entity set's EDM type: A collection type. ODataPath path = Request.ODataProperties().Path; IEdmCollectionType collectionType = (IEdmCollectionType)path.EdmType; IEdmEntityTypeReference entityType = collectionType.ElementType.AsEntity(); // Create an untyped collection with the EDM collection type. EdmEntityObjectCollection collection = new EdmEntityObjectCollection(new EdmCollectionTypeReference(collectionType)); // Add untyped objects to collection. DataSourceProvider.Get((string)Request.Properties[Constants.ODataDataSource], entityType, collection); return(collection); }
// Get entityset public IActionResult Get() { // Get entity set's EDM type: A collection type. ODataPath path = Request.ODataFeature().Path; IEdmCollectionType collectionType = (IEdmCollectionType)path.EdmType; IEdmEntityTypeReference entityType = collectionType.ElementType.AsEntity(); // Create an untyped collection with the EDM collection type. EdmEntityObjectCollection collection = new EdmEntityObjectCollection(new EdmCollectionTypeReference(collectionType)); string sourceString = Request.GetDataSource(); // Add untyped objects to collection. DataSourceProvider.Get(sourceString, entityType, collection); return(collection); }
void BrowseContentDialog_ResourceSelected(object sender, ResourceSelectedEventArgs e) { if (e == null) { return; } IDataSourceWithResources dataSource = DataSourceProvider.CreateNewDataSourceForConnectionType(e.ConnectionType) as IDataSourceWithResources; if (dataSource == null) { return; } Resource resource = e.Resource; if (resource == null) { return; } // Notify listeners that a resource has been selected OnResourceSelected(e); dataSource.CreateLayerCompleted += (o, args) => { Dispatcher.BeginInvoke((Action) delegate { OnLayerAdded(new LayerAddedEventArgs() { Layer = args.Layer }); }); }; dataSource.CreateLayerFailed += (o, args) => { Dispatcher.BeginInvoke((Action) delegate { Logger.Instance.LogError(args.Exception); OnLayerAddFailed(args); return; }); }; dataSource.CreateLayerAsync(resource, Map != null ? Map.SpatialReference : BrowseContentDialog.MapSpatialReference, null); // NOTE:- layer can only be instantiated on the UI thread because it has a Canvas (UI) element }
private object GetDataObject(object dataContext) { object result = dataContext; DataSourceProvider provider = dataContext as DataSourceProvider; if (provider != null) { result = provider.Data; } else { var icv = dataContext as ICollectionView; if (icv != null) { result = icv.CurrentItem; } } return(result); }
public void Register(string name, DataSourceProvider provider) { var key = name.ToLower(); m_DataSourceProviders.Add(key, provider); }