Ejemplo n.º 1
0
 private void InitialiseThePipeLine()
 {
     yahooPipeline = new PipeLine<YahooProjectedPointsMessage>();
      yahooPipeline.Register( msg => new LoadPlayerGameMetric( msg ) );
      yahooPipeline.Register( msg => new AddYahooPassingPoints( msg ) );
      yahooPipeline.Register( msg => new AddYahooRushingPoints( msg ) );
      yahooPipeline.Register( msg => new AddYahooReceivingPoints( msg ) );
     yahooPipeline.Register( msg => new AddYahooKickingPoints(msg));
 }
Ejemplo n.º 2
0
        public async Task Compose_Should_Compute_Result_OK(int iin, int iout)
        {
            var current = Thread.CurrentThread;
            var pip     = PipeLine.Create(_Func.Function).Next(_Func2.Function).Next(_Act.Action);
            await pip.Consume(iin);

            _Func.LastIn.Should().Be(iin);

            _Func2.LastOut.Should().Be(iout);
            _Func2.CallingThread.Should().NotBe(current);
            _Func2.CallingThread.Should().NotBe(_Func.CallingThread);

            _Act.Threads.Count.Should().Be(1);
            _Act.CallingThread.Should().NotBe(current);
            _Act.CallingThread.Should().NotBe(_Func.CallingThread);
        }
Ejemplo n.º 3
0
        public async Task Next_Action_With_Paralelism_Parameter_Should_Compute_Result_OK()
        {
            var current = Thread.CurrentThread;

            var pipe = PipeLine.Create(_Func3.Function).Next(_Act3.Action, 5);

            await Task.WhenAll(Enumerable.Range(0, 100).Select(i => pipe.Consume(i)));


            _Func3.Threads.Count.Should().Be(1);
            _Func3.CallingThread.Should().NotBe(current);

            _Act3.Threads.Count.Should().Be(5);
            _Act3.Threads.Should().NotContain(_Func4.CallingThread);
            _Act3.Threads.Should().NotContain(current);
        }
Ejemplo n.º 4
0
        public void ConditionalConnectorTests_BasicConnectPipes()
        {
            //         2
            //       /   \
            // -> 1-+--3--+-5
            //       \   /
            //         4
            var pipeLine = new PipeLine()
                           .Pipe(load => load["pipe1"] = true)
                           .ConnectWhen((pipes, load) =>
            {
                var chosenPath = load["ChosenPipe"].ToString();
                return(pipes.OfType <NamedPipe>().First(p => p.Name == chosenPath));
            })
                           .Pipe("pipe2", load => load["pipe2"] = true)
                           .Pipe("pipe3", load => load["pipe3"] = true)
                           .Pipe("pipe4", load => load["pipe4"] = true)
                           .Join()
                           .Pipe(load => load["pipe5"] = true)
                           .Finish();

            var path125 = new Dictionary <string, object> {
                ["ChosenPipe"] = "pipe2"
            };
            var path135 = new Dictionary <string, object> {
                ["ChosenPipe"] = "pipe3"
            };
            var path145 = new Dictionary <string, object> {
                ["ChosenPipe"] = "pipe4"
            };

            pipeLine.Run(path125);
            pipeLine.Run(path135);
            pipeLine.Run(path145);

            Assert.AreEqual(path125["pipe1"], true);
            Assert.AreEqual(path125["pipe2"], true);
            Assert.AreEqual(path125["pipe5"], true);

            Assert.AreEqual(path135["pipe1"], true);
            Assert.AreEqual(path135["pipe3"], true);
            Assert.AreEqual(path135["pipe5"], true);

            Assert.AreEqual(path145["pipe1"], true);
            Assert.AreEqual(path145["pipe4"], true);
            Assert.AreEqual(path145["pipe5"], true);
        }
Ejemplo n.º 5
0
        public bool StartDraw(out bool status)
        {
            status = false;
            Editor   ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = HostApplicationServices.WorkingDatabase;

            if (this.startPoint == null)
            {
                PromptPointOptions opt = new PromptPointOptions("\n 选择管道的初始点");
                PromptPointResult  res = ed.GetPoint(opt);
                if (res.Status == PromptStatus.Cancel)
                {
                    status = true;
                }
                if (res.Status != PromptStatus.OK)
                {
                    return(false);
                }
                this.startPoint = res.Value;
            }
            mline = new Mline();
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                DBDictionary mlineStyleDic = (DBDictionary)tr.GetObject(db.MLStyleDictionaryId, OpenMode.ForRead);
                mline.Style = mlineStyleDic.GetAt("MLINEJIG");
            }
            mline.Normal = Vector3d.ZAxis;
            mline.Scale  = PipeLine.GetScale();
            mline.AppendSegment((Point3d)this.startPoint);
            mline.AppendSegment((Point3d)this.startPoint);
            PromptResult res2 = ed.Drag(this);

            if (res2.Status == PromptStatus.OK)
            {
                return(true);
            }
            else if (res2.Status == PromptStatus.Cancel || res2.Status == PromptStatus.None)
            {
                if (res2.Status == PromptStatus.Cancel)
                {
                    status = true;
                }
                return(false);
            }
            return(true);
        }
Ejemplo n.º 6
0
        public async Task Composition7()
        {
            Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
            var finaliser1 = PipeLine.Create <int>(i => Console.WriteLine("{0} {1}", Thread.CurrentThread.ManagedThreadId, i));

            Func <int, int> M3 = i => { Console.WriteLine("M3 {0}", Thread.CurrentThread.ManagedThreadId); return(i * 3); };
            Func <int, int> M5 = i => { Console.WriteLine("M5 {0}", Thread.CurrentThread.ManagedThreadId); return(i * 5); };

            var pip1 = PipeLine.Create <int, int>(M3).Next(finaliser1);
            var pip2 = PipeLine.Create <int, int>(M5).Next(finaliser1);

            var pip = PipeLine.Create <int, int>(a => a * 2).Next(pip1, pip2);

            await pip.Consume(1);

            await pip.Consume(10);
        }
Ejemplo n.º 7
0
        public void InvokeTest()
        {
            var source = new[] { 1, 2, 3, 4, 5 };

            using (var p = new PipeLine(CancellationToken.None)) {
                var first  = p.Add(1, 10, source, i => i * 10);
                var second = p.AddSelectMany(1, 100, first.Results, i => Enumerable.Range(0, i));
                var list   = new List <int>();
                p.Invoke(() => { list.AddRange(second.Results.GetConsumingEnumerable()); });

                foreach (var x in list.OrderBy(x => x).Zip(source.Select(x => x * 10).SelectMany(x => Enumerable.Range(0, x)).OrderBy(x => x),
                                                           (s, t) => new { s, t }))
                {
                    Assert.Equal(x.s, x.t);
                }
            }
        }
Ejemplo n.º 8
0
        public async Task Compose_Parralel_Should_Compute_Result_OK_NoParameter()
        {
            var current = Thread.CurrentThread;

            var fin = PipeLine.Create(_Act.Action);

            var pip1 = PipeLine.Create(_Func.Function).Next(fin);
            var pip2 = PipeLine.Create(_Func2.Function).Next(fin);

            var pip = PipeLine.Create <int, int>(a => a * 2).Next(pip1, pip2);

            await pip.Consume(1);

            _Act.Threads.Count.Should().Be(1);
            _Act.CallingThread.Should().NotBe(current);
            _Act.CallingThread.Should().NotBe(_Func.CallingThread);
            _Act.CallingThread.Should().NotBe(_Func2.CallingThread);
        }
Ejemplo n.º 9
0
        public void Connect_Should_Compute_Result_OK()
        {
            var current = Thread.CurrentThread;

            var pipe = PipeLine.Create(_Func.Function).Next(_Act.Action);

            var obs = Observable.Range(0, 100);
            var res = Enumerable.Range(0, 100).Select(_Func.Function);

            var disp = pipe.Connect(obs);

            Thread.Sleep(10);

            _Act.Threads.Count.Should().Be(1);
            _Act.Results.Should().BeEquivalentTo(res);

            disp.Dispose();
        }
Ejemplo n.º 10
0
        public void ThenSelectManyBufferTest()
        {
            using (var p = new PipeLine(CancellationToken.None)) {
                var x = p.InitSelectMany(Enumerable.Range(0, 100), 10, 10, i => Enumerable.Repeat(i, 3));
                var y = x.Buffer(10, 10);
                Assert.NotSame(x, y);
                Assert.Same(y, x.Next);
                Assert.Null(y.Next);

                var s = p.Start(() => {
                    Assert.Equal(
                        Enumerable.Range(0, 100).SelectMany(i => Enumerable.Repeat(i, 3)).Sum(),
                        y.Out.SelectMany(i => i).Sum()
                        );
                });
                Assert.Equal(PipeLine.PipeLineStatus.Completed, s);
            }
        }
Ejemplo n.º 11
0
 public void Exceptions()
 {
     using (var p = new PipeLine(CancellationToken.None)) {
         Assert.Throws <PipeLineException>(() => p.Init(Enumerable.Range(0, 10), 0, 0, i => i));
         Assert.Throws <PipeLineException>(() => p.Init(Enumerable.Range(0, 10), 1, 0, i => i));
         Assert.Throws <PipeLineException>(() => p.Init(Enumerable.Range(0, 10), 0, 1, i => i));
         var init = p.Init(Enumerable.Range(0, 10), 10, 10, i => i);
         Assert.Throws <PipeLineException>(() => init.Then(0, 0, i => i * i));
         Assert.Throws <PipeLineException>(() => init.Then(0, 1, i => i * i));
         Assert.Throws <PipeLineException>(() => init.Then(1, 0, i => i * i));
         Assert.Throws <PipeLineException>(() => init.ThenSelectMany(0, 0, i => $"{i}"));
         Assert.Throws <PipeLineException>(() => init.ThenSelectMany(0, 1, i => $"{i}"));
         Assert.Throws <PipeLineException>(() => init.ThenSelectMany(1, 0, i => $"{i}"));
         Assert.Throws <PipeLineException>(() => init.Buffer(0, 0));
         Assert.Throws <PipeLineException>(() => init.Buffer(0, 1));
         Assert.Throws <PipeLineException>(() => init.Buffer(1, 0));
     }
 }
Ejemplo n.º 12
0
        protected BaseStatefulServiceInstance(
            CoreDependencies coreDependencies,
            StatefulDependencies statefulDependencies) : base(coreDependencies)
        {
            _stateRepository    = statefulDependencies.StateRepository;
            _currentEnvironment = coreDependencies.EnvironmentResolver.Environment;
            CreatedDate         = ServiceClock.CurrentTime();
            ModifiedDate        = CreatedDate;

            // REMOVE THE DEFAULT VALIDATION AND REPLACE WITH THE STATEFUL VALIDATION SERVICE
            var existingValidation = PipeLine.FirstOrDefault(x => typeof(ValidationMiddleware) == x.GetType());
            var idx = PipeLine.IndexOf(existingValidation);

            PipeLine.RemoveAt(idx);
            PipeLine.Insert(idx, new StateMachineValidatorMiddleware <TTrigger>(coreDependencies.RequestValidator));

            _data   = new TData();
            Machine = new StateMachine <TState, TTrigger>(() => _data.State, s => _data.State = s);
            Machine.OnTransitionCompletedAsync(OnTransitionAction);
        }
Ejemplo n.º 13
0
        public void ThenThenTest()
        {
            using (var p = new PipeLine(CancellationToken.None)) {
                var x = p.Init(Enumerable.Range(0, 100), 10, 10, i => i * i);
                var y = x.Then(10, 10, i => i + 1);
                var z = y.Then(10, 10, i => i * 2);

                Assert.NotSame(x, y);
                Assert.Same(y, x.Next);
                Assert.Same(z, y.Next);

                var s = p.Start(() => {
                    Assert.Equal(
                        Enumerable.Range(0, 100).Select(i => (i * i + 1) * 2).Sum(),
                        z.Out.Sum()
                        );
                });
                Assert.Equal(PipeLine.PipeLineStatus.Completed, s);
            }
        }
Ejemplo n.º 14
0
        public async Task Compose_Parralel_Should_Compute_Result_OK(int entry, int s1, int s2)
        {
            var current    = Thread.CurrentThread;
            var finaliser1 = PipeLine.Create(_Func.Function).Next(_Act.Action);
            var finaliser2 = PipeLine.Create(_Func3.Function).Next(_Act2.Action);

            await PipeLine.Create <int, int>(a => a).Next(finaliser1, finaliser2).Consume(entry);


            _Func.LastIn.Should().Be(entry);
            _Func.LastOut.Should().Be(s1);

            _Func3.LastIn.Should().Be(entry);
            _Func3.LastOut.Should().Be(s2);

            _Func3.CallingThread.Should().NotBe(current);
            _Func3.CallingThread.Should().NotBe(_Func.CallingThread);

            _Func.CallingThread.Should().NotBe(current);
            _Func.CallingThread.Should().NotBe(_Func3.CallingThread);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Cancels the currently executing pipeline by instructing it to abort
 /// </summary>
 public override void Cancel()
 {
     if (PipeLine != null)
     {
         try
         {
             Log.LogDebug("WARNING: Aborting pipeline due to cancellation");
             PipeLine.Abort();
         }
         catch (Exception e)
         {
             Log.LogError(e, "Exception occurred during pipeline cancellation");
             // Just in case the pipeline commits suicide before other related tasks are
             // cancelled (and so also inform the pipeline that it is cancelled), swallow
             // any exception generated for the abort request.
         }
         finally
         {
             Log.LogInformation("Nulling pipeline reference");
             PipeLine = null;
         }
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Read specific message off the defined error queue and move it to the user defined read queue
        /// </summary>
        public void ReturnErrorMessage(string id)
        {
            GuardAgainstInvalidReadQueue();
            GuardAgainstInvalidErrorQueue();

            try
            {
                // configure the pipeline for return a message to its original queue
                var pipe = new PipeLine <MessageContext>();
                pipe.AddAspect(new TransactionAspect <MessageContext>());
                pipe.AddAspect(new LoggingAspect <MessageContext>());
                pipe.Register(new ReturnToSource());

                Message message = _errorQueue.PeekMessageBy(id);
                var     ctx     = new MessageContext {
                    Message = message, Config = _config, ReadQueue = _readQueue, ErrorQueue = _errorQueue, OpType = ReturnOperation, OnStep = LogMessage
                };
                pipe.Invoke(ctx);
            }
            catch (Exception)
            {
                throw new BusException($"Message with id {id} was not found on the error queue");
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Reads a specific message off a queue, deserializes it into the
        /// specified type T and invokes registered handlers.
        /// </summary>
        public void ReceiveOne <T>(string id)
        {
            GuardAgainstInvalidReadQueue();
            GuardAgainstInvalidErrorQueue();

            // configure the pipeline for receiving messages
            var pipe = new PipeLine <MessageContext>();

            pipe.AddAspect(new FailFastAspect <MessageContext>());
            pipe.AddAspect(new DiscardAspect <MessageContext>());
            pipe.AddAspect(new TransactionAspect <MessageContext>());
            pipe.AddAspect(new LoggingAspect <MessageContext>());
            pipe.AddAspect(new MoveToErrorQueueAspect <MessageContext>());
            pipe.AddAspect(new RemoveFromReadQueueAspect <MessageContext>());
            pipe.AddAspect(new RetryAspect <MessageContext>());
            pipe.Register(new InvokeUserHandlers <T>());

            Message message = _readQueue.PeekMessageBy(id);
            var     ctx     = new MessageContext {
                Message = message, Config = _config, ReadQueue = _readQueue, ErrorQueue = _errorQueue, Handlers = _handlers, OpType = ReceiveOperation, OnStep = LogMessage
            };

            pipe.Invoke(ctx);
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            SystemStart = ActorSystem.Create("SystemStart");

            var pipeline = new PipeLine(new DataflowOptions
            {
                MonitorInterval        = TimeSpan.FromSeconds(2),
                PerformanceMonitorMode = DataflowOptions.PerformanceLogMode.Verbose,
                //FlowMonitorEnabled = false,
                //BlockMonitorEnabled = false,
                RecommendedCapacity = 10000,
                RecommendedParallelismIfMultiThreaded = 64,
            }, 20);

            var actor = SystemStart.ActorOf(Props.Create(() =>
                                                         new ProviderBatchActor(@"C:\Users\eduar\Desktop\lista_cnpj2.txt", pipeline)),
                                            ActorPath.Provider.Name);

            actor.Tell(new MessageReader {
                CountBatch = 20, RefPointer = 0
            });

            SystemStart.WhenTerminated.Wait();
        }
Ejemplo n.º 19
0
        public CoordinatorBatchActor(PipeLine pipeline)
        {
            _pipeline = pipeline;

            Processing();
        }
Ejemplo n.º 20
0
        public void restore()
        {
            isReStoring = true;
            if (Application.DocumentManager.MdiActiveDocument == null)
            {
                return;
            }
            Application.DocumentManager.MdiActiveDocument.Database.ObjectAppended -= Database_ObjectAppended;
            globalProperty = new GlobalProperty(true);
            Utility.ImportBlocks();
            BindEventListener();
            showSolution();
            BaseModel.ApplicationBaseModels.Clear();
            buildings.Clear();
            solutions.Clear();
            ToolPanel.changedEntityList.Clear();
            currentSolution = null;
            this.LoadMLineStyle();
            if (Application.DocumentManager.MdiActiveDocument == null)
            {
                return;
            }
            //先将所有注册的对象都清空!
            using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                globalProperty.Initialize();
                Document doc = Application.DocumentManager.MdiActiveDocument;
                Editor   ed  = doc.Editor;
                Database db  = HostApplicationServices.WorkingDatabase;
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    //首先重建所有的Solution
                    LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForWrite, false);
                    foreach (ObjectId layerId in lt)
                    {
                        //设置图层颜色
                        LayerTableRecord            ltr   = (LayerTableRecord)trans.GetObject(layerId, OpenMode.ForWrite);
                        Dictionary <String, String> pairs = BaseModel.Load(layerId);
                        if (pairs != null && pairs.ContainsKey("type") && pairs["type"].CompareTo("solution") == 0)
                        {
                            ChromeTabItem chrometabitem = solutionPanel.chrometabs.RestoreTab(new System.Windows.Controls.Label(), false);
                            chrometabitem.CanDelete = true;
                            solutionPanel.AddCloseHandler(chrometabitem);
                            Solution solution = new Solution(false);
                            solution.ResetAttributes(pairs, layerId);
                            solution.RestoreAttributes();
                            solution.TabItem     = chrometabitem;
                            chrometabitem.Header = solution.SolutionName;
                            solutions.Add(solution);
                        }
                        else if (ltr.Name != "our_outline_layer" && (pairs == null || !pairs.ContainsKey("type")))
                        {
                            ltr.Color = Autodesk.AutoCAD.Colors.Color.FromColor(System.Drawing.Color.Gray);
                        }
                    }
                    trans.Commit();
                    trans.Dispose();
                }
                using (Transaction trans1 = db.TransactionManager.StartTransaction())
                {
                    LayerTable lt = (LayerTable)db.LayerTableId.GetObject(OpenMode.ForWrite);
                    foreach (var layerid in lt)
                    {
                        LayerTableRecord ltr = (LayerTableRecord)layerid.GetObject(OpenMode.ForRead);
                        if (ltr.Name.Contains("outline_layer") || ltr.Name.Contains("方案"))
                        {
                            TypedValue[] tvs = new TypedValue[1] {
                                new TypedValue((int)DxfCode.LayerName, (ltr.Name))
                            };
                            SelectionFilter       sf  = new SelectionFilter(tvs);
                            PromptSelectionResult psr = ed.SelectAll(sf);
                            if (psr.Value != null)
                            {
                                foreach (var objectid in psr.Value.GetObjectIds())
                                {
                                    Dictionary <String, String> pairs = BaseModel.Load(objectid);
                                    if (pairs != null && pairs.ContainsKey("type"))
                                    {
                                        String type = pairs["type"];
                                        if (type.CompareTo(Building.modelType) == 0)
                                        {
                                            Building b = new Building(false);
                                            b.ResetAttributes(pairs, objectid);
                                            buildings.Add(objectid, b);
                                        }
                                        else if (type.CompareTo(HeatProducer.modelType) == 0)
                                        {
                                            var b = new HeatProducer();
                                            b.ResetAttributes(pairs, objectid);
                                        }
                                        else if (type.CompareTo(SubStation.modelType) == 0)
                                        {
                                            var b = new SubStation();
                                            b.ResetAttributes(pairs, objectid);
                                        }

                                        else if (type.CompareTo(PipeLine.modelType) == 0)
                                        {
                                            var b = new PipeLine();
                                            b.ResetAttributes(pairs, objectid);
                                            b.RetriveMline();
                                        }
                                        else if (type.CompareTo(District.modelType) == 0)
                                        {
                                            var d = new District();
                                            d.ResetAttributes(pairs, objectid);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    trans1.Dispose();
                }
                using (Transaction trans2 = db.TransactionManager.StartTransaction())
                {
                    //然后遍历所有的管道结头
                    DBDictionary groups = trans2.GetObject(db.GroupDictionaryId, OpenMode.ForRead) as DBDictionary;
                    foreach (DBDictionaryEntry entry in groups)
                    {
                        ObjectId objId = entry.Value;
                        Dictionary <String, String> pairs = BaseModel.Load(objId);
                        if (pairs != null && pairs.ContainsKey("type"))
                        {
                            string type = pairs["type"];
                            if (type.CompareTo(SimplePipeJoint.modelType) == 0)
                            {
                                var b = new SimplePipeJoint();
                                b.ResetAttributes(pairs, objId);
                                b.Retrive();
                            }
                            if (type.CompareTo(MultiPipeJoint.modelType) == 0)
                            {
                                var b = new MultiPipeJoint();
                                b.ResetAttributes(pairs, objId);
                                b.Retrive();
                            }
                        }
                        // }
                    }
                    trans2.Dispose();
                }
                foreach (var item in BaseModel.ApplicationBaseModels)
                {
                    item.Value.RestoreAttributes();
                }

                if (globalProperty.ActiveTab == -1 || globalProperty.ActiveTab == 0)
                {
                    solutionPanel.SelectOutLineLayer();
                    HeatSourceLayoutApp.currentSolution = null;
                }
                else
                {
                    foreach (var i_solution in solutions)
                    {
                        if (i_solution.SId == globalProperty.ActiveTab)
                        {
                            solutionPanel.chrometabs.ChangeSelectedItem(i_solution.TabItem);
                            HeatSourceLayoutApp.currentSolution = i_solution;
                            break;
                        }
                    }
                }
            }
            isReStoring = false;
            Application.DocumentManager.MdiActiveDocument.Database.ObjectAppended += Database_ObjectAppended;
        }
 /// <summary>
 /// 从一固定点创建管道
 /// </summary>
 /// <param name="startPoint"></param>
 /// <returns>返回结果如上</returns>
 public Point3d? CreatePipeLineConnectedPipeLine(Point3d startPoint, out bool status)
 {
     PipeLine newPipeline = null;
     PipeJig jig = new PipeJig(startPoint);
     if (!jig.StartDraw(out status)) { return null; }
     newPipeline = new PipeLine((Point3d)jig.startPoint, jig.endPoint, false, this);
     return this.PipeLineCrossTest(newPipeline);
 }
 /// <summary>
 /// 每一次创建管道的时候初始状态获取点的方式是从界面上选取一点
 /// 后面都是从上一次的尾点开始
 /// </summary>
 /// <returns>空或者尾点坐标,空意味着管道创建结束</returns>
 public Point3d? CreatePipeLineWithoutInitialPoint(out bool status)
 {
     status = false;
     PipeLine newPipeLine = null;
     PipeJig jig = new PipeJig(null);
     if (!jig.StartDraw(out status)) { return null; }
     newPipeLine = new PipeLine((Point3d)jig.startPoint, jig.endPoint, false, this);
     //相交测试
     //和简单接口测试相交
     return this.PipeLineCrossTest(newPipeLine);
 }
Ejemplo n.º 23
0
 public SpaceCommand(Key key, PipeLine pipeLine) :
     base(key)
 {
     this.pipeLine = pipeLine;
 }
 private void InitialiseThePipeLine()
 {
     pipeline = new PipeLine<PlayerGameProjectionMessage>();
      pipeline.Register( msg => new GetGamePrediction( msg ) );
      pipeline.Register( msg => new ClearGameMetrics( msg ) );
      //  this takes most of the time
      pipeline.Register( msg => new PullMetricsFromPrediction( msg ) );
      pipeline.Register( msg => new SavePlayerGameMetrics( msg ) );
 }
        /// <summary>
        /// 从node节点出发不经过parent节点的最长路径
        /// </summary>
        /// <param name="parent">node的上一访问节点</param>
        /// <param name="node">node几点</param>
        /// <param name="pipes">从node节点出发不经过parent节点的最长路径的距离</param>
        /// <returns>最长路径的大小</returns>
        public double GetPipeLineLength(PipeLine parent, PipeLine node, out List<PipeLine> pipes)
        {
            pipes = new List<PipeLine>();
            if (node.HeadConnectedObject == null)
            {
                pipes.Add(node);
                return node.CalculateLength();
            }
            if (node.TailConnectedObject == null)
            {
                pipes.Add(node);
                return node.CalculateLength();
            }
            if (node.IsVisit == false)
            {
                node.IsVisit = true;
                ReadOnlyCollection<PipeLine> children = null;
                if (node.HeadConnectedObject.ConnectedPipes.Contains(parent) == true)
                {
                    children = node.TailConnectedObject.ConnectedPipes;
                }
                if (node.TailConnectedObject.ConnectedPipes.Contains(parent) == true)
                {
                    children = node.HeadConnectedObject.ConnectedPipes;
                }
                double max = 0;

                foreach (var item in children)
                {
                    if (item != node)
                    {
                        List<PipeLine> lines;
                        double v = GetPipeLineLength(node, item, out lines);
                        if (v > max)
                        {
                            pipes = lines;
                            max = v;
                        }
                    }
                }
                pipes.Add(node);
                max += node.CalculateLength();
                node.IsVisit = false;
                return max;
            }
            return 0;
        }
Ejemplo n.º 26
0
    public void genNewPipeLine()
    {
        GameObject newPipeline;

        pipeCounter++;
        if (pipeCounter % (firstBossAppearAfter + bossCounter * 5) == 0)
        {
            nextPLtypename = PipeLine.PipeLineType.simple;
            pipeCounter    = 0;
            bossCounter++;
        }

        switch (nextPLtypename)
        {
        case PipeLine.PipeLineType.simple:
            newPipeline        = (GameObject)Instantiate(prefab_pl_simple, new Vector3(0, 5.5f, 0), Quaternion.identity);
            distanceToNextPipe = 2;
            break;

        case PipeLine.PipeLineType.closing:
            newPipeline        = (GameObject)Instantiate(prefab_pl_closing, new Vector3(0, 5.5f, 0), Quaternion.identity);
            distanceToNextPipe = 2;
            break;

        case PipeLine.PipeLineType.moving:
            newPipeline        = (GameObject)Instantiate(prefab_pl_moving, new Vector3(0, 5.5f, 0), Quaternion.identity);
            distanceToNextPipe = 2;
            break;

        case PipeLine.PipeLineType.moving2:
            newPipeline        = (GameObject)Instantiate(prefab_pl_moving2, new Vector3(0, 5.5f, 0), Quaternion.identity);
            distanceToNextPipe = 2.55f;
            break;

        case PipeLine.PipeLineType.stair2:
            newPipeline        = (GameObject)Instantiate(prefab_pl_stair2, new Vector3(0, 5.5f, 0), Quaternion.identity);
            distanceToNextPipe = 2.55f;
            break;

        case PipeLine.PipeLineType.stair3:
            newPipeline        = (GameObject)Instantiate(prefab_pl_stair3, new Vector3(0, 5.5f, 0), Quaternion.identity);
            distanceToNextPipe = 3.1f;
            break;

        case PipeLine.PipeLineType.stair4:
            newPipeline        = (GameObject)Instantiate(prefab_pl_stair4, new Vector3(0, 5.5f, 0), Quaternion.identity);
            distanceToNextPipe = 3.65f;
            break;

        default:
            newPipeline        = (GameObject)Instantiate(prefab_pl_simple, new Vector3(0, 5.5f, 0), Quaternion.identity);
            distanceToNextPipe = 2;
            break;
        }


        if (lastPipeLine)
        {
            lastPipeLine.GetComponent <PipeLine>().setNextPipeLine(newPipeline);
        }
        lastPipeLine = newPipeline;
        PipeLine npl = newPipeline.GetComponent <PipeLine>();

        npl.speed     = currentSpeed;
        npl.type      = nextPLtypename;
        npl.holeWidth = minHoleWidth + (maxHoleWidth - minHoleWidth) * (timeToMaxSpeedLeft / timeToMaxSpeedFull);
        npl.enabled   = true;


        if (pipeCounter == 0)
        {
            ArenaController arena = this.GetComponent <ArenaController>();
            arena.arenaPipeLine = npl;
            arena.enabled       = true;
            arena.isFighting    = false;
            this.enabled        = false;
        }
    }
Ejemplo n.º 27
0
        public static PipeLine Join(this PipeLine pipeLine)
        {
            pipeLine.Connector(new JoinConnector());

            return(pipeLine);
        }
Ejemplo n.º 28
0
 public Application()
 {
     pipeLine = new PipeLine(Width, Height, Delay);
 }
Ejemplo n.º 29
0
 public void Exchange_PipeLine_Info(PipeLine Target_cs)
 {
     MyState    = Target_cs.MyState;
     MyRotState = Target_cs.MyRotState;
     ResetRotState();
 }
Ejemplo n.º 30
0
        public CommanderBatchActor(PipeLine pipeline)
        {
            _pipeline = pipeline;

            Working();
        }
Ejemplo n.º 31
0
 public async Task Composition2()
 {
     var pip   = PipeLine.Create <int, int>(a => a * 2);
     var final = pip.Next(Console.WriteLine);
     await final.Consume(25);
 }
Ejemplo n.º 32
0
    // Update is called once per frame

    void Update()
    {
        if (!b_CameraScroll)
        {
            Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, new Vector3(Camera.main.transform.position.x, 18 - (i_Floor * f_floorDistance), Camera.main.transform.position.z), 0.5f);
        }

        if (Input.GetKeyDown(KeyCode.Mouse0) && !b_IsPointerInButton)
        {
            //Debug.Log("Down");
            if (!b_IsMouseDown)
            {
                target_GameObject = GetClickedObject();
                if (target_GameObject != null && target_GameObject.gameObject.tag == "PipeLine")  //선택된게 나라면
                {
                    //Debug.Log("MY tag is !!! : " + target_GameObject.gameObject.tag);
                    b_IsMouseDown      = true;
                    target_PipeLine_cs = target_GameObject.GetComponent <PipeLine>();

                    //Debug.Log(target_PipeLine_cs.b_IsPlaced);

                    if (target_PipeLine_cs.b_IsPlaced)
                    {
                        if (target_PipeLine_cs.MyRotState == PipeLine.PipeLine_RotState.PRS_Bottom)
                        {
                            target_PipeLine_cs.MyRotState = PipeLine.PipeLine_RotState.PRS_Left;
                        }
                        else
                        {
                            target_PipeLine_cs.MyRotState++;
                        }

                        b_IsMouseDown = false;
                        target_PipeLine_cs.GetComponent <PipeInfo>().Rotate();
                        target_PipeLine_cs.b_IsWater = false;
                    }
                }
                else
                {
                    b_CameraScroll = true;
                    v_LastMousePos = Input.mousePosition;
                }
            }
        }


        if (Input.GetKey(KeyCode.Mouse0))
        {
            //Debug.Log("Press");
            if (b_IsMouseDown)
            {
                Vector3 v_MousePos; // = Camera.main.ScreenToWorldPoint(Input.mousePosition);//Input.mousePosition;
                                    //v_MousePos = Camera.main.ScreenToWorldPoint(v_MousePos);
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (true == Physics.Raycast(ray, out hit, 30f, i_Tile_LayerMask))
                {
                    v_MousePos = hit.point;

                    target_GameObject.transform.position = new Vector3(v_MousePos.x, -i_Floor * f_floorDistance + 1.2f, v_MousePos.z);
                }
            }
            else if (b_CameraScroll)
            {
                v_CurMousePos  = Input.mousePosition;
                f_ScrollOffset = v_CurMousePos.y - v_LastMousePos.y;
                v_LastMousePos = Input.mousePosition;

                Camera.main.transform.position += new Vector3(0, f_ScrollOffset / 10f, 0);
            }
        }


        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            if (b_IsMouseDown)
            {
                //Debug.Log("Up");
                b_IsMouseDown = false;

                //GameObject TempPipeLine_GameObject = PipeLine_GameObject;

                Vector3 v_TempPipeLine_Position = SetPipeLinePosition(target_GameObject.transform.position);

                if (v_TempPipeLine_Position != Vector3.zero)
                {
                    //Debug.Log("타겟 정보 : " + target_PipeLine_cs.MyState + " " + target_PipeLine_cs.MyRotState +
                    //          "생성 정보 : " + TempPipeLine_PipeLine_cs.MyState + " " + TempPipeLine_PipeLine_cs.MyRotState);
                    GameObject TempPipeLine_GameObject = PipesSpawn.instance.TakePipeFromPool(v_TempPipeLine_Position);//Instantiate(PipeLine_GameObject, v_TempPipeLine_Position, target_GameObject.transform.rotation);

                    PipeLine TempPipeLine_PipeLine_cs = TempPipeLine_GameObject.GetComponent <PipeLine>();

                    TempPipeLine_PipeLine_cs.v_MyPosition = v_CurPosition;//;
                    TempPipeLine_PipeLine_cs.Exchange_PipeLine_Info(target_PipeLine_cs);
                    TempPipeLine_PipeLine_cs.b_IsPlaced = true;

                    //print(TempPipeLine_PipeLine_cs.gameObject.name);
                    TempPipeLine_PipeLine_cs.GetComponent <PipeInfo>().Placement();

                    PipeLineHealth TempPipeLine_PipeLineHealth_cs = TempPipeLine_GameObject.GetComponent <PipeLineHealth>();
                    TempPipeLine_PipeLineHealth_cs.StartBreaking();

                    target_GameObject.transform.localPosition = Vector3.zero;
                    target_PipeLine_cs.Reset_PipeLine_Info();
                    target_PipeLine_cs.MyState    = PipeLine.PipeLine_State.PS_None;
                    target_PipeLine_cs.b_IsPlaced = false;
                }
                else
                {
                    target_GameObject.transform.localPosition = Vector3.zero;
                }
                target_GameObject = null;
            }


            else if (b_CameraScroll)
            {
                b_CameraScroll = false;

                if (Camera.main.transform.position.y - 18 <= 0)
                {
                    i_Floor = (int)Mathf.Abs(Camera.main.transform.position.y - 18 - 7) / f_floorDistance;
                }
                else
                {
                    i_Floor = 0;
                }

                if (i_Floor > 4)
                {
                    i_Floor = 4;
                }

                ResetPipeLinePosition();
            }
        }
    }
        /// <summary>
        /// 计算以包含某管道的最长管道路径
        /// </summary>
        /// <param name="pipeLine">指定的管道</param>
        /// <param name="maxPipelines">最长管道路径所包含的节点</param>
        /// <returns>最长管道路径的长度</returns>
        public double GetMainPipeLineLength(PipeLine pipeLine, out List<PipeLine> maxPipelines)
        {
            double max_head = 0;
            double max_tail = 0;
            maxPipelines = new List<PipeLine>();
            List<PipeLine> maxLeftPipeLines = new List<PipeLine>();
            List<PipeLine> maxRightPipeLines = new List<PipeLine>();
            List<PipeLine> pipes = new List<PipeLine>();
            foreach (var item in PipeLines)
            {
                item.Value.IsVisit = false;
            }
            pipeLine.IsVisit = true;
            if (pipeLine.HeadConnectedObject != null)
            {
                foreach (var item in pipeLine.HeadConnectedObject.ConnectedPipes)
                {
                    if (item != pipeLine)
                    {
                        double v = GetPipeLineLength(pipeLine, item, out pipes);
                        if (v > max_head)
                        {
                            max_head = v;
                            maxLeftPipeLines = pipes;
                        }
                    }
                }
            }
            if (pipeLine.TailConnectedObject != null)
            {
                foreach (var item in pipeLine.TailConnectedObject.ConnectedPipes)
                {
                    if (item != pipeLine)
                    {
                        double v = GetPipeLineLength(pipeLine, item, out pipes);
                        if (v > max_tail)
                        {
                            max_tail = v;
                            maxRightPipeLines = pipes;
                        }
                    }
                }
            }
            maxPipelines.AddRange(maxLeftPipeLines);
            maxPipelines.Add(pipeLine);
            maxPipelines.AddRange(maxRightPipeLines);

            return max_head + max_tail + pipeLine.CalculateLength();
        }
 public ScraperQueue(PipeLine <PipelinedCrawlDescription> pipeline)
 {
     _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline));
 }
Ejemplo n.º 35
0
 public static PipeLine Connect(this PipeLine pipeLine)
 {
     pipeLine.Connector(new DirectConnector());
     return(pipeLine);
 }
        /// <summary>
        /// 管道相交测试
        /// </summary>
        /// <param name="pipeLine">测试管道</param>
        /// <param name="isFirst">相交测试是一个递归的过程,在一层递归里面PipeLine并没有被实际创建,而是在测试结束后才创建,下面的递归
        /// 层,测试的管道都是已经被创建了的</param>
        /// <returns></returns>
        public Point3d? PipeLineCrossTest(PipeLine pipeLine)
        {
            Point3d? res;
            Dictionary<ObjectId, PipeLine> copyPipelines = new Dictionary<ObjectId, PipeLine>();
            foreach (var item in PipeLines)
            {
                copyPipelines.Add(item.Key, item.Value);
            }

            //和管道测试相交
            foreach (var item in copyPipelines)
            {
                PipeLine cItem = (PipeLine)item.Value;
                if (cItem == pipeLine)
                {
                    continue;
                }
                PipeLine.CrossType type = cItem.PipeLineCrossTest(pipeLine);
                if (type == PipeLine.CrossType.CrossNone)
                {
                    continue;
                }
                else if (type == PipeLine.CrossType.ParallelHead)
                {
                    Point3d p1 = pipeLine.Point(0);
                    Point3d p2 = pipeLine.Point(1);
                    Point3d p3;
                    bool result = false;
                    if ((p1 - cItem.Point(0)).Length < (p2 - cItem.Point(0)).Length)
                    {
                        result = false;
                        p3 = p2;
                    }
                    else
                    {
                        result = true;
                        p3 = p1;
                    }
                    Vector3d v = cItem.Point(0) - cItem.Point(1);
                    Vector3d v1 = p3 - cItem.Point(0);
                    Point3d p = cItem.Point(0) + v1.DotProduct(v.GetNormal()) * v.GetNormal();
                    //
                    pipeLine = new PipeLine(p, cItem.Point(1), false, this);
                    pipeLine.TailConnectedObject = cItem.TailConnectedObject;
                    if (pipeLine.TailConnectedObject != null)
                    {
                        pipeLine.TailConnectedObject.RemovePipeLine(cItem);
                        pipeLine.TailConnectedObject.AddPipeLine(pipeLine);
                    }
                    cItem.Delete();
                    //递归调用

                    res = PipeLineCrossTest(pipeLine);
                    if (result)
                    {
                        return null;
                    }
                    else
                    {
                        return res;
                    }
                }
                else if (type == PipeLine.CrossType.ParallelTail)
                {
                    Point3d p1 = pipeLine.Point(0);
                    Point3d p2 = pipeLine.Point(1);
                    Point3d p3;
                    bool result;
                    if ((p1 - cItem.Point(1)).Length < (p2 - cItem.Point(1)).Length)
                    {
                        result = false;
                        p3 = p2;
                    }
                    else
                    {
                        result = true;
                        p3 = p1;
                    }
                    Vector3d v = cItem.Point(1) - cItem.Point(0);
                    Vector3d v1 = p3 - cItem.Point(1);
                    Point3d p = cItem.Point(1) + v1.DotProduct(v.GetNormal()) * v.GetNormal();
                    //
                    pipeLine = new PipeLine(cItem.Point(0), p, false, this);
                    pipeLine.HeadConnectedObject = cItem.HeadConnectedObject;
                    if (pipeLine.HeadConnectedObject != null)
                    {
                        pipeLine.HeadConnectedObject.RemovePipeLine(cItem);
                        pipeLine.HeadConnectedObject.AddPipeLine(pipeLine);
                    }
                    cItem.Delete();
                    //递归调用
                    res = PipeLineCrossTest(pipeLine);
                    if (result)
                    {
                        return null;
                    }
                    else
                    {
                        return res;
                    }
                }
                else if (type == PipeLine.CrossType.NonParallelHead)
                {
                    Point3d p1 = pipeLine.Point(0);
                    Point3d p2 = pipeLine.Point(1);
                    Point3d p3;
                    bool result;
                    if ((p1 - cItem.Point(0)).Length < (p2 - cItem.Point(0)).Length)
                    {
                        result = false;
                        p3 = p2;
                    }
                    else
                    {
                        result = true;
                        p3 = p1;
                    }
                    SimplePipeJoint simplePipeJoint = new SimplePipeJoint(cItem.Point(1), cItem.Point(0), p3, PipeLine.GetScale() / 2, this, true);
                    cItem.UpdateStartPoint(simplePipeJoint.CalculateLastMlineEndPoint());
                    Point3d startPoint = simplePipeJoint.CalculateMlineStartPoint();
                    simplePipeJoint.AddPipeLine(cItem);
                    PipeLine newLine = new PipeLine(p3, startPoint, false, this);
                    simplePipeJoint.AddPipeLine(newLine);
                    cItem.HeadConnectedObject = simplePipeJoint;
                    newLine.TailConnectedObject = simplePipeJoint;
                    if (pipeLine.HeadConnectedObject != null)
                    {
                        pipeLine.HeadConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.HeadConnectedObject.AddPipeLine(newLine);
                        newLine.HeadConnectedObject = pipeLine.HeadConnectedObject;
                    }
                    //递归调用
                    res = PipeLineCrossTest(newLine);
                    if (result)
                    {
                        return null;
                    }
                    else
                    {
                        return res;
                    }
                }
                else if (type == PipeLine.CrossType.NonParallelTail)
                {
                    Point3d p1 = pipeLine.Point(0);
                    Point3d p2 = pipeLine.Point(1);
                    Point3d p3;
                    bool result;
                    if ((p1 - cItem.Point(1)).Length < (p2 - cItem.Point(1)).Length)
                    {
                        result = false;
                        p3 = p2;
                    }
                    else
                    {
                        result = true;
                        p3 = p1;
                    }
                    SimplePipeJoint simplePipeJoint = new SimplePipeJoint(cItem.Point(0), cItem.Point(1), p3, PipeLine.GetScale() / 2, this, true);
                    cItem.UpdateEndPoint(simplePipeJoint.CalculateLastMlineEndPoint());
                    cItem.TailConnectedObject = simplePipeJoint;
                    Point3d startPoint = simplePipeJoint.CalculateMlineStartPoint();
                    simplePipeJoint.AddPipeLine(cItem);
                    PipeLine newLine = new PipeLine(startPoint, p3, false, this);
                    simplePipeJoint.AddPipeLine(newLine);
                    newLine.HeadConnectedObject = simplePipeJoint;
                    if (pipeLine.TailConnectedObject != null)
                    {
                        pipeLine.TailConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.TailConnectedObject.AddPipeLine(newLine);
                        newLine.TailConnectedObject = pipeLine.TailConnectedObject;
                    }
                    res = PipeLineCrossTest(newLine);
                    if (result)
                    {
                        return null;
                    }
                    else
                    {
                        return res;
                    }
                }
                else if (type == PipeLine.CrossType.CrossHead)
                {
                    MultiPipeJoint mj = new MultiPipeJoint(this, true);
                    List<Point3d> ps = mj.GenerateFromCrossPipe(cItem, pipeLine.Point(0), pipeLine.Point(1), PipeLine.GetScale() / 2);
                    PipeLine p1 = new PipeLine(cItem.Point(0), ps[0], this, true);
                    PipeLine p2 = new PipeLine(ps[1], cItem.Point(1), this, true);
                    //
                    if (cItem.HeadConnectedObject != null)
                    {
                        cItem.HeadConnectedObject.RemovePipeLine(cItem);
                        cItem.HeadConnectedObject.AddPipeLine(p1);
                    }
                    if (cItem.TailConnectedObject != null)
                    {
                        cItem.TailConnectedObject.RemovePipeLine(cItem);
                        cItem.TailConnectedObject.AddPipeLine(p2);

                    }
                    p1.HeadConnectedObject = cItem.HeadConnectedObject;
                    p1.TailConnectedObject = mj;
                    p2.HeadConnectedObject = mj;
                    p2.TailConnectedObject = cItem.TailConnectedObject;

                    Point3d startPoint = ps[2];
                    cItem.Delete();

                    PipeLine pLine = new PipeLine(startPoint, pipeLine.Point(1), false, this);
                    pLine.HeadConnectedObject = mj;
                    if (pipeLine.TailConnectedObject != null)
                    {
                        pipeLine.TailConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.TailConnectedObject.AddPipeLine(pLine);
                        pLine.TailConnectedObject = pipeLine.TailConnectedObject;
                    }
                    mj.AddPipeLine(p1);
                    mj.AddPipeLine(p2);
                    mj.AddPipeLine(pLine);

                    res = PipeLineCrossTest(pLine);
                    return res;
                }
                else if (type == PipeLine.CrossType.CrossTail)
                {
                    //
                    MultiPipeJoint mj = new MultiPipeJoint(this, true);
                    List<Point3d> ps = mj.GenerateFromCrossPipe(cItem, pipeLine.Point(1), pipeLine.Point(0), PipeLine.GetScale() / 2);
                    PipeLine p1 = new PipeLine(cItem.Point(0), ps[0], this, true);
                    PipeLine p2 = new PipeLine(ps[1], cItem.Point(1), this, true);
                    //
                    if (cItem.HeadConnectedObject != null)
                    {
                        cItem.HeadConnectedObject.RemovePipeLine(cItem);
                        cItem.HeadConnectedObject.AddPipeLine(p1);
                    }
                    if (cItem.TailConnectedObject != null)
                    {
                        cItem.TailConnectedObject.RemovePipeLine(cItem);
                        cItem.TailConnectedObject.AddPipeLine(p2);
                    }
                    p1.HeadConnectedObject = cItem.HeadConnectedObject;
                    p1.TailConnectedObject = mj;
                    p2.HeadConnectedObject = mj;
                    p2.TailConnectedObject = cItem.TailConnectedObject;
                    Point3d startPoint = ps[2];
                    cItem.Delete();
                    PipeLine pLine = new PipeLine(pipeLine.Point(0), startPoint, false, this);
                    pLine.TailConnectedObject = mj;
                    if (pipeLine.HeadConnectedObject != null)
                    {
                        pipeLine.HeadConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.HeadConnectedObject.AddPipeLine(pLine);
                        pLine.HeadConnectedObject = pipeLine.HeadConnectedObject;
                    }
                    mj.AddPipeLine(p1);
                    mj.AddPipeLine(p2);
                    mj.AddPipeLine(pLine);
                    PipeLineCrossTest(pLine);
                    return mj.CenterPoint;
                }
                else if (type == PipeLine.CrossType.CrossOver)
                {
                    MultiPipeJoint mj = new MultiPipeJoint(this, true);
                    List<Point3d> ps = mj.GenerateFromCrossPipe(cItem, pipeLine.Point(1), pipeLine.Point(0), PipeLine.GetScale() / 2);
                    PipeLine p1 = new PipeLine(cItem.Point(0), ps[0], this, true);
                    PipeLine p2 = new PipeLine(ps[1], cItem.Point(1), this, true);
                    if (cItem.HeadConnectedObject != null)
                    {
                        cItem.HeadConnectedObject.RemovePipeLine(cItem);
                        cItem.HeadConnectedObject.AddPipeLine(p1);
                    }
                    if (cItem.TailConnectedObject != null)
                    {
                        cItem.TailConnectedObject.RemovePipeLine(cItem);
                        cItem.TailConnectedObject.AddPipeLine(p2);
                    }

                    p1.HeadConnectedObject = cItem.HeadConnectedObject;
                    p1.TailConnectedObject = mj;
                    p2.HeadConnectedObject = mj;
                    p2.TailConnectedObject = cItem.TailConnectedObject;

                    Point3d startPoint = ps[2];
                    cItem.Delete();

                    PipeLine pLine = new PipeLine(pipeLine.Point(0), startPoint, false, this);
                    pLine.TailConnectedObject = mj;
                    if (pipeLine.HeadConnectedObject != null)
                    {
                        pipeLine.HeadConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.HeadConnectedObject.AddPipeLine(pLine);
                        pLine.HeadConnectedObject = pipeLine.HeadConnectedObject;
                    }
                    mj.AddPipeLine(p1);
                    mj.AddPipeLine(p2);
                    mj.AddPipeLine(pLine);
                    PipeLineCrossTest(pLine);
                    //插入新的点
                    PipeLine se = mj.UpdateMultiJoint(pipeLine.Point(1));
                    se.HeadConnectedObject = mj;
                    if (pipeLine.TailConnectedObject != null)
                    {
                        pipeLine.TailConnectedObject.RemovePipeLine(pipeLine);
                        pipeLine.TailConnectedObject.AddPipeLine(se);
                        se.TailConnectedObject = pipeLine.TailConnectedObject;
                    }
                    res = PipeLineCrossTest(se);
                    return res;
                }

            }
            foreach (var item in SimplePipeJoints)
            {
                SimplePipeJoint pItem = (SimplePipeJoint)item.Value;
                if (pItem.PointInJoint(pipeLine.Point(0)) && !pItem.ConnectedPipes.Contains(pipeLine))
                {
                    MultiPipeJoint mpj = new MultiPipeJoint(this, true);
                    PipeLine ps = mpj.GenerateFromSimpleJoint(pItem, pipeLine.Point(1), PipeLine.GetScale() / 2);
                    ps.HeadConnectedObject = mpj;
                    res = PipeLineCrossTest(ps);
                    return res;
                }
                if (pItem.PointInJoint(pipeLine.Point(1)) && !pItem.ConnectedPipes.Contains(pipeLine))
                {
                    MultiPipeJoint mpj = new MultiPipeJoint(this, true);
                    PipeLine ps = mpj.GenerateFromSimpleJoint(pItem, pipeLine.Point(0), PipeLine.GetScale() / 2);
                    ps.TailConnectedObject = mpj;
                    res = PipeLineCrossTest(ps);
                    return null;
                }
            }
            foreach (var item in MultiPipeJoints)
            {
                MultiPipeJoint pItem = (MultiPipeJoint)item.Value;
                if (pItem.PointInJoint(pipeLine.Point(0)) && !pItem.ConnectedPipes.Contains(pipeLine))
                {
                    PipeLine se = pItem.UpdateMultiJoint(pipeLine.Point(1));
                    se.HeadConnectedObject = pItem;
                    res = PipeLineCrossTest(se);
                    return res;
                }
                if (pItem.PointInJoint(pipeLine.Point(1)) && !pItem.ConnectedPipes.Contains(pipeLine))
                {
                    PipeLine se = pItem.UpdateMultiJoint(pipeLine.Point(0));
                    se.HeadConnectedObject = pItem;
                    res = PipeLineCrossTest(se);
                    return null;
                }
            }
            pipeLine.SaveEntity();
            return pipeLine.Point(1);
        }
Ejemplo n.º 37
0
 public async Task Composition3()
 {
     var pip = PipeLine.Create <int, int>(a => a * 2).Next(Console.WriteLine);
     await pip.Consume(25);
 }