Example #1
0
        private ActionFlow CopyAs(ActionFlow fq, string newName)
        {
            ActionFlow target = new ActionFlow();

            target.Name    = newName;
            target.Actions = new List <ActionImplementation>();

            Hashtable renamedIds = new Hashtable();

            foreach (ActionImplementation ai in fq.Actions)
            {
                Type                 t           = ai.GetType();
                ConstructorInfo      constructor = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) });
                object[]             parameters  = new object[] { Core };
                ActionImplementation obj         = (ActionImplementation)constructor.Invoke(parameters);
                obj.ID       = Guid.NewGuid().ToString("N");
                obj.Location = new System.Windows.Point(ai.Location.X, ai.Location.Y);
                obj.Values.AddRange(ai.Values);

                renamedIds.Add(ai.ID, obj.ID);
                target.Actions.Add(obj);
            }
            foreach (ActionImplementation ai in fq.Actions)
            {
                string actId             = (string)renamedIds[ai.ID];
                ActionImplementation act = (from a in target.Actions where a.ID == actId select a).FirstOrDefault();
                List <ActionImplementation.OutputConnectionInfo> srcCons = ai.GetOutputConnections();
                List <ActionImplementation.OutputConnectionInfo> dstCons = act.GetOutputConnections();
                foreach (ActionImplementation.OutputConnectionInfo con in srcCons)
                {
                    if (con.ConnectedAction != null)
                    {
                        ActionImplementation.OutputConnectionInfo nCon = new ActionImplementation.OutputConnectionInfo();
                        nCon.OutputOperator = con.OutputOperator;
                        string conToActId = renamedIds[con.ConnectedAction.ID] as string;
                        if (conToActId != null)
                        {
                            nCon.ConnectedAction = (from a in target.Actions where a.ID == conToActId select a).FirstOrDefault();
                        }
                        else
                        {
                            nCon.ConnectedAction = con.ConnectedAction;
                        }
                        dstCons.Add(nCon);
                    }
                }
            }
            return(target);
        }
Example #2
0
        private ActionFlow CopyAs(ActionFlow fq, string newName)
        {
            ActionFlow target = new ActionFlow();
            target.Name = newName;
            target.Actions = new List<ActionImplementation>();

            Hashtable renamedIds = new Hashtable();
            foreach (ActionImplementation ai in fq.Actions)
            {
                Type t = ai.GetType();
                ConstructorInfo constructor = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) });
                object[] parameters = new object[] { Core };
                ActionImplementation obj = (ActionImplementation)constructor.Invoke(parameters);
                obj.ID = Guid.NewGuid().ToString("N");
                obj.Location = new System.Windows.Point(ai.Location.X, ai.Location.Y);
                obj.Values.AddRange(ai.Values);

                renamedIds.Add(ai.ID, obj.ID);
                target.Actions.Add(obj);

            }
            foreach (ActionImplementation ai in fq.Actions)
            {
                string actId = (string)renamedIds[ai.ID];
                ActionImplementation act = (from a in target.Actions where a.ID == actId select a).FirstOrDefault();
                List<ActionImplementation.OutputConnectionInfo> srcCons = ai.GetOutputConnections();
                List<ActionImplementation.OutputConnectionInfo> dstCons = act.GetOutputConnections();
                foreach (ActionImplementation.OutputConnectionInfo con in srcCons)
                {
                    if (con.ConnectedAction != null)
                    {
                        ActionImplementation.OutputConnectionInfo nCon = new ActionImplementation.OutputConnectionInfo();
                        nCon.OutputOperator = con.OutputOperator;
                        string conToActId = renamedIds[con.ConnectedAction.ID] as string;
                        if (conToActId != null)
                        {
                            nCon.ConnectedAction = (from a in target.Actions where a.ID == conToActId select a).FirstOrDefault();
                        }
                        else
                        {
                            nCon.ConnectedAction = con.ConnectedAction;
                        }
                        dstCons.Add(nCon);
                    }
                }
            }
            return target;
        }