コード例 #1
0
 public void PersistentCollectionsShouldBeUniquelyIdentifiedByFileName( )
 {
     using (var first = MakeList <int> ( ))
         using (var second = MakeList <int> ( ))
         {
             Assert.AreSame(first, second);
             Assert.Throws <InvalidCastException> (() => MakeList <string> ( ));
             Assert.Throws <InvalidCastException> (() => PersistentSet <char> .Build(ListFileName));
             Assert.DoesNotThrow(() => MakeSet <string> ( )?.Dispose( ));
             Assert.DoesNotThrow(() => MakeDictionary <string, string> ( )?.Dispose( ));
         }
 }
コード例 #2
0
        public TelegramBotData( )
        {
            Users = PersistentSet <User> .Build(
                Path.Combine(FolderName, "TelegramBotUsers.json"));

            UserRoles = PersistentDictionary <int, UserRole> .Build(
                Path.Combine(FolderName, "TelegramUserRoles.json"));

            PercentChangeSubscriptions =
                PersistentSet <TelegramPercentChangeSubscription> .Build(
                    Path.Combine(FolderName, "TelegramPercentChangeSubscriptions.json"));

            collections = new List <IPersistentCollection>
            {
                Users,
                UserRoles,
                PercentChangeSubscriptions
            };

            foreach (var collection in collections)
            {
                collection.OnError += OnError;
            }
        }
コード例 #3
0
 private static PersistentSet <T> MakeSet <T> ( ) =>
 PersistentSet <T> .Build(SetFileName);