Exemple #1
0
        public static async Task <CompositeDataMap> Expand(ApplicationSchemaDefinition compositeApplication, DataMap compositeDataMap)
        {
            var repository = new DataRepository();
            var components = new List <Component>();

            foreach (var composition in compositeApplication.Compositions)
            {
                var filters = new List <FilterExpression>();

                // Handles the composition criteria, which can
                // be either literals ("hardcoded") values or
                // based on the data map current state.
                foreach (var criterion in composition.EntityAssociation.Attributes)
                {
                    var value = string.IsNullOrEmpty(criterion.Literal)
                        ? compositeDataMap.Value(criterion.From)
                        : criterion.Literal;

                    filters.Add(new Exactly(criterion.To, value));
                }

                // Fetches all data maps ("components") that
                // satisfies the composition criteria.
                var componentApplication = composition.To();
                var componentDataMaps    = (await repository
                                            .LoadAsync(componentApplication, filters))
                                           .ToList();

                components.Add(new Component(componentApplication, componentDataMaps));
            }

            return(new CompositeDataMap(compositeApplication, compositeDataMap, components));
        }
Exemple #2
0
 public static string Id(this DataMap dataMap, IApplicationIdentifier application)
 {
     return(dataMap.Value(application.IdFieldName));
 }
Exemple #3
0
 public static T Id <T>(this DataMap dataMap, IApplicationIdentifier application)
 {
     return(dataMap.Value <T>(application.IdFieldName));
 }