Inheritance: RavenLinqpadDriver.ViewModelBase
Esempio n. 1
0
        public override object[] GetContextConstructorArguments(IConnectionInfo cxInfo)
        {
            _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);
// ReSharper disable CoVariantArrayConversion
            return(new[] { _connInfo });
// ReSharper restore CoVariantArrayConversion
        }
 public override object[] GetContextConstructorArguments(IConnectionInfo cxInfo)
 {
     _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);
     // ReSharper disable CoVariantArrayConversion
     return new[] { _connInfo };
     // ReSharper restore CoVariantArrayConversion
 }
Esempio n. 3
0
        public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager)
        {
            _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);

            var rc = (RavenContext)context;

            rc.LogWriter = executionManager.SqlTranslationWriter;
        }
        public RavenConectionDialog(RavenConnectionDialogViewModel conn)
        {
            if (conn == null)
                throw new ArgumentNullException("conn", "conn is null.");

            InitializeComponent();

            DataContext = _connInfo = conn;
            txtPassword.Password = conn.Password;
        }
Esempio n. 5
0
        public RavenContext(RavenConnectionDialogViewModel connInfo)
        {
            if (connInfo == null)
            {
                throw new ArgumentNullException("connInfo");
            }

            _docStore    = CreateDocStore(connInfo).Initialize();
            _lazySession = new Lazy <IDocumentSession>(_docStore.OpenSession);
            SetupLogWriting();
        }
Esempio n. 6
0
        public RavenConectionDialog(RavenConnectionDialogViewModel conn)
        {
            if (conn == null)
            {
                throw new ArgumentNullException("conn", "conn is null.");
            }

            InitializeComponent();

            DataContext          = _connInfo = conn;
            txtPassword.Password = conn.Password;
        }
        public override bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnection)
        {
            _connInfo = isNewConnection
                ? new RavenConnectionDialogViewModel { CxInfo = cxInfo }
                : RavenConnectionDialogViewModel.Load(cxInfo);

            var win = new RavenConectionDialog(_connInfo);
            var result = win.ShowDialog() == true;

            if (result)
            {
                _connInfo.Save();
                cxInfo.CustomTypeInfo.CustomAssemblyPath = Assembly.GetAssembly(typeof(RavenContext)).Location;
                cxInfo.CustomTypeInfo.CustomTypeName = "RavenLinqpadDriver.RavenContext";
            }

            return result;
        }
Esempio n. 8
0
        public override bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnection)
        {
            _connInfo = isNewConnection
                ? new RavenConnectionDialogViewModel {
                CxInfo = cxInfo
            }
                : RavenConnectionDialogViewModel.Load(cxInfo);

            var win    = new RavenConectionDialog(_connInfo);
            var result = win.ShowDialog() == true;

            if (result)
            {
                _connInfo.Save();
                cxInfo.CustomTypeInfo.CustomAssemblyPath = Assembly.GetAssembly(typeof(RavenContext)).Location;
                cxInfo.CustomTypeInfo.CustomTypeName     = "RavenLinqpadDriver.RavenContext";
            }

            return(result);
        }
Esempio n. 9
0
        private void InitDocStore(RavenConnectionDialogViewModel conn)
        {
            if (conn == null)
            {
                throw new ArgumentNullException("conn", "conn is null.");
            }



            var assemblies = conn.GetAssemblyPaths().Select(Path.GetFileNameWithoutExtension).Select(Assembly.Load);

            var docStoreCreatorType = (from a in assemblies
                                       from t in a.TypesImplementing <ICreateDocumentStore>()
                                       select t).FirstOrDefault();

            if (docStoreCreatorType != null)
            {
                var docStoreCreator = (ICreateDocumentStore)docStoreCreatorType.CreateInstance();
                _docStore = docStoreCreator.CreateDocumentStore(new ConnectionInfo
                {
                    Url             = conn.Url,
                    DefaultDatabase = conn.DefaultDatabase,
                    Credentials     = new NetworkCredential
                    {
                        UserName = conn.Username,
                        Password = conn.Password
                    },
                    ResourceManagerId = conn.ResourceManagerId,
                    ApiKey            = conn.ApiKey
                });
            }
            else
            {
                _docStore = conn.CreateDocStore();
            }

            _docStore.Initialize();
        }
Esempio n. 10
0
        private static IDocumentStore CreateDocStore(RavenConnectionDialogViewModel conn)
        {
            if (conn == null)
            {
                throw new ArgumentNullException("conn", "conn is null.");
            }

            var assemblies = conn.AssemblyPaths.Select(Path.GetFileNameWithoutExtension).Select(Assembly.Load);

            var docStoreCreatorType = (from a in assemblies
                                       from t in a.TypesImplementing <ICreateDocumentStore>()
                                       let hasDefaultCtor = t.GetConstructor(Type.EmptyTypes) != null
                                                            where !t.IsAbstract && hasDefaultCtor
                                                            select t).FirstOrDefault();

            if (docStoreCreatorType == null)
            {
                return(conn.CreateDocStore());
            }

            var docStoreCreator = (ICreateDocumentStore)Activator.CreateInstance(docStoreCreatorType);

            var connectionInfo = new ConnectionInfo
            {
                Url             = conn.Url,
                DefaultDatabase = conn.DefaultDatabase,
                Credentials     = new NetworkCredential
                {
                    UserName = conn.Username,
                    Password = conn.Password
                },
                ResourceManagerId = conn.ResourceManagerId,
                ApiKey            = conn.ApiKey
            };

            return(docStoreCreator.CreateDocumentStore(connectionInfo));
        }
        public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager)
        {
            _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);

            var rc = (RavenContext) context;
            rc.LogWriter = executionManager.SqlTranslationWriter;
        }
        public override ParameterDescriptor[] GetContextConstructorParameters(IConnectionInfo cxInfo)
        {
            _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);

            return new[] { new ParameterDescriptor("connInfo", "RavenLinqpadDriver.RavenConnectionDialogViewModel") };
        }
 public override string GetConnectionDescription(IConnectionInfo cxInfo)
 {
     _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);
     return string.Format("RavenDB: {0}", _connInfo.Name);
 }
Esempio n. 14
0
        public override ParameterDescriptor[] GetContextConstructorParameters(IConnectionInfo cxInfo)
        {
            _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);

            return(new[] { new ParameterDescriptor("connInfo", "RavenLinqpadDriver.RavenConnectionDialogViewModel") });
        }
Esempio n. 15
0
 public override string GetConnectionDescription(IConnectionInfo cxInfo)
 {
     _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);
     return(string.Format("RavenDB: {0}", _connInfo.Name));
 }