示例#1
0
 public static void ImportData <T>(Site site, ISiteElementProvider <T> provider, string fileName, Stream zipStream, bool @override)
     where T : ISiteObject, IFilePersistable, IPersistable, IIdentifiable
 {
     using (ZipFile zipFile = ZipFile.Read(zipStream))
     {
         if (zipFile.ContainsEntry(fileName))
         {
             using (MemoryStream ms = new MemoryStream())
             {
                 var entry = zipFile[fileName];
                 entry.Extract(ms);
                 ms.Position = 0;
                 var list = Deserialize <List <T> >(ms, null);
                 foreach (var item in list)
                 {
                     item.Site = site;
                     var o = provider.Get(item);
                     if (o != null && @override)
                     {
                         provider.Update(item, o);
                     }
                     if (o == null)
                     {
                         provider.Add(item);
                     }
                 }
             }
         }
     }
 }
示例#2
0
 public SiteElementProviderBase(ISiteElementProvider <T> inner)
     : base(inner)
 {
     this.innerProvider = inner;
 }