本文整理汇总了C#中IObjectSpace.IsNewObject方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectSpace.IsNewObject方法的具体用法?C# IObjectSpace.IsNewObject怎么用?C# IObjectSpace.IsNewObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObjectSpace
的用法示例。
在下文中一共展示了IObjectSpace.IsNewObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: OnSaving
/// <summary>
/// Обрабатывает генерацию нового регистрационного номера и кода документа в соответствии с нумератором
/// </summary>
public static void OnSaving(ISerialDataObject serialDataObject, IObjectSpace os)
{
if (os != null ? os.IsNewObject(serialDataObject) : false)
{
serialDataObject.RegDate = DateTime.Now;
serialDataObject.Number = 0;
GenerateSequence(serialDataObject, os);
if (serialDataObject.Numerator == null)
{
serialDataObject.Numerator = DBNumerator.GetNumerator(os, XafTypesInfo.Instance.FindTypeInfo(serialDataObject.GetType()), serialDataObject.Department);
}
if (String.IsNullOrEmpty(serialDataObject.RegCode))
{
serialDataObject.RegCode = serialDataObject.Numerator != null ? ParseExtension(serialDataObject, serialDataObject.Numerator.ExpressionCodeGeneration) : serialDataObject.Number.ToString();
}
if (String.IsNullOrEmpty(serialDataObject.ObjectCode))
{
serialDataObject.ObjectCode = serialDataObject.RegCode;
}
}
}
示例4: SetObject
/// <summary>
/// Устанавливает ссылку на объект
/// </summary>
/// <param name="objectSpace">Пространство объектов</param>
/// <param name="value">Объект, на который устанавливается ссылка</param>
/// <exception cref="ArgumentException">Попытка установить ссылку на несохраненный объект</exception>
public void SetObject(IObjectSpace objectSpace, object value)
{
if (value == null)
TargetKeyValue = null;
else if (objectSpace.IsNewObject(value))
throw new ArgumentException("Referenced saved object expected");
else
TargetKeyValue = objectSpace.GetKeyValue(value);
}