Ejemplo n.º 1
0
        private static EvaluatorContextDescriptor GetEvaluatorContextDescriptor(Type objectType, object targetObject)
        {
            var objectSpace = XPObjectSpace.FindObjectSpaceByObject(targetObject);

            return(objectSpace != null?objectSpace.GetEvaluatorContextDescriptor(objectType)
                       : new EvaluatorContextDescriptorDefault(objectType));
        }
Ejemplo n.º 2
0
        public IList <IStateMachine> GetStateMachines()
        {
            List <IStateMachine> result = new List <IStateMachine>();

            result.Add(new TSDataKeluhan(XPObjectSpace.FindObjectSpaceByObject(this)));
            return(result);
        }
Ejemplo n.º 3
0
        public static void ReleaseSequence(ISupportSequenceObject supportSequenceObject)
        {
            var typeName    = supportSequenceObject.Prefix + supportSequenceObject.GetType().FullName;
            var objectSpace = (XPObjectSpace)XPObjectSpace.FindObjectSpaceByObject(supportSequenceObject);

            ReleaseSequence(objectSpace.Session, typeName, supportSequenceObject.Sequence);
        }
Ejemplo n.º 4
0
        public IList <IStateMachine> GetStateMachines()
        {
            List <IStateMachine> result = new List <IStateMachine>();

            result.Add(new ClaimTrxsStateMachine(XPObjectSpace.FindObjectSpaceByObject(this)));
            return(result);
        }
Ejemplo n.º 5
0
        void OnCurrentObjectChanged(object sender, EventArgs eventArgs)
        {
            IObjectSpace objectSpace = XPObjectSpace.FindObjectSpaceByObject(_propertyEditor.CurrentObject);

            objectSpace.ObjectChanged += ObjectSpaceOnObjectChanged;
            UpdateEditor(((ISupportEditControl)_propertyEditor).GetControl());
        }
Ejemplo n.º 6
0
        public static void SupportCompositeKeyPersistentObjects(this IPersistentAssemblyInfo persistentAssemblyInfo)
        {
            var keys =
                persistentAssemblyInfo.PersistentClassInfos.SelectMany(info => info.OwnMembers)
                .OfType <IPersistentReferenceMemberInfo>()
                .Where(
                    memberInfo =>
                    memberInfo.ReferenceClassInfo.CodeTemplateInfo.CodeTemplate.TemplateType ==
                    TemplateType.Struct);
            var dictionary  = new Dictionary <IPersistentClassInfo, ITemplateInfo>();
            var objectSpace = XPObjectSpace.FindObjectSpaceByObject(persistentAssemblyInfo);

            foreach (var key in keys)
            {
                if (!dictionary.ContainsKey(key.Owner))
                {
                    var info = objectSpace.Create <ITemplateInfo>();
                    info.Name = SupportPersistentObjectsAsAPartOfACompositeKey;
                    key.Owner.TemplateInfos.Add(info);
                    dictionary.Add(key.Owner, info);
                }
                ITemplateInfo templateInfo = dictionary[key.Owner];
                templateInfo.TemplateCode = @"protected override void OnLoaded() {
                                                base.OnLoaded();
                                                " + GetCode(key) + @"
                                            }";
            }
        }
Ejemplo n.º 7
0
        public IList <IStateMachine> GetStateMachines()
        {
            List <IStateMachine> result = new List <IStateMachine>();

            result.Add(new WorkflowCaseStatusStateMachine(XPObjectSpace.FindObjectSpaceByObject(this)));
            return(result);
        }
Ejemplo n.º 8
0
 public ClassAtrributeGenerator(ClassGeneratorInfo classGeneratorInfo, string navigationPath)
 {
     _persistentClassInfo = classGeneratorInfo.PersistentClassInfo;
     _dbTable             = classGeneratorInfo.DbTable;
     _navigationPath      = navigationPath;
     _objectSpace         = XPObjectSpace.FindObjectSpaceByObject(_persistentClassInfo);
 }
Ejemplo n.º 9
0
        public override void Update()
        {
            if (Session.FindObject <PersistentAssemblyInfo>(info => info.Name == DynamicAssemblyCalculatedField.AttributeRegistrator.MasterDetailDynamicAssembly) == null)
            {
                IPersistentAssemblyInfo persistentAssemblyInfo = new DynamicAssemblyBuilder(Session).Build(DynamicAssemblyCalculatedField.AttributeRegistrator.DMDCustomer, DMDOrder,
                                                                                                           DMDOrderLine, DynamicAssemblyCalculatedField.AttributeRegistrator.MasterDetailDynamicAssembly);
                IPersistentClassInfo persistentClassInfo =
                    persistentAssemblyInfo.PersistentClassInfos.Single(info => info.Name == DynamicAssemblyCalculatedField.AttributeRegistrator.DMDCustomer);
                var persistentCoreTypeMemberInfo = new PersistentCoreTypeMemberInfo(persistentClassInfo.Session);
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInDetailViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInListViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInLookupListViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentPersistentAliasAttribute(persistentCoreTypeMemberInfo.Session)
                {
                    AliasExpression = "DMDOrders.Min(OrderDate)"
                });
                persistentCoreTypeMemberInfo.Name     = "FirstOrderDate";
                persistentCoreTypeMemberInfo.DataType = DBColumnType.DateTime;
                var codeTemplateInfo = new CodeTemplateInfo(persistentCoreTypeMemberInfo.Session);
                var codeTemplate     = new CodeTemplate(codeTemplateInfo.Session)
                {
                    TemplateType = TemplateType.XPCalculatedPropertyMember
                };
                codeTemplate.SetDefaults();
                codeTemplate.Name             = "CalculatedProperty";
                codeTemplateInfo.TemplateInfo = codeTemplate;

                persistentCoreTypeMemberInfo.CodeTemplateInfo = codeTemplateInfo;
                persistentClassInfo.OwnMembers.Add(persistentCoreTypeMemberInfo);
                XPObjectSpace.FindObjectSpaceByObject(persistentClassInfo).CommitChanges();
            }
        }
Ejemplo n.º 10
0
 public MemberAttributeGenerator(MemberGeneratorInfo memberGeneratorInfo, ClassGeneratorInfo classGeneratorInfo)
 {
     _objectSpace          = XPObjectSpace.FindObjectSpaceByObject(memberGeneratorInfo.PersistentMemberInfo);
     _persistentMemberInfo = memberGeneratorInfo.PersistentMemberInfo;
     _column       = memberGeneratorInfo.DbColumn;
     _isPrimaryKey = CalculatePrimaryKey(memberGeneratorInfo, classGeneratorInfo);
     _dbTable      = classGeneratorInfo.DbTable;
 }
Ejemplo n.º 11
0
        public override void AfterConstruction()
        {
            base.AfterConstruction();

            IObjectSpace os = XPObjectSpace.FindObjectSpaceByObject(this);

            Doctor = os.GetObject(SecuritySystem.CurrentUser as Doctor);
        }
Ejemplo n.º 12
0
        public static void CreateAssociation(this IPersistentMemberInfo persistentMemberInfo, string associationName)
        {
            var objectSpace = XPObjectSpace.FindObjectSpaceByObject(persistentMemberInfo);
            var attribute   = objectSpace.CreateWCObject <IPersistentAssociationAttribute>();

            attribute.AssociationName = associationName;
            persistentMemberInfo.TypeAttributes.Add(attribute);
        }
Ejemplo n.º 13
0
        public static SecuritySystemTypePermissionObject CreateTypePermission(this SecuritySystemRoleBase systemRole, Type targetType)
        {
            var objectSpace      = XPObjectSpace.FindObjectSpaceByObject(systemRole);
            var permissionObject = objectSpace.CreateObject <SecuritySystemTypePermissionObject>();

            permissionObject.TargetType = targetType;
            systemRole.TypePermissions.Add(permissionObject);
            return(permissionObject);
        }
Ejemplo n.º 14
0
                           public static ValidationState StateOf(this RuleSet ruleSet, object targetObject,
                                                                 Func <RuleSetValidationResultItem, bool> filter)
                           {
                               var objectSpace             = XPObjectSpace.FindObjectSpaceByObject(targetObject);
                               var ruleSetValidationResult = Validator.RuleSet.ValidateTarget(objectSpace, targetObject, ContextIdentifier.Save);
                               var validationResultItem    = ruleSetValidationResult.Results.First(filter);

                               return(validationResultItem.State);
                           }
Ejemplo n.º 15
0
 public override void AfterConstruction()
 {
     base.AfterConstruction();
     IsActive = true;
     if (ObjectSpace == null)
     {
         ObjectSpace = XPObjectSpace.FindObjectSpaceByObject(this);
     }
 }
Ejemplo n.º 16
0
        public AssemblyGenerator(LogonObject logonObject, IPersistentAssemblyInfo persistentAssemblyInfo, string[] tables)
        {
            _persistentAssemblyInfo = persistentAssemblyInfo;
            var dataStoreSchemaExplorer = ((IDataStoreSchemaExplorer)XpoDefault.GetConnectionProvider(logonObject.ConnectionString, AutoCreateOption.None));

            dataStoreSchemaExplorer = GetDataStoreSchemaExplorer(dataStoreSchemaExplorer);
            _storageTables          = dataStoreSchemaExplorer.GetStorageTables(tables).Where(table => table.PrimaryKey != null).ToArray();
            _logonObject            = logonObject;
            _objectSpace            = XPObjectSpace.FindObjectSpaceByObject(persistentAssemblyInfo);
        }
Ejemplo n.º 17
0
 private static bool CanApply(IModelDashboardDataSource modelDashboardDataSource, FilterEnabled filterEnabled, IDashboardDefinition template)
 {
     if (modelDashboardDataSource.NodeEnabled && new[] { FilterEnabled.Always, filterEnabled }.Contains(modelDashboardDataSource.Enabled))
     {
         var objectSpace            = XPObjectSpace.FindObjectSpaceByObject(template);
         var isObjectFitForCriteria = objectSpace.IsObjectFitForCriteria(template, CriteriaOperator.Parse(modelDashboardDataSource.DashboardDefinitionCriteria));
         return(isObjectFitForCriteria.HasValue && isObjectFitForCriteria.Value);
     }
     return(false);
 }
Ejemplo n.º 18
0
        public override void AfterConstruction()
        {
            base.AfterConstruction();
            IObjectSpace objectSpace = XPObjectSpace.FindObjectSpaceByObject(this);

            if (objectSpace != null)
            {
                CreatedBy = (SecuritySystemUser)objectSpace.GetObject(SecuritySystem.CurrentUser);
            }
        }
Ejemplo n.º 19
0
        public static IPersistentMemberInfo CreateCollection(this IPersistentClassInfo classInfo, string assemblyName, string classInfoName)
        {
            var collectionMemberInfo = XPObjectSpace.FindObjectSpaceByObject(classInfo).CreateWCObject <IPersistentCollectionMemberInfo>();

            collectionMemberInfo.Owner = classInfo;
            collectionMemberInfo.Name  = classInfoName + "s";
            collectionMemberInfo.SetCollectionTypeFullName(assemblyName + "." + classInfoName);
            collectionMemberInfo.Init(WCTypesInfo.Instance.FindBussinessObjectType <ICodeTemplate>());
            collectionMemberInfo.CodeTemplateInfo.CloneProperties();
            classInfo.OwnMembers.Add(collectionMemberInfo);
            return(collectionMemberInfo);
        }
Ejemplo n.º 20
0
        public static void SetDefaultTemplate(this IPersistentTemplatedTypeInfo persistentMemberInfo, TemplateType templateType)
        {
            var objectSpace = XPObjectSpace.FindObjectSpaceByObject(persistentMemberInfo);

            persistentMemberInfo.CodeTemplateInfo = objectSpace.CreateWCObject <ICodeTemplateInfo>();

            ICodeTemplate defaultTemplate = CodeTemplateBuilder.CreateDefaultTemplate(templateType, persistentMemberInfo.Session,
                                                                                      WCTypesInfo.Instance.FindBussinessObjectType <ICodeTemplate>(),
                                                                                      GetProvider(persistentMemberInfo));

            persistentMemberInfo.CodeTemplateInfo.CodeTemplate = defaultTemplate;
            persistentMemberInfo.CodeTemplateInfo.CloneProperties();
        }
Ejemplo n.º 21
0
        static bool Fit(object targetObject, string criteria)
        {
            Type objectType = targetObject.GetType();
            var  wrapper    = new LocalizedCriteriaWrapper(objectType, criteria);

            wrapper.UpdateParametersValues(targetObject);
            var objectSpace = XPObjectSpace.FindObjectSpaceByObject(targetObject);
            EvaluatorContextDescriptor descriptor = objectSpace != null?objectSpace.GetEvaluatorContextDescriptor(objectType) : new EvaluatorContextDescriptorDefault(objectType);

            var evaluator = new ExpressionEvaluator(descriptor, wrapper.CriteriaOperator, XpandModuleBase.Dictiorary.CustomFunctionOperators);

            return(evaluator.Fit(targetObject));
        }
Ejemplo n.º 22
0
        public static SecuritySystemMemberPermissionsObject CreateMemberPermission(this SecuritySystemTypePermissionObject securitySystemTypePermissionObject, Action <SecuritySystemMemberPermissionsObject> action, bool defaultAllowValues = true)
        {
            IObjectSpace objectSpace = XPObjectSpace.FindObjectSpaceByObject(securitySystemTypePermissionObject);
            var          permission  = objectSpace.CreateObject <SecuritySystemMemberPermissionsObject>();

            permission.AllowRead      = defaultAllowValues;
            permission.AllowWrite     = defaultAllowValues;
            permission.EffectiveRead  = defaultAllowValues;
            permission.EffectiveWrite = defaultAllowValues;
            securitySystemTypePermissionObject.MemberPermissions.Add(permission);
            action.Invoke(permission);
            return(permission);
        }
Ejemplo n.º 23
0
 public static void Init(this IPersistentTemplatedTypeInfo persistentTemplatedTypeInfo, Type codeTemplateType)
 {
     persistentTemplatedTypeInfo.CodeTemplateInfo = XPObjectSpace.FindObjectSpaceByObject(persistentTemplatedTypeInfo).CreateWCObject <ICodeTemplateInfo>();
     if (persistentTemplatedTypeInfo is IPersistentMemberInfo)
     {
         var persistentMemberInfo = ((IPersistentMemberInfo)persistentTemplatedTypeInfo);
         persistentMemberInfo.Init(codeTemplateType, persistentMemberInfo.Owner.PersistentAssemblyInfo.CodeDomProvider);
     }
     else if (persistentTemplatedTypeInfo is IPersistentClassInfo)
     {
         var persistentClassInfo = ((IPersistentClassInfo)persistentTemplatedTypeInfo);
         persistentClassInfo.Init(codeTemplateType, persistentClassInfo.PersistentAssemblyInfo.CodeDomProvider);
     }
 }
Ejemplo n.º 24
0
 private void DashboardDesigner1_DashboardSaving(object sender, DashboardSavingEventArgs e)
 {
     e.Handled = true;
     using (var ms = new MemoryStream())
     {
         e.Dashboard.SaveToXml(ms);
         ms.Position = 0;
         using (var sr = new StreamReader(ms, Encoding.UTF8))
         {
             var xml = sr.ReadToEnd();
             Xml = xml;
             XPObjectSpace.FindObjectSpaceByObject(this)?.CommitChanges();
         }
     }
 }
Ejemplo n.º 25
0
        void MapMemberValues(object previousObject, object currentObject)
        {
            var memberInfos = CommonMemberViewItems().Cast <IModelMemberViewItem>().Select(item => item.ModelMember.MemberInfo);

            foreach (var member in memberInfos)
            {
                var value = member.GetValue(previousObject);
                if (member.MemberTypeInfo.IsPersistent)
                {
                    value = XPObjectSpace.FindObjectSpaceByObject(currentObject).GetObject(value);
                }

                member.SetValue(currentObject, value);
            }
        }
Ejemplo n.º 26
0
        public static void ReleaseSequence(ISupportSequenceObject supportSequenceObject)
        {
            if (_defaultDataLayer == null)
            {
                return;
            }
            var objectSpace    = (XPObjectSpace)XPObjectSpace.FindObjectSpaceByObject(supportSequenceObject);
            var sequenceObject = objectSpace.GetObjectByKey(_sequenceObjectType, supportSequenceObject.Prefix + supportSequenceObject.ClassInfo.FullName) as ISequenceObject;

            if (sequenceObject != null)
            {
                var objectFromInterface = objectSpace.CreateObjectFromInterface <ISequenceReleasedObject>();
                objectFromInterface.Sequence       = supportSequenceObject.Sequence;
                objectFromInterface.SequenceObject = sequenceObject;
            }
        }
Ejemplo n.º 27
0
        private static EvaluatorContextDescriptor GetEvaluatorContextDescriptor(Type objectType, object targetObject)
        {
            var objectSpace = XPObjectSpace.FindObjectSpaceByObject(targetObject);

            if (objectSpace == null)
            {
                var iTypeInfo = targetObject.GetITypeInfo();
                if (iTypeInfo.IsDomainComponent)
                {
                    var classInfo = iTypeInfo.QueryXPClassInfo();
                    return(classInfo.GetEvaluatorContextDescriptor());
                }
            }
            return(objectSpace != null?objectSpace.GetEvaluatorContextDescriptor(objectType)
                       : new EvaluatorContextDescriptorDefault(objectType));
        }
Ejemplo n.º 28
0
        public static SecuritySystemObjectPermissionsObject AddNewObjectPermission(this SecuritySystemTypePermissionObject securitySystemTypePermissionObject, Action <SecuritySystemObjectPermissionsObject> action, bool defaultAllowValues = true)
        {
            var objectSpace = XPObjectSpace.FindObjectSpaceByObject(securitySystemTypePermissionObject);
            var permission  = objectSpace.CreateObject <SecuritySystemObjectPermissionsObject>();

            permission.AllowDelete       = defaultAllowValues;
            permission.AllowNavigate     = defaultAllowValues;
            permission.AllowRead         = defaultAllowValues;
            permission.AllowWrite        = defaultAllowValues;
            permission.EffectiveDelete   = defaultAllowValues;
            permission.EffectiveNavigate = defaultAllowValues;
            permission.EffectiveRead     = defaultAllowValues;
            permission.EffectiveWrite    = defaultAllowValues;
            securitySystemTypePermissionObject.ObjectPermissions.Add(permission);
            action?.Invoke(permission);
            return(permission);
        }
Ejemplo n.º 29
0
        public static bool Fit(this CriteriaOperator criteriaOperator, object targetObject)
        {
            if (ReferenceEquals(criteriaOperator, null))
            {
                return(true);
            }
            Type objectType = targetObject.GetType();
            var  wrapper    = new LocalizedCriteriaWrapper(objectType, criteriaOperator);

            wrapper.UpdateParametersValues(targetObject);
            var objectSpace = XPObjectSpace.FindObjectSpaceByObject(targetObject);
            EvaluatorContextDescriptor descriptor = objectSpace != null?objectSpace.GetEvaluatorContextDescriptor(objectType) : new EvaluatorContextDescriptorDefault(objectType);

            var evaluator = new ExpressionEvaluator(descriptor, wrapper.CriteriaOperator, XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary.CustomFunctionOperators);

            return(evaluator.Fit(targetObject));
        }
Ejemplo n.º 30
0
        public static void CloneProperties(this ICodeTemplateInfo codeTemplateInfo)
        {
            var templateInfo = codeTemplateInfo.TemplateInfo ?? XPObjectSpace.FindObjectSpaceByObject(codeTemplateInfo).CreateWCObject <ITemplateInfo>();

            codeTemplateInfo.TemplateInfo = templateInfo;
            var type  = templateInfo.GetType();
            var infos = typeof(ITemplateInfo).GetProperties().Select(propertyInfo =>
                                                                     new {
                Value = propertyInfo.GetValue(codeTemplateInfo.CodeTemplate, null),
                TypeInfoPropertyInfo = type.GetProperty(propertyInfo.Name)
            });

            foreach (var info in infos)
            {
                info.TypeInfoPropertyInfo.SetValue(templateInfo, info.Value, null);
            }
        }