Esempio n. 1
0
        public void AssignToSchemaIni()
        {
            var model = new ConnectionStringViewModel();
            var prov  = Container.GetExportedValue <IDataProviderController>();

            model.Reset(prov);
            Assert.IsNotNull(model);

            var schemaIni = new SchemaIniElement("name", "value");

            model.Configuration = new NamedConnectionElement();
            Assert.IsTrue(model.Configuration.SchemaIniSettings.Count == 0);

            model.Configuration.SchemaIniSettings.Add(schemaIni);
            Assert.IsTrue(model.Configuration.SchemaIniSettings.Count == 1);

            var col = new SchemaIniElementCollection();

            col.Add(schemaIni);
            model.Configuration.SchemaIniSettings = col;
            Assert.IsTrue(model.Configuration.SchemaIniSettings.Count == 1);

            var SchemaIniSettings = new SchemaIniElementCollection();

            SchemaIniSettings.Add(schemaIni);
            model.Configuration = new NamedConnectionElement();
            model.Configuration.SchemaIniSettings = SchemaIniSettings;
            Assert.IsTrue(model.Configuration.SchemaIniSettings.Count == 1);
        }
        // get the TextDelimeter value from the TextFileConnectionStringViewModel
        private void PushToConnectionElement(object sender, PropertyChangedEventArgs e)
        {
            SchemaIni = new SchemaIniElementCollection();

            // Per this documentation, the SchemaIni TextDelimeter is double-quote if not present, so we only need to set to none if user said none.
            // http://office.microsoft.com/en-us/access-help/initializing-the-text-data-source-driver-HP001032166.aspx
            if (!ViewModel.HasDoubleQuotes)
            {
                SchemaIni.Add(new SchemaIniElement("TextDelimiter", "none"));
            }
        }
        public TextFileConnectionStringView()
        {
            SchemaIni = new SchemaIniElementCollection();

            InitializeComponent();
            var model = new TextFileConnectionViewModel();

            provider = ServiceLocator.Current.GetAllInstances <IDataProviderController>().OfType <TextAceDataProviderController>().FirstOrDefault();
            model.Reset(provider);
            Model   = model;
            Loaded += (o, e) => ViewModel.Load(CreateConnectionStringBuilder());

            Filename = "uninitialized";
        }