Exemplo n.º 1
0
            public static int GenerateGraph(RelationalModelRepository repo, EntityPivot parent, int depth, int maxDepth, int branchSize)
            {
                if (depth == maxDepth)
                    return 0;

                var runningTotalCreated = 0;

                var children = new List<Relation>();
                for (var i = 0; i < branchSize; i++)
                {
                    var child = new EntityPivot(parent) { Id = Guid.NewGuid() };
                    var relation = new ContentOneToManyRelation(parent, child);
                    children.Add(relation);

                    children.AddRange(from permissionEntity in GetPermissionEntities(child)
                                      let metadata = new RelationMetadata(PermissionRelationType.Default)
                                                         {
                                                             {"allow", "read"},
                                                             {"deny", "write"}
                                                         }
                                      select new PermissionRelation(metadata, child, permissionEntity));

                    runningTotalCreated++;
                    runningTotalCreated += GenerateGraph(repo, child, depth + 1, maxDepth, branchSize);
                }
                parent.AddAssociates(children);
                return runningTotalCreated;
            }
Exemplo n.º 2
0
            public static int GenerateGraph(RelationalModelRepository repo, EntityPivot parent, int depth, int maxDepth, int branchSize)
            {
                if (depth == maxDepth)
                {
                    return(0);
                }

                var runningTotalCreated = 0;

                var children = new List <Relation>();

                for (var i = 0; i < branchSize; i++)
                {
                    var child = new EntityPivot(parent)
                    {
                        Id = Guid.NewGuid()
                    };
                    var relation = new ContentOneToManyRelation(parent, child);
                    children.Add(relation);

                    children.AddRange(from permissionEntity in GetPermissionEntities(child)
                                      let metadata = new RelationMetadata(PermissionRelationType.Default)
                    {
                        { "allow", "read" },
                        { "deny", "write" }
                    }
                                      select new PermissionRelation(metadata, child, permissionEntity));

                    runningTotalCreated++;
                    runningTotalCreated += GenerateGraph(repo, child, depth + 1, maxDepth, branchSize);
                }
                parent.AddAssociates(children);
                return(runningTotalCreated);
            }
Exemplo n.º 3
0
 public static IEnumerable<EntityPivot> GetPermissionEntities(EntityPivot parent)
 {
     if (PermissionEntities.Count == 0)
     {
         PermissionEntities.Add(new EntityPivot(parent));
         PermissionEntities.Add(new EntityPivot(parent));
         PermissionEntities.Add(new EntityPivot(parent));
     }
     return PermissionEntities;
 }
Exemplo n.º 4
0
 public static IEnumerable <EntityPivot> GetPermissionEntities(EntityPivot parent)
 {
     if (PermissionEntities.Count == 0)
     {
         PermissionEntities.Add(new EntityPivot(parent));
         PermissionEntities.Add(new EntityPivot(parent));
         PermissionEntities.Add(new EntityPivot(parent));
     }
     return(PermissionEntities);
 }
Exemplo n.º 5
0
        public static void Init(TestContext context)
        {
            _modelRepository = new RelationalModelRepository();

            _pivotRoot = new EntityPivot(_modelRepository) { Id = Guid.Empty };
            var timer = new Stopwatch();
            timer.Start();
            var generateGraph = GraphBuilder.HiveGraphBuilder.GenerateGraph(_modelRepository, _pivotRoot, 0, 10, 15);
            Console.WriteLine("{0} EntityPivots created in {1}ms",
                              generateGraph, timer.ElapsedMilliseconds);
        }
Exemplo n.º 6
0
        public static void Init(TestContext context)
        {
            _modelRepository = new RelationalModelRepository();

            _pivotRoot = new EntityPivot(_modelRepository)
            {
                Id = Guid.Empty
            };
            var timer = new Stopwatch();

            timer.Start();
            var generateGraph = GraphBuilder.HiveGraphBuilder.GenerateGraph(_modelRepository, _pivotRoot, 0, 10, 15);

            Console.WriteLine("{0} EntityPivots created in {1}ms",
                              generateGraph, timer.ElapsedMilliseconds);
        }