Exemple #1
0
        private void AddChildEntity(IEntity entity, bool readOnly, bool child)
        {
            if (Configuration.Instance.ExcludeRegexIsMatch(entity.EntityKeyName))
            {
                return;
            }

            if (readOnly)
            {
                if (ReadOnlyChildEntities.Count > 0 && ReadOnlyChildEntities.Contains(entity))
                {
                    return;
                }
                if (ReadOnlyRootEntities.Count > 0 && ReadOnlyRootEntities.Contains(entity))
                {
                    return;
                }

                if (child)
                {
                    ReadOnlyChildEntities.Add(entity);
                }
                else
                {
                    ReadOnlyRootEntities.Add(entity);
                }
            }
            else
            {
                if (DynamicRootEntities.Count > 0 && DynamicRootEntities.Contains(entity))
                {
                    return;
                }
                if (EditableChildEntities.Count > 0 && EditableChildEntities.Contains(entity))
                {
                    return;
                }
                if (EditableRootEntities.Count > 0 && EditableRootEntities.Contains(entity))
                {
                    return;
                }
                if (SwitchableObjectEntities.Count > 0 && SwitchableObjectEntities.Contains(entity))
                {
                    return;
                }

                if (child)
                {
                    EditableChildEntities.Add(entity);
                }
                else
                {
                    EditableRootEntities.Add(entity);
                }
            }
        }
Exemple #2
0
        private void OnReadOnlyRootChanged()
        {
            CleanTemplateContextByValue(Constants.ReadOnlyRoot);

            foreach (var entity in ReadOnlyRootEntities)
            {
                string key = String.Format(Constants.ReadOnlyFormat, entity.EntityKeyName);

                if (ContextData.Get(key) != null)
                {
                    ContextData.Remove(key);
                }

                ReadOnlyChildEntities.Remove(entity);

                ContextData.Add(key, Constants.ReadOnlyRoot);

                if (State == TemplateState.RestoringProperties)
                {
                    continue;
                }

                //Many-To-One
                foreach (var childEntity in GetChildAssociations(entity.Associations))
                {
                    foreach (AssociationProperty property in childEntity.Properties)
                    {
                        AddChildEntity(property.Association.Entity, true, true);
                    }
                }

                //One-To-Many & Many-To-Many
                foreach (var childList in GetChildListAssociations(entity.Associations))
                {
                    foreach (AssociationProperty property in childList.Properties)
                    {
                        AddChildList(property.Association.Entity, true, true);
                    }
                }
            }
        }