Esempio n. 1
0
 bool IsHasManyThrough(KeyValuePair <RelationshipProxy, IEnumerable> kvp,
                       out IEnumerable entities,
                       out RelationshipProxy proxy)
 {
     proxy    = kvp.Key;
     entities = (kvp.Value);
     return(kvp.Key.Attribute is HasManyThroughAttribute);
 }
Esempio n. 2
0
 /// <summary>
 /// Parses all relationships from <paramref name="type"/> to
 /// other models in the resource resourceGraphs by constructing RelationshipProxies .
 /// </summary>
 /// <param name="type">The type to parse</param>
 private void RegisterRelationshipProxies(RightType type)
 {
     foreach (RelationshipAttribute attr in _resourceGraph.GetRelationships(type))
     {
         if (!attr.CanInclude)
         {
             continue;
         }
         if (!_relationshipProxies.TryGetValue(attr, out _))
         {
             RightType rightType             = GetRightTypeFromRelationship(attr);
             bool      isContextRelation     = false;
             var       relationshipsToUpdate = _targetedFields.Relationships;
             if (relationshipsToUpdate != null)
             {
                 isContextRelation = relationshipsToUpdate.Contains(attr);
             }
             var proxy = new RelationshipProxy(attr, rightType, isContextRelation);
             _relationshipProxies[attr] = proxy;
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Reflective helper method to create an instance of <see cref="RelationshipGroup{TRight}"/>;
        /// </summary>
        private IRelationshipGroup CreateRelationshipGroupInstance(Type thisLayerType, RelationshipProxy proxy, List <IIdentifiable> leftEntities, List <IIdentifiable> rightEntities)
        {
            var rightEntitiesHashed = TypeHelper.CreateInstanceOfOpenType(typeof(HashSet <>), thisLayerType, rightEntities.Cast(thisLayerType));

            return((IRelationshipGroup)TypeHelper.CreateInstanceOfOpenType(typeof(RelationshipGroup <>),
                                                                           thisLayerType, proxy, new HashSet <IIdentifiable>(leftEntities), rightEntitiesHashed));
        }
Esempio n. 4
0
 private void AddToRelationshipGroup(Dictionary <RelationshipProxy, List <IIdentifiable> > target, RelationshipProxy proxy, IEnumerable <IIdentifiable> newEntities)
 {
     if (!target.TryGetValue(proxy, out List <IIdentifiable> entities))
     {
         entities      = new List <IIdentifiable>();
         target[proxy] = entities;
     }
     entities.AddRange(newEntities);
 }
 public RelationshipGroup(RelationshipProxy proxy, HashSet <IIdentifiable> leftEntities, HashSet <TRight> rightEntities)
 {
     Proxy         = proxy;
     LeftEntities  = leftEntities;
     RightEntities = rightEntities;
 }
 public RelationshipGroup(RelationshipProxy proxy, HashSet <IIdentifiable> principalEntities, HashSet <TDependent> dependentEntities)
 {
     Proxy             = proxy;
     PrincipalEntities = principalEntities;
     DependentEntities = dependentEntities;
 }