/// <summary>
        /// 绑定配置。
        /// </summary>
        /// <param name="bindingSource">绑定源。</param>
        /// <param name="binder">绑定委托。</param>
        /// <returns>形状候补建造者。</returns>
        public ShapeAlterationBuilder BoundAs(string bindingSource, Func <ShapeDescriptor, Func <DisplayContext, IHtmlString> > binder)
        {
            return(Configure(descriptor =>
            {
                Func <DisplayContext, IHtmlString> target = null;

                var binding = new ShapeBinding
                {
                    ShapeDescriptor = descriptor,
                    BindingName = _bindingName,
                    BindingSource = bindingSource,
                    Binding = displayContext =>
                    {
                        if (target == null)
                        {
                            target = binder(descriptor);
                        }

                        return target(displayContext);
                    }
                };

                descriptor.Bindings[_bindingName] = binding;
            }));
        }
        /// <summary>
        /// 绑定配置。
        /// </summary>
        /// <param name="bindingSource">绑定源。</param>
        /// <param name="binder">绑定委托。</param>
        /// <returns>形状候补建造者。</returns>
        public ShapeAlterationBuilder BoundAs(string bindingSource, Func<ShapeDescriptor, Func<DisplayContext, IHtmlString>> binder)
        {
            return Configure(descriptor =>
            {
                Func<DisplayContext, IHtmlString> target = null;

                var binding = new ShapeBinding
                {
                    ShapeDescriptor = descriptor,
                    BindingName = _bindingName,
                    BindingSource = bindingSource,
                    Binding = displayContext =>
                    {
                        if (target == null)
                            target = binder(descriptor);

                        return target(displayContext);
                    }
                };

                descriptor.Bindings[_bindingName] = binding;
            });
        }
 private static IHtmlString Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context)
 {
     if (shapeBinding == null || shapeBinding.Binding == null)
     {
         return shape.Metadata.ChildContent ?? new HtmlString(string.Empty);
     }
     return CoerceHtmlString(shapeBinding.Binding(context));
 }
        private static bool TryGetDescriptorBinding(string shapeType, IEnumerable<string> shapeAlternates, ShapeTable shapeTable, out ShapeBinding shapeBinding)
        {
            foreach (var shapeAlternate in shapeAlternates.Reverse())
            {
                if (shapeTable.Bindings.TryGetValue(shapeAlternate, out shapeBinding))
                {
                    return true;
                }
            }

            var shapeTypeScan = shapeType;
            for (; ; )
            {
                if (shapeTable.Bindings.TryGetValue(shapeTypeScan, out shapeBinding))
                {
                    return true;
                }

                var delimiterIndex = shapeTypeScan.LastIndexOf("__", StringComparison.Ordinal);
                if (delimiterIndex < 0)
                {
                    return false;
                }

                shapeTypeScan = shapeTypeScan.Substring(0, delimiterIndex);
            }
        }