Ejemplo n.º 1
0
        public static void AddOffset2D(this IHas <IQuboidLogic> quboid, double length, double width, int direction)
        {
            switch (direction)
            {
            case 0:
                quboid.Length(quboid.Length() + length);
                quboid.Width(quboid.Width() + width);
                break;

            case 1:
                quboid.Length(quboid.Length() - width);
                quboid.Width(quboid.Width() + length);
                break;

            case 2:
                quboid.Length(quboid.Length() - length);
                quboid.Width(quboid.Width() - width);
                break;

            case 3:
                quboid.Length(quboid.Length() + width);
                quboid.Width(quboid.Width() - length);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        /// <exception cref="ArgumentNullException"><c>has</c> is null.</exception>
        public static IResourceDefinition ResourcesWithKey(this IHas has, object resourceKey)
        {
            if (has == null)
            {
                throw new ArgumentNullException("has");
            }
            if (resourceKey == null)
            {
                throw new ArgumentNullException("resourceKey");
            }

            var  resourceKeyAsType    = resourceKey as Type;
            bool isStrictRegistration = false;

            if (resourceKeyAsType != null && CodecRegistration.IsStrictRegistration(resourceKeyAsType))
            {
                resourceKey          = CodecRegistration.GetStrictType(resourceKeyAsType);
                isStrictRegistration = true;
            }
            var registration = new ResourceModel
            {
                ResourceKey          = resourceKey,
                IsStrictRegistration = isStrictRegistration
            };

            var hasBuilder = (IFluentTarget)has;

            hasBuilder.Repository.ResourceRegistrations.Add(registration);
            return(new ResourceDefinition(hasBuilder.TypeSystem, registration));
        }
Ejemplo n.º 3
0
        public static double GetWidth(this IHas <IQuboidLogic> logicHolder, int rotation)
        {
            var Logic = logicHolder.Logic;

            switch (rotation)
            {
            case 0:
                return(Logic.Width);

            case 1:
                return(Logic.Length);

            case 2:
                return(Logic.Width);

            case 3:
                return(Logic.Height);

            case 4:
                return(Logic.Height);

            case 5:
                return(Logic.Length);

            default:
                return(-1);
            }
        }
Ejemplo n.º 4
0
        public static IResponse Json <T>(this IHas @this, T content)
        {
            @this.AssertPositive(AssertContentEqual(content));
            @this.AssertNegative(AssertContentNotEqual(content));

            return((IResponse)@this);
        }
Ejemplo n.º 5
0
        public static IResponse Header(this IHas @this, string name, string value)
        {
            @this.AssertPositive(AssertHeaderValueEqual(name, value));
            @this.AssertNegative(AssertHeaderValueNotEqual(name, value));

            return((IResponse)@this);
        }
        public static IResponse ReasonPhrase(this IHas @this, string reasonPhrase)
        {
            @this.AssertPositive(AssertReasonPhraseEqual(reasonPhrase));
            @this.AssertNegative(AssertReasonPhraseNotEqual(reasonPhrase));

            return((IResponse)@this);
        }
Ejemplo n.º 7
0
        public static IResponse Version(this IHas @this, Version version)
        {
            @this.AssertPositive(AssertVersionEqual(version));
            @this.AssertNegative(AssertVersionNotEqual(version));

            return((IResponse)@this);
        }
Ejemplo n.º 8
0
        public static IResponse Status(this IHas @this, int statusCode)
        {
            @this.AssertPositive(AssertStatusEqual(statusCode));
            @this.AssertNegative(AssertStatusNotEqual(statusCode));

            return((IResponse)@this);
        }
Ejemplo n.º 9
0
        public static IResponse ByteArray(this IHas @this, byte[] content)
        {
            @this.AssertPositive(AssertContentEqual(content));
            @this.AssertNegative(AssertContentNotEqual(content));

            return((IResponse)@this);
        }
Ejemplo n.º 10
0
        public static IResponse Content(this IHas @this)
        {
            @this.AssertPositive(AssertContentExists);
            @this.AssertNegative(AssertContentDoesNotExist);

            return((IResponse)@this);
        }
Ejemplo n.º 11
0
        public static IResponse Xml(this IHas @this, XDocument content)
        {
            @this.AssertPositive(AssertContentEqual(content));
            @this.AssertNegative(AssertContentNotEqual(content));

            return((IResponse)@this);
        }
Ejemplo n.º 12
0
        public static IResourceDefinition ResourcesNamed(this IHas has, string name)
        {
            var definition = has.ResourcesWithKey(name);

            definition.Resource.Name = name;
            return(definition);
        }
Ejemplo n.º 13
0
 public static void TakeSimpleValues <T>(this IHas <T> taker, IHas <T> model) where T : ILogic
 {
     if (taker != null && model != null)
     {
         taker.Logic.TakeSimpleValues <T>(model.Logic);
     }
 }
Ejemplo n.º 14
0
        public static IResponse String(this IHas @this, string content)
        {
            @this.AssertPositive(AssertContentEqual(content));
            @this.AssertNegative(AssertContentNotEqual(content));

            return((IResponse)@this);
        }
Ejemplo n.º 15
0
        public static IResponse Header(this IHas @this, string name)
        {
            @this.AssertPositive(AssertHeaderExists(name));
            @this.AssertNegative(AssertHeaderDoesNotExist(name));

            return((IResponse)@this);
        }
Ejemplo n.º 16
0
        //public static LWQuboidPlace EncloseCopy(this IHas<IQuboidPlaceLogic> qplace, IHas<IQuboidPlaceLogic> placeToEnclose)
        //{
        //    LWQuboidPlace quboidplace = new LWQuboidPlace();
        //    double right = qplace.Right();
        //    double front = qplace.Front();
        //    double up = qplace.Up();

        //    quboidplace.Left = Math.Min(qplace.Left, placeToEnclose.Left);
        //    quboidplace.Back = Math.Min(qplace.Back, placeToEnclose.Back);
        //    quboidplace.Down = Math.Min(qplace.Down, placeToEnclose.Down);
        //    quboidplace.Width = Math.Max(right, placeToEnclose.Right()) - quboidplace.Left;
        //    quboidplace.Length = Math.Max(front, placeToEnclose.Front()) - quboidplace.Back;
        //    quboidplace.Height = Math.Max(up, placeToEnclose.Up()) - quboidplace.Down;

        //    return quboidplace;
        //}

        public static LWQuboidPlace MoveCopy(this IHas <IQuboidPlaceLogic> quboidPlace, double x, double y, double z)
        {
            LWQuboidPlace qplace = new LWQuboidPlace(quboidPlace);

            qplace.Move(x, y, z);
            return(qplace);
        }
Ejemplo n.º 17
0
        private MinBorderNode transformNode(IHas <INodeLogic> arg)
        {
            var newNode = new MinBorderNode(arg);

            newNode.UnSelectedNeighbours = arg.Logic.Neighbours.Count();

            return(newNode);
        }
Ejemplo n.º 18
0
 public static double Space(this IHas <IQuboidLogic> quboid)
 {
     if (quboid == null)
     {
         return(0.0);
     }
     return(quboid.Length() * quboid.Width() * quboid.Height());
 }
Ejemplo n.º 19
0
        public static void AddRdm <IndividualType>(this IHas <IndividualLogic <IndividualType> > individualOne, double weight)
        {
            var resultingCode = individualOne.Logic.Code;

            for (int i = 0; i < resultingCode.Length; i++)
            {
                resultingCode[i] += weight * (Random.NextDouble() - 0.5);
            }
        }
Ejemplo n.º 20
0
 public LWQuboidPlace(IHas <IQuboidPlaceLogic> model)
 {
     //this.TakeSimpleValues<IQuboidPlaceLogic>(model);
     Left   = model.Left();
     Width  = model.Width();
     Back   = model.Back();
     Length = model.Length();
     Down   = model.Down();
     Height = model.Height();
 }
Ejemplo n.º 21
0
 public static bool Contains(this IHas <IQuboidLogic> quboid, IHas <IQuboidLogic> other)
 {
     if (quboid.Length() >= other.Length() &&
         quboid.Width() >= other.Width() &&
         quboid.Height() >= other.Height())
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 22
0
 public static void AddOffset2D(this IHas <IQuboidLogic> quboid, double length, double width, int direction, int side)
 {
     if (side == 0)
     {
         quboid.AddOffset2D(length, 0, direction);
     }
     else
     {
         quboid.AddOffset2D(0, width, direction);
     }
 }
Ejemplo n.º 23
0
        public static void Scale(this IHas <IQuboidLogic> quboid, double x, double y, double z)
        {
            if (x < 0 || y < 0 || z < 0)
            {
                throw new ArgumentException("Negative scaling not allowed.");
            }

            quboid.Width(quboid.Width() * x);
            quboid.Length(quboid.Length() * y);
            quboid.Height(quboid.Height() * z);
        }
        protected override void SetUp()
        {
            base.SetUp();
            Resolver = new InternalDependencyResolver();
            Resolver.AddDependency <ITypeSystem, ReflectionBasedTypeSystem>();
            MetaModel         = new MetaModelRepository(Resolver);
            ResourceSpaceHas  = new FluentTarget(Resolver, MetaModel);
            ResourceSpaceUses = new FluentTarget(Resolver, MetaModel);

            DependencyManager.SetResolver(Resolver);
        }
        protected override void SetUp()
        {
            base.SetUp();
            Resolver = new InternalDependencyResolver();
            Resolver.AddDependency<ITypeSystem, ReflectionBasedTypeSystem>();
            MetaModel = new MetaModelRepository(Resolver);
            ResourceSpaceHas = new FluentTarget(Resolver, MetaModel);
            ResourceSpaceUses = new FluentTarget(Resolver, MetaModel);

            DependencyManager.SetResolver(Resolver);
        }
Ejemplo n.º 26
0
        //public static IHas<IQuboidLogic> ScaleCopy(this IHas<IQuboidLogic> quboid, double x, double y, double z)
        //{
        //    if (x < 0 || y < 0 || z < 0)
        //        throw new ArgumentException("Negative scaling not allowed.");

        //    var qplace = new LWQuboid();
        //    qplace.Width(quboid.Width() * x);
        //    qplace.Length(quboid.Length() * y);
        //    qplace.Height(quboid.Height() * z);

        //    return qplace;
        //}
        //public static LWQuboid ScaleCopy(this IHas<IQuboidLogic> quboid, double factor)
        //{
        //    if (factor < 0)
        //        throw new ArgumentException("Negative scaling not allowed.");

        //    LWQuboid qplace = new LWQuboid();
        //    qplace.Width(quboid.Width() * factor);
        //    qplace.Length(quboid.Length() * factor);
        //    qplace.Height(quboid.Height() * factor);

        //    return qplace;
        //}
        public static void Scale(this IHas <IQuboidLogic> quboid, double factor)
        {
            if (factor < 0)
            {
                throw new ArgumentException("Negative scaling not allowed.");
            }

            quboid.Width(quboid.Width() * factor);
            quboid.Length(quboid.Length() * factor);
            quboid.Height(quboid.Height() * factor);
        }
Ejemplo n.º 27
0
        public static bool Intersect2D(this IHas <IQuboidPlaceLogic> quboidPlace, IHas <IQuboidPlaceLogic> otherQuboidPlace)
        {
            if (
                (quboidPlace.Back() >= otherQuboidPlace.Front()) || (quboidPlace.Front() <= otherQuboidPlace.Back()) ||
                (quboidPlace.Left() >= otherQuboidPlace.Right()) || (quboidPlace.Right() <= otherQuboidPlace.Left())
                )
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 28
0
        //public static IEnumerable<IHas<INodeLogic>> Neighbours(this IHas<INodeLogic> node)
        //{
        //    return node.Logic.Neighbours;
        //}
        public static LinkedList <NodeType> Neighbourhood <NodeType, EdgeType>(this IHas <INodeLogic <NodeType, EdgeType> > node)
            where NodeType : IHas <INodeLogic <NodeType, EdgeType> >
            where EdgeType : IHas <IEdgeLogic <NodeType, EdgeType> >
        {
            var nbhood = new LinkedList <NodeType>();

            nbhood.AddRange(node.Neighbours());
            foreach (var nb in node.Logic.Neighbours(node))
            {
                nbhood.AddRange(nb.Neighbours().Where(nbnb => !nbhood.Contains(nbnb) && !nbnb.Equals(node)));
            }
            return(nbhood);
        }
Ejemplo n.º 29
0
        public static IResourceDefinition <TResource> ResourcesOfType <TResource>(this IHas has)
        {
            if (has == null)
            {
                throw new ArgumentNullException("has");
            }

            var hasBuilder = (IFluentTarget)has;

            ResourceModel registration = RegisterResourceModel(hasBuilder, typeof(TResource));

            return(new ResourceDefinition <TResource>(hasBuilder, hasBuilder.TypeSystem, registration));
        }
Ejemplo n.º 30
0
        //public static void Rotate(this IHas<IQuboidPlaceLogic> place, int direction)
        //{
        //    var left = place.Left;
        //    var back = place.Back;
        //    var length = place.Length;
        //    switch (direction)
        //    {
        //        case 0:
        //            break;
        //        case 1:
        //            place.Back = -left - place.Width;
        //            place.Left = back;
        //            place.Length = place.Width;
        //            place.Width = length;
        //            break;
        //        case 2:
        //            place.Back = -back - place.Length;
        //            place.Left = -left - place.Width;
        //            break;
        //        case 3:
        //            place.Back = left;
        //            place.Left = -back - place.Length;
        //            place.Length = place.Width;
        //            place.Width = length;
        //            break;
        //        default:
        //            break;
        //    }
        //}
        public static void Enclose(this IHas <IQuboidPlaceLogic> quboidplace, IHas <IQuboidPlaceLogic> placeToEnclose)
        {
            double right = quboidplace.Right();
            double front = quboidplace.Front();
            double up    = quboidplace.Up();

            quboidplace.Left(Math.Min(quboidplace.Left(), placeToEnclose.Left()));
            quboidplace.Back(Math.Min(quboidplace.Back(), placeToEnclose.Back()));
            quboidplace.Down(Math.Min(quboidplace.Down(), placeToEnclose.Down()));
            quboidplace.Width(Math.Max(right, placeToEnclose.Right()) - quboidplace.Left());
            quboidplace.Length(Math.Max(front, placeToEnclose.Front()) - quboidplace.Back());
            quboidplace.Height(Math.Max(up, placeToEnclose.Up()) - quboidplace.Down());
        }
Ejemplo n.º 31
0
 public static NodeType Neighbour <NodeType, EdgeType>(this IHas <INodeLogic <NodeType, EdgeType> > node, IHas <IEdgeLogic <NodeType, EdgeType> > edge)
     where NodeType : IHas <INodeLogic <NodeType, EdgeType> >
     where EdgeType : IHas <IEdgeLogic <NodeType, EdgeType> >
 {
     if (edge.Head().Equals(node))
     {
         return(edge.Foot());
     }
     if (edge.Foot().Equals(node))
     {
         return(edge.Head());
     }
     return(default(NodeType));
 }