本文整理汇总了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;
}
示例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;
}
}
示例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 };
}
示例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");
}
示例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;
}
示例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);
}
示例7: Fetch
public CustomIdentity Fetch(Csla.Security.UsernameCriteria criteria)
{
if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["CslaIsInRoleProvider"]))
return DoFetch(criteria);
else
return PermissionFetch(criteria);
}
示例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;
}
示例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);
}
示例10: MapBrokenRules
public static void MapBrokenRules(ModelStateDictionary modelState, Csla.Core.BusinessBase businessObject)
{
foreach (var brokenRule in businessObject.BrokenRulesCollection)
{
modelState.AddModelError(brokenRule.Property, brokenRule.Description);
}
}
示例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);
}
示例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;
}
}
示例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 );
}
示例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();
}
示例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();
}
}