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


C# Csla类代码示例

本文整理汇总了C#中Csla的典型用法代码示例。如果您正苦于以下问题:C# Csla类的具体用法?C# Csla怎么用?C# Csla使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Csla类属于命名空间,在下文中一共展示了Csla类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        protected override void Execute(Csla.Rules.AuthorizationContext context)
        {
            if (context.Target is User)
            {
                var businessIdentity = (IBusinessIdentity)Csla.ApplicationContext.User.Identity;

                if (businessIdentity.UserId == ((User)context.Target).UserId)
                {
                    context.HasPermission = true;

                    return;
                }
            }

            if (context.Target is UserPassword)
            {
                var identity = (IBusinessIdentity)Csla.ApplicationContext.User.Identity;

                if (identity.UserId == ((UserPassword)context.Target).UserId)
                {
                    context.HasPermission = true;

                    return;
                }
            }

            context.HasPermission = false;
        }
开发者ID:mattruma,项目名称:epiworx-csla,代码行数:28,代码来源:IsInUser.cs

示例2: PropertyHasChanged

        protected override void PropertyHasChanged(Csla.Core.IPropertyInfo property)
        {
            base.PropertyHasChanged(property);

            switch (property.Name)
            {
                case "AssignedTo":
                    this.OnAssignedToChanged();
                    break;
                case "CategoryId":
                    this.OnCategoryIdChanged();
                    break;
                case "EstimatedCompletedDate":
                    this.OnEstimatedCompletedDateChanged();
                    break;
                case "ProjectId":
                    this.OnProjectIdChanged();
                    break;
                case "StatusId":
                    this.OnStatusIdChanged();
                    break;
                default:
                    break;
            }
        }
开发者ID:WhiteIsland,项目名称:epiworx,代码行数:25,代码来源:Task.Methods.cs

示例3: DateTimeRequired

 public DateTimeRequired(Csla.Core.IPropertyInfo primaryProperty, DateTime minValue, DateTime maxValue)
     : base(primaryProperty)
 {
     this.MinValue = minValue.Date;
     this.MaxValue = maxValue.Date;
     this.InputProperties = new List<Csla.Core.IPropertyInfo> { primaryProperty };
 }
开发者ID:mattruma,项目名称:epiworx-csla,代码行数:7,代码来源:DateTimeRequired.cs

示例4: OnSetState

 protected override void OnSetState(Csla.Serialization.Mobile.SerializationInfo info, Csla.Core.StateMode mode)
 {
   base.OnSetState(info, mode);
   Name = info.GetValue<string>("SilverlightPrincipal.Criteria.Name");
   Password = info.GetValue<string>("SilverlightPrincipal.Criteria.Password");
   ProviderType = info.GetValue<string>("SilverlightPrincipal.Criteria.ProviderType");
 }
开发者ID:nschonni,项目名称:csla-svn,代码行数:7,代码来源:SilverlightPrincipal.cs

示例5: CorrectToIncrementSize

        /* This method rectifies to the closes possible muiltiplier */
        public static bool CorrectToIncrementSize(Csla.PropertyInfo<UnitValue> propertyName)
        {
            PropertyManager _propertyManager = PropertyManager.Instance;
            Factor propertyFactor = _propertyManager.GetFactor(propertyName);

            decimal[] increments = propertyFactor.IncrementSizes;
            if (increments.Length == 0) return false;

            decimal currentValue = _propertyManager.GetValue(propertyName);

            bool allowIncrementStepping = _propertyManager.GetFactor(propertyName).IncrementStepping;

            if (currentValue == 0) return false;

            decimal newValue = 0;
            List<int> foundIndices = new List<int>();

            if (!allowIncrementStepping)
                newValue = MathExt.GetNearestValueByIncrements(currentValue, increments.ToArray(), out foundIndices);
            else
                newValue = MathExt.GetNearestMultiplierByIncrements(currentValue, increments.ToArray(), out foundIndices);

            if ((double)newValue != (double)currentValue)
            {
                _propertyManager.SetValue(propertyName, newValue);
                return true;
            }

            return false;
        }
开发者ID:halcwb,项目名称:GenPres_Old,代码行数:31,代码来源:PropertyValueCorrect.cs

示例6: OnGetState

 protected override void OnGetState(Csla.Serialization.Mobile.SerializationInfo info, Csla.Core.StateMode mode)
 {
   info.AddValue("SilverlightPrincipal.Criteria.Name", Name);
   info.AddValue("SilverlightPrincipal.Criteria.Password", Password);
   info.AddValue("SilverlightPrincipal.Criteria.ProviderType", ProviderType);
   base.OnGetState(info, mode);
 }
开发者ID:nschonni,项目名称:csla-svn,代码行数:7,代码来源:SilverlightPrincipal.cs

示例7: Fetch

 public CustomIdentity Fetch(Csla.Security.UsernameCriteria criteria)
 {
   if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["CslaIsInRoleProvider"]))
     return DoFetch(criteria);
   else
     return PermissionFetch(criteria);
 }
开发者ID:nschonni,项目名称:csla-svn,代码行数:7,代码来源:CustomIdentityFactory.cs

示例8: PermissionFetch

 private CustomIdentity PermissionFetch(Csla.Security.UsernameCriteria criteria)
 {
   CustomIdentity obj;
   using (var ctx = Csla.Data.ObjectContextManager<SecurityEntities>.GetManager("SecurityEntities"))
   {
     var q = (from r in ctx.ObjectContext.Users
              where r.Username == criteria.Username
              select r).FirstOrDefault();
     if (q != null)
     {
       q.Roles.Load();
       var roles = new List<string>();
       var permissions = new List<string>();
       foreach (var r in q.Roles)
       {
         roles.Add(r.Name);
         r.Permissions.Load();
         foreach (var p in r.Permissions)
           if (!permissions.Contains(p.Name))
             permissions.Add(p.Name);
       }
       obj = new CustomIdentity(q.Username, roles, permissions);
     }
     else
     {
       obj = new CustomIdentity();
     }
   }
   return obj;
 }
开发者ID:nschonni,项目名称:csla-svn,代码行数:30,代码来源:CustomIdentityFactory.cs

示例9: OnSetState

 protected override void OnSetState(Csla.Serialization.Mobile.SerializationInfo info, StateMode mode)
 {
   _username = (string)info.Values["_username"].Value;
   _password = (string)info.Values["_password"].Value;
   _roles = (string)info.Values["_roles"].Value;
   base.OnSetState(info, mode);
 }
开发者ID:nschonni,项目名称:csla-svn,代码行数:7,代码来源:CredentialsCriteria.cs

示例10: MapBrokenRules

 public static void MapBrokenRules(ModelStateDictionary modelState, Csla.Core.BusinessBase businessObject)
 {
     foreach (var brokenRule in businessObject.BrokenRulesCollection)
     {
         modelState.AddModelError(brokenRule.Property, brokenRule.Description);
     }
 }
开发者ID:mattruma,项目名称:epiworx-csla,代码行数:7,代码来源:ModelHelper.cs

示例11: OnGetState

 protected override void OnGetState(Csla.Serialization.Mobile.SerializationInfo info, StateMode mode)
 {
   info.AddValue("_username", _username);
   info.AddValue("_password", _password);
   info.AddValue("_roles", _roles);
   base.OnGetState(info, mode);
 }
开发者ID:nschonni,项目名称:csla-svn,代码行数:7,代码来源:CredentialsCriteria.cs

示例12: Execute

        protected override void Execute(Csla.Rules.AuthorizationContext context)
        {
            if (context == null)
            {
                throw new ArgumentException("Context cannot be null.");
            }

            var entryType = context.Target as IHaveEntryType;
            context.HasPermission = false;

            if (entryType == null)
            {
                context.HasPermission = true;
            }
            else
            {
                if (entryType.EntryType == ActivityEntryType.Any)
                {
                    context.HasPermission = true;
                }
                else
                {
                    var role = entryType.EntryType.ToString();
                    if (entryType.EntryType != ActivityEntryType.Unset)
                    {
                        context.HasPermission = ApplicationContext.User.IsInRole(role);
                    }
                }
            }

            if (ApplicationContext.User.IsInRole(PermissionType.Administrator.ToString()))
            {
                context.HasPermission = true;
            }
        }
开发者ID:Bowman74,项目名称:Badge-Application,代码行数:35,代码来源:CanCreateSubmission.cs

示例13: UserDataSource_UpdateObject

    protected void UserDataSource_UpdateObject( object sender, Csla.Web.UpdateObjectArgs e )
    {
        User obj = GetUser( User.ID );
        Csla.Data.DataMapper.Map( e.Values, obj );

        e.RowsAffected = SaveDetails( obj );
    }
开发者ID:TertiumQuid,项目名称:Aphelion-Trigger,代码行数:7,代码来源:UserProfile.aspx.cs

示例14: SetPrincipal

 private static void SetPrincipal(Csla.Security.CslaIdentity identity)
 {
   if (identity != null && identity.IsAuthenticated)
     Csla.ApplicationContext.User = new SLPrincipal(identity);
   else
     Csla.ApplicationContext.User = new Csla.Security.UnauthenticatedPrincipal();
 }
开发者ID:nschonni,项目名称:csla-svn,代码行数:7,代码来源:SLPrincipal.cs

示例15: ContainsRule

 public static bool ContainsRule(Csla.Core.BusinessBase obj, DbType type, string propertyName)
 {
     switch (type)
     {
         case DbType.Int16:
         case DbType.Int32:
         case DbType.Int64:
             return obj.BrokenRulesCollection.Any(
                  brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.core.validation.integerrequired/{0}", propertyName))
                     || obj.BrokenRulesCollection.Any(
                         brokenRule => brokenRule.RuleName == string.Format("rule://csla.rules.commonrules.dataannotation/{0}?a=Epiworx.Core.Validation.IntegerRequiredAttribute", propertyName));
         case DbType.Decimal:
             return obj.BrokenRulesCollection.Any(
                 brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.core.validation.decimalrequired/{0}", propertyName));
         case DbType.Date:
             return obj.BrokenRulesCollection.Any(
               brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.core.validation.daterequired/{0}", propertyName));
         case DbType.DateTime:
             return obj.BrokenRulesCollection.Any(
               brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.core.validation.datetimerequired/{0}", propertyName));
         case DbType.String:
         case DbType.StringFixedLength:
             return obj.BrokenRulesCollection.Any(
              brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.core.validation.stringrequired/{0}", propertyName));
         default:
             throw new NotSupportedException();
     }
 }
开发者ID:mattruma,项目名称:epiworx-csla,代码行数:28,代码来源:ValidationHelper.cs


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