private static void RunRegisterCompositionListener(CompositionCommandInfo info,
                                                           XmlProcessingContext xmlProcessingContext)
        {
            if (!(info is RegisterCompositionListenerInfo registerCompositionListenerInfo))
            {
                throw new ArgumentException("Invalid runner input type: error in static setup.");
            }

            var listener = XmlValueParser.ParseValue(registerCompositionListenerInfo.XElements,
                                                     registerCompositionListenerInfo.XAttributes,
                                                     xmlProcessingContext);

            if (listener == null)
            {
                xmlProcessingContext.ReportError("Provided value is null for registering composition listeners.");
                return;
            }

            if (!(listener is ICompositionListener compositionListener))
            {
                xmlProcessingContext.ReportError(
                    "Registering composition listeners are only allowed for ICompositionListener implementations. Provided type: " +
                    listener.GetType().FullName);
                return;
            }

            xmlProcessingContext.ComponentContext.RegisterCompositionListener(registerCompositionListenerInfo.Name,
                                                                              compositionListener);
        }
        private static Lazy <object> CreateLazyXmlValue(XmlElement[] xElements, XmlAttribute[] xAttributes,
                                                        XmlProcessingContext xmlProcessingContext)
        {
            return(new Lazy <object>(delegate
            {
                object result = XmlValueParser.ParseValue(xElements, xAttributes, xmlProcessingContext);
                xmlProcessingContext.ThrowIfErrors();

                xElements = null;
                xAttributes = null;
                xmlProcessingContext = null;

                return result;
            }));
        }