Ejemplo n.º 1
0
 void RemoveEntity(IDictionary <Guid, IDomainObject> domainDictionary, IDomainObject domainObject)
 {
     if (ContainsKey(domainDictionary, domainObject))
     {
         domainDictionary.Remove(domainObject.SystemId);
     }
 }
 protected override void Validation(IDomainObject obj)
 {
     if (!(obj is Contract))
     {
         throw new ArgumentException();
     }
 }
        public static void SetForeignKeyProperty(IDomainObject domainObject, RelationEndPointDefinition endPointDefinition, ObjectID relatedID)
        {
            var relatedObject = LifetimeService.GetObjectReference(ClientTransaction.Current, relatedID);
            var properties    = new PropertyIndexer(domainObject);

            properties[endPointDefinition.PropertyName].SetValue(relatedObject);
        }
Ejemplo n.º 4
0
        protected override object Execute(IDomainObject entity)
        {
            Activity        a          = (Activity)entity;
            List <Activity> activities = broker.Select(entity).OfType <Activity>().ToList();

            return(activities);
        }
Ejemplo n.º 5
0
 /// <summary>
 ///     Builds the tree.
 /// </summary>
 /// <param name="rootNode">The root node.</param>
 /// <param name="data">The complexity.</param>
 private void BuildTree(TreeListNode rootNode, IDomainObject data)
 {
     if (FoldersOnly)
     {
         if (!(data is IFolder))
         {
             return;
         }
     }
     if (!ShowRoot)
     {
         if (data is IComposedObject)
         {
             var obj = (IComposedObject)data;
             BuildTree(rootNode, obj.Parts);
         }
         else
         {
             BuildTree(rootNode, new[] { data });
         }
     }
     else
     {
         BuildTree(rootNode, new[] { data });
     }
 }
Ejemplo n.º 6
0
        public Guid GetRequestMapId(IDomainObject connectedToObject, out SetTargetChoice setTarget)
        {
            setTarget = SetTargetChoice.No;

            if (NHibernate.Proxy.NHibernateProxyHelper.GetClassWithoutInitializingProxy(connectedToObject) == typeof(ServiceMethod))
            {
                if (connectedToObject.Id == AddServiceMethodId)
                {
                    return(AddServiceMethodMapId);
                }
                else if (connectedToObject.Id == RemoveServiceMethodId)
                {
                    return(RemoveServiceMethodMapId);
                }
                else if (connectedToObject.Id == LeftFindServiceMethodId)
                {
                    return(LeftFindServiceMethodMapId);
                }
                else if (connectedToObject.Id == RightFindServiceMethodId)
                {
                    return(RightFindServiceMethodMapId);
                }
                else
                {
                    return(Guid.Empty);
                }
            }
            else
            {
                return(Guid.Empty);
            }
        }
Ejemplo n.º 7
0
 private void ValidateObject(IDomainObject obj, ValidationResult result)
 {
     foreach (var validator in obj.Validators)
     {
         validator.Validate(obj, result);
     }
 }
Ejemplo n.º 8
0
        private IList GetLinkedEntities(IUnitOfWork uow, ClearDependenceInfo depend, IDomainObject masterEntity)
        {
            var list = uow.Session.CreateCriteria(depend.ObjectClass)
                       .Add(Restrictions.Eq(depend.PropertyName + ".Id", masterEntity.Id)).List();

            return(list);
        }
Ejemplo n.º 9
0
        public async Task <TState> StateFor <TState>(string domainObjectId, Type domainObjectType)
            where TState : StateBase, new()
        {
            IDomainObject domainObject = await domainObjectRepository.Get(domainObjectId, domainObjectType);

            return(domainObject.State <TState>());
        }
 public PermissionRequirement(PermissionType demandAction, IDomainObject resource)
 {
     IsResourcesCollection = false;
     DemandAction          = demandAction;
     Resource          = resource;
     ResourcesTypeInfo = Resource?.GetResourceInfo();
 }
        protected override void DoOperation(IDomainObject obj)
        {
            int res = broker.InsertOne(obj);

            if (res != 0)
            {
                Done = true;
            }
            else
            {
                Done = false;
                return;
            }

            C.Member    = new StaffMember();
            C.Member.Id = res;

            if (broker.SaveComplex(C))
            {
                Done = true;
            }
            else
            {
                Done = false;
            }
        }
Ejemplo n.º 12
0
 protected override void Validate(IDomainObject entity)
 {
     if (!(entity is EngagementHelper))
     {
         throw new ArgumentException();
     }
 }
Ejemplo n.º 13
0
        protected override object Execute(IDomainObject entity)
        {
            EngagementHelper        e           = (EngagementHelper)entity;
            List <EngagementHelper> engagements = broker.Select(entity).OfType <EngagementHelper>().ToList();

            return(engagements);
        }
        protected override object Execute(IDomainObject entity)
        {
            TypeOfActivity        t     = (TypeOfActivity)entity;
            List <TypeOfActivity> types = broker.Select(entity).OfType <TypeOfActivity>().ToList();

            return(types);
        }
Ejemplo n.º 15
0
        protected override object Execute(IDomainObject entity)
        {
            Member        m      = (Member)entity;
            List <Member> member = broker.Select(entity).OfType <Member>().ToList();

            return(member);
        }
        public object ExecuteSO(IDomainObject entity)
        {
            object res = null;

            try
            {
                Validate(entity);
                broker.OpenConnection();
                broker.BeginTransaction();

                res = Execute(entity);

                broker.CommitTransaction();
            }
            catch (Exception)
            {
                broker.RollbackTransaction();
            }
            finally
            {
                broker.CloseConnection();
            }

            return(res);
        }
Ejemplo n.º 17
0
 protected override void Validation(IDomainObject obj)
 {
     if (!(obj is SportsDirector))
     {
         throw new ArgumentException();
     }
 }
Ejemplo n.º 18
0
 public DomainObjectStateRuntime(IDomainObject domainObject, EventsourceDIContext diContext,
                                 IStateEventMapping mapper, EventSourceConfiguration config)
 {
     this.domainObject  = domainObject;
     this.diContext     = diContext;
     stateToEventMapper = mapper;
 }
Ejemplo n.º 19
0
 private void ValidateProperty(IDomainObject obj, IDomainProperty property, ValidationResult result)
 {
     foreach (var validator in property.Validators)
     {
         validator.Validate(obj, property, result);
     }
 }
Ejemplo n.º 20
0
        public void TestSetMemento()
        {
            IDomainObjectMementoService service = DomainObjectMementoService.GetInstance();
            Customer customer = new Customer(null)
            {
                Name = "John Doe", Number = "123"
            };
            IDomainObjectMemento snapshotMemento = service.CreateMemento(customer);

            //Test original
            Assert.AreEqual("John Doe", customer.Name);
            Assert.AreEqual("123", customer.Number);

            //Alter
            customer.Name   = "Juan dela Cruz";
            customer.Number = "345";

            //Test altered persistency
            Assert.AreEqual("Juan dela Cruz", customer.Name);
            Assert.AreEqual("345", customer.Number);

            //Restore
            IDomainObject domainObject = customer;

            service.SetMemento(ref domainObject, snapshotMemento);

            //Test original
            IDomainObjectMemento latestSnapshotMemento = service.CreateMemento(customer);

            Assert.AreEqual("John Doe", customer.Name);
            Assert.AreEqual("123", customer.Number);
            Assert.AreEqual(snapshotMemento.HashCode, latestSnapshotMemento.HashCode);
        }
Ejemplo n.º 21
0
        public virtual Guid GetRequestMapId(IDomainObject connectedToObject, out SetTargetChoice setTarget)
        {
            object[] propertyMapAttributes = this.GetType().GetProperty("RequestMap").GetCustomAttributes(typeof(PropertyMapAttribute), true);
            setTarget = ((PropertyMapAttribute)propertyMapAttributes[0]).SetTarget;

            if (connectedToObject == null)
            {
                return(RequestMap == null ? Guid.Empty : RequestMap.Id);
            }
            else if (NHibernate.Proxy.NHibernateProxyHelper.GetClassWithoutInitializingProxy(connectedToObject) == NHibernate.Proxy.NHibernateProxyHelper.GetClassWithoutInitializingProxy(MappedToObject))
            {
                if (MappedToObject.Id == connectedToObject.Id)
                {
                    return(RequestMap == null ? Guid.Empty : RequestMap.Id);
                }
                else
                {
                    return(Guid.Empty);
                }
            }
            else
            {
                return(Guid.Empty);
            }
        }
Ejemplo n.º 22
0
        private void BuildGraph(object state)
        {
            try
            {
                using (new SessionScope(MetaManagerServices.GetSessionFactory(), MetaManagerServices.GetDomainInterceptor(), true, FlushMode.Never, true))
                {
                    IDomainObject currentObject = modelService.GetDomainObject(ContaindDomainObjectIdAndType.Key, ContaindDomainObjectIdAndType.Value);
                    FindDependencies(currentObject, null);
                }

                if (!abort)
                {
                    Invoke(new System.Action(() =>
                    {
                        RenderGraph();
                    }));
                }
            }
            finally
            {
                waitEvent.Set();

                if (!abort)
                {
                    Invoke(new System.Action(() =>
                    {
                        this.Cursor = Cursors.Default;
                    }));
                }
            }
        }
Ejemplo n.º 23
0
 protected override void Validate(IDomainObject entity)
 {
     if (!(entity is Activity))
     {
         throw new ArgumentException();
     }
 }
Ejemplo n.º 24
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (svc != null)
            {
                IDomainObject domainObject = context.Instance as IDomainObject;
                if (domainObject != null)
                {
                    IBaseNode variables = domainObject.Tree.RootNode.GetNode(eNodeType.VariableDefinitions);
                    string    modelName = (domainObject as IDomainObjectImpl).FullModelName;
                    using (BulkImportForm frm = new BulkImportForm(variables, ucProperties.App, modelName))
                    {
                        if (svc.ShowDialog(frm) == DialogResult.OK)
                        {
                            domainObject.Nodes.Clear();
                            if (frm.ModelFile != "")
                            {
                                foreach (IBaseNode baseNode in frm.ImportVariables)
                                {
                                    domainObject.AddNode(baseNode);
                                }
                            }

                            value = frm.ModelFile;
                        }
                    }
                }
            }

            return(value);
        }
Ejemplo n.º 25
0
 public void AddToBusinessApplets(IDomainObject item)
 {
     if (BusinessAppletFolder != null)
     {
         BusinessAppletFolder.AddPart(item);
     }
 }
Ejemplo n.º 26
0
        protected override object Execute(IDomainObject entity)
        {
            City        c      = (City)entity;
            List <City> cities = broker.Select(entity).OfType <City>().ToList();

            return(cities);
        }
 protected override void Validation(IDomainObject obj)
 {
     if (!(obj is StaffMember))
     {
         throw new ArgumentException();
     }
 }
Ejemplo n.º 28
0
        protected override object Execute(IDomainObject entity)
        {
            bool success = false;

            if (broker.Insert(entity) > 0)
            {
                success = true;
            }
            int noviId = broker.GetNewId(entity) - 1;

            foreach (Workplace w in c.Workplaces)
            {
                w.Company    = new Company();
                w.Company.ID = noviId;
            }
            foreach (Workplace w in c.Workplaces)
            {
                if (broker.Insert(w) > 0)
                {
                    success = true;
                }
                else
                {
                    success = false;
                }
            }
            return(success);
        }
Ejemplo n.º 29
0
        void ApplyOperation(
            UnitOfWorkAction action, IList <IDomainObject> affectedEntities,
            SuccessfulUoWInvocationDelegate successfulInvocation, FailedUoWInvocationDelegate failedInvocation
            )
        {
            for (int index = 0; index < affectedEntities.Count; index++)
            {
                IDomainObject entity = affectedEntities[index];

                if (entity == null)
                {
                    continue;
                }

                IBaseMapper       mapper    = entity.Mapper;
                OperationDelegate operation = GetOperation(action, mapper);

                bool success = operation(ref entity,
                                         (domainObject, results) =>
                {
                    if (successfulInvocation != null)
                    {
                        successfulInvocation(domainObject, action, results);
                    }
                },
                                         (domainObject, results) =>
                {
                    if (failedInvocation != null)
                    {
                        failedInvocation(domainObject, action, results);
                    }
                });
            }
        }
Ejemplo n.º 30
0
        public void GetState()
        {
            IDomainObject domainObject = DomainObjectMother.CreateFakeObject <Order> ();

            var state = domainObject.GetState();

            Assert.That(state, Is.EqualTo(domainObject.TransactionContext[domainObject.RootTransaction.ActiveTransaction].State));
        }