private void ProcessPlacementFile(ShapeTableBuilder builder, FeatureDescriptor featureDescriptor, PlacementFile placementFile) {
            var feature = new Feature { Descriptor = featureDescriptor };

            // invert the tree into a list of leaves and the stack
            var entries = DrillDownShapeLocations(placementFile.Nodes, Enumerable.Empty<PlacementMatch>());
            foreach (var entry in entries) {
                var shapeLocation = entry.Item1;
                var matches = entry.Item2;

                string shapeType;
                string differentiator;
                GetShapeType(shapeLocation, out shapeType, out differentiator);

                Func<ShapePlacementContext, bool> predicate = ctx => true;
                if (differentiator != "") {
                    predicate = ctx => (ctx.Differentiator ?? "") == differentiator;
                }

                if (matches.Any()) {
                    predicate =  matches.SelectMany(match => match.Terms).Aggregate(predicate, BuildPredicate);
                }

                var placement = new PlacementInfo();

                var segments = shapeLocation.Location.Split(';').Select(s => s.Trim());
                foreach (var segment in segments) {
                    if (!segment.Contains('=')) {
                        placement.Location = segment;
                    }
                    else {
                        var index = segment.IndexOf('=');
                        var property = segment.Substring(0, index).ToLower();
                        var value = segment.Substring(index + 1);
                        switch (property) {
                            case "shape":
                                placement.ShapeType = value;
                                break;
                            case "alternate":
                                placement.Alternates = new[] { value };
                                break;
                            case "wrapper":
                                placement.Wrappers = new[] { value };
                                break;
                        }
                    }
                }

                builder.Describe(shapeType)
                    .From(feature)
                    .Placement(ctx => {
                                   var hit = predicate(ctx);
                                   // generate 'debugging' information to trace which file originated the actual location
                                    if (hit) {
                                       var virtualPath = featureDescriptor.Extension.Location + "/" + featureDescriptor.Extension.Id + "/Placement.info";
                                       ctx.Source = virtualPath;
                                   }
                                   return hit;
                               }, placement);
            }
        }
        private void ProcessPlacementFile(ShapeTableBuilder builder, FeatureDescriptor featureDescriptor, PlacementFile placementFile)
        {
            var feature = new Feature { Descriptor = featureDescriptor };

            foreach (var entry in placementFile)
            {
                var shapeType = entry.Key;
                var matches = entry.Value;


                foreach (var filter in entry.Value)
                {
                    var placement = new PlacementInfo();
                    placement.Location = filter.Location;
                    placement.Alternates = filter.Alternates;
                    placement.Wrappers = filter.Wrappers;
                    placement.ShapeType = filter.ShapeType;

                    builder.Describe(shapeType)
                        .From(feature)
                        .Placement(ctx => CheckFilter(ctx, filter), placement);
                }
            }
        }
示例#3
0
        private void ProcessPlacementFile(ShapeTableBuilder builder, IFeatureInfo featureDescriptor, PlacementFile placementFile)
        {
            foreach (var entry in placementFile)
            {
                var shapeType = entry.Key;
                var matches   = entry.Value;


                foreach (var filter in entry.Value)
                {
                    var placement = new PlacementInfo();
                    placement.Location   = filter.Location;
                    placement.Alternates = filter.Alternates;
                    placement.Wrappers   = filter.Wrappers;
                    placement.ShapeType  = filter.ShapeType;

                    builder.Describe(shapeType)
                    .From(featureDescriptor)
                    .Placement(ctx => CheckFilter(ctx, filter), placement);
                }
            }
        }
        private void ProcessPlacementFile(ShapeTableBuilder builder, FeatureDescriptor featureDescriptor, PlacementFile placementFile)
        {
            var feature = new Feature {
                Descriptor = featureDescriptor
            };

            // invert the tree into a list of leaves and the stack
            var entries = DrillDownShapeLocations(placementFile.Nodes, Enumerable.Empty <PlacementMatch>());

            foreach (var entry in entries)
            {
                var shapeLocation = entry.Item1;
                var matches       = entry.Item2;

                string shapeType;
                string differentiator;
                GetShapeType(shapeLocation, out shapeType, out differentiator);

                Func <ShapePlacementContext, bool> predicate = ctx => true;
                if (differentiator != "")
                {
                    predicate = ctx => (ctx.Differentiator ?? "") == differentiator;
                }

                if (matches.Any())
                {
                    predicate = matches.SelectMany(match => match.Terms).Aggregate(predicate, BuildPredicate);
                }

                var placement = new PlacementInfo();

                var segments = shapeLocation.Location.Split(';').Select(s => s.Trim());
                foreach (var segment in segments)
                {
                    if (!segment.Contains('='))
                    {
                        placement.Location = segment;
                    }
                    else
                    {
                        var index    = segment.IndexOf('=');
                        var property = segment.Substring(0, index).ToLower();
                        var value    = segment.Substring(index + 1);
                        switch (property)
                        {
                        case "shape":
                            placement.ShapeType = value;
                            break;

                        case "alternate":
                            placement.Alternates = new[] { value };
                            break;

                        case "wrapper":
                            placement.Wrappers = new[] { value };
                            break;
                        }
                    }
                }

                builder.Describe(shapeType)
                .From(feature)
                .Placement(ctx => {
                    var hit = predicate(ctx);
                    // generate 'debugging' information to trace which file originated the actual location
                    if (hit)
                    {
                        var virtualPath = featureDescriptor.Extension.Location + "/" + featureDescriptor.Extension.Id + "/Placement.info";
                        ctx.Source      = virtualPath;
                    }
                    return(hit);
                }, placement);
            }
        }
示例#5
0
        private void ProcessPlacementFile(ShapeTableBuilder builder, IFeatureInfo featureDescriptor, PlacementFile placementFile)
        {
            foreach (var entry in placementFile)
            {
                var shapeType = entry.Key;

                foreach (var filter in entry.Value)
                {
                    var matches = filter.Filters.ToList();

                    Func <ShapePlacementContext, bool> predicate = ctx => CheckFilter(ctx, filter);

                    if (matches.Any())
                    {
                        predicate = matches.Aggregate(predicate, BuildPredicate);
                    }

                    var placement = new PlacementInfo();

                    placement.Location = filter.Location;
                    if (filter.Alternates?.Length > 0)
                    {
                        placement.Alternates = new AlternatesCollection(filter.Alternates);
                    }

                    if (filter.Wrappers?.Length > 0)
                    {
                        placement.Wrappers = new AlternatesCollection(filter.Wrappers);
                    }

                    placement.ShapeType = filter.ShapeType;

                    builder.Describe(shapeType)
                    .From(featureDescriptor)
                    .Placement(ctx => predicate(ctx), placement);
                }
            }
        }