示例#1
0
 public static ModelShapeBuilder WithParent(this ModelShapeBuilder builder, ModelShapeContext parent)
 {
     if (parent == null)
     {
         builder.Context.ParentContext = null;
         builder.Context.CustomContext = null;
     }
     else
     {
         builder.Context.ParentContext = parent;
         builder.Context.CustomContext = parent.CustomContext;
     }
     return(builder);
 }
示例#2
0
        public void Build(ModelShapeBuilder builder, dynamic root)
        {
            var context = builder.Context;

            context.Shape = root;

            BindPlacement(context, context.DisplayType, context.Stereotype, builder.ContentType);

            foreach (var driver in Drivers)
            {
                var result = driver.Run(context);
                // Null check for driver result
                if (result != null)
                {
                    result.Apply(context);
                }
            }

            // Chain sub results?
            // They are applied to the same base object (as opposed to rendering an entirely new shape with its own zones)
            foreach (var chain in context.ChainedResults)
            {
                var newRoot = chain.Root ?? root;

                Build(
                    Builder(chain.Model)
                    // TODO: Could be nice to chain from displays to editors and back; assuming updater is available
                    // To do that we could pass a whole new Builder into context instead of this hack?
                    .WithMode(context.Mode)
                    .WithUpdater(context.Updater, chain.Prefix)
                    .WithDisplayType(chain.DisplayType ?? context.DisplayType)
                    .WithStereotype(context.Stereotype)
                    .WithContentType(builder.ContentType)
                    .WithParent(context)
                    .WithParadigms(context.Paradigms)
                    , newRoot);

                // Fire an event so parent shape can perform work after the update
                chain.OnCompleted(context);
            }

            // Invoke Updated event now all drivers have been executed
            if (context.Updater != null)
            {
                context.InvokeUpdated();
            }

            // Done
        }
示例#3
0
        public void Build(ModelShapeBuilder builder, dynamic root) {
            var context = builder.Context;
            context.Shape = root;

            BindPlacement(context, context.DisplayType, context.Stereotype, builder.ContentType);

            foreach (var driver in Drivers) {
                var result = driver.Run(context);
                // Null check for driver result
                if (result != null) {
                    result.Apply(context);
                }
            }

            // Chain sub results?
            // They are applied to the same base object (as opposed to rendering an entirely new shape with its own zones)
            foreach (var chain in context.ChainedResults) {
                var newRoot = chain.Root ?? root;

                Build(
                    Builder(chain.Model)
                        // TODO: Could be nice to chain from displays to editors and back; assuming updater is available 
                        // To do that we could pass a whole new Builder into context instead of this hack?
                        .WithMode(context.Mode)
                        .WithUpdater(context.Updater,chain.Prefix)
                        .WithDisplayType(chain.DisplayType??context.DisplayType)
                        .WithStereotype(context.Stereotype)
                        .WithContentType(builder.ContentType)
                        .WithParent(context)
                        .WithParadigms(context.Paradigms)
                        ,newRoot);

                // Fire an event so parent shape can perform work after the update
                chain.OnCompleted(context);
            }

            // Invoke Updated event now all drivers have been executed
            if (context.Updater != null) {
                context.InvokeUpdated();
            }

            // Done
        }
示例#4
0
 public static ModelShapeBuilder WithGroup(this ModelShapeBuilder builder, string groupId)
 {
     builder.Context.GroupId = groupId;
     return(builder);
 }
示例#5
0
 public static ModelShapeBuilder WithParadigms(this ModelShapeBuilder builder, ParadigmsContext paradigms)
 {
     builder.Context.Paradigms = new ParadigmsContext(paradigms);
     return(builder);
 }
示例#6
0
 public static ModelShapeBuilder WithParadigms(this ModelShapeBuilder builder, IEnumerable <String> paradigms)
 {
     builder.Context.Paradigms.Add(paradigms);
     return(builder);
 }
示例#7
0
 public static ModelShapeBuilder WithParadigms(this ModelShapeBuilder builder, params string[] paradigms)
 {
     builder.Context.Paradigms.Add(paradigms);
     return(builder);
 }
示例#8
0
 public static ModelShapeBuilder WithContentType(this ModelShapeBuilder builder, string contentType)
 {
     builder.ContentType = contentType;
     return(builder);
 }
示例#9
0
 public static ModelShapeBuilder WithStereotype(this ModelShapeBuilder builder, string stereotype)
 {
     builder.Context.Stereotype = stereotype;
     return(builder);
 }
示例#10
0
 public static ModelShapeBuilder WithDisplayType(this ModelShapeBuilder builder, string displayType)
 {
     builder.Context.DisplayType = displayType;
     return(builder);
 }
示例#11
0
 public static ModelShapeBuilder WithUpdater(this ModelShapeBuilder builder, IUpdateModel updater, string prefix)
 {
     builder.Context.Updater = updater;
     builder.Context.Prefix  = prefix;
     return(builder);
 }
示例#12
0
 public static ModelShapeBuilder WithMode(this ModelShapeBuilder builder, string mode)
 {
     builder.Context.Mode = mode;
     return(builder);
 }