Пример #1
0
		public static CodeEditorOptions TryCreate(ITextViewOptionsGroup group, IContentTypeRegistryService contentTypeRegistryService, ICodeEditorOptionsDefinitionMetadata md) {
			if (group == null)
				throw new ArgumentNullException(nameof(group));
			if (contentTypeRegistryService == null)
				throw new ArgumentNullException(nameof(contentTypeRegistryService));
			if (md == null)
				throw new ArgumentNullException(nameof(md));

			if (md.ContentType == null)
				return null;
			var contentType = contentTypeRegistryService.GetContentType(md.ContentType);
			if (contentType == null)
				return null;

			if (md.Guid == null)
				return null;
			Guid guid;
			if (!Guid.TryParse(md.Guid, out guid))
				return null;

			if (md.LanguageName == null)
				return null;

			return new CodeEditorOptions(group, contentType, guid, md.LanguageName);
		}
Пример #2
0
        public static CodeEditorOptions TryCreate(ITextViewOptionsGroup group, IContentTypeRegistryService contentTypeRegistryService, ICodeEditorOptionsDefinitionMetadata md)
        {
            if (group == null)
            {
                throw new ArgumentNullException(nameof(group));
            }
            if (contentTypeRegistryService == null)
            {
                throw new ArgumentNullException(nameof(contentTypeRegistryService));
            }
            if (md == null)
            {
                throw new ArgumentNullException(nameof(md));
            }

            if (md.ContentType == null)
            {
                return(null);
            }
            var contentType = contentTypeRegistryService.GetContentType(md.ContentType);

            if (contentType == null)
            {
                return(null);
            }

            if (md.Guid == null)
            {
                return(null);
            }
            if (!Guid.TryParse(md.Guid, out var guid))
            {
                return(null);
            }

            if (md.LanguageName == null)
            {
                return(null);
            }

            return(new CodeEditorOptions(group, contentType, guid, md.LanguageName));
        }