Exemplo n.º 1
0
        public void SetUp(IActivateItems activator, ArgumentValueUIArgs args)
        {
            var instanceOfParentType = Activator.CreateInstance(_typeOfUnderlyingClass);

            var factory = new PipelineSelectionUIFactory(args.CatalogueRepository, args.Required, args, instanceOfParentType);

            _pipelineSelectionUIInstance = factory.Create(activator);
            _pipelineSelectionUIInstance.CollapseToSingleLineMode();

            var c = (Control)_pipelineSelectionUIInstance;

            Controls.Add(c);

            try
            {
                Pipeline p = null;
                try
                {
                    p = (Pipeline)args.InitialValue;
                }
                catch (Exception e)
                {
                    ExceptionViewer.Show(e);
                }
            }
            catch (Exception e)
            {
                args.Fatal(e);
            }
        }
Exemplo n.º 2
0
        public void SetUp(IActivateItems activator, ArgumentValueUIArgs args)
        {
            _args = args;

            tbSql.Text        = FormatSqlForTextbox(args.InitialValue);
            lblSqlClause.Text = args.ContextText;
        }
Exemplo n.º 3
0
        public void SetUp(ArgumentValueUIArgs args)
        {
            _args = args;

            var value = ((Array)(args.InitialValue));

            SetUp(value);
        }
Exemplo n.º 4
0
        public void SetUp(IActivateItems activator, ArgumentValueUIArgs args)
        {
            _args = args;

            var value = ((Array)(args.InitialValue));

            SetUp(value);
        }
Exemplo n.º 5
0
        public ArgumentValueUIArgs Clone()
        {
            var newInstance = new ArgumentValueUIArgs();

            newInstance.Parent              = Parent;
            newInstance.InitialValue        = InitialValue;
            newInstance.Type                = Type;
            newInstance.Required            = Required;
            newInstance.CatalogueRepository = CatalogueRepository;
            newInstance.Setter              = Setter;
            newInstance.Fatal               = Fatal;

            return(newInstance);
        }
Exemplo n.º 6
0
        public void SetUp(IActivateItems activator, ArgumentValueUIArgs args)
        {
            _args     = args;
            _bLoading = true;

            //if no value has been selected set it to false
            if (args.InitialValue == null)
            {
                cbValue.Checked = false;
                args.Setter(false);
            }
            else
            {
                cbValue.Checked = (bool)args.InitialValue;//otherwise use the previous value
            }
            _bLoading = false;
        }
Exemplo n.º 7
0
        public void SetUp(ArgumentValueUIArgs args)
        {
            _args = args;
            var concreteType = args.Type;

            //get an IDictionary either from the object or a new empty one (e.g. if Value is null)
            _dictionary = (IDictionary)(args.InitialValue ?? Activator.CreateInstance(concreteType));

            _kType = concreteType.GenericTypeArguments[0];
            _vType = concreteType.GenericTypeArguments[1];

            foreach (DictionaryEntry kvp in _dictionary)
            {
                AddRow(kvp.Key, kvp.Value);
            }

            btnSave.Enabled = false;
        }
Exemplo n.º 8
0
        public void SetUp(IActivateItems activator, ArgumentValueUIArgs args)
        {
            _bLoading = true;
            _args     = args;

            object currentValue = null;

            try
            {
                if (_isEnum && _args.InitialValue == null)
                {
                    args.Setter(cbxValue.SelectedItem);
                }
                else
                {
                    currentValue = _args.InitialValue;
                }
            }
            catch (Exception e)
            {
                _args.Fatal(e);
            }

            if (cbxValue.Items.Count == 0 && _args.InitialValue != null)
            {
                cbxValue.Items.Add(_args.InitialValue);
            }

            if (currentValue != null)
            {
                if (types != null)
                {
                    cbxValue.Text = ((Type)currentValue).Name;
                }
                else
                {
                    cbxValue.Text = currentValue.ToString();
                }
            }

            _bLoading = false;
        }
        public void SetUp(IActivateItems activator, ArgumentValueUIArgs args)
        {
            _args = args;

            try
            {
                Type t = _args.Type;

                string expectedUIClassName = t.FullName + "UI";

                _uiType = _args.CatalogueRepository.MEF.GetType(expectedUIClassName);

                //if we did not find one with the exact name (including namespace), try getting it just by the end of it's name (omit namespace)
                if (_uiType == null)
                {
                    string shortUIClassName = t.Name + "UI";
                    var    candidates       = _args.CatalogueRepository.MEF.GetAllTypes().Where(type => type.Name.Equals(shortUIClassName)).ToArray();

                    if (candidates.Length > 1)
                    {
                        throw new Exception("Found " + candidates.Length + " classes called '" + shortUIClassName + "' : (" + string.Join(",", candidates.Select(c => c.Name)) + ")");
                    }

                    if (candidates.Length == 0)
                    {
                        throw new Exception("Could not find UI class called " + shortUIClassName + " make sure that it exists, is public and is marked with class attribute ");
                    }

                    _uiType = candidates[0];
                }


                btnLaunchCustomUI.Text  = "Launch Custom UI (" + _uiType.Name + ")";
                btnLaunchCustomUI.Width = btnLaunchCustomUI.PreferredSize.Width;
            }
            catch (Exception)
            {
                btnLaunchCustomUI.Enabled = false;
            }
        }
Exemplo n.º 10
0
        public IArgumentValueUI HandleCreateForIMapsDirectlyToDatabaseTable(ArgumentValueUIArgs args)
        {
            //value is in IMapsDirectly type e.g. .Catalogue/TableInfo or something
            object[] array;

            var argumentType = args.Type;

            //if it is an interface e.g. IExternalDatabaseServer look for ExternalDatabaseServer
            if (argumentType.IsInterface)
            {
                var implmenetationType = args.CatalogueRepository.MEF.GetType(args.Type.Name.Substring(1));
                if (implmenetationType != null)
                {
                    argumentType = implmenetationType;
                }
            }

            //Populate dropdown with the appropriate types
            if (argumentType == typeof(TableInfo))
            {
                array = GetTableInfosInScope(args.CatalogueRepository, args.Parent).ToArray(); //explicit cases where selection is constrained somehow
            }
            else if (argumentType == typeof(ColumnInfo))
            {
                array = GetColumnInfosInScope(args.CatalogueRepository, args.Parent).ToArray();
            }
            else if (argumentType == typeof(PreLoadDiscardedColumn))
            {
                array = GetAllPreloadDiscardedColumnsInScope(args.CatalogueRepository, args.Parent).ToArray();
            }
            else if (argumentType == typeof(LoadProgress) && args.Parent is ProcessTask pt)
            {
                array = pt.LoadMetadata.LoadProgresses;
            }
            else
            {
                array = args.CatalogueRepository.GetAllObjects(argumentType).ToArray(); //Default case fetch all the objects of the Type
            }
            return(new ArgumentValueComboBoxUI(_activator, array));
        }
Exemplo n.º 11
0
        public void SetUp(IActivateItems activator, ArgumentValueUIArgs args)
        {
            _bLoading = true;
            _args     = args;

            tbText.Text = args.InitialValue == null ? "":args.InitialValue.ToString();

            if (args.Type == typeof(DirectoryInfo))
            {
                tbText.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
                tbText.AutoCompleteSource = AutoCompleteSource.FileSystemDirectories;
            }

            if (args.Type == typeof(CultureInfo))
            {
                tbText.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
                tbText.AutoCompleteSource = AutoCompleteSource.CustomSource;

                var collection = new AutoCompleteStringCollection();
                collection.AddRange(CultureInfo.GetCultures(CultureTypes.AllCultures).Select(c => c.Name).ToArray());

                tbText.AutoCompleteCustomSource = collection;
            }

            if (args.Type == typeof(FileInfo))
            {
                tbText.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
                tbText.AutoCompleteSource = AutoCompleteSource.FileSystem;
            }

            if (_isPassword)
            {
                tbText.UseSystemPasswordChar = true;
                var val = args.InitialValue;
                tbText.Text = val != null ? ((IEncryptedString)val).GetDecryptedValue() : "";
            }

            _bLoading = false;
        }
Exemplo n.º 12
0
 public void SetUp(IActivateItems activator, ArgumentValueUIArgs args)
 {
 }
Exemplo n.º 13
0
 public void SetUp(ArgumentValueUIArgs args)
 {
 }
Exemplo n.º 14
0
        public IArgumentValueUI Create(IActivateItems activator, ArgumentValueUIArgs args)
        {
            _activator = activator;
            var argumentType = args.Type;
            IArgumentValueUI toReturn;
            var catalogueRepository = args.CatalogueRepository;

            try
            {
                //if it's an array
                if (typeof(IDictionary).IsAssignableFrom(argumentType))
                {
                    toReturn = new ArgumentValueDictionaryUI();
                }
                else
                if (typeof(Array).IsAssignableFrom(argumentType))
                {
                    toReturn = new ArgumentValueArrayUI(activator);
                }
                else
                //if it's a pipeline
                if (typeof(IPipeline).IsAssignableFrom(argumentType))
                {
                    toReturn = new ArgumentValuePipelineUI(catalogueRepository, args.Parent, argumentType);
                }
                else if (typeof(bool) == argumentType)
                {
                    toReturn = new ArgumentValueBoolUI();
                }
                else if (args.Required.Demand.DemandType == DemandType.SQL)     //if it is SQL
                {
                    if (typeof(string) != argumentType)
                    {
                        throw new NotSupportedException(
                                  "Demanded type (of DemandsInitialization) was DemandType.SQL but the ProcessTaskArgument Property was of type " +
                                  argumentType + " (Expected String)");
                    }

                    toReturn = new ArgumentValueSqlUI();
                }
                else if (typeof(ICustomUIDrivenClass).IsAssignableFrom(argumentType))
                {
                    toReturn = new ArgumentValueCustomUIDrivenClassUI();
                }
                else if (argumentType == typeof(Type))
                {
                    //Handle case where Demand is for the user to pick a Type (derived from a given parent Type/Interface).  Use case for this is when you want them to pick e.g. a IDilutionOperation where these are a list of classes corrupt data to greater or lesser degree and can be plugin Types but all share the same parent interface IDilutionOperation

                    //There must be a shared parent Type for the user to  pick from
                    if (args.Required.Demand.TypeOf == null)
                    {
                        throw new NotSupportedException("Property " + args.Required.Name + " has Property Type '" +
                                                        argumentType +
                                                        "' but does not have a TypeOf specified (e.g. [DemandsInitialization(\"some desc\",DemandType.Unspecified,null,typeof(IDilutionOperation))]).  Without the typeof(X) we do not know what Types to advertise as selectable to the user");
                    }

                    toReturn =
                        new ArgumentValueComboBoxUI(activator,
                                                    catalogueRepository.MEF.GetAllTypes()
                                                    .Where(t => args.Required.Demand.TypeOf.IsAssignableFrom(t))
                                                    .ToArray());
                }
                else if (typeof(IMapsDirectlyToDatabaseTable).IsAssignableFrom(argumentType))
                {
                    toReturn = HandleCreateForIMapsDirectlyToDatabaseTable(args);
                }
                else if (typeof(Enum).IsAssignableFrom(argumentType))
                {
                    toReturn =
                        new ArgumentValueComboBoxUI(activator,
                                                    Enum.GetValues(argumentType).Cast <object>().ToArray());
                }
                else if (typeof(ICatalogueRepository).IsAssignableFrom(argumentType))
                {
                    toReturn = new ArgumentValueLabelUI("<this value cannot be set manually>");
                }
                else     //type is simple
                {
                    toReturn =
                        new ArgumentValueTextUI(isPassword: typeof(IEncryptedString).IsAssignableFrom(argumentType));
                }
            }
            catch (Exception e)
            {
                throw new Exception("A problem occured trying to create an ArgumentUI for Property '" + args.Required.Name + "' of Type '" + argumentType + "' on parent class of Type '" + args.Parent.GetClassNameWhoArgumentsAreFor() + "'", e);
            }

            ((Control)toReturn).Dock = DockStyle.Fill;

            toReturn.SetUp(activator, args);
            return(toReturn);
        }