当前位置: 首页>>代码示例>>C#>>正文


C# IObjectSpace.FindObject方法代码示例

本文整理汇总了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;
 }
开发者ID:shukla2009,项目名称:Personal,代码行数:28,代码来源:AuthenticateUser.cs

示例2: Authenticate

 public override object Authenticate(IObjectSpace objectSpace) {
     object user = objectSpace.FindObject(UserType, findUserCriteria);
     if (user == null) {
         throw new AuthenticationException(findUserCriteria.ToString());
     }
     return user;
 }
开发者ID:aries544,项目名称:eXpand,代码行数:7,代码来源:WorkflowServerAuthentication.cs

示例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;
 }
开发者ID:kamchung322,项目名称:eXpand,代码行数:26,代码来源:AuthenticationCombined.cs

示例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);
        }
开发者ID:apobekiaris,项目名称:X,代码行数:46,代码来源:ModuleUpdaterHelper.cs

示例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;
 }
开发者ID:kamchung322,项目名称:eXpand,代码行数:9,代码来源:AuthenticationCombined.cs

示例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;
 }
开发者ID:smoo7h,项目名称:PDFScanAndSort,代码行数:9,代码来源:ServerAuthentication.cs

示例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;
        }
开发者ID:gvilas,项目名称:eXpand,代码行数:10,代码来源:XpandAuthenticationStandard.cs

示例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;
 }
开发者ID:Rukhlov,项目名称:DataStudio,代码行数:10,代码来源:IFirstLaunchParameters.cs

示例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;
 }
开发者ID:xafdelta,项目名称:xafdelta,代码行数:23,代码来源:ExternalProtocolSession.cs

示例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;
        }
开发者ID:kevin3274,项目名称:eXpand,代码行数:17,代码来源:ViewShortCutProccesor.cs

示例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;
        }
开发者ID:ZixiangBoy,项目名称:CIIP,代码行数:19,代码来源:DataInitializeWindowController.cs

示例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;
        }
开发者ID:ZixiangBoy,项目名称:CIIP,代码行数:20,代码来源:DataInitializeWindowController.cs

示例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();
        }
开发者ID:noxe,项目名称:eXpand,代码行数:24,代码来源:Parameters.cs

示例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;
 }
开发者ID:kevin3274,项目名称:eXpand,代码行数:10,代码来源:SecurityDemoLogonParameters.cs

示例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);
 }
开发者ID:xafdelta,项目名称:xafdelta,代码行数:9,代码来源:PackageMarker.cs


注:本文中的IObjectSpace.FindObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。