示例#1
0
        public static Dictionary <string, MediaFolder> GetList(Repository repository)
        {
            var container = MediaBlobHelper.InitializeRepositoryContainer(repository);

            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

            var folderBlob = container.GetBlobReference(MediaBlobHelper.MediaDirectoryName);

            Dictionary <string, MediaFolder> folders = null;

            try
            {
                folderBlob.FetchAttributes();
                if (folderBlob.CheckIfMediaFolder())
                {
                    var xml = folderBlob.DownloadText();
                    folders = DataContractSerializationHelper.DeserializeFromXml <Dictionary <string, MediaFolder> >(xml);
                }
            }
            catch { }

            if (folders == null)
            {
                folders = new Dictionary <string, MediaFolder>();
            }
            return(new Dictionary <string, MediaFolder>(folders, StringComparer.OrdinalIgnoreCase));
        }
示例#2
0
文件: PageEntity.cs 项目: Epitomy/CMS
        public static Page ToPage(this IPageEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }
            var dummy = new Page(new Site(entity.SiteName), entity.FullName);

            var page = DataContractSerializationHelper.DeserializeFromXml <Page>(entity.ObjectXml, KnownTypes);

            ((IPersistable)page).Init(dummy);

            return(page);
        }
示例#3
0
        public static Kooboo.CMS.Sites.Models.User ToUser(this SiteUserEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }
            var dummy = new Kooboo.CMS.Sites.Models.User()
            {
                Site = new Site(entity.SiteName), UserName = entity.UserName
            };

            var user = DataContractSerializationHelper.DeserializeFromXml <Kooboo.CMS.Sites.Models.User>(entity.ObjectXml);

            ((IPersistable)user).Init(dummy);

            return(user);
        }
示例#4
0
        public static ABPageTestResult ToABPageTestResult(this IABPageTestResultEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dummy = new ABPageTestResult();

            dummy.UUID = entity.UUID;
            dummy.Site = new Site(entity.SiteName);

            var result = DataContractSerializationHelper.DeserializeFromXml <ABPageTestResult>(entity.ObjectXml, KnownTypes);

            ((IPersistable)result).Init(dummy);

            return(result);
        }
示例#5
0
        public static ABSiteSetting ToABSiteSetting(this IABSiteSettingEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dummy = new ABSiteSetting();

            dummy.UUID     = entity.UUID;
            dummy.MainSite = entity.SiteName;

            var result = DataContractSerializationHelper.DeserializeFromXml <ABSiteSetting>(entity.ObjectXml, KnownTypes);

            ((IPersistable)result).Init(dummy);

            return(result);
        }
示例#6
0
        public static CustomError ToCustomError(this ICustomErrorEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dummy = new CustomError();

            dummy.UUID = entity.UUID;
            dummy.Site = new Site(entity.SiteName);

            var customError = DataContractSerializationHelper.DeserializeFromXml <CustomError>(entity.ObjectXml, KnownTypes);

            ((IPersistable)customError).Init(dummy);

            return(customError);
        }
示例#7
0
        public static Site ToSite(this ISiteSettingEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }
            Site dummy;

            if (String.IsNullOrWhiteSpace(entity.ParentName))
            {
                dummy = new Site(entity.FullName);
            }
            else
            {
                dummy = new Site(new Site(entity.ParentName), entity.FullName);
            }
            var site = DataContractSerializationHelper.DeserializeFromXml <Site>(entity.ObjectXml, KnownTypes);

            ((IPersistable)site).Init(dummy);
            return(site);
        }
示例#8
0
        public static UrlRedirect ToUrlRedirect(this IUrlRedirectEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }
            UrlRedirect dummy;

            if (!String.IsNullOrWhiteSpace(entity.SiteName))
            {
                dummy = new UrlRedirect(new Site(entity.SiteName));
            }
            else
            {
                dummy = new UrlRedirect();
            }
            dummy.UUID = entity.UUID;
            var urlRedirect = DataContractSerializationHelper.DeserializeFromXml <UrlRedirect>(entity.ObjectXml, KnownTypes);

            ((IPersistable)urlRedirect).Init(dummy);
            return(urlRedirect);
        }