本文整理汇总了C#中IMembershipService.GetById方法的典型用法代码示例。如果您正苦于以下问题:C# IMembershipService.GetById方法的具体用法?C# IMembershipService.GetById怎么用?C# IMembershipService.GetById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMembershipService
的用法示例。
在下文中一共展示了IMembershipService.GetById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
//.........这里部分代码省略.........
new RelationMetaDatum(FixedPermissionIds.Move, PermissionStatus.Inherit.ToString())
),
new RelationById(
_userGroups.Last().Id,
_systemRootNode.Id,
FixedRelationTypes.PermissionRelationType,
0,
new RelationMetaDatum(FixedPermissionIds.Copy, PermissionStatus.Allow.ToString()),
new RelationMetaDatum(FixedPermissionIds.Save, PermissionStatus.Deny.ToString()),
new RelationMetaDatum(FixedPermissionIds.Publish, PermissionStatus.Allow.ToString()),
new RelationMetaDatum(FixedPermissionIds.Hostnames, PermissionStatus.Allow.ToString()),
new RelationMetaDatum(FixedPermissionIds.Move, PermissionStatus.Inherit.ToString())
)
};
var childContentNodePermissionRelations = new List<RelationById>
{
new RelationById(
_userGroups.Skip(1).First().Id,
_childContentNode.Id,
FixedRelationTypes.PermissionRelationType,
0,
new RelationMetaDatum(FixedPermissionIds.BackOfficeAccess, PermissionStatus.Deny.ToString()), // Back office access is not an entity action so this should get ignored
new RelationMetaDatum(FixedPermissionIds.Copy, PermissionStatus.Allow.ToString()),
new RelationMetaDatum(FixedPermissionIds.Save, PermissionStatus.Deny.ToString()),
new RelationMetaDatum(FixedPermissionIds.Publish, PermissionStatus.Allow.ToString()),
new RelationMetaDatum(FixedPermissionIds.Hostnames, PermissionStatus.Allow.ToString()),
new RelationMetaDatum(FixedPermissionIds.Move, PermissionStatus.Inherit.ToString())
)
};
var childContentNodeAncestorRelations = new List<RelationById>
{
new RelationById(
_systemRootNode.Id,
_childContentNode.Id,
FixedRelationTypes.DefaultRelationType,
0)
};
var userGroupRelations = new List<RelationById>
{
new RelationById(
_userGroups.First().Id,
_userId,
FixedRelationTypes.UserGroupRelationType,
0),
new RelationById(
_userGroups.Skip(1).First().Id,
_userId,
FixedRelationTypes.UserGroupRelationType,
0),
new RelationById(
_userGroups.Last().Id,
_userId,
FixedRelationTypes.UserGroupRelationType,
0)
};
_membershipService = Substitute.For<IMembershipService<User>>();
_membershipService.GetById(_userId, true).Returns(new User
{
Id = _userId,
Username = "DummyUser",
Groups = _userGroups.Select(x => x.Id).ToArray()
});
//Setup hive
_hive = MockHiveManager.GetManager()
.MockContentStore(out _readonlyContentStoreSession, out _readonlyContentStoreSchemaSession, out _contentStoreRepository, out _contentStoreSchemaRepository)
.MockSecurityStore(out _readonlySecurityStoreSession, out _readonlySecurityStoreSchemaSession, out _securityStoreRepository, out _securityStoreSchemaRepository);
//Setup content store
_readonlyContentStoreSession.Exists<TypedEntity>(HiveId.Empty).ReturnsForAnyArgs(true);
_readonlySecurityStoreSession
.Get<UserGroup>(true, Arg.Any<HiveId[]>())
.Returns(MockHiveManager.MockReturnForGet<UserGroup>());
_readonlyContentStoreSession
.Get<UserGroup>(true, Arg.Any<HiveId[]>())
.Returns(MockHiveManager.MockReturnForGet<UserGroup>());
_securityStoreRepository
.Get<UserGroup>(true, Arg.Any<HiveId[]>())
.Returns(MockHiveManager.MockReturnForGet<UserGroup>());
_contentStoreRepository
.Get<UserGroup>(true, Arg.Any<HiveId[]>())
.Returns(MockHiveManager.MockReturnForGet<UserGroup>());
//Setup security store
_readonlySecurityStoreSession.GetParentRelations(_systemRootNode.Id, FixedRelationTypes.PermissionRelationType).Returns(systemRootPermissionRelations);
_readonlySecurityStoreSession.GetParentRelations(_childContentNode.Id, FixedRelationTypes.PermissionRelationType).Returns(childContentNodePermissionRelations);
_readonlySecurityStoreSession.GetAncestorRelations(_childContentNode.Id, FixedRelationTypes.DefaultRelationType).Returns(childContentNodeAncestorRelations);
_readonlySecurityStoreSession.GetParentRelations(_userId, FixedRelationTypes.UserGroupRelationType).Returns(userGroupRelations);
_readonlySecurityStoreSession.Query<UserGroup>().Returns(x => Enumerable.Repeat(new UserGroup() { Name = "Administrator" }, 1).AsQueryable());
}