Exemplo n.º 1
0
 internal void OnDataSourceAdd(DataSourceAddEventArgs args)
 {
     if (DataSourceAdd != null)
     {
         DataSourceAdd(_service, args);
     }
 }
Exemplo n.º 2
0
 public DataSource GetDataSource(OperationContext context) {
   // We must account for Linked apps, like logging app; the same contet/session might be used for quering entities in main app (book store) and logging app
   // so cached data source in context might not be what we're looking for - it might be from different app. 
   var ds = context.DataSource;
   if(ds != null && ds.Name == context.DataSourceName && ds.App == context.App)
     return ds;
   ds = LookupDataSource(context.DataSourceName);
   if (ds == null) {
     //Fire event 
     var args = new DataSourceAddEventArgs(context);
     Events.OnDataSourceAdd(args);
     ds = args.NewDataSource;
     // If app/event handler uses app.ConnectTo method, then data source must be already registered
     // but just in case, let's make sure it is registered (the call is ignored if ds is already there).
     if(ds != null)
       RegisterDataSource(ds); 
   }
   Util.Check(ds != null, "Failed to find data source, name: {0}", context.DataSourceName);
   context.DataSource = ds;
   return context.DataSource;
 }
Exemplo n.º 3
0
        public DataSource GetDataSource(OperationContext context)
        {
            // We must account for Linked apps, like logging app; the same contet/session might be used for quering entities in main app (book store) and logging app
            // so cached data source in context might not be what we're looking for - it might be from different app.
            var ds = context.DataSource;

            if (ds != null && ds.Name == context.DataSourceName && ds.App == context.App)
            {
                return(ds);
            }
            ds = LookupDataSource(context.DataSourceName);
            if (ds == null)
            {
                //Fire event
                var args = new DataSourceAddEventArgs(context);
                Events.OnDataSourceAdd(args);
                ds = args.NewDataSource;
                // if DataSource is returned by event handler, it might be registered or not - it is up to a handler
            }
            Util.Check(ds != null, "Failed to find data source, name: {0}", context.DataSourceName);
            context.DataSource = ds;
            return(context.DataSource);
        }
Exemplo n.º 4
0
 internal void OnDataSourceAdd(DataSourceAddEventArgs args)
 {
     if(DataSourceAdd != null)
     DataSourceAdd(_service, args);
 }