internal Asset CreateFromConfiguration()

in src/Foundation/Assets/code/AssetRepository.cs [121:177]


    internal Asset CreateFromConfiguration(XmlNode node)
     {
      var assetTypeString = XmlUtil.GetAttribute("type", node, null);
      var assetFile = XmlUtil.GetAttribute("file", node, null);
      var scriptLocationString = XmlUtil.GetAttribute("location", node, null);
      var innerValue = node.InnerXml;

      if (string.IsNullOrWhiteSpace(assetTypeString))
      {
        Log.Warn($"Invalid asset in GetPageRendering.AddAssets pipeline: {node.OuterXml}", this);
        return null;
      }
      AssetType assetType;
      if (!Enum.TryParse(assetTypeString, true, out assetType))
      {
        Log.Warn($"Invalid asset type in GetPageRendering.AddAssets pipeline: {node.OuterXml}", this);
        return null;
      }

      ScriptLocation? scriptLocation = null;
      if (scriptLocationString != null)
      {
        ScriptLocation location;
        if (!Enum.TryParse(scriptLocationString, true, out location))
        {
          Log.Warn($"Invalid script location in GetPageRendering.AddAssets pipeline: {node.OuterXml}", this);
          return null;
        }
        scriptLocation = location;
      }

      Asset asset = null;
      if (!string.IsNullOrEmpty(assetFile))
      {
        if (scriptLocation.HasValue)
        {
          asset = new Asset(assetType, assetFile, scriptLocation.Value);
        }
        else
        {
          asset = new Asset(assetType, assetFile);
        }
      }
      else if (!string.IsNullOrEmpty(innerValue))
      {
        if (scriptLocation.HasValue)
        {
          asset = new Asset(assetType, null, inline: innerValue, addOnceToken: innerValue.GetHashCode().ToString(), location: scriptLocation.Value);
        }
        else
        {
          asset = new Asset(assetType, null, inline: innerValue, addOnceToken: innerValue.GetHashCode().ToString());
        }
      }

      return asset;
    }