Beispiel #1
0
 public IBuildIntention <IConstantBool> GetBuildIntention(IConversionContext context)
 {
     var(toBuild, maker) = ConstantBool.Create();
     return(new BuildIntention <IConstantBool>(toBuild, () =>
     {
         maker.Build(
             Value.GetOrThrow());
     }));
 }
Beispiel #2
0
        public void ExpressionFactoryBool_SuccessfullyCreates_ConstantBoolExpression_Test()
        {
            //Arrange
            var constantBool = new ConstantBool <IContext>(true);
            //Act
            var sut = _expressions.Bool(true);

            //Assert
            Assert.True(sut.Interpret(_context) == constantBool.Interpret(_context));
        }
Beispiel #3
0
        public void Not()
        {
            //Arrange
            var trueConstant = new ConstantBool <IContext>(true);
            //Act
            var sut = new Not <IContext>(trueConstant).Interpret(_context);

            //Assert
            Assert.False(sut);
        }
        static void HandleConstants(GraphBuilder builder, out INode node, out PortMapper portToOffsetMapping,
                                    IConstantNodeModel constantNodeModel)
        {
            portToOffsetMapping = new PortMapper();
            var outputPortId = constantNodeModel.OutputPort?.UniqueId ?? "";

            switch (constantNodeModel)
            {
            case StringConstantModel stringConstantModel:
            {
                var index = builder.StoreStringConstant(stringConstantModel.value ?? string.Empty);
                var cf    = new ConstantString {
                    Value = new StringReference(index, StringReference.Storage.Managed)
                };
                node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf);
                return;
            }

            case BooleanConstantNodeModel booleanConstantNodeModel:
            {
                var cf = new ConstantBool {
                    Value = booleanConstantNodeModel.value
                };
                node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf);
                return;
            }

            case IntConstantModel intConstantModel:
            {
                var cf = new ConstantInt {
                    Value = intConstantModel.value
                };
                node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf);
                return;
            }

            case FloatConstantModel floatConstantModel:
            {
                var cf = new ConstantFloat {
                    Value = floatConstantModel.value
                };
                node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf);
                return;
            }

            case Vector2ConstantModel vector2ConstantModel:
            {
                var cf = new ConstantFloat2 {
                    Value = vector2ConstantModel.value
                };
                node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf);
                return;
            }

            case Vector3ConstantModel vector3ConstantModel:
            {
                var cf = new ConstantFloat3 {
                    Value = vector3ConstantModel.value
                };
                node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf);
                return;
            }

            case Vector4ConstantModel vector4ConstantModel:
            {
                var cf = new ConstantFloat4 {
                    Value = vector4ConstantModel.value
                };
                node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf);
                return;
            }

            case QuaternionConstantModel quaternionConstantModel:
            {
                var cf = new ConstantQuaternion {
                    Value = quaternionConstantModel.value
                };
                node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf);
                return;
            }

            case ObjectConstantModel _:
            {
                throw new NotImplementedException(
                          "Conversion and all - either a prefab (might live in a graph) or a scene object (must be injected during runtime bootstrap)");

                // portToOffsetMapping = new Dictionary<IPortModel, uint>();
                // var cf = new ConstantEntity {Value = objectConstantModel.value};
                // MapPort(portToOffsetMapping, objectConstantModel.OutputPort, ref cf.ValuePort.Port, nodeId);
                // node = cf;
                // return;
            }

            default:
                throw new NotImplementedException();
            }
        }
Beispiel #5
0
        public void DocumentNode(SearcherItem searcherItem, INodeModel nodeModel)
        {
            INode node;

            switch (nodeModel)
            {
            case IDotsNodeModel baseDotsNodeModel:
                node = baseDotsNodeModel.Node;
                break;

            case StringConstantModel _:
                node = new ConstantString();
                break;

            case BooleanConstantNodeModel _:
                node = new ConstantBool();
                break;

            case IntConstantModel _:
                node = new ConstantInt();
                break;

            case FloatConstantModel _:
                node = new ConstantFloat();
                break;

            case Vector2ConstantModel _:
                node = new ConstantFloat2();
                break;

            case Vector3ConstantModel _:
                node = new ConstantFloat3();
                break;

            case Vector4ConstantModel _:
                node = new ConstantFloat4();
                break;

            case QuaternionConstantModel _:
                node = new ConstantQuaternion();
                break;

            default:
                return;
            }
            var nodeType      = node.GetType();
            var executionType = GetNodeExecutionType(nodeType, node);
            var title         = Attribute.IsDefined(node.GetType(), typeof(WorkInProgressAttribute))
                ? $"{searcherItem.Name} [WIP]"
                : searcherItem.Name;

            SectionTitle(title, 1);

            var nodeDescription = GetNodeDescription(nodeType, executionType, out string exampleText, out string dataSetup);

            if (!String.IsNullOrEmpty(nodeDescription))
            {
                Paragraph(nodeDescription);
            }

            GetPortsDescription(executionType, node);

            if (exampleText != null)
            {
                SectionTitle("Examples", 2);
                Paragraph(exampleText);
            }

            if (dataSetup != null)
            {
                SectionTitle("Data Setup", 2);
                Paragraph(dataSetup);
            }
        }