Esempio n. 1
0
        /// <summary>
        ///    Copy the references for first and second Neighbor from <paramref name="sourcecNeighborhoodBuilder" /> to
        ///    <paramref name="targetNeighborhoodBuilder" />.
        /// </summary>
        /// <param name="sourcecNeighborhoodBuilder">The source neighborhood builder to copy neighbors from.</param>
        /// <param name="targetNeighborhoodBuilder">The neighborhood builder to copy neighbors to.</param>
        private void updateNeighborsReferences(INeighborhoodBuilder sourcecNeighborhoodBuilder, INeighborhoodBuilder targetNeighborhoodBuilder)
        {
            var objectPathFactory = new ObjectPathFactory(new AliasCreator());
            var firstPath         = objectPathFactory.CreateAbsoluteObjectPath(sourcecNeighborhoodBuilder.FirstNeighbor);
            var secondPath        = objectPathFactory.CreateAbsoluteObjectPath(sourcecNeighborhoodBuilder.SecondNeighbor);

            foreach (var topContainer in TopContainers)
            {
                var firstNeighbor  = firstPath.Resolve <IContainer>(topContainer);
                var secondNeighbor = secondPath.Resolve <IContainer>(topContainer);

                if (firstNeighbor != null)
                {
                    targetNeighborhoodBuilder.FirstNeighbor = firstNeighbor;
                }

                if (secondNeighbor != null)
                {
                    targetNeighborhoodBuilder.SecondNeighbor = secondNeighbor;
                }

                //both neighbors set. early exit
                if (targetNeighborhoodBuilder.FirstNeighbor != null && targetNeighborhoodBuilder.SecondNeighbor != null)
                {
                    return;
                }
            }
        }
        public void TestSerializationEvent()
        {
            Event x1 = CreateObject <Event>().WithName("Eve").WithDimension(DimensionLength);

            x1.Formula         = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(1.0);
            x1.ParentContainer = C0;

            EventAssignment ea1 = CreateObject <EventAssignment>().WithName("Eva").WithDimension(DimensionLength);

            ea1.UseAsValue = true;
            ea1.Formula    = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);
            ea1.ObjectPath = ObjectPathFactory.CreateAbsoluteObjectPath(P);
            x1.AddAssignment(ea1);
            ea1.ResolveChangedEntity();

            IEvent x2 = SerializeAndDeserialize(x1);

            x2.ParentContainer = C0;

            var refResolver = new ReferencesResolver();

            refResolver.ResolveReferencesIn(x2);

            AssertForSpecs.AreEqualEvent(x2, x1);
        }
Esempio n. 3
0
 /// <summary>
 ///     Gets the path to a Container by a given compartment id.
 /// </summary>
 protected internal IObjectPath GetPathToContainerOfCompartmentId(string compartmentId)
 {
     return((from container in GetMainTopContainer().Children where container.Name == compartmentId select ObjectPathFactory.CreateAbsoluteObjectPath(container)).FirstOrDefault());
 }