Ejemplo n.º 1
0
 public static void AddModules(ModuleOptions options)
 {
 }
Ejemplo n.º 2
0
        // *******************************************************************

        /// <summary>
        /// This method builds links for embedded style sheets.
        /// </summary>
        /// <param name="asm">The assembly to use for the operation.</param>
        /// <param name="staticResourceNames">The static resources avaiable in the assmbly.</param>
        /// <param name="module">The options for the module.</param>
        private static void BuildStyleSheetLinks(
            Assembly asm,
            string[] staticResourceNames,
            ModuleOptions module
            )
        {
            // Does the module contain stylesheets?
            if (null != module.StyleSheets)
            {
                // Loop through all the style sheets.
                foreach (var resource in module.StyleSheets)
                {
                    // Check for embedded html in the path.
                    if (resource.IsHTML())
                    {
                        // Panic!
                        throw new InvalidOperationException(
                                  message: string.Format(
                                      Resources.ServiceCollectionExtensions_HtmlStyle,
                                      resource
                                      )
                                  );
                    }

                    // Format a link and save it.
                    if (resource.StartsWith('/'))
                    {
                        // Check for the resource in the assembly.
                        if (staticResourceNames.Contains($"{asm.GetName().Name}.wwwroot.{resource[1..]}"))
                        {
                            // Panic!
                            throw new InvalidOperationException(
                                      message: string.Format(
                                          Resources.ServiceCollectionExtensions_ResStyle,
                                          resource,
                                          asm.GetName().Name
                                          )
                                      );
                        }

                        // Add the link.
                        BlazorResources.StyleSheets.Add(
                            $"<link rel=\"stylesheet\" href=\"_content/{asm.GetName().Name}{resource}\" />"
                            );
                    }
                    else
                    {
                        // Check for the resource in the assembly.
                        if (false == staticResourceNames.Contains($"{asm.GetName().Name}.wwwroot.{resource}"))
                        {
                            // Panic!
                            throw new InvalidOperationException(
                                      message: string.Format(
                                          Resources.ServiceCollectionExtensions_ResStyle,
                                          resource,
                                          asm.GetName().Name
                                          )
                                      );
                        }

                        // Add the link.
                        BlazorResources.StyleSheets.Add(
                            $"<link rel=\"stylesheet\" href=\"_content/{asm.GetName().Name}/{resource}\" />"
                            );
                    }
                }
            }
        }