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");
        }
Пример #2
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();
        }
Пример #4
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");
        }
Пример #5
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));
            });
        }
 public ConfiguredCancellationPolicy(int actCode, ModelDataPath path, IMappingTransform transform, IEnumerable <ITransformArgument> arguments, IMappingVariableExpander expander, IServiceLocator services)
     : base(path, transform, arguments, expander, services)
 {
     _actCode = actCode;
 }
Пример #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)));
            });
        }
Пример #8
0
 public FieldArgument(string name, ModelDataPath path)
 {
     _name = name;
     _path = path;
 }