本文整理汇总了C#中IObjectSpace.FindObject方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectSpace.FindObject方法的具体用法?C# IObjectSpace.FindObject怎么用?C# IObjectSpace.FindObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObjectSpace
的用法示例。
在下文中一共展示了IObjectSpace.FindObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Authenticate
public override object Authenticate(IObjectSpace objectSpace)
{
string systemUserName = WindowsIdentity.GetCurrent().Name;
string enteredUserName = ((AuthenticationStandardLogonParameters)LogonParameters).UserName;
if (string.IsNullOrEmpty(enteredUserName))
{
throw new ArgumentException(SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.UserNameIsEmpty));
}
if (!String.Equals(systemUserName, enteredUserName))
{
throw new AuthenticationException(enteredUserName, "Invalid user name");
}
object user = objectSpace.FindObject(UserType, new BinaryOperator("UserName", systemUserName));
if (user == null)
{
user = objectSpace.CreateObject(UserType);
((IAuthenticationActiveDirectoryUser)user).UserName = systemUserName;
bool strictSecurityStrategyBehavior = SecurityModule.StrictSecurityStrategyBehavior;
SecurityModule.StrictSecurityStrategyBehavior = false;
objectSpace.CommitChanges();
SecurityModule.StrictSecurityStrategyBehavior = strictSecurityStrategyBehavior;
}
if (!((IAuthenticationStandardUser)user).ComparePassword(((AuthenticationStandardLogonParameters)LogonParameters).Password))
{
throw new AuthenticationException(systemUserName, SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.RetypeTheInformation));
}
return user;
}
示例2: Authenticate
public override object Authenticate(IObjectSpace objectSpace) {
object user = objectSpace.FindObject(UserType, findUserCriteria);
if (user == null) {
throw new AuthenticationException(findUserCriteria.ToString());
}
return user;
}
示例3: AuthenticateActiveDirectory
private object AuthenticateActiveDirectory(IObjectSpace objectSpace) {
var windowsIdentity = WindowsIdentity.GetCurrent();
if (windowsIdentity != null) {
string userName = windowsIdentity.Name;
var user = (IAuthenticationActiveDirectoryUser)objectSpace.FindObject(UserType, new BinaryOperator("UserName", userName));
if (user == null) {
if (_createUserAutomatically) {
var args = new CustomCreateUserEventArgs(objectSpace, userName);
if (!args.Handled) {
user = (IAuthenticationActiveDirectoryUser)objectSpace.CreateObject(UserType);
user.UserName = userName;
if (Security != null) {
//Security.InitializeNewUser(objectSpace, user);
Security.CallMethod("InitializeNewUser", new object[]{objectSpace, user});
}
}
objectSpace.CommitChanges();
}
}
if (user == null) {
throw new AuthenticationException(userName);
}
return user;
}
return null;
}
示例4: CreateDummyUsers
public static void CreateDummyUsers(IObjectSpace ObjectSpace)
{
var adminRole =
ObjectSpace.FindObject<SecuritySystemRole>(new BinaryOperator("Name",
SecurityStrategy.AdministratorRoleName));
if (adminRole == null) {
adminRole = ObjectSpace.CreateObject<SecuritySystemRole>();
adminRole.Name = SecurityStrategy.AdministratorRoleName;
adminRole.IsAdministrative = true;
adminRole.Save();
}
var userRole = ObjectSpace.FindObject<SecuritySystemRole>(new BinaryOperator("Name", "User"));
if (userRole == null) {
userRole = ObjectSpace.CreateObject<SecuritySystemRole>();
userRole.Name = "User";
var userTypePermission = ObjectSpace.CreateObject<SecuritySystemTypePermissionObject>();
userTypePermission.TargetType = typeof(SecuritySystemUser);
var currentUserObjectPermission = ObjectSpace.CreateObject<SecuritySystemObjectPermissionsObject>();
currentUserObjectPermission.Criteria = "[Oid] = CurrentUserId()";
currentUserObjectPermission.AllowNavigate = true;
currentUserObjectPermission.AllowRead = true;
userTypePermission.ObjectPermissions.Add(currentUserObjectPermission);
userRole.TypePermissions.Add(userTypePermission);
}
var user1 = ObjectSpace.FindObject<SecuritySystemUser>(
new BinaryOperator("UserName", "Sam"));
if (user1 == null) {
user1 = ObjectSpace.CreateObject<SecuritySystemUser>();
user1.UserName = "Sam";
// Set a password if the standard authentication type is used
user1.SetPassword("");
}
// If a user named 'John' doesn't exist in the database, create this user
var user2 = ObjectSpace.FindObject<SecuritySystemUser>(
new BinaryOperator("UserName", "John"));
if (user2 == null) {
user2 = ObjectSpace.CreateObject<SecuritySystemUser>();
user2.UserName = "John";
// Set a password if the standard authentication type is used
user2.SetPassword("");
}
user1.Roles.Add(adminRole);
user2.Roles.Add(userRole);
}
示例5: AuthenticateStandard
private object AuthenticateStandard(IObjectSpace objectSpace) {
if (string.IsNullOrEmpty(logonParameters.UserName))
throw new ArgumentException(SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.UserNameIsEmpty));
var user = (IAuthenticationStandardUser)objectSpace.FindObject(UserType, new BinaryOperator("UserName", logonParameters.UserName));
if (user == null || !user.ComparePassword(logonParameters.Password)) {
throw new AuthenticationException(logonParameters.UserName, SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.RetypeTheInformation));
}
return user;
}
示例6: Authenticate
public override object Authenticate(IObjectSpace objectSpace)
{
object user = objectSpace.FindObject(UserType, workflowWorkerUserCriteria);
if (user == null)
{
throw new AuthenticationException("", "Cannot find workflow worker user.");
}
return user;
}
示例7: Authenticate
public override object Authenticate(IObjectSpace objectSpace) {
if (string.IsNullOrEmpty(parameters.UserName))
throw new ArgumentException(SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.UserNameIsEmpty));
var user = (IAuthenticationStandardUser)objectSpace.FindObject(UserType,CriteriaOperator.Parse("UserName = ?", parameters.UserName));
if (user == null ||!user.ComparePassword(parameters.Password)){
throw new AuthenticationException(parameters.UserName, SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.RetypeTheInformation));
}
return user;
}
示例8: GetInstance
public static IFirstLaunchParameters GetInstance(IObjectSpace objectSpace)
{
var parameters = objectSpace.FindObject<IFirstLaunchParameters>(null);
if (parameters == null)
{
parameters = objectSpace.CreateObject<IFirstLaunchParameters>();
parameters.DummyObjectsCreated = false;
}
return parameters;
}
示例9: GetSession
/// <summary>
/// Gets the session.
/// </summary>
/// <param name="objectSpace">The object space.</param>
/// <param name="packageSession">The package session.</param>
/// <returns>New external protocol session</returns>
public static ExternalProtocolSession GetSession(IObjectSpace objectSpace, PackageSession packageSession)
{
var result =
objectSpace.FindObject<ExternalProtocolSession>(
CriteriaOperator.Parse("SessionId = ?", packageSession.SessionId), true);
if(result == null)
{
result = objectSpace.CreateObject<ExternalProtocolSession>();
result.SessionId = packageSession.SessionId;
result.Route = packageSession.Route;
result.StartedOn = packageSession.StartedOn;
result.CommitedOn = packageSession.CommitedOn;
if (packageSession.Parent != null)
result.Parent = GetSession(objectSpace, packageSession.Parent);
}
return result;
}
示例10: GetObjectCore
protected virtual object GetObjectCore(IModelDetailView modelView, object objectKey, IObjectSpace objectSpace) {
Type type = modelView.ModelClass.TypeInfo.Type;
object obj;
if (XafTypesInfo.CastTypeToTypeInfo(type).IsPersistent) {
if (objectKey != null && !(objectKey is CriteriaOperator))
obj = objectSpace.GetObjectByKey(type, objectKey);
else {
obj = objectSpace.FindObject(type, (CriteriaOperator)objectKey) ?? objectSpace.CreateObject(type);
if (!(objectSpace.IsNewObject(obj)))
((IXafApplication)_application).AfterViewShown += OnAfterViewShown;
}
} else {
obj = (type.GetConstructor(new[] { typeof(Session) }) != null) ? objectSpace.CreateObject(type) : Activator.CreateInstance(type);
}
return obj;
}
示例11: CreateNameSpace
public static NameSpace CreateNameSpace(string ns,IObjectSpace ObjectSpace)
{
var find = ObjectSpace.FindObject<NameSpace>(new BinaryOperator("FullName", ns));
if (find == null)
{
var part = ns.Split('.');
if (part.Length > 0)
{
find = ObjectSpace.CreateObject<NameSpace>();
find.名称 = part[part.Length - 1];
if (part.Length > 1)
{
find.Parent = CreateNameSpace(string.Join(".", part.Take(part.Length - 1)), ObjectSpace);
}
}
}
return find;
}
示例12: AddBusinessObject
public static BusinessObject AddBusinessObject(Type type, string caption, NameSpace nameSpace, string description, bool isRuntimeDefine,IObjectSpace ObjectSpace)
{
var t = ObjectSpace.FindObject<BusinessObject>(new BinaryOperator("FullName", type.FullName),true);
if (t == null)
{
t = ObjectSpace.CreateObject<BusinessObject>();
t.DisableCreateGenericParameterValues = true;
t.Category = nameSpace;
t.名称 = type.Name;
t.Caption = caption;
t.Description = description;
t.FullName = type.FullName;
//t.CanCustomLogic = typeof(ICustomLogic).IsAssignableFrom(type);
t.IsGenericTypeDefine = type.IsGenericType;
t.IsRuntimeDefine = isRuntimeDefine;
}
return t;
}
示例13: Process
public void Process(XafApplication application,IObjectSpace objectSpace) {
var user = objectSpace.FindObject(XpandModuleBase.UserType, new GroupOperator(GroupOperatorType.Or,new BinaryOperator("UserName", UserName),new BinaryOperator("Email",Email)),true) as IAuthenticationStandardUser;
if (user != null&&!objectSpace.IsNewObject(user))
throw new ArgumentException(CaptionHelper.GetLocalizedText(XpandSecurityModule.XpandSecurity, "AlreadyRegistered"));
var securityUserWithRoles = objectSpace.IsNewObject(user)? (ISecurityUserWithRoles) user
: (ISecurityUserWithRoles)objectSpace.CreateObject(XpandModuleBase.UserType);
User = securityUserWithRoles;
var userTypeInfo = application.TypesInfo.FindTypeInfo(XpandModuleBase.UserType);
var modelRegistration = (IModelRegistration)((IModelOptionsRegistration)application.Model.Options).Registration;
AddRoles(modelRegistration, userTypeInfo, securityUserWithRoles, objectSpace);
userTypeInfo.FindMember("UserName").SetValue(securityUserWithRoles,UserName);
userTypeInfo.FindMember("IsActive").SetValue(securityUserWithRoles,modelRegistration.ActivateUser);
modelRegistration.EmailMember.MemberInfo.SetValue(securityUserWithRoles,Email);
var activationLinkMember = modelRegistration.ActivationIdMember;
if (activationLinkMember!=null) {
activationLinkMember.MemberInfo.SetValue(securityUserWithRoles, Guid.NewGuid().ToString());
}
securityUserWithRoles.CallMethod("SetPassword", Password);
objectSpace.CommitChanges();
}
示例14: Authenticate
public override object Authenticate(IObjectSpace objectSpace) {
if(string.IsNullOrEmpty(logonParameters.UserName)) {
throw new UserFriendlyException("The 'User' field must not be empty.");
}
object user = objectSpace.FindObject<SecurityDemoUser>(new DevExpress.Data.Filtering.BinaryOperator("UserName", logonParameters.UserName));
if(user == null) {
throw new AuthenticationException(logonParameters.UserName);
}
return user;
}
示例15: GetInstance
/// <summary>
/// Gets the instance.
/// </summary>
/// <param name="objectSpace">The object space.</param>
/// <returns>Package marker singleton for specified object space</returns>
public static PackageMarker GetInstance(IObjectSpace objectSpace)
{
return objectSpace.FindObject<PackageMarker>(null, true);
}