Example #1
0
        public void Setup()
        {
            Input = PipeSegment.Input(PipeSegment.End());
            Scope = Input.NewSubscriptionScope();

            EstablishContext();
        }
Example #2
0
        public void Setup()
        {
            _addCalled    = new Future <bool>();
            _removeCalled = new Future <bool>();

            _input = PipeSegment.Input(PipeSegment.End());

            _subscriberScope = _input.NewSubscriptionScope();
            _subscriberScope.Subscribe <SubscriberAdded>(x =>
            {
                if (x.MessageType == typeof(ClaimModified))
                {
                    _addCalled.Complete(true);
                }
            });
            _subscriberScope.Subscribe <SubscriberRemoved>(x =>
            {
                if (x.MessageType == typeof(ClaimModified))
                {
                    _removeCalled.Complete(true);
                }
            });

            using (ISubscriptionScope scope = _input.NewSubscriptionScope())
            {
                scope.Subscribe <ClaimModified>(x => { });
            }
        }
Example #3
0
        private void RegisterApplicationServices(IContainer container)
        {
            var pipe = PipeSegment.Input(PipeSegment.End());

            container.RegisterAsSingleton((Pipe)pipe);
            container.RegisterAsSingleton <IEventsProvider, EventsProvider>();
        }
Example #4
0
    private void AddSegment(PipeSegment segment)
    {
        // Segment se instancira kao dete cele cevi (PipeRoot)
        var seg = Instantiate(segment, transform);

        // Generisu se objekti unutar cevi
        seg.SpawnObjects(objectsToSpawn);

        /*
         * Segment se postavlja na lokalni koordinatni pocetak ukoliko je prvi u nizu,
         * inace se postavlja na End poziciju poslednje cevi u nizu
         */
        if (segments.Count == 0)
        {
            seg.transform.position = transform.position;
        }
        else
        {
            seg.transform.position = segments[segments.Count - 1].End.position;
        }

        // Random rotacija cevi oko pravca pruzanja. Postize se utisak skretanja u random smer, ukoliko je kosa cev
        seg.transform.Rotate(new Vector3(0f, Random.Range(0, 360), 0f));

        // Dodaje se instancirani segment
        segments.Add(seg);
    }
Example #5
0
        public void Should_display_an_InputSegment()
        {
            var  end   = PipeSegment.End <object>();
            Pipe input = PipeSegment.Input(end);

            new TracePipeVisitor().Trace(input);
        }
Example #6
0
        private Pipe VisitObjectRecipientList(RecipientListSegment recipientList)
        {
            var result = base.VisitRecipientList(recipientList) as RecipientListSegment;

            if (result == null)
            {
                return(null);
            }

            if (_bound)
            {
                return(result);
            }

            Pipe list   = PipeSegment.RecipientList(_segment.MessageType, new[] { _segment });
            Pipe filter = PipeSegment.Filter(list, _segment.MessageType);

            IList <Pipe> recipients = new List <Pipe>(result.Recipients);

            recipients.Add(filter);

            _bound = true;

            return(new RecipientListSegment(recipientList.MessageType, recipients));
        }
Example #7
0
        public void Should_display_a_RecipientListSegment_with_one_child_segment()
        {
            var  end           = PipeSegment.End <ClaimModified>();
            Pipe recipientList = PipeSegment.RecipientList <ClaimModified>(new Pipe[] { end });

            new TracePipeVisitor().Trace(recipientList);
        }
Example #8
0
        public void Should_display_a_FilterSegment()
        {
            var  end    = PipeSegment.End <ClaimModified>();
            Pipe filter = PipeSegment.Filter <object>(end);

            new TracePipeVisitor().Trace(filter);
        }
Example #9
0
        private bool CheckSegmentForValidCoverage(RoutingPreferenceManager routingPreferenceManager, double lowerBound, double upperBound, ElementId segmentId, RoutingPreferenceRuleGroupType groupType, List <double> sizesNotCovered)
        {
            bool retval = true;

            if (segmentId == ElementId.InvalidElementId)
            {
                throw new Exception("Invalid segment ElementId");
            }

            PipeSegment segment = this.m_document.GetElement(segmentId) as PipeSegment;

            foreach (MEPSize size in segment.GetSizes())
            {
                //skip sizes outside of rp bounds
                if (size.NominalDiameter < lowerBound)
                {
                    continue;
                }
                if (size.NominalDiameter > upperBound)
                {
                    break;
                }

                RoutingConditions conditions = new RoutingConditions(RoutingPreferenceErrorLevel.None);
                conditions.AppendCondition(new RoutingCondition(size.NominalDiameter));
                ElementId foundFitting = routingPreferenceManager.GetMEPPartId(groupType, conditions);
                if (foundFitting == ElementId.InvalidElementId)
                {
                    sizesNotCovered.Add(size.NominalDiameter);
                    retval = false;
                }
            }
            return(retval);
        }
Example #10
0
        /// <summary>
        /// Creates an instance of the ServiceBus, which implements IServiceBus. This is normally
        /// not called and should be created using the ServiceBusConfigurator to ensure proper defaults
        /// and operation.
        /// </summary>
        public ServiceBus(IEndpoint endpointToListenOn,
                          IObjectBuilder objectBuilder,
                          IEndpointFactory endpointFactory)
        {
            ReceiveTimeout = TimeSpan.FromSeconds(3);
            endpointToListenOn.MustNotBeNull("endpointToListenOn", "This parameter cannot be null");
            objectBuilder.MustNotBeNull("objectBuilder", "This parameter cannot be null");
            endpointFactory.MustNotBeNull("endpointFactory", "This parameter cannot be null");

            Endpoint        = endpointToListenOn;
            ObjectBuilder   = objectBuilder;
            EndpointFactory = endpointFactory;

            _eventAggregator      = PipeSegment.New();
            _eventAggregatorScope = _eventAggregator.NewSubscriptionScope();

            _serviceContainer = new ServiceContainer(this);

            OutboundPipeline = MessagePipelineConfigurator.CreateDefault(ObjectBuilder, this);

            InboundPipeline = MessagePipelineConfigurator.CreateDefault(ObjectBuilder, this);
            InboundPipeline.Configure(x => { _unsubscribeEventDispatchers += x.Register(new InboundOutboundSubscriptionBinder(OutboundPipeline, Endpoint)); });

            PoisonEndpoint = new PoisonEndpointDecorator(new NullEndpoint());

            ControlBus = this;

            InitializePerformanceCounters();
        }
Example #11
0
 public override void OnEnter()
 {
     Debugger.Instance.Log("The player is rolling now");
     this.Character.Velocity         = new Vector2(this.Character.Velocity.X, -CharacterMoveAbilities.RollFowardSpeed);
     this.Character.Scale            = 1;
     this.Character.HorAcceleraltion = CharacterMoveAbilities.RollHorAcceleration;
     _CachedSegment = null;
 }
Example #12
0
        public StraightThroughPipelineRunner()
        {
            Pipe consumer = PipeSegment.Consumer <ClaimModified>(m => Interlocked.Increment(ref _count));

            _input = PipeSegment.Input(consumer);

            _message = new ClaimModified();
        }
Example #13
0
        public void Setup()
        {
            Input        = PipeSegment.Input(PipeSegment.End <object>());
            BeforeCalled = new ManualResetEvent(false);
            AfterCalled  = new ManualResetEvent(false);

            EstablishContext();
        }
Example #14
0
        public void Setup()
        {
            _received = new ManualResetEvent(false);

            var recipients    = new Pipe[] {};
            var recipientList = PipeSegment.RecipientList <object>(recipients);

            _pipe = PipeSegment.Input(recipientList);
        }
Example #15
0
        public void Second_example()
        {
            _eventAggregator = PipeSegment.Input(PipeSegment.End());

            _scope = _eventAggregator.NewSubscriptionScope();
            _scope.Subscribe <CustomerChanged>(message => Trace.WriteLine("Customer changed: " + message.CustomerName));

            new TracePipeVisitor().Trace(_eventAggregator);
        }
Example #16
0
        private void CreateRecipientList(InputSegment input, Type messageType)
        {
            var recipients = input.Output.SegmentType == PipeSegmentType.End ? new Pipe[] {} : new[] { input.Output };

            Pipe list   = PipeSegment.RecipientList(messageType, recipients);
            Pipe result = Visit(list);

            input.ReplaceOutput(input.Output, result);
        }
Example #17
0
        private string GetSegmentName(ElementId id)
        {
            if (id == ElementId.InvalidElementId)
            {
                throw new Exception("Invalid ElementId");
            }
            PipeSegment segment = m_document.GetElement(id) as PipeSegment;

            return(segment.Name);
        }
Example #18
0
        public void Should_display_a_complex_segment_chain()
        {
            var  consumer      = PipeSegment.Consumer <ClaimModified>(x => { });
            var  end           = PipeSegment.End <ClaimModified>();
            var  recipientList = PipeSegment.RecipientList <ClaimModified>(new Pipe[] { consumer, end });
            var  filter        = PipeSegment.Filter <object>(recipientList);
            Pipe input         = PipeSegment.Input(filter);

            new TracePipeVisitor().Trace(input);
        }
Example #19
0
        public void Setup()
        {
            _pipe = PipeSegment.Input(PipeSegment.End <object>());
            _subscriptionScope = _pipe.NewSubscriptionScope();

            _called = new ManualResetEvent(false);
            _subscriptionScope.Subscribe <ClaimModified>(x => _called.Set());

            EstablishContext();
        }
        public static void LoadAllData()
        {
            OpenExcelApp(resourcesPath);
            //load data from excel file if it's not already loaded
            //loading fixtures flow
            if (fixturesFlow == null)
            {
                LoadFromExcel(1);
            }
            //loading materials
            if (materials == null)
            {
                materials = LoadMaterialsFromExcel();
            }
            if (pipeTypes == null)
            {
                LoadBimitPipeTypes();
            }
            //initializing vars
            calculationsSchedule = PipeScheduleType.Create(doc, string.Concat(calculatedSystem.Name, DateTime.Now.ToString("yyyyMMddHHmmss")));
            List <string> matNames = new List <string>(materials.Keys);

            segments = new Dictionary <string, PipeSegment>();
            //creating this here so it doesn't get created multiple times
            FilteredElementCollector materialElementCollector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Materials);

            foreach (string matName in matNames)
            {
                ElementId matId;
                var       existingMat = materialElementCollector.FirstOrDefault(x => string.Compare(x.Name, matName.Remove(0, 5), true) == 0);
                if (null == existingMat)
                {
                    matId = Material.Create(doc, matName.Remove(0, 5));
                }
                else
                {
                    matId = existingMat.Id;
                }

                /*else
                 *  matId = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Materials).FirstOrDefault(x => x.Name == matName).Id;*/
                /*FamilySymbol newPipeType = CreateNewPipeType(standardPipeType, matName, matId);
                 * pipeTypes.Add(newPipeType);*/
                Values         defaultSize = materials[matName][0];
                double         nd          = (defaultSize.intd + defaultSize.extd) / 2;
                MEPSize        size        = new MEPSize(nd / 304.8, defaultSize.intd / 304.8, defaultSize.extd / 304.8, true, true);
                List <MEPSize> sizes       = new List <MEPSize>();
                sizes.Add(size);
                PipeSegment seg = PipeSegment.Create(doc, matId, calculationsSchedule.Id, sizes);
                segments.Add(matName, seg);
            }

            CloseExcelApp();
            dataIsExtracted = true;
        }
Example #21
0
        public void Subscribe <T>(TimeSpan interval, MessageConsumer <IList <T> > consumer)
            where T : class
        {
            Pipe segment = PipeSegment.IntervalConsumer(interval, consumer);

            var binder = new SubscriberBinder(segment);

            binder.Bind(_pipe);

            _disposables.Add(segment);
        }
Example #22
0
        public void Subscribe <T>(MessageConsumer <T> consumer)
            where T : class
        {
            Pipe segment = PipeSegment.Consumer(consumer);

            var binder = new SubscriberBinder(segment);

            binder.Bind(_pipe);

            _disposables.Add(segment);
        }
Example #23
0
        public void Should_not_pass_unwanted_types_through_the_filter()
        {
            var received = new Future <bool>();

            Pipe consumer = PipeSegment.Consumer <SubClass>(x => received.Complete(true));
            Pipe filter   = PipeSegment.Filter <object>(consumer);

            filter.Send(new BaseClass());

            received.WaitUntilCompleted(TimeSpan.Zero).ShouldBeFalse();
        }
Example #24
0
        /// <summary>
        /// Create a PipeSegment from XML
        /// </summary>
        /// <param name="segmentXElement"></param>
        private void ParsePipeSegmentFromXML(XElement segmentXElement)
        {
            XAttribute xaMaterial  = segmentXElement.Attribute(XName.Get("materialName"));
            XAttribute xaSchedule  = segmentXElement.Attribute(XName.Get("pipeScheduleTypeName"));
            XAttribute xaRoughness = segmentXElement.Attribute(XName.Get("roughness"));

            ElementId materialId = GetMaterialByName(xaMaterial.Value); //There is nothing in the xml schema for creating new materials -- any material specified must already exist in the document.

            if (materialId == ElementId.InvalidElementId)
            {
                throw new RoutingPreferenceDataException("Cannot find Material: " + xaMaterial.Value + " in: " + segmentXElement.ToString());
            }
            ElementId scheduleId = GetPipeScheduleTypeByName(xaSchedule.Value);

            double roughness;
            bool   r1 = double.TryParse(xaRoughness.Value, out roughness);

            if (!r1)
            {
                throw new RoutingPreferenceDataException("Invalid roughness value: " + xaRoughness.Value + " in: " + segmentXElement.ToString());
            }

            if (roughness <= 0)
            {
                throw new RoutingPreferenceDataException("Invalid roughness value: " + xaRoughness.Value + " in: " + segmentXElement.ToString());
            }

            if (scheduleId == ElementId.InvalidElementId)
            {
                throw new RoutingPreferenceDataException("Cannot find Schedule: " + xaSchedule.Value + " in: " + segmentXElement.ToString()); //we will not create new schedules.
            }

            ElementId existingPipeSegmentId = GetSegmentByIds(materialId, scheduleId);

            if (existingPipeSegmentId != ElementId.InvalidElementId)
            {
                return; //Segment found, no need to create.
            }
            ICollection <MEPSize> sizes = new List <MEPSize>();

            foreach (XNode sizeNode in segmentXElement.Nodes())
            {
                if (sizeNode is XElement)
                {
                    MEPSize newSize = ParseMEPSizeFromXml(sizeNode as XElement, m_document);
                    sizes.Add(newSize);
                }
            }
            PipeSegment pipeSegment = PipeSegment.Create(m_document, materialId, scheduleId, sizes);

            pipeSegment.Roughness = Convert.ConvertValueToFeet(roughness, m_document);

            return;
        }
Example #25
0
        // ReSharper disable UnusedMember.Local
        private void SubscribeConsumer <TConsumer, TMessage>(TConsumer consumer)
        // ReSharper restore UnusedMember.Local
            where TConsumer : IConsumer <TMessage>
            where TMessage : class
        {
            Pipe segment = PipeSegment.Consumer <TConsumer, TMessage>(consumer);

            var binder = new SubscriberBinder(segment);

            binder.Bind(_pipe);

            _disposables.Add(segment);
        }
Example #26
0
        // ReSharper disable UnusedMember.Local
        private void SubscribeAsyncComponent <TConsumer, TMessage>(Func <TConsumer> getConsumer)
        // ReSharper restore UnusedMember.Local
            where TConsumer : IAsyncConsumer <TMessage>
            where TMessage : class
        {
            Pipe segment = PipeSegment.AsyncConsumer <TConsumer, TMessage>(getConsumer);

            var binder = new SubscriberBinder(segment);

            binder.Bind(_pipe);

            _disposables.Add(segment);
        }
Example #27
0
        public void Intercept <T>(Action <IInterceptorConfigurator <T> > configureAction)
            where T : class
        {
            var binder = new InterceptionBinder(typeof(T), x =>
            {
                var interceptor = PipeSegment.Interceptor(x, configureAction);
                _disposables.Add(interceptor);

                return(interceptor);
            });

            binder.Bind(_pipe);
        }
Example #28
0
        public void Should_result_in_an_expression_being_called()
        {
            var called = new ManualResetEvent(false);

            var consumer = PipeSegment.Consumer <ClaimModified>(message => called.Set());

            var recipients = new[] { consumer };

            var recipientList = PipeSegment.RecipientList <ClaimModified>(recipients);

            recipientList.Send(new ClaimModified());

            Assert.IsTrue(called.WaitOne(TimeSpan.Zero, false));
        }
Example #29
0
        public RecipientListPipelineRunner()
        {
            Pipe consumer  = PipeSegment.Consumer <ClaimModified>(m => Interlocked.Increment(ref _count));
            Pipe consumer2 = PipeSegment.Consumer <ClaimModified>(m => Interlocked.Increment(ref _count2));

            var recipients = new[] { consumer, consumer2 };

            Pipe recipientList       = PipeSegment.RecipientList <ClaimModified>(recipients);
            Pipe filter              = PipeSegment.Filter <object>(recipientList);
            Pipe objectRecipientList = PipeSegment.RecipientList <object>(new[] { filter });

            _input = PipeSegment.Input(objectRecipientList);

            _message = new ClaimModified();
        }
Example #30
0
        public void Should_contain_all_nodes()

        {
            MessageConsumerSegment consumer      = PipeSegment.Consumer <SomethingHappenedEvent>(x => { });
            EndSegment             end           = PipeSegment.End <SomethingHappenedEvent>();
            RecipientListSegment   recipientList = PipeSegment.RecipientList <SomethingHappenedEvent>(new Pipe[] { consumer, end });
            FilterSegment          filter        = PipeSegment.Filter <object>(recipientList);
            Pipe input = PipeSegment.Input(filter);

            //var generator = new PipelineGraphGenerator();

            //string filename = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "graph.png");

            //generator.SaveGraphToFile(input.GetGraphData(), 2560, 1920, filename);

            PipelineDebugVisualizer.TestShowVisualizer(input.GetGraphData());
        }