Esempio n. 1
0
        public static dynamic ToJSON(this WidgetPackage pkg, IWidgetDescriptorRepository repository)
        {
            var widget = pkg.Model;
            var Url    = UrlUtility.CreateUrlHelper();
            //var repository = WebSiteContext.Current.DataContext.WidgetDescriptors;
            var installPath = pkg.Category + "\\" + pkg.Name;

            return(new
            {
                id = pkg.Name,
                category = pkg.Category,
                uid = widget.ID,
                name = new
                {
                    shortname = widget.Name != null ? widget.Name.ShortName : "Unknown",
                    fullname = widget.Name != null ? widget.Name.FullName : "Unknown"
                },
                icons = widget.Icons != null ? (widget.Icons.Select(i => new
                {
                    src = Url.Content(pkg.ResolveUri(i.Source)),
                    width = i.Width,
                    height = i.Height
                })) : null,
                desc = GE.GetContent(widget.Description),
                author = widget.Author != null ? new        //The user object is read from remote
                {
                    name = widget.Author.Name,
                    href = widget.Author.Uri,
                    email = widget.Author.Email
                } : null,
                totalUses = repository.InusingWidgetsCount(installPath),
                ratings = 0,       // from remote
                installed = repository.Contains(w => w.UID.Equals(widget.ID, StringComparison.OrdinalIgnoreCase)),
                version = widget.Version,
                languages = pkg.GetSupportLanguages(),
                //signed = pkg.HasSigned,
                //verified = pkg.Verify(),
                licenses = widget.Licenses != null ? (widget.Licenses.Select(l => new
                {
                    name = l.Text,
                    href = l.Source
                })) : null
                           //modified = tmpl.Modified
            });
        }
Esempio n. 2
0
 public static dynamic ToJSON(this WidgetPackage pkg, IWidgetDescriptorRepository repository)
 {
     var widget = pkg.Model;
     var Url = UrlUtility.CreateUrlHelper();
     //var repository = WebSiteContext.Current.DataContext.WidgetDescriptors;
     var installPath = pkg.Category + "\\" + pkg.Name;
     return new
            {
                id = pkg.Name,
                category=pkg.Category,
                uid = widget.ID,
                name = new
                {
                    shortname = widget.Name != null ? widget.Name.ShortName : "Unknown",
                    fullname = widget.Name != null ? widget.Name.FullName : "Unknown"
                },
                icons = widget.Icons != null ? (widget.Icons.Select(i => new
                {
                    src = Url.Content(pkg.ResolveUri(i.Source)),
                    width = i.Width,
                    height = i.Height
                })) : null,
                desc = GE.GetContent(widget.Description),
                author = widget.Author != null ? new //The user object is read from remote
                {
                    name = widget.Author.Name,
                    href = widget.Author.Uri,
                    email = widget.Author.Email
                } : null,
                totalUses = repository.InusingWidgetsCount(installPath),
                ratings = 0,// from remote
                installed = repository.Contains(w => w.UID.Equals(widget.ID, StringComparison.OrdinalIgnoreCase)),
                version = widget.Version,
                languages = pkg.GetSupportLanguages(),
                //signed = pkg.HasSigned,
                //verified = pkg.Verify(),
                licenses = widget.Licenses != null ? (widget.Licenses.Select(l => new
                {
                    name = l.Text,
                    href = l.Source
                })) : null
                //modified = tmpl.Modified
            };
 }