LoadOrCreateNew() static private method

static private LoadOrCreateNew ( IXPathNavigable contentTypeDefinitionXml ) : ContentType
contentTypeDefinitionXml IXPathNavigable
return ContentType
Example #1
0
        public override void Save()
        {
            if (!this.Path.StartsWith(Repository.ContentTypesFolderPath))
            {
                base.Save();
                return;
            }

            if (!Object.ReferenceEquals(this, ContentTypeManager.Current.GetContentTypeByName(this.Name)))
            {
                string src = this.ToXml();
                ContentTypeManager.LoadOrCreateNew(src);
            }
            else
            {
                //-- Name check
                Stream stream = this.Binary.GetStream();
                long   pos    = stream.Position;
                stream.Seek(0, SeekOrigin.Begin);
                StreamReader reader = new StreamReader(stream);
                string       xml    = reader.ReadToEnd();
                stream.Seek(pos, SeekOrigin.Begin);
                StringReader   sr       = new StringReader(xml);
                XPathDocument  xpathDoc = new XPathDocument(sr);
                XPathNavigator nav      = xpathDoc.CreateNavigator().SelectSingleNode("/*[1]/@name");
                string         name     = nav.Value;
                if (name != this.Name)
                {
                    throw new ContentRegistrationException(SR.Exceptions.Registration.Msg_InconsistentContentTypeName, this.Name);
                }
            }
            ContentTypeManager.ApplyChanges(this);
            base.Save();
            ContentTypeManager.Current.AddContentType(this);
        }
Example #2
0
        private void Install(CTD ctd)
        {
            ContentType contentType = ContentTypeManager.LoadOrCreateNew(ctd.Document);

            ContentTypeManager.ApplyChangesInEditor(contentType, _editor);
            contentType.Save(false);
            ContentTypeManager.Current.AddContentType(contentType);
        }
        private void Install(CTD ctd)
        {
            var contentType = ContentTypeManager.LoadOrCreateNew(ctd.Document);

            // skip notification during content type install to avoid missing field errors
            contentType.DisableObserver(TypeResolver.GetType(NodeObserverNames.NOTIFICATION, false));

            ContentTypeManager.ApplyChangesInEditor(contentType, _editor);
            contentType.Save(false);
            ContentTypeManager.Current.AddContentType(contentType);
        }
        private void Install(Ctd ctd)
        {
            var contentType = ContentTypeManager.LoadOrCreateNew(ctd.Document);

            if (contentType.IsInvalid)
            {
                // registering a content type with an invalid handler or field is not allowed
                throw new ContentRegistrationException(
                          $"Error during installing content type {contentType.Name}. Please check the log for " +
                          "a registration error or warning.");
            }

            // skip notification during content type install to avoid missing field errors
            contentType.DisableObserver(TypeResolver.GetType(NodeObserverNames.NOTIFICATION, false));

            ContentTypeManager.ApplyChangesInEditor(contentType, _editor);
            contentType.Save(false);
            ContentTypeManager.Instance.AddContentType(contentType);
        }