Example #1
0
        public List <UIOutputItem> FindNextChildrenInChain(UIOutputItem output)
        {
            List <UIOutputItem> items = new List <UIOutputItem>();

            foreach (UIOutputItem source in Sources)
            {
                UIOutputItem parent = source;

                bool found = false;

                while (parent.Parent != null)
                {
                    if (parent.Parent == output || parent.Parent.ExchangeItem == output.ExchangeItem)
                    {
                        found = true;
                        break;
                    }

                    parent = parent.Parent;
                }

                if (found)
                {
                    items.Add(parent);
                }
            }

            return(items);
        }
Example #2
0
        bool CheckOutputItemEqual(UIOutputItem item1, UIOutputItem item2)
        {
            if (item1 != null && item2 != null && item1 == item2 || item1.ExchangeItem == item2.ExchangeItem)
            {
                return(true);
            }

            return(false);
        }
Example #3
0
        string GetOutputItemString(UIOutputItem item)
        {
            string       toString = item.ToString();
            UIOutputItem parent   = item.Parent;

            while (parent != null)
            {
                toString = parent + " => " + toString;
                parent   = parent.Parent;
            }

            return(toString);
        }
Example #4
0
        public UIAdaptedOutputItem NewAdaptedUIOutputItem(string decoratorId, UIOutputItem parent, ITimeSpaceInput target)
        {
            IIdentifiable[] ids = _factory.GetAvailableAdaptedOutputIds(parent.TimeSpaceOutput, target);

            IIdentifiable found = (from n in ids
                                   where n.Id == decoratorId select n).FirstOrDefault();

            IBaseAdaptedOutput iAdapted = _factory.CreateAdaptedOutput(found, parent.TimeSpaceOutput, target);

            UIAdaptedOutputItem item = new UIAdaptedOutputItem(this, found, (ITimeSpaceAdaptedOutput)iAdapted, parent);

            parent.AddAdaptedOutput(item.TimeSpaceAdaptedOutput);

            return(item);
        }
Example #5
0
        public static List <UIOutputItem> ParentChain(UIOutputItem item)
        {
            List <UIOutputItem> parentChain = new List <UIOutputItem>();

            UIOutputItem parent = item;

            while (parent != null)
            {
                parentChain.Add(parent);
                parent = parent.Parent;
            }

            parentChain.Reverse();

            return(parentChain);
        }
Example #6
0
        public UIOutputItem FindInChain(ITimeSpaceOutput output)
        {
            foreach (UIOutputItem source in Sources)
            {
                UIOutputItem parent = source;

                while (parent != null)
                {
                    if (parent.ExchangeItem == output)
                    {
                        return(parent);
                    }

                    parent = parent.Parent;
                }
            }

            return(null);
        }
Example #7
0
        static oprConnectionDecorator[] Decorators(UIConnection connection, DirectoryInfo oprPath, out List <UIAdaptedOutputItem> allAdaptersInConnection)
        {
            allAdaptersInConnection = new List <UIAdaptedOutputItem>();

            UIOutputItem adapter = null;

            foreach (Link link in connection.Links)
            {
                foreach (UIOutputItem source in link.Sources)
                {
                    adapter = source;

                    while (adapter != null && adapter is UIAdaptedOutputItem)
                    {
                        if (!allAdaptersInConnection.Contains((UIAdaptedOutputItem)adapter))
                        {
                            allAdaptersInConnection.Add((UIAdaptedOutputItem)adapter);
                        }

                        adapter = adapter.Parent;
                    }
                }
            }

            oprConnectionDecorator[] oprDecorators = new oprConnectionDecorator[allAdaptersInConnection.Count];

            for (int n = 0; n < allAdaptersInConnection.Count; ++n)
            {
                oprDecorators[n]         = new oprConnectionDecorator();
                oprDecorators[n].item_id = allAdaptersInConnection[n].Id;
                oprDecorators[n].factory = allAdaptersInConnection[n].Factory.Persist(oprPath);

                IList <IArgument> ars = ((ITimeSpaceAdaptedOutput)allAdaptersInConnection[n].TimeSpaceOutput).Arguments;

                oprDecorators[n].arguments = DecoratorArgs(new List <IArgument>(ars).ToArray());
            }

            return(oprDecorators);
        }
Example #8
0
 public UIAdaptedOutputItem(UIAdaptedFactory factory, IIdentifiable decoratorId, ITimeSpaceAdaptedOutput item, UIOutputItem parent)
     : base(item, parent)
 {
     _factory     = factory;
     _decoratorId = decoratorId;
 }
Example #9
0
 public UIOutputItem(ITimeSpaceOutput item, UIOutputItem parent = null)
     : base(item)
 {
     _parent = parent;
 }
Example #10
0
 public Link(UIOutputItem source, UIInputItem target)
 {
     _sources = new List <UIOutputItem>();
     _target  = target;
     _sources.Add(source);
 }
Example #11
0
        // TODO Wrap Arguments so that exception thrown to indicate invalid value
        // can be caught and presented to the user.
        // e.g. valueA now = fred, valueB can only be ethal or freda
        //

        // Arguments list members (count as well as values) can change depending on
        // values of other arguments.
        // So say, 1 argument firstly which is file name to another list of
        // arguments to then display.

        // OpenWEB
        // model file change throws exception saying reload required
        // pipistrelle reconises exception_openweb type and reloads automatically

        static List <UIConnection> DeserializeConnectionsV2(opr opr, List <UIModel> models, DirectoryInfo oprPath)
        {
            List <UIConnection> connections = new List <UIConnection>();

            if (opr.connections == null)
            {
                return(connections);
            }

            Dictionary <string, UIAdaptedOutputItem> adaptedOutputs = new Dictionary <string, UIAdaptedOutputItem>();

            UIInputItem target;

            UIModel      uiSourceModel, uiTargetModel;
            UIConnection uiConnection;

            Dictionary <string, UIOutputItem> sources = new Dictionary <string, UIOutputItem>();
            Dictionary <string, UIInputItem>  targets = new Dictionary <string, UIInputItem>();
            List <Link> links = new List <Link>();


            foreach (oprConnection connection in opr.connections)
            {
                if (!connection.source_model_indexSpecified || !connection.target_model_indexSpecified)
                {
                    throw new NotImplementedException("Incompletly specified connections");
                }

                uiSourceModel = models[connection.source_model_index];
                uiTargetModel = models[connection.target_model_index];

                uiConnection = new UIConnection(uiSourceModel, uiTargetModel);
                connections.Add(uiConnection);

                sources.Clear();
                targets.Clear();

                foreach (ITimeSpaceOutput item in uiSourceModel.LinkableComponent.Outputs)
                {
                    sources.Add(item.Id, new UIOutputItem(item));
                }

                foreach (ITimeSpaceInput item in uiTargetModel.LinkableComponent.Inputs)
                {
                    targets.Add(item.Id, new UIInputItem(item));
                }

                # region delete later
                //nDecorators =  connection.decorators != null ? connection.decorators.Length : 0;

                //ids = new string[nDecorators];
                //oprFactories = new oprConnectionDecoratorFactory[nDecorators];
                //oprArguments = new oprConnectionDecoratorArgument[nDecorators][];

                //for (int n = 0; n < nDecorators; ++n)
                //{
                //    ids[n] = connection.decorators[n].item_id;
                //    oprFactories[n] = connection.decorators[n].factory;
                //    oprArguments[n] = connection.decorators[n].arguments;
                //}

                #endregion

                links = new List <Link>();

                foreach (oprConnectionLink oprLink in connection.links)
                {
                    target = targets[oprLink.target_item_id];

                    oprSourceItem       srcItem  = oprLink.source_item_id;
                    List <UIOutputItem> sourcesm = new List <UIOutputItem>();
                    UIOutputItem        source   = BuildOutputItemChain(uiSourceModel.LinkableComponent, srcItem, connection.decorators, sources, adaptedOutputs, oprPath, target);


                    foreach (oprSourceItem item in oprLink.source_item_ids)
                    {
                        UIOutputItem tempSrc = BuildOutputItemChain(uiSourceModel.LinkableComponent, item, connection.decorators, sources, adaptedOutputs, oprPath, target);
                        sourcesm.Add(tempSrc);
                    }



                    // Just telling target about most decorated source,
                    // not the intermediates (& visa versa).
                    // Probably the safest option re ensuring UI works
                    // in maximum number of cases.
                    // Thats what the UIOuputItem.Parent attribute is for!
                    // TODO ADH: However, might want
                    // to make explicit in Standard?

                    if (target.ExchangeItem is IBaseMultiInput)
                    {
                        IBaseMultiInput mtarget = (IBaseMultiInput)target.ExchangeItem;

                        foreach (UIOutputItem tempout in sourcesm)
                        {
                            mtarget.AddProvider(tempout);
                            tempout.AddConsumer(mtarget);
                        }
                    }
                    else
                    {
                        target.Provider = source;
                        source.AddConsumer(target);
                    }

                    Link tempLink = new Link(sourcesm, target);
                    //tempLink.Source = source;

                    links.Add(tempLink);
                }

                uiConnection.Links = links;
            }