Exemple #1
0
        public virtual IVgXmlContentFactory GetFactoryInstance()
        {
            if (ContentFactory == null)
            {
                return(null);
            }

            if (!ContentFactory.GetInterfaces().Any(i => i == typeof(IVgXmlContentFactory)))
            {
                throw new InvalidOperationException($"{nameof(ContentFactory)} must be type that implements {nameof(IVgXmlContentFactory)}.");
            }

            var constructor = ContentFactory.GetConstructor(System.Type.EmptyTypes) ??
                              throw new InvalidOperationException($"{nameof(ContentFactory)} must have default constructor.");

            return(constructor.Invoke(new object[] { }) as IVgXmlContentFactory);
        }