private void SetMode()
        {
            if(IsFileSelector)
            {
                ButtonText = "\uF15C";
                ButtonCommand = new RelayCommand(() => 
                {
                    var dlg = new OpenFileDialog();
                    if (!string.IsNullOrEmpty(OpenFileFilter))
                    {
                        dlg.Filter = OpenFileFilter;
                    }

                    if (dlg.ShowDialog() == true)
                    {
                        ConfigItemValue = new SDPath(dlg.FileName);
                    }
                }, true);
            }
            else
            {
                ButtonText = "\uF07C";
                ButtonCommand = new RelayCommand(() =>
                {
                    var dlg = new System.Windows.Forms.FolderBrowserDialog();
                    dlg.ShowNewFolderButton = true;
                    dlg.ShowDialog();
                    if (!string.IsNullOrEmpty(dlg.SelectedPath))
                    {
                        ConfigItemValue = new SDPath(dlg.SelectedPath);
                    }
                }, true);
            }
        }
Exemplo n.º 2
0
        public void FallsBackToFullPathsIfRelativePathsAreMissing()
        {
            var path = new SDPath("c:\\source\\someproject\\output", null);

            var resolvedPath = path.ResolvePath("c:\\buildagent\\CI_WS\\1234");

            Assert.AreEqual("c:\\source\\someproject\\output", resolvedPath);
        }
Exemplo n.º 3
0
        public void CanResolveRelativePaths()
        {
            var path = new SDPath();

            path.UpdatePath("c:\\source\\someproject\\output", "c:\\source\\someproject");

            var resolvedPath = path.ResolvePath("c:\\buildagent\\CI_WS\\1234");

            Assert.AreEqual("c:\\buildagent\\CI_WS\\1234\\output", resolvedPath);
        }
Exemplo n.º 4
0
        public void CorrectlyUpdatesThePaths()
        {
            var path = new SDPath();

            path.UpdatePath("c:\\source\\someproject\\output", "c:\\source\\someproject");

            Assert.AreEqual("c:\\source\\someproject\\output", path.FullPath);
            Assert.AreEqual("output", path.RelativePath);

            path.UpdatePath("c:\\completelydifferent\\output", "c:\\source\\someproject");

            Assert.AreEqual("c:\\completelydifferent\\output", path.FullPath);
            Assert.AreEqual("..\\..\\completelydifferent\\output", path.RelativePath);

            var resolvedPath = path.ResolvePath("c:\\source\\someproject\\superdeepdirectory");

            Assert.AreEqual("c:\\source\\completelydifferent\\output", resolvedPath);
        }
Exemplo n.º 5
0
        private void GetAndSetConfigValue(IConfigSection config, XElement item)
        {
            var propertyName = string.Empty;

            var keyAttribute = item.Attribute("key");
            if (keyAttribute != null)
            {
                propertyName = keyAttribute.Value;
            }
            else
            {
                propertyName = item.Name.LocalName;
            }
            
            var property = config.GetType().GetProperty(propertyName);
            if (property != null)
            {
                var excludeAttribute = (ExcludeAttribute)Attribute.GetCustomAttribute(property, typeof(ExcludeAttribute));
                if (excludeAttribute == null)
                {
                    if (property.PropertyType.Name == "Boolean")
                    {
                        property.SetValue(config, item.Attribute("value").Value.ToLower() == "true", null);
                    }
                    else if (property.PropertyType.Name == "ObservableCollection`1")
                    {
                        property.SetValue(config, new ObservableCollection<string>(item.Attribute("value").Value.Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList()), null);
                    }
                    else if (property.PropertyType == typeof(SDPath) && item.Element("Full") != null)
                    {
                        var fullPath = item.Element("Full").Value;
                        var relativePath = item.Element("Relative").Value;

                        var path = new SDPath(fullPath, relativePath);
                        property.SetValue(config, path, null);
                    }
                    else if (property.PropertyType == typeof(SDPath))
                    {
                        // Backwards compatibility code
                        var fullPath = item.Attribute("value").Value;

                        var path = new SDPath(fullPath);
                        property.SetValue(config, path, null);
                    }
                    else
                    {
                        property.SetValue(config, item.Attribute("value").Value, null);
                    }
                }
            }
        }