Ejemplo n.º 1
0
 public static void WithWorkspaceRules(this PrefetchPolicyBuilder @this, Class @class)
 {
     foreach (var roleType in @class.WorkspaceRoleTypes)
     {
         @this.WithRule(roleType);
     }
 }
Ejemplo n.º 2
0
        // Indexer declaration
        public PrefetchPolicy this[IClass @class]
        {
            get
            {
                PrefetchPolicy prefetchPolicy;
                if (!this.prefetchPolicyByClass.TryGetValue(@class, out prefetchPolicy))
                {
                    var prefetchPolicyBuilder = new PrefetchPolicyBuilder();

                    foreach (var roleType in @class.RoleTypes)
                    {
                        prefetchPolicyBuilder.WithRule(roleType);
                    }

                    foreach (var associationType in @class.AssociationTypes)
                    {
                        prefetchPolicyBuilder.WithRule(associationType);
                    }

                    prefetchPolicy = prefetchPolicyBuilder.Build();
                    this.prefetchPolicyByClass[@class] = prefetchPolicy;
                }

                return prefetchPolicy;
            }
        }
Ejemplo n.º 3
0
        public static void WithSecurityRules(this PrefetchPolicyBuilder @this, Class @class)
        {
            if (@class.DelegatedAccessRoleTypes != null)
            {
                var builder = new PrefetchPolicyBuilder()
                              .WithRule(MetaObject.Instance.SecurityTokens, SecurityTokenPrefetchPolicy)
                              .WithRule(MetaObject.Instance.DeniedPermissions)
                              .Build();

                var delegatedAccessRoleTypes = @class.DelegatedAccessRoleTypes;
                foreach (var delegatedAccessRoleType in delegatedAccessRoleTypes)
                {
                    @this.WithRule(delegatedAccessRoleType, builder);
                }
            }

            @this.WithRule(MetaObject.Instance.SecurityTokens, SecurityTokenPrefetchPolicy);
            @this.WithRule(MetaObject.Instance.DeniedPermissions);
        }
Ejemplo n.º 4
0
 public static void WithSecurityRules(this PrefetchPolicyBuilder @this)
 {
     @this.WithRule(MetaAccessControlledObject.Instance.SecurityTokens, SecuritTokenPrefetchPolicy);
     @this.WithRule(MetaAccessControlledObject.Instance.DeniedPermissions);
 }
Ejemplo n.º 5
0
        public void PrefetchCompositesRoleOne2ManyEmptyAndUnit()
        {
            var prefetchPolicy = new PrefetchPolicyBuilder()
                .WithRule(C1.Meta.C1C2one2manies, new IPropertyType[] { C2.Meta.C2AllorsString })
                .Build();

            foreach (var twice in TrueFalse)
            {
                foreach (var init in this.Inits)
                {
                    init();

                    var c1A = C1.Create(this.Session);

                    this.Session.Commit();

                    this.Session.Prefetch(prefetchPolicy, c1A);
                    if (twice)
                    {
                        this.Session.Prefetch(prefetchPolicy, c1A);
                    }

                    Assert.AreEqual(0, c1A.C1C2one2manies.Count);

                    this.Session.Prefetch(prefetchPolicy, c1A);
                    if (twice)
                    {
                        this.Session.Prefetch(prefetchPolicy, c1A);
                    }

                    Assert.AreEqual(0, c1A.C1C2one2manies.Count);
                }
            }
        }
Ejemplo n.º 6
0
        public void PrefetchCompositeRoleOne2OneAndUnit()
        {
            var prefetchPolicy = new PrefetchPolicyBuilder()
                .WithRule(C1.Meta.C1C2one2one, new IPropertyType[] { C2.Meta.C2AllorsString })
                .Build();

            foreach (var twice in TrueFalse)
            {
                foreach (var init in this.Inits)
                {
                    init();

                    var c1a = C1.Create(this.Session);
                    var c2a = C2.Create(this.Session);
                    var c2b = C2.Create(this.Session);

                    c2a.C2AllorsString = "c2a";
                    c2b.C2AllorsString = "c2b";

                    c1a.C1C2one2one = c2a;

                    this.Session.Prefetch(prefetchPolicy, c1a);
                    if (twice)
                    {
                        this.Session.Prefetch(prefetchPolicy, c1a);
                    }

                    Assert.AreEqual(c2a, c1a.C1C2one2one);

                    this.Session.Commit();

                    Assert.AreEqual(c2a, c1a.C1C2one2one);

                    this.Session.Commit();

                    this.Session.Prefetch(prefetchPolicy, c1a);
                    if (twice)
                    {
                        this.Session.Prefetch(prefetchPolicy, c1a);
                    }

                    Assert.AreEqual(c2a, c1a.C1C2one2one);

                    this.Session.Commit();

                    c1a.C1C2one2one = c2b;

                    this.Session.Prefetch(prefetchPolicy, c1a);

                    Assert.AreEqual(c2b, c1a.C1C2one2one);

                    this.Session.Rollback();

                    this.Session.Prefetch(prefetchPolicy, c1a);
                    if (twice)
                    {
                        this.Session.Prefetch(prefetchPolicy, c1a);
                    }

                    Assert.AreEqual(c2a, c1a.C1C2one2one);

                    this.Session.Rollback();

                    Assert.AreEqual(c2a, c1a.C1C2one2one);
                }
            }
        }
Ejemplo n.º 7
0
        public void PrefetchAssociationOne2OneEmptyAndUnit()
        {
            var prefetchPolicy = new PrefetchPolicyBuilder().WithRule(C2.Meta.C1WhereC2one2one, new IPropertyType[] { C1.Meta.C1AllorsString }).Build();
            foreach (var twice in TrueFalse)
            {
                foreach (var init in this.Inits)
                {
                    init();

                    var c2A = C2.Create(this.Session);

                    this.Session.Commit();

                    this.Session.Prefetch(prefetchPolicy, c2A);
                    if (twice)
                    {
                        this.Session.Prefetch(prefetchPolicy, c2A);
                    }

                    Assert.AreEqual(0, c2A.C1sWhereC2many2many.Count);

                    this.Session.Commit();

                    this.Session.Prefetch(prefetchPolicy, c2A);
                    if (twice)
                    {
                        this.Session.Prefetch(prefetchPolicy, c2A);
                    }

                    Assert.AreEqual(0, c2A.C1sWhereC2many2many.Count);
                }
            }
        }