Esempio n. 1
0
 public static void CreateRuntimeMembers(IModelApplication model)
 {
     using (var objectSpace = CreateObjectSpace()) {
         Tracing.Tracer.LogVerboseSubSeparator("RuntimeMembers Creation started");
         var modelMemberOneToManyCollections = new List <IModelMemberOneToManyCollection>();
         var xpObjectSpace  = objectSpace as XPObjectSpace;
         var modelMemberExs = GetMembersEx(model).ToArray();
         foreach (var memberEx in modelMemberExs)
         {
             var customCreateMemberArgs = new CustomCreateMemberArgs(memberEx);
             OnCustomCreateMember(customCreateMemberArgs);
             if (!customCreateMemberArgs.Handled)
             {
                 var modelMemberOneToManyCollection = memberEx as IModelMemberOneToManyCollection;
                 if (modelMemberOneToManyCollection == null)
                 {
                     CreateXpandCustomMemberInfo(memberEx, xpObjectSpace);
                 }
                 else
                 {
                     modelMemberOneToManyCollections.Add(modelMemberOneToManyCollection);
                 }
             }
         }
         RefreshTypes(model.GetTypesInfo(), modelMemberExs.Select(ex => ex.ModelClass.TypeInfo).Distinct());
         CreateAssociatedCollectionMembers(modelMemberOneToManyCollections, xpObjectSpace);
         RefreshTypes(model.GetTypesInfo(), modelMemberOneToManyCollections.Select(collection => collection.CollectionType.TypeInfo).Distinct());
     }
     Tracing.Tracer.LogVerboseSubSeparator("RuntimeMembers Creation finished");
 }
Esempio n. 2
0
 public static void CreateRuntimeMembers(IModelApplication model) {
     using (var objectSpace = CreateObjectSpace()) {
         Tracing.Tracer.LogVerboseSubSeparator("RuntimeMembers Creation started");
         var modelMemberOneToManyCollections = new List<IModelMemberOneToManyCollection>();
         var xpObjectSpace = objectSpace as XPObjectSpace;
         var modelMemberExs = GetMembersEx(model);
         foreach (var memberEx in modelMemberExs) {
             var customCreateMemberArgs = new CustomCreateMemberArgs(memberEx);
             OnCustomCreateMember(customCreateMemberArgs);
             if (!customCreateMemberArgs.Handled) {
                 var modelMemberOneToManyCollection = memberEx as IModelMemberOneToManyCollection;
                 if (modelMemberOneToManyCollection == null) {
                     CreateXpandCustomMemberInfo(memberEx, xpObjectSpace);
                 }
                 else {
                     modelMemberOneToManyCollections.Add(modelMemberOneToManyCollection);
                 }
             }
         }
         RefreshTypes(model.GetTypesInfo(), modelMemberExs.Select(ex => ex.ModelClass.TypeInfo).Distinct());
         CreateAssociatedCollectionMembers(modelMemberOneToManyCollections, xpObjectSpace);
         RefreshTypes(model.GetTypesInfo(), modelMemberOneToManyCollections.Select(collection => collection.CollectionType.TypeInfo).Distinct());
     }
     Tracing.Tracer.LogVerboseSubSeparator("RuntimeMembers Creation started");
 }
Esempio n. 3
0
        static void OnCustomCreateMember(CustomCreateMemberArgs e)
        {
            EventHandler <CustomCreateMemberArgs> handler = CustomCreateMember;

            if (handler != null)
            {
                handler(null, e);
            }
        }
Esempio n. 4
0
 void RuntimeMemberBuilderOnCustomCreateMember(object sender, CustomCreateMemberArgs customCreateMemberArgs) {
     var modelMemberAuditTrail = customCreateMemberArgs.ModelMemberEx as IModelMemberAuditTrail;
     if (modelMemberAuditTrail != null) {
         XPClassInfo owner = Dictiorary.GetClassInfo(modelMemberAuditTrail.ModelClass.TypeInfo.Type);
         if (owner.FindMember(modelMemberAuditTrail.Name)==null) {
             new AuditTrailCollectionMemberInfo(owner, modelMemberAuditTrail.Name,modelMemberAuditTrail.CollectionType.TypeInfo.Type);
         }
         customCreateMemberArgs.Handled = true;
     }
 }
Esempio n. 5
0
 public static void CreateRuntimeMembers(IModelApplication model)
 {
     using (var objectSpace = CreateObjectSpace()) {
         Tracing.Tracer.LogVerboseSubSeparator("RuntimeMembers Creation started");
         var modelMemberOneToManyCollections = new List <IModelMemberOneToManyCollection>();
         var xpObjectSpace  = objectSpace as XPObjectSpace;
         var modelMemberExs = GetMembersEx(model).ToArray();
         var exceptions     = new List <Exception>();
         foreach (var memberEx in modelMemberExs)
         {
             try{
                 var customCreateMemberArgs = new CustomCreateMemberArgs(memberEx);
                 OnCustomCreateMember(customCreateMemberArgs);
                 if (!customCreateMemberArgs.Handled)
                 {
                     var modelMemberOneToManyCollection = memberEx as IModelMemberOneToManyCollection;
                     if (modelMemberOneToManyCollection == null)
                     {
                         CreateXpandCustomMemberInfo(memberEx, xpObjectSpace);
                     }
                     else
                     {
                         modelMemberOneToManyCollections.Add(modelMemberOneToManyCollection);
                     }
                 }
             }
             catch (Exception e) {
                 exceptions.Add(new Exception($"Failed to create {memberEx.Name} on {memberEx.ModelClass.Name}", e));
             }
         }
         foreach (var exception in exceptions)
         {
             Tracing.Tracer.LogError(exception);
         }
         if (!SuppressException && exceptions.Any())
         {
             throw new AggregateException("Runtime members creation failed", exceptions);
         }
         RefreshTypes(XafTypesInfo.Instance, modelMemberExs.Select(ex => ex.ModelClass.TypeInfo).Distinct());
         CreateAssociatedCollectionMembers(modelMemberOneToManyCollections, xpObjectSpace);
         RefreshTypes(XafTypesInfo.Instance, modelMemberOneToManyCollections.Select(collection => collection.CollectionType.TypeInfo).Distinct());
     }
     Tracing.Tracer.LogVerboseSubSeparator("RuntimeMembers Creation finished");
 }
Esempio n. 6
0
 static void OnCustomCreateMember(CustomCreateMemberArgs e) {
     EventHandler<CustomCreateMemberArgs> handler = CustomCreateMember;
     if (handler != null) handler(null, e);
 }
Esempio n. 7
0
        static void OnCustomCreateMember(CustomCreateMemberArgs e)
        {
            EventHandler <CustomCreateMemberArgs> handler = CustomCreateMember;

            handler?.Invoke(null, e);
        }