Permalink
Browse files

WC: fixed bug with TargetObjectCrietria

  • Loading branch information...
1 parent 7ec2daa commit 65d44e267490e0580359f88ebd1cb48ae0ef0e15 @apobekiaris committed Aug 7, 2011
@@ -174,7 +174,7 @@ public static class CodeEngine {
}
}
string properties = GetPropertiesCode(attributeInfoAttribute);
- return string.Format("[{0}{1}({2}){3}]", assemblyDecleration, attribute.GetType().FullName, args, properties);
+ return string.Format("[{0}{1}({2}{3})]", assemblyDecleration, attribute.GetType().FullName, args, properties);
}
static string GetPropertiesCode(AttributeInfoAttribute attributeInfoAttribute) {
@@ -185,13 +185,13 @@ public static class CodeEngine {
Func<string, IMemberInfo, string> func = (current, memberInfo)
=> current + (memberInfo.Name + "=" + GetArgumentCodeCore(memberInfo.MemberType, memberInfo.GetValue(attributeInfoAttribute.Instance)) + ",");
string code = memberInfos.Aggregate(null, func).TrimEnd(',');
- return string.Format("{{{0}}}", code);
+ return string.IsNullOrEmpty(code) ? null : string.Format(",{0}", code);
}
private static object GetArgumentCodeCore(Type type, object argumentValue) {
if (type == typeof(string))
return @"@""" + argumentValue + @"""";
- if (type == typeof(Type))
+ if (typeof(Type).IsAssignableFrom(type))
return "typeof(" + ((Type)argumentValue).FullName + ")";
if (typeof(Enum).IsAssignableFrom(type))
return argumentValue.GetType().FullName + "." + argumentValue;
@@ -48,12 +48,16 @@ public class CompileEngine {
return CompileModule(persistentAssemblyBuilder.PersistentAssemblyInfo, true, path);
}
+
+ static void RegisterPersistentTypes(Type compileModule) {
+ foreach (var type in compileModule.Assembly.GetTypes()) {
+ XafTypesInfo.Instance.RegisterEntity(type);
+ }
+ }
public Type CompileModule(IPersistentAssemblyInfo persistentAssemblyInfo, bool registerPersistentTypes, string path) {
Type compileModule = CompileModule(persistentAssemblyInfo, path);
if (registerPersistentTypes && compileModule != null)
- foreach (var type in compileModule.Assembly.GetTypes()) {
- XafTypesInfo.Instance.RegisterEntity(type);
- }
+ RegisterPersistentTypes(compileModule);
return compileModule;
}
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;
using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
@@ -15,9 +16,9 @@ public class ExistentTypesMemberCreator {
var types = CreateCollectionMembers(session);
types.AddRange(CreateReferenceMembers(session));
types.AddRange(CreateCoreMembers(session));
-
+
foreach (var type in types) {
- XpandModuleBase.TypesInfo.RefreshInfo(type);
+ XafTypesInfo.Instance.RefreshInfo(type);
}
}
@@ -27,7 +28,7 @@ public class ExistentTypesMemberCreator {
}
private bool memberExists(IExtendedMemberInfo info) {
- return XpandModuleBase.TypesInfo.FindTypeInfo(info.Owner).FindMember(info.Name) != null;
+ return XafTypesInfo.Instance.FindTypeInfo(info.Owner).FindMember(info.Name) != null;
}
public List<Type> CreateCollectionMembers(Session session) {
@@ -43,7 +44,7 @@ public class ExistentTypesMemberCreator {
}
XPCustomMemberInfo GetXPCustomMemberInfo(IExtendedCollectionMemberInfo info) {
- var classInfo = XpandModuleBase.Dictiorary.GetClassInfo(info.Owner);
+ var classInfo = XafTypesInfo.XpoTypeInfoSource.XPDictionary.GetClassInfo(info.Owner);
if (!(info is IExtendedOrphanedCollection)) {
return classInfo.CreateMember(info.Name, typeof(XPCollection), true);
}
@@ -63,20 +64,20 @@ public class ExistentTypesMemberCreator {
return types;
}
- public List<Type> CreateCoreMembers(Session session){
+ public List<Type> CreateCoreMembers(Session session) {
var types = new List<Type>();
var memberInfos = GetMembers(session, WCTypesInfo.Instance.FindBussinessObjectType<IExtendedCoreTypeMemberInfo>());
- foreach (var info in memberInfos.Cast<IExtendedCoreTypeMemberInfo>()){
+ foreach (var info in memberInfos.Cast<IExtendedCoreTypeMemberInfo>()) {
var referenceType = Type.GetType("System." + info.DataType, true);
- var member = GetMember(info,referenceType);
+ var member = GetMember(info, referenceType);
CreateAttributes(info, member);
types.Add(info.Owner);
}
return types;
}
XPCustomMemberInfo GetMember(IExtendedMemberInfo info, Type referenceType) {
- var classInfo = XpandModuleBase.Dictiorary.GetClassInfo(info.Owner);
+ var classInfo = XafTypesInfo.XpoTypeInfoSource.XPDictionary.GetClassInfo(info.Owner);
return info.TypeAttributes.OfType<IPersistentPersistentAliasAttribute>().FirstOrDefault() == null
? classInfo.CreateMember(info.Name, referenceType)
: classInfo.CreateCalculabeMember(info.Name, referenceType);
@@ -4,28 +4,23 @@
using Xpand.Persistent.Base.PersistentMetaData;
namespace Xpand.ExpressApp.WorldCreator.Core {
- public class WCTypesInfo
- {
+ public class WCTypesInfo {
static readonly WCTypesInfo _instance;
Dictionary<Type, Type> _dictionary;
static WCTypesInfo() {
- _instance=new WCTypesInfo();
+ _instance = new WCTypesInfo();
Instance._dictionary = new Dictionary<Type, Type>();
}
- public static WCTypesInfo Instance
- {
+ public static WCTypesInfo Instance {
get { return _instance; }
}
public Type FindBussinessObjectType(Type type) {
Type findBussinessObjectType;
- try
- {
+ try {
findBussinessObjectType = _dictionary[type];
- }
- catch (KeyNotFoundException)
- {
+ } catch (KeyNotFoundException) {
throw new KeyNotFoundException("Register " + type + " at your AdditionalBusinessClasses");
}
return findBussinessObjectType;
@@ -35,25 +30,24 @@ public static WCTypesInfo Instance
return FindBussinessObjectType(typeof(T));
}
- public void Reset()
- {
- _dictionary.Clear();
+ public void Reset() {
+ _dictionary.Clear();
}
public void Register(IEnumerable<Type> types) {
IEnumerable<Type> persistentTypes = GetPersistentTypes(types);
foreach (var persistentType in persistentTypes) {
- var interfaceType = persistentType.GetCustomAttributes(typeof(InterfaceRegistratorAttribute),false).OfType<InterfaceRegistratorAttribute>().Single().InterfaceType;
+ var interfaceType = persistentType.GetCustomAttributes(typeof(InterfaceRegistratorAttribute), false).OfType<InterfaceRegistratorAttribute>().Single().InterfaceType;
if (!_dictionary.ContainsKey(interfaceType))
- _dictionary.Add(interfaceType,persistentType);
+ _dictionary.Add(interfaceType, persistentType);
}
}
IEnumerable<Type> GetPersistentTypes(IEnumerable<Type> types) {
- return types.Where(type => type.GetCustomAttributes(typeof(InterfaceRegistratorAttribute),false).OfType<InterfaceRegistratorAttribute>().Count()==1);
+ return types.Where(type => type.GetCustomAttributes(typeof(InterfaceRegistratorAttribute), false).OfType<InterfaceRegistratorAttribute>().Count() == 1);
}
public void Register(Type type) {
- Register(new List<Type>{type});
+ Register(new List<Type> { type });
}
}
}
@@ -34,6 +34,8 @@ public sealed class XpandSystemModule : XpandModuleBase, IModelXmlConverter {
} catch (Exception) {
}
+ RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.SystemModule.SystemModule));
+ RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.Security.SecurityModule));
}
static XpandSystemModule() {
@@ -10,6 +10,12 @@
namespace Xpand.Persistent.Base.General {
public static class ObjectSpaceExtensions {
+
+ public static void RollBackSilent(this IObjectSpace objectSpace) {
+ objectSpace.ConfirmationRequired += (sender, args) => args.ConfirmationResult = ConfirmationResult.No;
+ objectSpace.Rollback();
+ }
+
public static IEnumerable<ClassType> GetNonDeletedObjectsToSave<ClassType>(this IObjectSpace objectSpace) {
return objectSpace.GetObjectsToSave(true).OfType<ClassType>().Where(type => !(objectSpace.IsDeletedObject(type)));
}
@@ -66,7 +72,7 @@ public static class ObjectSpaceExtensions {
public static T FindObject<T>(this ObjectSpace objectSpace, Expression<Func<T, bool>> expression, PersistentCriteriaEvaluationBehavior persistentCriteriaEvaluationBehavior) {
var objectType = XafTypesInfo.Instance.FindBussinessObjectType<T>();
CriteriaOperator criteriaOperator = GetCriteriaOperator(objectType, expression, objectSpace);
- bool inTransaction = persistentCriteriaEvaluationBehavior == PersistentCriteriaEvaluationBehavior.InTransaction ? true : false;
+ bool inTransaction = persistentCriteriaEvaluationBehavior == PersistentCriteriaEvaluationBehavior.InTransaction;
return (T)objectSpace.FindObject(objectType, criteriaOperator, inTransaction);
}

0 comments on commit 65d44e2

Please sign in to comment.