Ejemplo n.º 1
0
 public override void ProcessMessage(JObject data, IAssemblyLoadContext assemblyLoadContext)
 {
     _messageBroker.SendMessage(assemblyLoadContext);
 }
Ejemplo n.º 2
0
 public void ProcessMessage(JObject data, IAssemblyLoadContext assemblyLoadContext)
 {
     _messageBroker.SendMessage(data["Data"].ToString() + "!");
 }
Ejemplo n.º 3
0
            public bool ProcessMessage(JObject data, IAssemblyLoadContext assemblyLoadContext)
            {
                _messageBroker.SendMessage(data["Data"].ToString() + "!");

                return(true);
            }
Ejemplo n.º 4
0
            public override bool ProcessMessage(JObject data, IAssemblyLoadContext assemblyLoadContext)
            {
                _messageBroker.SendMessage(assemblyLoadContext);

                return(true);
            }
Ejemplo n.º 5
0
        public bool ProcessMessage(JObject data, IAssemblyLoadContext assemblyLoadContext)
        {
            var message = data.ToObject <RazorPluginRequestMessage>();

            if (message.MessageType == null)
            {
                throw new InvalidOperationException(
                          Resources.FormatValueMustBeProvidedInMessage(
                              nameof(message.MessageType),
                              nameof(RazorPluginRequestMessage)));
            }

            switch (message.MessageType)
            {
            case RazorPluginMessageTypes.ResolveTagHelperDescriptors:
                if (message.Data == null)
                {
                    throw new InvalidOperationException(
                              Resources.FormatValueMustBeProvidedInMessage(
                                  nameof(message.Data),
                                  RazorPluginMessageTypes.ResolveTagHelperDescriptors));
                }

                var messageData = message.Data.ToObject <ResolveTagHelperDescriptorsRequestData>();

                if (messageData.AssemblyName == null)
                {
                    throw new InvalidOperationException(
                              Resources.FormatValueMustBeProvidedInMessage(
                                  nameof(messageData.AssemblyName),
                                  RazorPluginMessageTypes.ResolveTagHelperDescriptors));
                }
                else if (messageData.SourceLocation == SourceLocation.Undefined)
                {
                    throw new InvalidOperationException(
                              Resources.FormatValueMustBeProvidedInMessage(
                                  nameof(messageData.SourceLocation),
                                  RazorPluginMessageTypes.ResolveTagHelperDescriptors));
                }

                var assemblyName          = messageData.AssemblyName;
                var errorSink             = new ErrorSink();
                var tagHelperTypeResolver = new AssemblyLoadContextTagHelperTypeResolver(assemblyLoadContext);
                var tagHelperTypes        = tagHelperTypeResolver.Resolve(
                    assemblyName,
                    messageData.SourceLocation,
                    errorSink);
                var tagHelperDescriptors = tagHelperTypes.SelectMany(
                    type => TagHelperDescriptorFactory.CreateDescriptors(
                        assemblyName,
                        type,
                        designTime: true,
                        errorSink: errorSink));

                var responseMessage = new ResolveTagHelperDescriptorsMessage(
                    new ResolveTagHelperDescriptorsResponseData
                {
                    AssemblyName = assemblyName,
                    Descriptors  = tagHelperDescriptors,
                    Errors       = errorSink.Errors
                });

                _messageBroker.SendMessage(responseMessage);
                break;

            default:
                // Unknown message.
                return(false);
            }

            return(true);
        }