Ejemplo n.º 1
0
 internal void PostPrepare(TagBatchDefinition batchDefinition, TagBatchItem batchItem)
 {
     foreach (ValueItem vi in _parts)
     {
         vi.PostPrepare(batchDefinition, batchItem);
     }
 }
Ejemplo n.º 2
0
        internal override object GetValue <TKey>(TagBatchDefinition <TKey> definition, TagBatchInstance <TKey> instance)
        {
            string s = base.ApplyItems(instance);

            //throw new NotImplementedException();

            return(CreateValue(s));
        }
Ejemplo n.º 3
0
 internal virtual void PrePrepare(TagBatchDefinition batchDefinition)
 {
     if (_preparedFor != batchDefinition)
     {
         batchDefinition.Prepared = false;
         _preparedFor             = null;
     }
 }
Ejemplo n.º 4
0
        public void CreateBatch()
        {
            TagEnvironment env = CreateEnvironment();

            Assert.That(env, Is.Not.Null);

            TagBatchDefinition <string> tbd = new TagBatchDefinition <string>();

            tbd.Add("src", "@(ProjectOutput);static1", typeof(ITagItem[]));
            tbd.Add("src2", "@(ProjectOutput)", typeof(string[]));
            tbd.Add("to", "@(ProjectOutput->'%(FullPath)')", typeof(string));
            tbd.Add("info", "%(FileOrigin)", typeof(string));
            tbd.AddCondition("if", "'%(FileOrigin)' == 'c:\\work\\app\\bin\\debug'");

            int n = 0;

            foreach (TagBatchInstance <string> r in env.RunBatch(tbd, false))
            {
                Assert.That(r, Is.Not.Null);
                Assert.That(r["src"], Is.TypeOf(typeof(ITagItem[])));
                Assert.That(r["to"], Is.TypeOf(typeof(string)));
                Assert.That(r["info"], Is.TypeOf(typeof(string)));
                Assert.That(r["if"], Is.TypeOf(typeof(bool)));

                switch (n++)
                {
                case 0:
                    Assert.That(r["src2"], Has.Some.EqualTo("assembly.dll"));
                    Assert.That(r["src2"], Has.Some.EqualTo("assembly.pdb"));
                    Assert.That(r["src2"], Has.Some.EqualTo("en\\assembly.resources.dll"));
                    Assert.That(r["info"], Is.EqualTo("c:\\work\\app\\bin\\debug"));
                    Assert.That(r.ConditionResult("if"), "'if' condition true");
                    Assert.That(r.ConditionResult(), "All conditions true");
                    foreach (ITagItem ii in (IEnumerable)r["src"])
                    {
                        if (ii.ItemSpec == "static1")
                        {
                            Assert.That(ii.MetadataCount, Is.EqualTo(0));
                        }
                        else
                        {
                            Assert.That(ii.MetadataCount, Is.GreaterThan(0));
                            Assert.That(ii.KeyNames, Has.Some.EqualTo("FileOrigin"));
                        }
                    }
                    break;

                case 1:
                    Assert.That(r["info"], Is.EqualTo("c:\\work\\app"));
                    Assert.That(r["src2"], Has.All.EqualTo("res.txt"));
                    Assert.That(r.ConditionResult("if"), Is.False, "If condition false");
                    Assert.That(r.ConditionResult(), Is.False, "'if' conditions false");
                    break;
                }
            }

            Assert.That(n, Is.EqualTo(2));
        }
Ejemplo n.º 5
0
        internal override void PrePrepare(TagBatchDefinition batchDefinition)
        {
            base.PrePrepare(batchDefinition);

            if (_expression == null)
            {
                _expression = QQn.TurtleUtils.Tags.ExpressionParser.Parser.Parse(Definition, ConditionArgs);
            }
        }
Ejemplo n.º 6
0
        public override void PostPrepare(TagBatchDefinition batchDefinition, TagBatchItem batchItem)
        {
            base.PostPrepare(batchDefinition, batchItem);

            foreach (ValueItem vi in _items)
            {
                vi.PostPrepare(batchDefinition, batchItem);
            }
        }
Ejemplo n.º 7
0
        internal override void PostPrepare(TagBatchDefinition batchDefinition, TagBatchItem batchItem)
        {
            base.PostPrepare(batchDefinition, batchItem);

            if (Key != null)
            {
                _parts = batchItem.PrepareString(batchDefinition, Key, _mode);
            }
        }
Ejemplo n.º 8
0
        protected internal override void PostPrepare(TagBatchDefinition batchDefinition)
        {
            base.PostPrepare(batchDefinition);

            foreach (ValuePart vp in _parts)
            {
                vp.PostPrepare(batchDefinition, this);
            }
        }
Ejemplo n.º 9
0
        internal override void PostPrepare(TagBatchDefinition batchDefinition, TagBatchItem batchItem)
        {
            base.PostPrepare(batchDefinition, batchItem);

            if (IsConstraint)
            {
                batchDefinition.AddConstraint(Item, Key);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Posts the prepare.
 /// </summary>
 protected virtual internal void PostPrepare(TagBatchDefinition batchDefinition)
 {
     if (_items != null)
     {
         foreach (ValueItem tv in _items)
         {
             tv.PostPrepare(batchDefinition, this);
         }
     }
 }
Ejemplo n.º 11
0
        internal override object GetValue <TKey>(TagBatchDefinition <TKey> definition, TagBatchInstance <TKey> instance)
        {
            List <ITagItem> items = new List <ITagItem>();

            foreach (ValuePart vp in _parts)
            {
                vp.ApplyTo(items, instance);
            }

            return(CreateValue(items));
        }
Ejemplo n.º 12
0
        protected internal override void PostPrepare(TagBatchDefinition batchDefinition)
        {
            base.PostPrepare(batchDefinition);

            foreach (TagExpression te in _expression.GetAllLeaveExpressions())
            {
                DynamicStringExpression dse = te as DynamicStringExpression;

                if (dse != null)
                {
                    dse.PostPrepare(batchDefinition, this);
                }
            }
        }
Ejemplo n.º 13
0
        protected internal ValueItem[] PrepareString(TagBatchDefinition batchDefinition, string definition, PrepareMode mode)
        {
            int lastOffset = 0;
            int offset     = 0;

            List <ValueItem> list            = new List <ValueItem>();
            List <string>    freeConstraints = new List <string>();

            string flat = TagExpander.ItemKeyOrPropertyRegex.Replace(definition, delegate(Match match)
            {
                if (offset > lastOffset)
                {
                    list.Add(new StringValueItem(definition.Substring(lastOffset, offset - lastOffset)));
                }
                int ofs    = match.Index - offset;
                offset     = match.Index + match.Length;
                lastOffset = offset;

                Group g, gp, gs;
                if (null != (g = match.Groups[TagExpander.RegexGroupItem]) && g.Success)
                {
                    gp = match.Groups[TagExpander.RegexGroupTransform];
                    gs = match.Groups[TagExpander.RegexGroupSeparator];

                    batchDefinition.AddUsedItem(this, g.Value);

                    list.Add(new ItemValueItem(g.Value, gp.Success ? gp.Value : null, gs.Success ? gs.Value : null, mode));
                }
                else if (null != (g = match.Groups[TagExpander.RegexGroupKey]) && g.Success)
                {
                    gp = match.Groups[TagExpander.RegexGroupItemPrefix];

                    list.Add(new TagValueItem(gp.Success ? gp.Value : null, g.Value));
                }
                else if (null != (g = match.Groups[TagExpander.RegexGroupProperty]) && g.Success)
                {
                    list.Add(new PropertyValueItem(g.Value));
                }
                return("");
            });

            offset = definition.Length;
            if (offset > lastOffset)
            {
                list.Add(new StringValueItem(definition.Substring(lastOffset, offset - lastOffset)));
            }

            return(list.ToArray());
        }
Ejemplo n.º 14
0
        protected virtual object CreateValue(string value)
        {
            if (_itemType.IsAssignableFrom(typeof(string)))
            {
                return(value);
            }
            else if (_itemType == typeof(ITagItem))
            {
                return(new StubItem(value));
            }
            else if (_itemType == TagBatchDefinition.ITaskItemTypeUnsafe)
            {
                return(TagBatchDefinition.CreateTaskItem("", value));
            }

            throw new InvalidOperationException();
        }
Ejemplo n.º 15
0
        public void PropertyTests()
        {
            TagPropertyCollection tpc = new TagPropertyCollection();

            tpc.LoadEnvironmentVariables();

            Assert.That(tpc, Is.All.Not.Null);

            Assert.That(tpc["PATH"], Is.Not.Null);

            Assert.That(tpc.ExpandProperties("$(Path)"), Is.EqualTo(Environment.GetEnvironmentVariable("PATH")));

            Assert.That(TagBatchDefinition.IsTagItemType(typeof(Microsoft.Build.Framework.ITaskItem)), Is.True);
            Assert.That(TagBatchDefinition.IsTagItemType(typeof(string)), Is.True);
            Assert.That(TagBatchDefinition.IsTagItemType(typeof(ITagItem)), Is.True);
            Assert.That(TagBatchDefinition.IsTagItemType(typeof(int)), Is.False);
        }
Ejemplo n.º 16
0
        protected internal override void Prepare(TagBatchDefinition batchDefinition, int offset)
        {
            InitPreparation(batchDefinition, offset);

            List <ValuePart> parts = new List <ValuePart>();

            foreach (string item in TagExpander.SplitItemList(Definition))
            {
                ValueItem[] vi = PrepareString(batchDefinition, item, PrepareMode.List);

                if (vi.Length == 1)
                {
                    ValueItem v = vi[0];

                    ItemValueItem   ivi;
                    StringValueItem svi;
                    if (null != (ivi = v as ItemValueItem))
                    {
                        if (string.IsNullOrEmpty(ivi.Separator) || ivi.Separator.Trim() == ";")
                        {
                            parts.Add(new ItemValuePart(ivi));
                            continue;
                        }
                    }
                    else if (null != (svi = v as StringValueItem))
                    {
                        // TODO: Shortcut single string value
                        parts.Add(new ConstantValuePart(svi.Value));
                        continue;
                    }
                }

                parts.Add(new DynamicValuePart(vi));
            }

            _parts = parts.ToArray();
        }
Ejemplo n.º 17
0
 public virtual void PostPrepare(TagBatchDefinition batchDefinition, TagBatchItem batchItem)
 {
 }
Ejemplo n.º 18
0
        public override void PostPrepare(TagBatchDefinition batchDefinition, TagBatchItem batchItem)
        {
            base.PostPrepare(batchDefinition, batchItem);

            _item.PostPrepare(batchDefinition, batchItem);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Prepares the specified batch definition.
        /// </summary>
        /// <param name="batchDefinition">The batch definition.</param>
        /// <param name="offset">The offset.</param>
        protected internal virtual void Prepare(TagBatchDefinition batchDefinition, int offset)
        {
            InitPreparation(batchDefinition, offset);

            _items = PrepareString(batchDefinition, Definition, ProvidesList ? PrepareMode.List : PrepareMode.String);
        }
Ejemplo n.º 20
0
 internal override object GetValue <TKey>(TagBatchDefinition <TKey> definition, TagBatchInstance <TKey> instance)
 {
     return(EvaluateCondition(instance));
 }
Ejemplo n.º 21
0
 internal virtual void PostPrepare(TagBatchDefinition batchDefinition, TagBatchItem batchItem)
 {
     //throw new NotImplementedException();
 }
Ejemplo n.º 22
0
 internal void Prepare(TagBatchDefinition batchDefinition, TagBatchItem batchItem)
 {
     _parts = batchItem.PrepareString(batchDefinition, Value, PrepareMode.Condition);
 }
Ejemplo n.º 23
0
 internal override void PrePrepare(TagBatchDefinition batchDefinition)
 {
     base.PrePrepare(batchDefinition);
 }
Ejemplo n.º 24
0
 internal abstract object GetValue <TKey>(TagBatchDefinition <TKey> definition, TagBatchInstance <TKey> instance)
     where TKey : class;
Ejemplo n.º 25
0
 protected void InitPreparation(TagBatchDefinition batchDefinition, int offset)
 {
     _preparedFor = batchDefinition;
     _offset      = offset;
 }