示例#1
0
 static MercuryApiController()
 {
     _viewModel = new AggregateModel()
     {
         ResponseModels = new List <ResponseModel>()
     };
 }
示例#2
0
 public void BuildEventInterfaceMethodsWithContext(AggregateModel context)
 {
     this.PushIndent("\t\t");
     foreach (DomainEvent evt in context.AggregateRoot.DomainEvents)
     {
         this.WriteLine("void Apply(" + evt.Name + " e, MessageContext context);");
     }
     this.PopIndent();
 }
示例#3
0
 public string GetAggregateRootDescription(AggregateModel context)
 {
     if (context != null && context.AggregateRoot != null)
     {
         return(context.AggregateRoot.Description);
     }
     else
     {
         return("Aggregate Root description cannot be obtained. Make sure your model contains an aggregate root with a description");
     }
 }
示例#4
0
 public string GetAggregateRootName(AggregateModel context)
 {
     if (context != null && context.AggregateRoot != null)
     {
         return(context.AggregateRoot.Name);
     }
     else
     {
         return("Aggregate Root name cannot be obtained. Make sure your model contains an aggregate root with a name");
     }
 }
示例#5
0
        public DispatcherTests()
        {
            Events   = Substitute.For <IEventStore>();
            Services = Substitute.For <IServiceProvider>();
            Services.GetService(typeof(Domains.Airline.FlightReservation)).Returns(new Domains.Airline.FlightReservation());
            var resv = new AggregateModel(typeof(Domains.Airline.FlightReservation));

            resv.SetFactoryHandler("Create");
            resv.AddCommandHandler("Cancel");
            Dispatcher = new Dispatcher(new BoundedContextModel(new[] { resv }), Events, Services);
        }
示例#6
0
 public void BuildCommandInterfaceMethodsWithContext(AggregateModel context)
 {
     this.PushIndent("\t\t");
     foreach (DomainCommand command in context.AggregateRoot.DomainCommands)
     {
         if (!string.IsNullOrEmpty(command.RequiredPrivilege))
         {
             this.WriteLine("[RequiresPrivilege(\"" + command.RequiredPrivilege + "\")]");
         }
         this.WriteLine("void Handle(" + command.Name + " c, MessageContext context);");
     }
     this.PopIndent();
 }
示例#7
0
        public async Task <IActionResult> OnGetAsync(Guid id)
        {
            Product = await _dispatcher.GetResultAsync(new GetProduct
            {
                ProductId = id
            });

            AggregateModel = await _dispatcher.GetResultAsync(new GetAggregateModel
            {
                AggregateRootId = id
            });

            return(Page());
        }
示例#8
0
        public IActionResult Post(AggregateModel model)
        {
            var queryView = _queryViewFinder.FindById(model.QueryViewId);

            if (queryView == null)
            {
                return(NotFound());
            }
            if (queryView != null && queryView.AggregateConfig.IsNotEmpty())
            {
                var aggFields = new List <AggregateExpressionField>().DeserializeFromJson(queryView.AggregateConfig);
                if (aggFields.NotEmpty())
                {
                    var queryExp = new QueryExpression().DeserializeFromJson(queryView.FetchConfig);
                    if (model.Filter != null &&
                        (model.Filter.Conditions.NotEmpty() || (model.Filter.Filters.NotEmpty() && model.Filter.Filters.First().Conditions.NotEmpty())))
                    {
                        queryExp.Criteria.AddFilter(model.Filter);
                    }
                    var aggExp = new AggregateExpression
                    {
                        ColumnSet       = queryExp.ColumnSet,
                        Criteria        = queryExp.Criteria,
                        EntityName      = queryExp.EntityName,
                        LinkEntities    = queryExp.LinkEntities,
                        AggregateFields = aggFields
                    };
                    var aggDatas   = _aggregateService.Execute(aggExp);
                    var attributes = _attributeFinder.FindByName(queryView.EntityId, aggFields.Select(x => x.AttributeName).ToArray());
                    foreach (dynamic item in aggDatas)
                    {
                        var line      = item as IDictionary <string, object>;
                        var attribute = attributes.Find(x => x.Name.IsCaseInsensitiveEqual(line.Keys.First()));
                        item.metadata      = new { attribute.Name, attribute.LocalizedName, attribute.AttributeTypeName, attribute.EntityId, attribute.EntityName, attribute.EntityLocalizedName };
                        item.aggregatetype = aggFields.Find(x => x.AttributeName.IsCaseInsensitiveEqual(attribute.Name)).AggregateType;
                    }
                    return(JOk(new { View = new { queryView.QueryViewId, queryView.Name }, Data = aggDatas }));
                }
            }
            return(JOk());
        }
示例#9
0
        public string GetCommandInterfaceExtenders(AggregateModel context)
        {
            //this.PushIndent("\t\t");
            StringBuilder sb    = new StringBuilder();
            int           count = 0;

            foreach (DomainCommand cmd in context.AggregateRoot.DomainCommands)
            {
                if (count == 0)
                {
                    sb.AppendFormat("\n\t\tIHandleCommand<{0}>\n", cmd.Name);
                }
                else
                {
                    sb.AppendFormat(",\n\t\tIHandleCommand<{0}>\n", cmd.Name);
                }
                count++;
            }
            //this.PopIndent();
            return(sb.ToString());
        }
示例#10
0
        public string GetEventInterfaceExtenders(AggregateModel context)
        {
            //IApplyEvent<PlayerCreated>
            //this.PushIndent("\t\t");
            StringBuilder sb    = new StringBuilder();
            int           count = 0;

            foreach (DomainEvent evt in context.AggregateRoot.DomainEvents)
            {
                if (count == 0)
                {
                    sb.AppendFormat("\n\t\tIApplyEvent<{0}>\n", evt.Name);
                }
                else
                {
                    sb.AppendFormat(",\n\t\tIApplyEvent<{0}>\n", evt.Name);
                }
                count++;
            }
            //this.PopIndent();
            return(sb.ToString());
        }
示例#11
0
        public override object EditValue(
            ITypeDescriptorContext context,
            IServiceProvider provider,
            object value)
        {
            if ((context == null) || (provider == null) || (context.PropertyDescriptor == null))
            {
                return(base.EditValue(context, provider, value));
            }

            _wfes = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            ListBox listBox = new ListBox();

            listBox.Sorted = true;
            listBox.Click += new EventHandler(List_Click);

            listBox.Items.Add("String");
            listBox.Items.Add("Boolean");
            listBox.Items.Add("Currency");
            listBox.Items.Add("DateTime");
            listBox.Items.Add("Decimal");
            listBox.Items.Add("Double");
            listBox.Items.Add("Int32");
            listBox.Items.Add("Single");
            listBox.Items.Add("Int62");
            listBox.Items.Add("Guid");
            listBox.Items.Add("Object");
            listBox.Items.Add("TimeSpan");

            ElementPropertyDescriptor desc = context.PropertyDescriptor as ElementPropertyDescriptor;
            Property       currentElement  = desc.ModelElement as Property;
            AggregateModel currentModel    = currentElement.AggregateModel;

            listBox.SelectedItem = value;

            _wfes.DropDownControl(listBox);
            return(listBox.SelectedItem);
        }
示例#12
0
        public void TestGenerate()
        {
            var code = @"using Atomiv.Core.Domain;

namespace Generator.Core.Domain.MyCats
{
    public class MyCatIdentity : Identity<int>
    {
        public static readonly MyCatIdentity Null = new MyCatIdentity(0);

        public MyCatIdentity(int id) : base(id)
        {
        }
    }
}";

            var model = new AggregateModel("MyCat", "MyCats");

            var identityGenerator = new IdentityGenerator(model);

            var identitySourceCode = identityGenerator.Generate();

            Assert.Equal(code, identitySourceCode);
        }
示例#13
0
 public AggregateModelTests()
 {
     Model = new AggregateModel(typeof(Domains.Airline.FlightReservation));
     Model.SetFactoryHandler(new CommandHandlerModel(Model.Type.GetMethods().Single(c => c.Name == "Create")));
     Model.AddCommandHandler(new CommandHandlerModel(Model.Type.GetMethods().Single(c => c.Name == "Cancel")));
 }
示例#14
0
 public IdentityGenerator(AggregateModel model) : base(model)
 {
 }
 public AggregateModelBuilder()
 {
     _model = new AggregateModel(typeof(T));
 }
        public BoundedContextModelTests()
        {
            var aggregate = new AggregateModel(typeof(Domains.Airline.FlightReservation));

            Model = new BoundedContextModel(new [] { aggregate });
        }
示例#17
0
 public Generator(AggregateModel model)
 {
     Model = model;
 }