コード例 #1
0
        public object Create(ConnectionParameterBase param)
        {
            if (param is FilePathConnectionParameter)
            {
                return(new FilePathConnectionParameterViewModel((FilePathConnectionParameter)param));
            }

            if (param is FolderPathConnectionParameter)
            {
                return(new FolderPathConnectionParameterViewModel((FolderPathConnectionParameter)param));
            }

            if (param is StringConnectionParameter)
            {
                if (param.Name == KnownParameters.Password)
                {
                    return(new PasswordConnectionParameterViewModel((StringConnectionParameter)param));
                }
                return(new StringConnectionParameterViewModel((StringConnectionParameter)param));
            }

            if (param is SwitchConnectionParameter)
            {
                return(new SwitchConnectionParameterViewModel((SwitchConnectionParameter)param));
            }

            if (param is PredefinedConnectionParameter)
            {
                return(new PredefinedConnectionParameterViewModel((PredefinedConnectionParameter)param));
            }

            throw new Exception("Unsupported parameter type");
        }
コード例 #2
0
        public ConnectionGroup(IList <ConnectionParameterIntance> parameterInstances = null)
        {
            Connections = new List <ConnectionDescription>();
            Groups      = new List <ConnectionGroup>();

            Parameters = new ConnectionParameterBase[]
            {
                new StringConnectionParameter()
                {
                    Name        = KnownParameters.Host,
                    DisplayName = "Хост по умолчанию",
                    Delimiter   = "",
                    Value       = string.Empty,
                },

                new StringConnectionParameter()
                {
                    Name        = KnownParameters.Port,
                    DisplayName = "Порт по умолчанию",
                    Delimiter   = "",
                    Value       = string.Empty,
                },

                new StringConnectionParameter
                {
                    Name        = "User",
                    DisplayName = "Юзер по умолчанию",
                    Delimiter   = "",
                    Value       = string.Empty
                },

                new StringConnectionParameter
                {
                    Name        = "Password",
                    DisplayName = "Пароль по умолчанию",
                    Delimiter   = "",
                    Value       = string.Empty,
                },
            }.ToList();

            if (parameterInstances != null)
            {
                foreach (var param in Parameters)
                {
                    var pi = parameterInstances.FirstOrDefault(p => p.Name == param.Name);
                    if (pi != null && !string.IsNullOrEmpty(pi.Value))
                    {
                        param.Value = pi.Value;
                    }
                }
            }
        }