private static PlacementInfo FindPlacementImpl(ShapeTable shapeTable, string shapeType, string differentiator, string displayType, IBuildShapeContext context)
        {
            var delimiterIndex = shapeType.IndexOf("__");

            if (delimiterIndex > 0)
            {
                shapeType = shapeType.Substring(0, delimiterIndex);
            }

            if (shapeTable.Descriptors.TryGetValue(shapeType, out var descriptor))
            {
                var placementContext = new ShapePlacementContext(
                    shapeType,
                    displayType,
                    differentiator,
                    context.Shape
                    );

                var placement = descriptor.Placement(placementContext);
                if (placement != null)
                {
                    placement.Source = placementContext.Source;
                    return(placement);
                }
            }

            return(null);
        }
Exemple #2
0
        private void BindPlacement(ModelShapeContext context, string displayType, string stereotype)
        {
            context.FindPlacement = (partShapeType, differentiator, defaultLocation) =>
            {
                var theme      = _themeService.Value.GetRequestTheme(_requestContext);
                var shapeTable = _shapeTableManager.GetShapeTable(theme.Id);
                var request    = _requestContext.HttpContext.Request;

                ShapeDescriptor descriptor;
                if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor))
                {
                    var placementContext = new ShapePlacementContext
                    {
                        Stereotype     = stereotype,
                        DisplayType    = displayType,
                        Differentiator = differentiator,
                        Path           = VirtualPathUtility.AppendTrailingSlash(VirtualPathUtility.ToAppRelative(request.Path)) // get the current app-relative path, i.e. ~/my-blog/foo
                    };

                    var placement = descriptor.Placement(placementContext);
                    if (placement != null)
                    {
                        placement.Source = placementContext.Source;
                        return(placement);
                    }
                }

                return(new PlacementInfo
                {
                    Location = defaultLocation,
                    Source = String.Empty
                });
            };
        }
        public void TwoArgumentVariationDoesSameThing()
        {
            var shapeDetail  = new ShapePlacementContext("Foo", "Detail", "", null);
            var shapeSummary = new ShapePlacementContext("Foo", "Summary", "", null);
            var shapeTitle   = new ShapePlacementContext("Foo", "Title", "", null);

            _serviceProvider.GetService <TestShapeProvider>().Discover =
                builder => builder.Describe("Hello2").From(TestFeature())
                .Placement(ctx => ctx.DisplayType == "Detail", new PlacementInfo {
                Location = "Main"
            })
                .Placement(ctx => ctx.DisplayType == "Summary", new PlacementInfo {
                Location = ""
            });

            var manager = _serviceProvider.GetService <IShapeTableManager>();
            var hello   = manager.GetShapeTable(null).Descriptors["Hello2"];
            var result1 = hello.Placement(shapeDetail);
            var result2 = hello.Placement(shapeSummary);
            var result3 = hello.Placement(shapeTitle);

            hello.DefaultPlacement = "Header:5";
            var result4 = hello.Placement(shapeDetail);
            var result5 = hello.Placement(shapeSummary);
            var result6 = hello.Placement(shapeTitle);

            Assert.Equal("Main", result1.Location);
            Assert.Empty(result2.Location);
            Assert.Null(result3);
            Assert.Equal("Main", result4.Location);
            Assert.Empty(result5.Location);
            Assert.Equal("Header:5", result6.Location);
        }
Exemple #4
0
        public bool IsMatch(ShapePlacementContext context, JToken expression)
        {
            var contentItem = GetContent(context);

            if (contentItem == null)
            {
                return(false);
            }

            IEnumerable <string> contentTypes;

            if (expression is JArray)
            {
                contentTypes = expression.Values <string>();
            }
            else
            {
                contentTypes = new string[] { expression.Value <string>() };
            }

            return(contentTypes.Any(ct =>
            {
                if (ct.EndsWith('*'))
                {
                    var prefix = ct.Substring(0, ct.Length - 1);

                    return (contentItem.ContentType ?? "").StartsWith(prefix, StringComparison.OrdinalIgnoreCase) || (GetStereotype(context) ?? "").StartsWith(prefix, StringComparison.OrdinalIgnoreCase);
                }

                return contentItem.ContentType == ct || GetStereotype(context) == ct;
            }));
        }
Exemple #5
0
        protected async Task BindPlacementAsync(IBuildShapeContext context)
        {
            var theme = await _themeManager.GetThemeAsync();

            var shapeTable = _shapeTableManager.GetShapeTable(theme.Id);

            context.FindPlacement = (partShapeType, differentiator, displayType) =>
            {
                ShapeDescriptor descriptor;
                if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor))
                {
                    var placementContext = new ShapePlacementContext
                    {
                        Shape = context.Shape
                    };

                    var placement = descriptor.Placement(placementContext);
                    if (placement != null)
                    {
                        placement.Source = placementContext.Source;
                        return(placement);
                    }
                }

                return(null);
            };
        }
Exemple #6
0
        public bool IsMatch(ShapePlacementContext context, JToken expression)
        {
            IEnumerable <string> paths;

            if (expression is JArray)
            {
                paths = expression.Values <string>();
            }
            else
            {
                paths = new string[] { expression.Value <string>() };
            }

            var requestPath = _httpContextAccessor.HttpContext.Request.Path;

            return(paths.Any(p =>
            {
                var normalizedPath = NormalizePath(p);

                if (normalizedPath.EndsWith("*"))
                {
                    var prefix = normalizedPath.Substring(0, normalizedPath.Length - 1);
                    return requestPath.ToString().StartsWith(prefix, StringComparison.OrdinalIgnoreCase);
                }

                normalizedPath = AppendTrailingSlash(normalizedPath);
                requestPath = AppendTrailingSlash(requestPath);
                return requestPath.ToString().Equals(normalizedPath, StringComparison.OrdinalIgnoreCase);
            }));
        }
Exemple #7
0
        private async Task BindPlacementAsync(BuildShapeContext context, string displayType, string stereotype)
        {
            var theme = await _themeManager.GetThemeAsync();

            var shapeTable = _shapeTableManager.GetShapeTable(theme.Id);

            context.FindPlacement = (partShapeType, differentiator, defaultLocation) => {
                ShapeDescriptor descriptor;
                if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor))
                {
                    var placementContext = new ShapePlacementContext
                    {
                        Shape = context.Shape
                    };

                    // define which location should be used if none placement is hit
                    descriptor.DefaultPlacement = defaultLocation;

                    var placement = descriptor.Placement(placementContext);
                    if (placement != null)
                    {
                        placement.Source = placementContext.Source;
                        return(placement);
                    }
                }

                return(new PlacementInfo
                {
                    Location = defaultLocation,
                    Source = String.Empty
                });
            };
        }
Exemple #8
0
        private string GetStereotype(ShapePlacementContext context)
        {
            var    shape         = context.ZoneShape as Shape;
            object stereotypeVal = null;

            shape?.Properties?.TryGetValue("Stereotype", out stereotypeVal);
            return(stereotypeVal?.ToString());
        }
            public PlacementInfo ResolvePlacement(ShapePlacementContext placementContext)
            {
                PlacementInfo placement = null;

                if (_placements.ContainsKey(placementContext.ShapeType))
                {
                    var shapePlacements = _placements[placementContext.ShapeType];

                    foreach (var placementRule in shapePlacements)
                    {
                        var filters = placementRule.Filters.ToList();

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

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

                        if (!predicate(placementContext))
                        {
                            // Ignore rule
                            continue;
                        }

                        if (placement == null)
                        {
                            placement = new PlacementInfo
                            {
                                Source = "OrchardCore.Placements"
                            };
                        }

                        if (!string.IsNullOrEmpty(placementRule.Location))
                        {
                            placement.Location = placementRule.Location;
                        }

                        if (!string.IsNullOrEmpty(placementRule.ShapeType))
                        {
                            placement.ShapeType = placementRule.ShapeType;
                        }

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

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

                return(placement);
            }
Exemple #10
0
        public bool Match(ShapePlacementContext context, string expression)
        {
            if (expression.EndsWith("*"))
            {
                var prefix = expression.Substring(0, expression.Length - 1);
                return((context.DisplayType ?? "").StartsWith(prefix));
            }

            return(context.DisplayType == expression);
        }
Exemple #11
0
        protected ContentItem GetContent(ShapePlacementContext context)
        {
            if (!HasContent(context))
            {
                return(null);
            }

            var shape = context.ZoneShape as Shape;

            return(shape.Properties["ContentItem"] as ContentItem);
        }
Exemple #12
0
        public static T Model <T> (this ShapePlacementContext ctx)
            where T : class
        {
            var ctx2 = ctx as ModelShapePlacementContext;

            if (ctx2 == null)
            {
                return(default(T));
            }

            return(ctx2.ModelContext.Model as T);
        }
Exemple #13
0
        protected ContentItem GetContent(ShapePlacementContext context)
        {
            if (!HasContent(context))
            {
                return(null);
            }

            var shape = context.ZoneShape as Shape;

            shape.TryGetProperty("ContentItem", out ContentItem contentItem);

            return(contentItem);
        }
        DriverResult IContentPartDriver.UpdateEditor(UpdateEditorContext context)
        {
            var part = context.ContentItem.As <TContent>();

            if (part == null)
            {
                return(null);
            }

            // checking if the editor needs to be updated (e.g. if it was not hidden)
            var editor = Editor(part, context.New) as ContentShapeResult;

            if (editor != null)
            {
                ShapeDescriptor descriptor;
                if (context.ShapeTable.Descriptors.TryGetValue(editor.GetShapeType(), out descriptor))
                {
                    var placementContext = new ShapePlacementContext {
                        Content        = part.ContentItem,
                        ContentType    = part.ContentItem.ContentType,
                        Differentiator = editor.GetDifferentiator(),
                        DisplayType    = null,
                        Path           = context.Path
                    };

                    var location = descriptor.Placement(placementContext).Location;

                    if (String.IsNullOrEmpty(location) || location == "-")
                    {
                        return(editor);
                    }

                    var editorGroup  = editor.GetGroup() ?? "";
                    var contextGroup = context.GroupId ?? "";

                    if (!String.Equals(editorGroup, contextGroup, StringComparison.OrdinalIgnoreCase))
                    {
                        return(editor);
                    }
                }
            }

            DriverResult result = Editor(part, context.Updater, context.New);

            if (result != null)
            {
                result.ContentPart = part;
            }

            return(result);
        }
Exemple #15
0
        public static bool CheckFilter(ShapePlacementContext ctx, PlacementNode filter)
        {
            if (!String.IsNullOrEmpty(filter.DisplayType) && filter.DisplayType != ctx.DisplayType)
            {
                return(false);
            }

            if (!String.IsNullOrEmpty(filter.Differentiator) && filter.Differentiator != ctx.Differentiator)
            {
                return(false);
            }

            return(true);
        }
Exemple #16
0
        public static bool CheckFilter(ShapePlacementContext ctx, PlacementNode filter)
        {
            if (!String.IsNullOrEmpty(filter.DisplayType) && filter.DisplayType != ctx.DisplayType)
            {
                return(false);
            }

            if (!String.IsNullOrEmpty(filter.Differentiator) && filter.Differentiator != ctx.Differentiator)
            {
                return(false);
            }

            return(true);

            //switch (term.Key)
            //{
            //case "ContentPart":
            //    return ctx => ctx.Content != null
            //        && ctx.Content.ContentItem.Has(expression)
            //        && predicate(ctx);
            //case "ContentType":
            //    if (expression.EndsWith("*"))
            //    {
            //        var prefix = expression.Substring(0, expression.Length - 1);
            //        return ctx => ((ctx.ContentType ?? "").StartsWith(prefix) || (ctx.Stereotype ?? "").StartsWith(prefix)) && predicate(ctx);
            //    }
            //    return ctx => ((ctx.ContentType == expression) || (ctx.Stereotype == expression)) && predicate(ctx);
            //case "DisplayType":
            //    if (expression.EndsWith("*"))
            //    {
            //        var prefix = expression.Substring(0, expression.Length - 1);
            //        return ctx => (ctx.DisplayType ?? "").StartsWith(prefix) && predicate(ctx);
            //    }
            //    return ctx => (ctx.DisplayType == expression) && predicate(ctx);
            //case "Path":
            //    throw new Exception("Path Not currently Supported");
            //var normalizedPath = VirtualPathUtility.IsAbsolute(expression)
            //                         ? VirtualPathUtility.ToAppRelative(expression)
            //                         : VirtualPathUtility.Combine("~/", expression);

            //if (normalizedPath.EndsWith("*")) {
            //    var prefix = normalizedPath.Substring(0, normalizedPath.Length - 1);
            //    return ctx => VirtualPathUtility.ToAppRelative(String.IsNullOrEmpty(ctx.Path) ? "/" : ctx.Path).StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && predicate(ctx);
            //}

            //normalizedPath = VirtualPathUtility.AppendTrailingSlash(normalizedPath);
            //return ctx => (ctx.Path.Equals(normalizedPath, StringComparison.OrdinalIgnoreCase)) && predicate(ctx);
            //}
        }
Exemple #17
0
        public bool Match(ShapePlacementContext context, string expression)
        {
            var normalizedPath = VirtualPathUtility.IsAbsolute(expression)
                                            ? VirtualPathUtility.ToAppRelative(expression)
                                            : VirtualPathUtility.Combine("~/", expression);

            if (normalizedPath.EndsWith("*"))
            {
                var prefix = normalizedPath.Substring(0, normalizedPath.Length - 1);
                return(VirtualPathUtility.ToAppRelative(string.IsNullOrEmpty(context.Path) ? "/" : context.Path).StartsWith(prefix, StringComparison.OrdinalIgnoreCase));
            }

            normalizedPath = VirtualPathUtility.AppendTrailingSlash(normalizedPath);
            return(context.Path.Equals(normalizedPath, StringComparison.OrdinalIgnoreCase));
        }
Exemple #18
0
        public bool IsMatch(ShapePlacementContext context, JToken expression)
        {
            var contentItem = GetContent(context);

            if (contentItem == null)
            {
                return(false);
            }

            if (expression is JArray)
            {
                return(expression.Any(p => contentItem.Has(p.Value <string>())));
            }
            else
            {
                return(contentItem.Has(expression.Value <string>()));
            }
        }
        private static PlacementInfo FindPlacementImpl(IList <IPlacementInfoResolver> placementResolvers, string shapeType, string differentiator, string displayType, IBuildShapeContext context)
        {
            var delimiterIndex = shapeType.IndexOf("__", StringComparison.Ordinal);

            if (delimiterIndex > 0)
            {
                shapeType = shapeType.Substring(0, delimiterIndex);
            }

            var placementContext = new ShapePlacementContext(
                shapeType,
                displayType,
                differentiator,
                context.Shape
                );

            return(placementResolvers.Aggregate <IPlacementInfoResolver, PlacementInfo>(null, (prev, resolver) =>
                                                                                        PlacementInfoExtensions.Combine(prev, resolver.ResolvePlacement(placementContext))
                                                                                        ));
        }
Exemple #20
0
        public bool Match(ShapePlacementContext context, string expression)
        {
            // expression is a comma-separated list of part names
            var partNames = expression
                            .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                            .Select(s => s.Trim())
                            .Where(s => !string.IsNullOrWhiteSpace(s));
            var match = context.Content != null && context.Content.ContentItem != null;

            if (match)
            {
                // we will return true if the content has all the parts we selected
                foreach (var name in partNames)
                {
                    match &= context.Content.ContentItem.Parts
                             .Any(pa => pa.PartDefinition.Name.Equals(name));
                }
            }
            return(match);
        }
Exemple #21
0
        public bool WasDisplayed(UpdateEditorContext context)
        {
            ShapeDescriptor descriptor;

            if (context.ShapeTable.Descriptors.TryGetValue(_shapeType, out descriptor))
            {
                var placementContext = new ShapePlacementContext {
                    Content        = context.ContentItem,
                    ContentType    = context.ContentItem.ContentType,
                    Differentiator = _differentiator,
                    DisplayType    = null,
                    Path           = context.Path
                };

                var placementInfo = descriptor.Placement(placementContext);

                var location = placementInfo.Location;

                if (String.IsNullOrEmpty(location) || location == "-")
                {
                    return(false);
                }

                var editorGroup = _groupId;
                if (String.IsNullOrEmpty(editorGroup))
                {
                    editorGroup = placementInfo.GetGroup() ?? "";
                }

                var contextGroup = context.GroupId ?? "";

                if (!String.Equals(editorGroup, contextGroup, StringComparison.OrdinalIgnoreCase))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #22
0
        private void BindPlacement(BuildShapeContext context, string displayType, string stereotype)
        {
            context.FindPlacement = (partShapeType, differentiator, defaultLocation) =>
            {
                var theme      = _siteThemeService.GetSiteTheme();
                var shapeTable = _shapeTableLocator.Lookup(theme.Id);

                var request = _requestContext.HttpContext.Request;

                ShapeDescriptor descriptor;
                if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor))
                {
                    var placementContext = new ShapePlacementContext
                    {
                        ContentType    = context.ContentItem.ContentType,
                        Stereotype     = stereotype,
                        DisplayType    = displayType,
                        Differentiator = differentiator,
                        Path           = VirtualPathUtility.AppendTrailingSlash(_virtualPathProvider.ToAppRelative(request.Path)) // get the current app-relative path, i.e. ~/my-blog/foo
                    };

                    // define which location should be used if none placement is hit
                    descriptor.DefaultPlacement = defaultLocation;

                    var placement = descriptor.Placement(placementContext);
                    if (placement != null)
                    {
                        placement.Source = placementContext.Source;
                        return(placement);
                    }
                }

                return(new PlacementInfo
                {
                    Location = defaultLocation,
                    Source = String.Empty
                });
            };
        }
        private void BindPlacement(BuildShapeContext context, string displayType, string stereotype, string bindingType)
        {
            context.FindPlacement = (partShapeType, differentiator, defaultLocation) => {
                var workContext = _workContextAccessor.GetContext(_requestContext.HttpContext);

                var theme      = workContext.CurrentTheme;
                var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id);

                ShapeDescriptor descriptor;
                if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor))
                {
                    var placementContext = new ShapePlacementContext {
                        Content        = context.ContentItem,
                        ContentType    = context.ContentItem.ContentType,
                        Stereotype     = stereotype,
                        DisplayType    = displayType,
                        BindingType    = bindingType,
                        Differentiator = differentiator,
                        Path           = GetPath()
                    };

                    // define which location should be used if none placement is hit
                    descriptor.DefaultPlacement = defaultLocation;

                    var placement = descriptor.Placement(placementContext);
                    if (placement != null)
                    {
                        placement.Source = placementContext.Source;
                        return(placement);
                    }
                }

                return(new PlacementInfo {
                    Location = defaultLocation,
                    Source = String.Empty
                });
            };
        }
        private static PlacementInfo FindPlacementImpl(ShapeTable shapeTable, string shapeType, string differentiator, string displayType, IBuildShapeContext context)
        {
            ShapeDescriptor descriptor;

            if (shapeTable.Descriptors.TryGetValue(shapeType, out descriptor))
            {
                var placementContext = new ShapePlacementContext(
                    shapeType,
                    displayType,
                    differentiator,
                    context.Shape
                    );

                var placement = descriptor.Placement(placementContext);
                if (placement != null)
                {
                    placement.Source = placementContext.Source;
                    return(placement);
                }
            }

            return(null);
        }
Exemple #25
0
        private static PlacementInfo FindPlacementImpl(ShapeTable shapeTable, IShape shape, string differentiator, string displayType)
        {
            ShapeDescriptor descriptor;
            var             shapeType = shape.Metadata.Type;

            if (shapeTable.Descriptors.TryGetValue(shapeType, out descriptor))
            {
                var placementContext = new ShapePlacementContext
                {
                    Shape          = shape,
                    DisplayType    = displayType,
                    Differentiator = differentiator
                };

                var placement = descriptor.Placement(placementContext);
                if (placement != null)
                {
                    placement.Source = placementContext.Source;
                    return(placement);
                }
            }

            return(null);
        }
        public static bool CheckFilter(ShapePlacementContext ctx, PlacementNode filter)
        {
            if (!String.IsNullOrEmpty(filter.DisplayType) && filter.DisplayType != ctx.DisplayType)
            {
                return false;
            }

            if (!String.IsNullOrEmpty(filter.Differentiator) && filter.Differentiator != ctx.Differentiator)
            {
                return false;
            }

            return true;

            //switch (term.Key)
            //{
            //case "ContentPart":
            //    return ctx => ctx.Content != null
            //        && ctx.Content.ContentItem.Has(expression)
            //        && predicate(ctx);
            //case "ContentType":
            //    if (expression.EndsWith("*"))
            //    {
            //        var prefix = expression.Substring(0, expression.Length - 1);
            //        return ctx => ((ctx.ContentType ?? "").StartsWith(prefix) || (ctx.Stereotype ?? "").StartsWith(prefix)) && predicate(ctx);
            //    }
            //    return ctx => ((ctx.ContentType == expression) || (ctx.Stereotype == expression)) && predicate(ctx);
            //case "DisplayType":
            //    if (expression.EndsWith("*"))
            //    {
            //        var prefix = expression.Substring(0, expression.Length - 1);
            //        return ctx => (ctx.DisplayType ?? "").StartsWith(prefix) && predicate(ctx);
            //    }
            //    return ctx => (ctx.DisplayType == expression) && predicate(ctx);
            //case "Path":
            //    throw new Exception("Path Not currently Supported");
            //var normalizedPath = VirtualPathUtility.IsAbsolute(expression)
            //                         ? VirtualPathUtility.ToAppRelative(expression)
            //                         : VirtualPathUtility.Combine("~/", expression);

            //if (normalizedPath.EndsWith("*")) {
            //    var prefix = normalizedPath.Substring(0, normalizedPath.Length - 1);
            //    return ctx => VirtualPathUtility.ToAppRelative(String.IsNullOrEmpty(ctx.Path) ? "/" : ctx.Path).StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && predicate(ctx);
            //}

            //normalizedPath = VirtualPathUtility.AppendTrailingSlash(normalizedPath);
            //return ctx => (ctx.Path.Equals(normalizedPath, StringComparison.OrdinalIgnoreCase)) && predicate(ctx);
            //}
        }
Exemple #27
0
 public bool Match(ShapePlacementContext context, string expression)
 {
     return(context.Content != null && context.Content.ContentItem.Parts.Any(part => part.PartDefinition.Name == expression));
 }
Exemple #28
0
        DriverResult IContentPartDriver.UpdateEditor(UpdateEditorContext context)
        {
            var part = context.ContentItem.As <TContent>();

            if (part == null)
            {
                return(null);
            }

            // checking if the editor needs to be updated (e.g. if any of the shapes were not hidden)
            DriverResult editor = Editor(part, context.New);
            IEnumerable <ContentShapeResult> contentShapeResults = GetShapeResults(editor);

            if (contentShapeResults.Any(contentShapeResult => {
                if (contentShapeResult == null)
                {
                    return(true);
                }

                ShapeDescriptor descriptor;
                if (context.ShapeTable.Descriptors.TryGetValue(contentShapeResult.GetShapeType(), out descriptor))
                {
                    var placementContext = new ShapePlacementContext {
                        Content = part.ContentItem,
                        ContentType = part.ContentItem.ContentType,
                        Differentiator = contentShapeResult.GetDifferentiator(),
                        DisplayType = null,
                        Path = context.Path
                    };

                    var placementInfo = descriptor.Placement(placementContext);

                    var location = placementInfo.Location;

                    if (String.IsNullOrEmpty(location) || location == "-")
                    {
                        return(false);
                    }

                    var editorGroup = contentShapeResult.GetGroup();
                    if (string.IsNullOrEmpty(editorGroup))
                    {
                        editorGroup = placementInfo.GetGroup() ?? "";
                    }
                    var contextGroup = context.GroupId ?? "";

                    if (!String.Equals(editorGroup, contextGroup, StringComparison.OrdinalIgnoreCase))
                    {
                        return(false);
                    }
                }

                return(true);
            }))
            {
                DriverResult result = Editor(part, context.Updater, context.New);

                if (result != null)
                {
                    result.ContentPart = part;
                }

                return(result);
            }

            return(editor);
        }
Exemple #29
0
        protected bool HasContent(ShapePlacementContext context)
        {
            var shape = context.ZoneShape as Shape;

            return(shape != null && shape.TryGetProperty("ContentItem", out object contentItem) && contentItem != null);
        }
Exemple #30
0
        private string GetStereotype(ShapePlacementContext context)
        {
            var shape = context.ZoneShape as Shape;

            return(shape?.Properties["Stereotype"]?.ToString());
        }
Exemple #31
0
        protected bool HasContent(ShapePlacementContext context)
        {
            var shape = context.ZoneShape as Shape;

            return(shape != null && shape.Properties["ContentItem"] != null);
        }