public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { // This method gets called after a DataServiceContext has been instantiated. It gives us a chance to // perform further initialization work. // // And as it happens, we have an interesting problem to solve! The typed data service context class // that Astoria's EntityClassGenerator generates handles the ResolveType delegate as follows: // // return this.GetType().Assembly.GetType (string.Concat ("<namespace>", typeName.Substring (19)), true); // // Because LINQPad subclasses the typed data context when generating a query, GetType().Assembly returns // the assembly of the user query rather than the typed data context! To work around this, we must take // over the ResolveType delegate and resolve using the context's base type instead: var dsContext = (DataServiceContext)context; var typedDataServiceContextType = context.GetType ().BaseType; dsContext.ResolveType = name => typedDataServiceContextType.Assembly.GetType (typedDataServiceContextType.Namespace + "." + name.Split ('.').Last ()); // The next step is to feed any supplied credentials into the Astoria service. // (This could be enhanced to support other authentication modes, too). var props = new AstoriaProperties (cxInfo); dsContext.Credentials = props.GetCredentials (); // Finally, we handle the SendingRequest event so that it writes the request text to the SQL translation window: dsContext.SendingRequest += (sender, e) => executionManager.SqlTranslationWriter.WriteLine (e.Request.RequestUri); }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { var assembly = LoadAssembly(cxInfo); var configurator = Configurator(cxInfo, assembly); var ctx = DatabaseContext.Create(OpenDB(cxInfo, configurator.Item1.Configure),configurator.Item2); CurrentContext.NewContext(ctx); }
public virtual void Run(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { var runners = GetMethodRunners(cxInfo, context, executionManager); if (runners == null) { return; } foreach (var runner in runners) { runner.Run(); } }
public override void TearDownContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager, object[] constructorArguments) { DataContext context2 = context as DataContext; if (context2 != null) { try { context2.Dispose(); } catch { } } }
public override void InitializeContext(IConnectionInfo r, object context, QueryExecutionManager executionManager) { AstoriaHelper.InitializeContext(r, context, false); }
public virtual void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { }
/// <summary> /// This virtual method is called after a query has completed. You can use this hook to /// perform cleanup activities such as disposing of the context or other objects. /// </summary> public override void TearDownContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager, object[] constructorArguments) { base.TearDownContext(cxInfo, context, executionManager, constructorArguments); }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { _connInfo = RavenConnectionDialogViewModel.Load(cxInfo); var rc = (RavenContext) context; rc.LogWriter = executionManager.SqlTranslationWriter; }
/// <summary> /// Initializes the data context. /// </summary> /// <remarks>In this driver, initialization consists of listening to the /// <see cref="DataServiceContext.SendingRequest"/> event in order to extract the requested /// URI and display it in the SQL tab.</remarks> /// <param name="connectionInfo">The connection info.</param> /// <param name="context">The context.</param> /// <param name="executionManager">The execution manager.</param> public override void InitializeContext(IConnectionInfo connectionInfo, object context, QueryExecutionManager executionManager) { var dsContext = (DataServiceContext)context; dsContext.SendingRequest += (sender, e) => executionManager.SqlTranslationWriter.WriteLine(e.Request.RequestUri); }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { base.InitializeContext(cxInfo, context, executionManager); }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { var rc = context as CassandraDriverContext; rc.LogWriter = executionManager.SqlTranslationWriter; }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { GetClientAssembly(cxInfo); var nhContext = (NHibernateContext)context; nhContext.Session = GetSessionFactory(cxInfo).OpenSession(); }
public override void TearDownContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager, object[] constructorArguments) { DataContext context2 = context as DataContext; if (context2 != null) { try { context2.Dispose(); } catch { } } }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { CheckForUnpatchedCx(context); }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { var dsContext = (DataServiceContext)context; }
public virtual void TearDownContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager, object[] constructorArguments) { }
public virtual void OnQueryFinishing(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { CheckForUnpatchedCx(context); }
public override void OnQueryFinishing(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { base.OnQueryFinishing(cxInfo, context, executionManager); }
public override void InitializeContext(IConnectionInfo r, object context, QueryExecutionManager executionManager) { AstoriaHelper.InitializeContext(r, context, false); }
public virtual void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { base.InitializeContext(cxInfo, context, executionManager); var ctx = (JsonDataContextBase) context; var xInputs = cxInfo.DriverData.Element("inputDefs"); if (xInputs == null) return; var jss = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; var inputs = JsonConvert.DeserializeObject<List<IJsonInput>>(xInputs.Value, jss).ToList(); inputs .OfType<JsonTextInput>() .ToList() .ForEach(c=> ctx._jsonTextInputs.Add(c.InputGuid, c.Json)); }
public virtual void OnQueryFinishing(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { var settings = GetCxSettings(cxInfo); var initType = settings.DriverInitializerType; if (initType == null) { return; } var initializer = initType.GetInstance<IDriverInitializer>(); if (initializer == null) { return; } initializer.Run(cxInfo, context, executionManager); }
public virtual void TearDownContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager, object[] constructorArguments) { }
public override void TearDownContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager, object[] constructorArguments) { base.TearDownContext(cxInfo, context, executionManager, constructorArguments); var rc = context as RavenContext; if (rc != null) rc.Dispose(); }
public override void InitializeContext(IConnectionInfo connectionInfo, object context, QueryExecutionManager executionManager) { var dsContext = (DataServiceContext)context; var properties = connectionInfo.GetConnectionProperties(); dsContext.Credentials = properties.GetCredentials(); dsContext.Configurations.RequestPipeline.OnMessageCreating += args => { var message = new CustomizedRequestMessage(args, properties); return message; }; dsContext.SendingRequest2 += (s, e) => { executionManager.SqlTranslationWriter.WriteLine($"URL:\t\t{e.RequestMessage.Url}"); if (properties.LogMethod) executionManager.SqlTranslationWriter.WriteLine($"Method:\t{e.RequestMessage.Method}"); if (properties.LogHeaders) { executionManager.SqlTranslationWriter.WriteLine("Headers:"); var headers = string.Join("\r\n", e.RequestMessage.Headers.Select(o => $"\t{o.Key}:{o.Value}")); executionManager.SqlTranslationWriter.WriteLine(headers); } }; }
/// <summary> /// This virtual method is called after a data context object has been instantiated, in /// preparation for a query. You can use this hook to perform additional initialization work. /// </summary> public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { // At this point, context is set to a ready-to-go DB2Connection. // NOTE: A useful application of overriding InitializeContext is to set up population of the SQL translation tab. executionManager.SqlTranslationWriter.WriteLine("I have nothing to say to you."); //executionManager.SqlTranslationWriter.WriteLine($"Executing object of type {context.GetType()}: {context.ToString()}"); //executionManager.SqlTranslationWriter.WriteLine($"Properties: {string.Join(", ", context.GetType().GetProperties().Select(x => x.Name))}"); //executionManager.SqlTranslationWriter.WriteLine($"Methods: {string.Join(", ", context.GetType().GetMethods().Select(x => x.Name))}"); // TODO: How can I grab a copy of the SQL I'm executing? base.InitializeContext(cxInfo, context, executionManager); }
/// <summary> /// Populate SQL tab if sql logging is wanted. /// </summary> public override void OnQueryFinishing(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { // LINQPad populates the sql tab just after this method is called, so this is our last chance to grab the sql. // The stopwatch is also stopped after this method completes, so any wait here counts in total exec time shown for the query. // The problem is that we're using a trace listener to obtain the sql, and it won't necessarily have the sql message // by the time this is called. If we have it fire an event to tell us when the sql mesage has arrived it will be too late. // So, we ask the logger for it, and the logger will impose a short wait if it's not ready. If the wait period // elapses without having obtained the sql, then we don't have anything to show in the sql tab for this execution. if (Logging) { executionManager.SqlTranslationWriter.Write(_logger.GetMessageWithWait()); } }
/// <summary> /// This method is called after the query's main thread has finished running the user's code, /// but before the query has stopped. If you've spun up threads that are still writing results, you can /// use this method to wait out those threads. /// </summary> /// <param name="cxInfo"> Connection information, as entered by the user. </param> /// <param name="context"> Context </param> /// <param name="executionManager"> execution manager </param> public override void OnQueryFinishing( IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { var playback = (Playback)context.GetType().GetProperty("playback").GetValue(context, new object[] { }); if (playback != null) { playback.Run(); } }
/// <summary> /// This is called after the EM is constructed. /// </summary> public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { // Set properties on the EM now DevForceTypes.InitializeEntityManager(context); // Initialize sql logging if enabled. InitializeLogger(cxInfo); }
public override void TearDownContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager, object[] constructorArguments) { CurrentContext.CloseContext(); }
protected virtual IEnumerable<MethodRunner> GetMethodRunners(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { var runners = new List<MethodRunner>(); runners.Add(new MethodRunner("Sitecore.ContentSearch.Hooks.Initializer, Sitecore.ContentSearch", "Initialize")); return runners; }
public override void OnQueryFinishing(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { base.OnQueryFinishing(cxInfo, context, executionManager); }
/// <summary> /// This virtual method is called after a query has completed. You can use this hook to /// perform cleanup activities such as disposing of the context or other objects.</summary> public override void TearDownContext(IConnectionInfo pCxInfo, object pContext, QueryExecutionManager pExecutionManager, object[] pConstructorArguments) { MethodInfo lMethod = pContext.GetType().GetMethod("CloseSession"); lMethod.Invoke(pContext, new object[] { }); }
public override void InitializeContext(IConnectionInfo connectionInfo, object context, QueryExecutionManager executionManager) { //TODO: Create LuceneProvider }
public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { // If the data context happens to be a LINQ to SQL DataContext, we can look up the SQL translation window. var l2s = context as System.Data.Linq.DataContext; if (l2s != null) l2s.Log = executionManager.SqlTranslationWriter; }