Ejemplo n.º 1
0
        public static void SetLocks(MetaModel metaModel, Locks locks)
        {
            if (metaModel == null)
            {
                return;
            }

            ImmutabilityExtensionMethods.SetLocks(metaModel, locks);

            foreach (PropertyGridEditor p in metaModel.PropertyGridEditors)
            {
                ImmutabilityExtensionMethods.SetLocks(p, locks);
            }

            foreach (DomainType p in metaModel.DomainTypes)
            {
                ImmutabilityExtensionMethods.SetLocks(p, locks);
            }

            foreach (BaseModelContext p in metaModel.ModelContexts)
            {
                ImmutabilityExtensionMethods.SetLocks(p, locks);

                if (p is LibraryModelContext)
                {
                    foreach (DiagramClass d in (p as LibraryModelContext).DiagramClasses)
                    {
                        ImmutabilityExtensionMethods.SetLocks(d, locks);
                        foreach (PresentationElementClass pe in d.PresentationElements)
                        {
                            ImmutabilityExtensionMethods.SetLocks(pe, locks);
                        }
                    }

                    LibraryModelContext lib = p as LibraryModelContext;
                    if (lib.SerializationModel != null)
                    {
                        ImmutabilityExtensionMethods.SetLocks(lib.SerializationModel, locks);
                        foreach (SerializationClass s in lib.SerializationModel.Children)
                        {
                            if (s == null)
                            {
                                continue;
                            }

                            ImmutabilityExtensionMethods.SetLocks(s, locks);
                            foreach (SerializationAttributeElement attr in s.Attributes)
                            {
                                if (attr != null)
                                {
                                    ImmutabilityExtensionMethods.SetLocks(attr, locks);
                                }
                            }

                            foreach (SerializationElement element in s.Children)
                            {
                                if (element is SerializationAttributeElement)
                                {
                                    ImmutabilityExtensionMethods.SetLocks(element, locks);
                                }
                            }

                            if (s is SerializedReferenceRelationship)
                            {
                                SerializedReferenceRelationship sRef = s as SerializedReferenceRelationship;
                                foreach (SerializedDomainRole role in sRef.SerializedDomainRoles)
                                {
                                    ImmutabilityExtensionMethods.SetLocks(role, locks);
                                }
                            }
                        }
                    }
                }
            }

            if (metaModel.AdditionalInformation != null)
            {
                ImmutabilityExtensionMethods.SetLocks(metaModel.AdditionalInformation, locks);

                if (metaModel.AdditionalInformation.FurtherInformation != null)
                {
                    ImmutabilityExtensionMethods.SetLocks(metaModel.AdditionalInformation.FurtherInformation, locks);
                    foreach (InformationItem p in metaModel.AdditionalInformation.FurtherInformation.InformationItems)
                    {
                        ImmutabilityExtensionMethods.SetLocks(p, locks);
                    }
                }

                if (metaModel.AdditionalInformation.Credits != null)
                {
                    ImmutabilityExtensionMethods.SetLocks(metaModel.AdditionalInformation.Credits, locks);
                    foreach (CreditItem p in metaModel.AdditionalInformation.Credits.CreditItems)
                    {
                        ImmutabilityExtensionMethods.SetLocks(p, locks);
                    }
                }
            }

            foreach (DomainClass p in metaModel.AllClasses)
            {
                ImmutabilityExtensionMethods.SetLocks(p, locks);
                foreach (DomainProperty prop in p.Properties)
                {
                    ImmutabilityExtensionMethods.SetLocks(prop, locks);
                }
            }

            foreach (DomainRelationship p in metaModel.AllRelationships)
            {
                ImmutabilityExtensionMethods.SetLocks(p, locks);
                foreach (DomainProperty prop in p.Properties)
                {
                    ImmutabilityExtensionMethods.SetLocks(prop, locks);
                }
                foreach (DomainRole prop in p.Roles)
                {
                    ImmutabilityExtensionMethods.SetLocks(prop, locks);
                }
            }

            if (metaModel.Validation != null)
            {
                ImmutabilityExtensionMethods.SetLocks(metaModel.Validation, locks);
            }
        }