// ReSharper disable once RedundantAssignment public override List <ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo connectionInfo, AssemblyName assemblyToBuild, ref string nameSpace, ref string typeName) { var properties = connectionInfo.GetConnectionProperties(); var codeGenerator = new ODataT4CodeGenerator { MetadataDocumentUri = properties.Uri, NamespacePrefix = nameSpace, TargetLanguage = ODataT4CodeGenerator.LanguageOption.CSharp, UseDataServiceCollection = false, EnableNamingAlias = false, IgnoreUnexpectedElementsAndAttributes = true, Properties = properties, }; var code = codeGenerator.TransformText(); BuildAssembly(code, assemblyToBuild); var model = properties.GetModel(); typeName = GetContainerName(model); var schema = model.GetSchema(); return(schema); }
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.GetWebProxy()); 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); } }; }
public override bool ShowConnectionDialog(IConnectionInfo connectionInfo, bool isNewConnection) { var connectionProperties = connectionInfo.GetConnectionProperties(); // Populate the default URI with a demo data: if (isNewConnection) { connectionProperties.Uri = "http://services.odata.org/TripPinRESTierService"; } return(new ConnectionDialog(connectionProperties).ShowDialog() == true); }
public override IEnumerable <string> GetNamespacesToAdd(IConnectionInfo connectionInfo) { if (_namespaces == null || _namespaces.Count == 0) { var model = connectionInfo.GetConnectionProperties().GetModel(); var namespaces = model.DeclaredNamespaces.Select(o => BaseNamespacePrefix + "." + o).ToList(); _namespaces = namespaces.Count > 1 ? namespaces.ToList() : new List <string>(1); _namespaces.Add("Microsoft.OData.Client"); } return(_namespaces); }
public override List <ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo connectionInfo, AssemblyName assemblyToBuild, ref string nameSpace, ref string typeName) { var properties = connectionInfo.GetConnectionProperties(); // using code from Microsoft's OData v4 Client Code Generator. see https://visualstudiogallery.msdn.microsoft.com/9b786c0e-79d1-4a50-89a5-125e57475937 var client = new ODataClient(new Configuration(properties.Uri, nameSpace, properties)); var code = client.GenerateCode(); // Compile the code into the assembly, using the assembly name provided: BuildAssembly(code, assemblyToBuild); var model = properties.GetModel(); typeName = GetContainerName(model); var schema = model.GetSchema(); return(schema); }
public override object[] GetContextConstructorArguments(IConnectionInfo connectionInfo) { // We need to pass the chosen URI into the DataServiceContext's constructor: return(new object[] { new Uri(connectionInfo.GetConnectionProperties().Uri) }); }
public override string GetConnectionDescription(IConnectionInfo connectionInfo) { return(connectionInfo.GetConnectionProperties().Uri); }
public override List<ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo connectionInfo, AssemblyName assemblyToBuild, ref string nameSpace, ref string typeName) { var properties = connectionInfo.GetConnectionProperties(); // using code from Microsoft's OData v4 Client Code Generator. see https://visualstudiogallery.msdn.microsoft.com/9b786c0e-79d1-4a50-89a5-125e57475937 var client = new ODataClient(new Configuration(properties.Uri, nameSpace, properties)); var code = client.GenerateCode(); // Compile the code into the assembly, using the assembly name provided: BuildAssembly(code, assemblyToBuild); var model = properties.GetModel(); typeName = GetContainerName(model); var schema = model.GetSchema(); return schema; }
public override IEnumerable<string> GetNamespacesToAdd(IConnectionInfo connectionInfo) { if (_namespaces == null || _namespaces.Count == 0) { var model = connectionInfo.GetConnectionProperties().GetModel(); var namespaces = model.DeclaredNamespaces.Select(o => BaseNamespacePrefix + "." + o).ToList(); _namespaces = namespaces.Count > 1 ? namespaces.ToList() : new List<string>(1); _namespaces.Add("Microsoft.OData.Client"); } return _namespaces; }
public override object[] GetContextConstructorArguments(IConnectionInfo connectionInfo) { // We need to pass the chosen URI into the DataServiceContext's constructor: return new object[] { new Uri(connectionInfo.GetConnectionProperties().Uri) }; }
public override string GetConnectionDescription(IConnectionInfo connectionInfo) { return connectionInfo.GetConnectionProperties().Uri; }
public override bool ShowConnectionDialog(IConnectionInfo connectionInfo, bool isNewConnection) { var connectionProperties = connectionInfo.GetConnectionProperties(); // Populate the default URI with a demo data: if (isNewConnection) connectionProperties.Uri = "http://services.odata.org/V4/OData/OData.svc/"; return new ConnectionDialog(connectionProperties).ShowDialog() == true; }
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); } }; }