convertResource method

WebDavStdResource convertResource(
  1. XmlElement? root, {
  2. required Uri path,
  3. required int status,
  4. required Uri? redirect,
})

Implementation

WebDavStdResource convertResource(
  XmlElement? root, {
  required Uri path,
  required int status,
  required Uri? redirect,
}) {
  final WebDavStdResError? error;
  final String? desc;
  final Iterable<WebDavStdResourceProp> props;

  switch ((root?.namespaceUri, root?.localName)) {
    case (kDavNamespaceUrlStr, "response"):
      final resource = parserManger.response?.convert(root!).firstOrNull;
      error = resource?.error;
      desc = resource?.desc;
      props = resource?.props ?? const [];
    case (_, _):
      final resourceTemplate =
          WebDavStdResource(path: path, status: status, redirect: redirect);
      (error, desc, props) = root != null
          ? convertProp(root, resourceTemplate)
          : const (null, null, <WebDavStdResourceProp>[]);
  }

  return WebDavStdResource.fromProps(
      path: path,
      status: status,
      error: error,
      desc: desc,
      redirect: redirect,
      props: props);
}