RichViewEntity GenerateEntity(Entity entity) { RichViewEntity richEntity = new RichViewEntity(); richEntity.Url = entity.Url; richEntity.Type = entity.Type; switch (entity.Type) { case EntityType.String: { FillEntityData(richEntity, entity); richEntity.Text = entity.Data as string; } break; case EntityType.Image: { richEntity.Text = entity.Data as string; richEntity.Image = _imageNotLoaded; LinkResolvedDelegate onLinkResolved = (string result) => { Uri uriResult; bool isUrl = Uri.TryCreate(result, UriKind.Absolute, out uriResult) && (uriResult.Scheme == "http" || uriResult.Scheme == "https"); if (isUrl) { richEntity.Image = RemoteImageCache.Instance.RegisterClient(uriResult, this); } else { richEntity.Image = ContentLoader.Current.Load <Texture2D>(richEntity.Text); _shouldUpdate = true; } }; _linkResolver.ResolveLink(richEntity.Text, onLinkResolved); } break; case EntityType.ListNumber: { richEntity.Type = EntityType.String; FillEntityData(richEntity, entity); richEntity.Text = string.Format("{0}. ", entity.Data); } break; case EntityType.ListBullet: { richEntity.Type = EntityType.String; FillEntityData(richEntity, entity); richEntity.Text = _bulletText; } break; } return(richEntity); }
void ILinkResolver.ResolveLink(string link, LinkResolvedDelegate onResolved) { onResolved(link); }