Пример #1
0
        public void Visit(EndTransform instruction)
        {
            executeInstruction(() =>
            {
                if (_propertyDef == null && _entries.Any())
                {
                    var configuredPath = ModelDataPath.Parse(ModelDataPath.This);
                    // BeginActEntry starts a mapped property so we have to skip
                    var configuredGeneric = _genericStack.Skip(1).First();

                    var entry = _entries.Peek();
                    configuredGeneric.AddTransform(new ConfiguredTransform(configuredPath, _transform,
                                                                           _arguments.ToArray(), _expander, _services, _ => _.Get <int>("type") == entry.Code));
                    _arguments.Clear();
                    return;
                }

                var field          = _propertyDef.Key;
                var path           = ModelDataPath.Parse(field);
                var currentGeneric = _genericStack.Peek();

                currentGeneric.AddTransform(new ConfiguredTransform(path, _transform, _arguments.ToArray(), _expander, _services));

                _arguments.Clear();
            });
        }
        public void sets_the_value_from_a_field_argument()
        {
            var transform = new StubTransform();
            var services  = new InMemoryServiceLocator();

            services.Add <ISimpleService>(new SimpleService());
            services.Add <IMappingVariableExpander>(new MappingVariableExpander(new MappingVariableRegistry(new List <IMappingVariableSource>()), services));

            var path = ModelDataPath.Parse("child.grandChild.property");

            var data = new ModelData();

            data["child"] = new ModelData();
            data["test"]  = "testing";
            data.Child("child")["grandChild"] = new ModelData();

            var arguments = new List <ITransformArgument>
            {
                new FieldArgument("foo", ModelDataPath.Parse("test"))
            };

            var configuredTransform = new ConfiguredTransform(path, transform, arguments, new MappingVariableExpander(new MappingVariableRegistry(new List <IMappingVariableSource>()), services), services);

            configuredTransform.Execute(data, services);

            data.Child("child").Child("grandChild").Get <string>("property").ShouldEqual("TESTING");
        }
Пример #3
0
        public void gets_the_value()
        {
            var data = new ModelData();

            data["child"] = new ModelData();
            data.Child("child")["foo"] = "bar";

            ModelDataPath.Parse("child.foo").Get(data).ShouldEqual("bar");
        }
        public void Visit(EndTransform instruction)
        {
            var field          = _propertyDef.Key;
            var path           = ModelDataPath.Parse(field);
            var currentGeneric = _genericStack.Peek();

            currentGeneric.AddTransform(new ConfiguredTransform(path, _transform, _arguments.ToArray(), _expander, _services));

            _arguments.Clear();
        }
Пример #5
0
        public void sets_the_value()
        {
            var data = new ModelData();

            data["child"] = new ModelData();

            ModelDataPath.Parse("child.foo").Set(data, "bar");

            data.Child("child").Get <string>("foo").ShouldEqual("bar");
        }
Пример #6
0
        public void Visit(EndCancellationPolicy instruction)
        {
            executeInstruction(() =>
            {
                var path = ModelDataPath.Parse(ModelDataPath.This);
                // BeginActEntry starts a mapped property so we have to skip
                var currentGeneric = _genericStack.Skip(1).First();
                var actCode        = _configurations.Last().Code;

                currentGeneric.AddTransform(new ConfiguredCancellationPolicy(actCode, path, _transform, new ITransformArgument[0], _expander, _services));
            });
        }
Пример #7
0
        public void Visit(AddTransformArgument instruction)
        {
            executeInstruction(() =>
            {
                if (instruction.Value != null)
                {
                    _arguments.Add(new ValueArgument(instruction.Name.Resolve(_services).ToString(),
                                                     instruction.Value.Resolve(_services)));
                    return;
                }

                var field = instruction.Property.Resolve(_services).ToString();
                _arguments.Add(new FieldArgument(instruction.Name.Resolve(_services).ToString(), ModelDataPath.Parse(field)));
            });
        }