Inheritance: RavenLinqpadDriver.ViewModelBase
Ejemplo n.º 1
0
        public override object[] GetContextConstructorArguments(IConnectionInfo cxInfo)
        {
            _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);
// ReSharper disable CoVariantArrayConversion
            return(new[] { _connInfo });
// ReSharper restore CoVariantArrayConversion
        }
Ejemplo n.º 2
0
 public override object[] GetContextConstructorArguments(IConnectionInfo cxInfo)
 {
     _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);
     // ReSharper disable CoVariantArrayConversion
     return new[] { _connInfo };
     // ReSharper restore CoVariantArrayConversion
 }
Ejemplo 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;
        }
Ejemplo 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();
        }
Ejemplo 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;
        }
Ejemplo n.º 7
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;
        }
Ejemplo 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);
        }
Ejemplo 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();
        }
Ejemplo 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));
        }
Ejemplo n.º 11
0
        public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager)
        {
            _connInfo = RavenConnectionDialogViewModel.Load(cxInfo);

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

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

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