Exemple #1
0
        public ConnectionDialog(IConnectionInfo cxInfo)
        {
            init();

            //DataContext = // this was for WPF dialog
            _properties = new FileDbDynamicDriverProperties(cxInfo);
        }
Exemple #2
0
        internal static List <ExplorerItem> GetSchemaAndBuildAssembly(FileDbDynamicDriverProperties props, AssemblyName name,
                                                                      ref string nameSpace, ref string typeName)
        {
            // Generate the C# code

            string code = GenerateCode(props.Folder, props.Extension, nameSpace);

            // Compile the code into the assembly, using the assembly name provided:
            BuildAssembly(code, name);

            // populate the Schema Explorer from the database files in the selected folder
            List <ExplorerItem> schema = GetSchema(props, out typeName);

            return(schema);
        }
Exemple #3
0
        internal static List <ExplorerItem> GetSchema(FileDbDynamicDriverProperties props, out string typeName)
        {
            typeName = "FileDbContext";

            var tables = new List <ExplorerItem>();

            DirectoryInfo dirInfo = new DirectoryInfo(props.Folder);

            FileInfo[] files = dirInfo.GetFiles(String.Format("*.{0}", props.Extension));

            foreach (FileInfo fi in files)
            {
                string tableName = fi.Name.Substring(0, fi.Name.LastIndexOf('.'));

                ExplorerItem item = new ExplorerItem(tableName, ExplorerItemKind.QueryableObject, ExplorerIcon.Table)
                {
                    IsEnumerable = true,
                    ToolTipText  = "", // FormatTypeName (prop.PropertyType, false),

                    // Store the filename to the Tag property - we'll use it below
                    Tag = fi.FullName
                };

                tables.Add(item);
            }

            // Populate the columns (properties) of each entity:

            foreach (ExplorerItem table in tables)
            {
                FileDbNs.Fields fields = getFieldsFromDb(table.Tag as string);

                var columns = new List <ExplorerItem>();

                foreach (FileDbNs.Field field in fields)
                {
                    string       name = string.Format("{0} ({1})", field.Name, field.DataType.ToString());
                    ExplorerItem item = new ExplorerItem(name, ExplorerItemKind.Property, ExplorerIcon.Column);
                    columns.Add(item);
                }
                table.Children = columns;
            }

            return(tables);
        }
        void init(IConnectionInfo cxInfo)
        {
            _properties = new FileDbDynamicDriverProperties(cxInfo);

            Background = SystemColors.ControlBrush;
            InitializeComponent();

            TxtExtension.Text = _properties.Extension = StrDefaultExtension;

#if DEBUG
            TxtFolder.Text = _properties.Folder = @"C:\Dev\EzTools.NET\FileDb\LinqPad Driver\Northwind Database";
#else
            //string path = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
            //path = System.IO.Path.Combine( path, "Northwind Database" );
            //if( Directory.Exists( path ) )
            //    TxtFolder.Text = _properties.Folder = path;
#endif

            DataContext = _properties;

            refreshList();
        }
        public override string GetConnectionDescription(IConnectionInfo cxInfo)
        {
            string friendlyName = new FileDbDynamicDriverProperties(cxInfo).FriendlyName;

            return(friendlyName);
        }