コード例 #1
0
        public static async Task<SchemaBuilder> FromTableInfosAsync(BigQueryContext context, DriverProperty property)
        {
            string[] datasets;
            if (property.ContextIsOnlyDataSet)
            {
                datasets = new[] { property.ContextDataSet };
            }
            else
            {
                datasets = await context.GetAllDatasetsAsync();
            }

            var list = new List<Schema>();
            foreach (var dataset in datasets)
            {
                var tables = await context.GetFastTableSchemasAsync(dataset);

                var schema = new Schema()
                {
                    DatasetName = dataset,
                    GroupedMetaTableSchemas = tables,
                };

                list.Add(schema);
            }

            return new SchemaBuilder(context, property, list.ToArray());
        }
コード例 #2
0
        public override object[] GetContextConstructorArguments(IConnectionInfo cxInfo)
        {
            var property = new DriverProperty(cxInfo);

            return(new object[]
            {
                property.ContextJsonAuthenticationKey,
                property.ContextUser,
                property.ContextProjectId
            });
        }
コード例 #3
0
        public ConnectionDialog(IConnectionInfo connectionInfo)
        {
            InitializeComponent();
            this.connectionInfo = connectionInfo;
            this.property = new DriverProperty(connectionInfo);

            JsonTextBox.Text = property.ContextJsonAuthenticationKey;
            UserTextBox.Text = property.ContextUser;
            ProjectIdBox.Text = property.ContextProjectId;
            UseDataSetCheckBox.IsChecked = property.ContextIsOnlyDataSet;
            DataSetBox.Text = property.ContextDataSet;
        }
コード例 #4
0
        // 3. explore item and generate assembly
        public override List <ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo cxInfo, AssemblyName assemblyToBuild, ref string nameSpace, ref string typeName)
        {
            var property = new DriverProperty(cxInfo);

            var context = ContextHelper.GetContext(property.ContextJsonAuthenticationKey, property.ContextUser, property.ContextProjectId);

            SchemaBuilder schemaBuilder = null;

            var useCache = false; // for debugging shortcut

            if (useCache)
            {
                var schemaCache = property.GetTempCache();
                if (schemaCache != null)
                {
                    try
                    {
                        var deserialized = JsonConvert.DeserializeObject <Schema[]>(schemaCache);
                        schemaBuilder = new SchemaBuilder(context, property, deserialized);
                    }
                    catch
                    {
                    }
                }
            }

            if (schemaBuilder == null)
            {
                schemaBuilder = SchemaBuilder.FromTableInfosAsync(context, property).GetAwaiter().GetResult();
                var cacheString = JsonConvert.SerializeObject(schemaBuilder.Schemas, Formatting.None);
                property.SetTempCache(cacheString);
            }

            BuildCodeResult[] generatedCodes;
            var namespacesToAdd = schemaBuilder.CompileTo(assemblyToBuild, nameSpace, out generatedCodes);
            var list            = schemaBuilder.BuildExplorerItems(generatedCodes);

            property.NamespacesToAdd = namespacesToAdd;
            typeName = "CustomBigQueryContext";

            return(list);
        }
コード例 #5
0
        // 3. explore item and generate assembly
        public override List<ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo cxInfo, AssemblyName assemblyToBuild, ref string nameSpace, ref string typeName)
        {
            var property = new DriverProperty(cxInfo);

            var context = ContextHelper.GetContext(property.ContextJsonAuthenticationKey, property.ContextUser, property.ContextProjectId);

            SchemaBuilder schemaBuilder = null;

            var useCache = false; // for debugging shortcut
            if (useCache)
            {
                var schemaCache = property.GetTempCache();
                if (schemaCache != null)
                {
                    try
                    {
                        var deserialized = JsonConvert.DeserializeObject<Schema[]>(schemaCache);
                        schemaBuilder = new SchemaBuilder(context, property, deserialized);
                    }
                    catch
                    {

                    }
                }
            }

            if (schemaBuilder == null)
            {
                schemaBuilder = SchemaBuilder.FromTableInfosAsync(context, property).GetAwaiter().GetResult();
                var cacheString = JsonConvert.SerializeObject(schemaBuilder.Schemas, Formatting.None);
                property.SetTempCache(cacheString);
            }

            BuildCodeResult[] generatedCodes;
            var namespacesToAdd = schemaBuilder.CompileTo(assemblyToBuild, nameSpace, out generatedCodes);
            var list = schemaBuilder.BuildExplorerItems(generatedCodes);

            property.NamespacesToAdd = namespacesToAdd;
            typeName = "CustomBigQueryContext";

            return list;
        }
コード例 #6
0
        public override IEnumerable <string> GetNamespacesToAdd(IConnectionInfo cxInfo)
        {
            var     asm = typeof(DynamicDataContextDriver).Assembly; // LINQPad.exe
            Version version;

            if (!Version.TryParse(asm.GetCustomAttribute <AssemblyFileVersionAttribute>()?.Version ?? "", out version))
            {
                version = new Version(1, 0, 0, 0);
            }

            var prop = new DriverProperty(cxInfo);

            return(base.GetNamespacesToAdd(cxInfo)
                   .Concat(prop.NamespacesToAdd)
                   .Concat(new[]
            {
                "System.Linq",
                "BigQuery.Linq",
                "System.Windows.Forms.DataVisualization.Charting"
            })
                   .Concat(new Version(5, 0, 0, 0) <= version ? new[] { "static BigQuery.Linq.BqFunc" } : new string[0])
                   .Distinct());
        }
コード例 #7
0
 public SchemaBuilder(BigQueryContext context, DriverProperty property, Schema[] schemas)
 {
     this.context = context;
     this.Schemas = schemas;
     this.property = property;
 }
コード例 #8
0
        public static async Task <SchemaBuilder> FromTableInfosAsync(BigQueryContext context, DriverProperty property)
        {
            string[] datasets;
            if (property.ContextIsOnlyDataSet)
            {
                datasets = new[] { property.ContextDataSet };
            }
            else
            {
                datasets = await context.GetAllDatasetsAsync();
            }

            var list = new List <Schema>();

            foreach (var dataset in datasets)
            {
                var tables = await context.GetFastTableSchemasAsync(dataset);

                var schema = new Schema()
                {
                    DatasetName             = dataset,
                    GroupedMetaTableSchemas = tables,
                };

                list.Add(schema);
            }

            return(new SchemaBuilder(context, property, list.ToArray()));
        }
コード例 #9
0
 public SchemaBuilder(BigQueryContext context, DriverProperty property, Schema[] schemas)
 {
     this.context  = context;
     this.Schemas  = schemas;
     this.property = property;
 }
コード例 #10
0
        public override IEnumerable<string> GetNamespacesToAdd(IConnectionInfo cxInfo)
        {
            var asm = typeof(DynamicDataContextDriver).Assembly; // LINQPad.exe
            Version version;
            if (!Version.TryParse(asm.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version ?? "", out version))
            {
                version = new Version(1, 0, 0, 0);
            }

            var prop = new DriverProperty(cxInfo);

            return base.GetNamespacesToAdd(cxInfo)
                .Concat(prop.NamespacesToAdd)
                .Concat(new[]
                {
                    "System.Linq",
                    "BigQuery.Linq",
                    "System.Windows.Forms.DataVisualization.Charting"
                })
                .Concat(new Version(5, 0, 0, 0) <= version ? new[] { "static BigQuery.Linq.BqFunc" } : new string[0])
                .Distinct();
        }
コード例 #11
0
        public override object[] GetContextConstructorArguments(IConnectionInfo cxInfo)
        {
            var property = new DriverProperty(cxInfo);

            return new object[]
            {
                property.ContextJsonAuthenticationKey,
                property.ContextUser,
                property.ContextProjectId
            };
        }