示例#1
0
 private ResourceRelationAccessor RelationAccessor(long id,
                                                   ResourceRelationType relationType = ResourceRelationType.ParentChild,
                                                   ResourceReferenceRole role        = ResourceReferenceRole.Target,
                                                   string relationName = null)
 {
     return(new ResourceRelationAccessor
     {
         Role = role,
         Entity = Relation(id, 1, relationType, role, relationName)
     });
 }
示例#2
0
        private ResourceRelation Relation(long id, long otherId,
                                          ResourceRelationType relationType = ResourceRelationType.ParentChild,
                                          ResourceReferenceRole role        = ResourceReferenceRole.Target,
                                          string relationName = null)
        {
            var relation = new ResourceRelation
            {
                RelationType = (int)relationType,
                TargetName   = relationName,
                TargetId     = role == ResourceReferenceRole.Target ? id : otherId,
                SourceId     = role == ResourceReferenceRole.Source ? id : otherId
            };

            relation.Target = new ResourceEntity {
                Id = relation.TargetId
            };
            relation.Source = new ResourceEntity {
                Id = relation.SourceId
            };
            return(relation);
        }
 /// <summary>
 /// Create a typed and named reference with a special name
 /// </summary>
 public ResourceReferenceAttribute(ResourceRelationType relationType, ResourceReferenceRole role, string name)
 {
     Role         = role;
     Name         = name;
     RelationType = relationType;
 }
 /// <summary>
 /// Create a typed reference and specify the role explicitly
 /// </summary>
 /// <param name="relationType">Type of the reference</param>
 /// <param name="role">Role of the reference in the relation</param>
 public ResourceReferenceAttribute(ResourceRelationType relationType, ResourceReferenceRole role)
     : this(relationType, role, null)
 {
 }
 /// <summary>
 /// Create a typed reference with <see cref="ResourceReferenceRole.Target"/>
 /// </summary>
 /// <param name="relationType">Type of the reference</param>
 /// <param name="name">Name of the reference if there is more than one</param>
 public ResourceReferenceAttribute(ResourceRelationType relationType, string name)
     : this(relationType, ResourceReferenceRole.Target, name)
 {
 }
 /// <summary>
 /// Create a typed reference with <see cref="ResourceReferenceRole.Target"/>
 /// </summary>
 /// <param name="relationType">Type of the reference</param>
 public ResourceReferenceAttribute(ResourceRelationType relationType)
     : this(relationType, ResourceReferenceRole.Target, null)
 {
 }