예제 #1
0
 public AuthenticationLib()
 {
     if (_Accounts == null)
     {
         lock (loc)
         {
             if (_Accounts == null)
             {
                 string filePath = HttpContext.Current.Server.MapPath("~/App_Data/accounts.xml");
                 if (!File.Exists(filePath))
                 {
                     _Accounts = new Dictionary <string, UserInfo>();
                 }
                 else
                 {
                     XElement doc = Xtensions.SafeLoad(filePath);
                     _Accounts = doc.Elements("a")
                                 .Select(
                         a => new UserInfo
                     {
                         Name       = a.GetAttributeValue("fname", string.Empty),
                         UserId     = a.GetAttributeValue("name", string.Empty).ToLowerInvariant(),
                         Password   = a.GetAttributeValue("password", string.Empty),
                         CoMembers  = a.GetAttributeValue("coMembers", string.Empty),
                         Address    = a.GetAttributeValue("addr", ""),
                         City       = a.GetAttributeValue("city", ""),
                         State      = a.GetAttributeValue("state", ""),
                         Zip        = a.GetAttributeValue("zip", ""),
                         Phone      = a.GetAttributeValue("phone", ""),
                         Email      = a.GetAttributeValue("email", ""),
                         Occupation = a.GetAttributeValue("job", ""),
                         Paid       = a.GetAttributeValue("paid", "false") == "true",
                         OtherBirds = a.GetAttributeValue("otherbirds", ""),
                         Birds      = a.Element("Birds")
                                      .ToNullHelper()
                                      .Propagate(
                             bs => bs.Elements("bird")
                             .Select(
                                 b => new BirdInfo {
                             Name    = b.GetAttributeValue("name", ""),
                             Species = b.GetAttributeValue("specie", ""),
                             Family  = b.GetAttributeValue("family", ""),
                             XID     = b.GetAttributeValue("xid", "")
                         })
                             .ToList())
                                      .Return(new List <BirdInfo>())
                     })
                                 .Where(
                         a => !string.IsNullOrWhiteSpace(a.UserId))
                                 .Distinct(
                         new GenericEqualityComparer <UserInfo, string>(
                             u => u.UserId))
                                 .ToDictionary(
                         u => u.UserId);
                 }
             }
         }
     }
 }
예제 #2
0
 public SwapandSaleLib()
 {
     if (_Entries == null)
     {
         lock (loc)
         {
             _FilePath = HttpContext.Current.Server.MapPath("~/App_Data/SwaporSales.xml");
             if (_Entries == null)
             {
                 XElement doc = Xtensions.SafeLoad(_FilePath);
                 _Entries = doc.Elements("Entry")
                            .Select(
                     ele => new SwaporSaleEntry(ele))
                            .ToList();
             }
         }
     }
 }