Exemple #1
0
 /// <summary>
 /// Creates an instance of <see cref="PinterestPostDownloader"/>.
 /// </summary>
 public PinterestPostDownloader()
 {
     SettingParser.Add(new Setting <string>(() => Search)
     {
         Description = $"The text to search for. Can be a board, user, or tags. The respective type must be set in {GatheringMethod}.",
     });
     SettingParser.Add(new Setting <PinterestGatheringMethod>(() => GatheringMethod, new[] { "method" })
     {
         Description = $"How to use {Search} to search through Pinterest.",
     });
 }
Exemple #2
0
 /// <summary>
 /// Creates an instance of <see cref="FlickrPostDownloader"/>.
 /// </summary>
 public FlickrPostDownloader()
 {
     SettingParser.Add(new Setting <string>(() => Search)
     {
         Description = "What to search for, can be a username or tags.",
     });
     SettingParser.Add(new Setting <FlickrGatheringMethod>(() => GatheringMethod, new[] { "method" })
     {
         Description = $"How to use {Search} for searching.",
     });
 }
 /// <summary>
 /// Creates an instance of <see cref="FourChanPostDownloader"/>.
 /// </summary>
 public FourChanPostDownloader()
 {
     SettingParser.Add(new Setting <string>(() => Board)
     {
         Description = "The board to download images from.",
     });
     SettingParser.Add(new Setting <int>(() => ThreadId)
     {
         Description = "The id of the thread to download images from. If left default, will download all threads.",
         IsOptional  = true,
     });
 }
Exemple #4
0
        private static void ParsingTest(Action <ISettingParser, TestClass> action)
        {
            var instanceInstance = new TestClass();
            var instanceParser   = new SettingParser
            {
                new Setting <string>(() => instanceInstance.StringValue),
                new Setting <string>(() => instanceInstance.StringValue2),
                new Setting <int>(() => instanceInstance.IntValue),
                new Setting <bool>(() => instanceInstance.BoolValue),
                new Setting <bool>(() => instanceInstance.FlagValue)
                {
                    IsFlag = true,
                },
                new Setting <bool>(() => instanceInstance.FlagValue2)
                {
                    IsFlag = true,
                },
                new Setting <ulong>(() => instanceInstance.UlongValue),
                new Setting <DateTime>(() => instanceInstance.DateTimeValue, parser: DateTime.TryParse),
                new CollectionSetting <string>(() => instanceInstance.CollectionStrings),
            };
            var instanceSettings = ((ISettingParser)instanceParser).GetSettings();

            Assert.AreEqual(instanceParser.Count, instanceSettings.Count);
            action(instanceParser, instanceInstance);

            var staticInstance = new TestClass();
            var staticParser   = new StaticSettingParser <TestClass>
            {
                new StaticSetting <TestClass, string>(x => x.StringValue),
                new StaticSetting <TestClass, string>(x => x.StringValue2),
                new StaticSetting <TestClass, int>(x => x.IntValue),
                new StaticSetting <TestClass, bool>(x => x.BoolValue),
                new StaticSetting <TestClass, bool>(x => x.FlagValue)
                {
                    IsFlag = true,
                },
                new StaticSetting <TestClass, bool>(x => x.FlagValue2)
                {
                    IsFlag = true,
                },
                new StaticSetting <TestClass, ulong>(x => x.UlongValue),
                new StaticSetting <TestClass, DateTime>(x => x.DateTimeValue, parser: DateTime.TryParse),
                new StaticCollectionSetting <TestClass, string>(x => x.CollectionStrings),
            };
            var staticSettings = ((ISettingParser)staticParser).GetSettings();

            Assert.AreEqual(staticParser.Count, staticSettings.Count);
            action(staticParser, staticInstance);
        }
Exemple #5
0
        public void InterfaceAndImplementation_Test()
        {
            var instanceInstance = new TestClass();
            var instanceParser   = new SettingParser
            {
                new Setting <string>(() => instanceInstance.StringValue),
            };

            var requiredAmt1 = instanceParser.GetNeededSettings().Count;

            Assert.AreEqual(1, requiredAmt1);
            var requiredAmt2 = ((ISettingParser)instanceParser).GetNeededSettings(null).Count;

            Assert.AreEqual(1, requiredAmt2);
        }
 /// <summary>
 /// Creates an instance of <see cref="PixivPostDownloader"/>.
 /// </summary>
 public PixivPostDownloader()
 {
     SettingParser.Add(new Setting <string>(() => LoginUsername)
     {
         Description = "The username to login with. This is what you use to login to Pixiv regularly.",
     });
     SettingParser.Add(new Setting <string>(() => LoginPassword)
     {
         Description = "The password to login with. This is what you use to login to Pixiv regularly.",
     });
     SettingParser.Add(new Setting <ulong>(() => UserId, new[] { "id" })
     {
         Description = "The id of the user to search for.",
     });
 }
 /// <summary>
 /// Creates an instance of <see cref="TwitterPostDownloader"/>.
 /// </summary>
 public TwitterPostDownloader()
 {
     SettingParser.Add(new Setting <string>(() => Search)
     {
         Description = "The term to search for. Can be a username if the method username is used, otherwise will be searched for regualarly.",
     });
     SettingParser.Add(new Setting <bool>(() => IncludeRetweets, new[] { "retweets" })
     {
         Description = "Whether or not to include retweets when getting tweets from a user. This does nothing if searching is used instead.",
         IsFlag      = true,
         IsOptional  = true,
     });
     SettingParser.Add(new Setting <TwitterGatheringMethod>(() => GatheringMethod, new[] { "method" })
     {
         Description = "How to gather posts. Will either use the search feature or go through the user's posts.",
     });
 }
Exemple #8
0
    public void Parse()
    {
        parser = new SettingParser(fileName);
        parser.Parse();
        var enumerator = parser.rows.GetEnumerator();

        while (enumerator.MoveNext())
        {
            TableRow  row     = enumerator.Current.Value;
            UISetting setting = new UISetting(row);
            if (pool.ContainsKey(row.primaryKey))
            {
                CDebug.LogError("settings is contains key " + row.primaryKey);
                continue;
            }
            pool.Add(row.primaryKey, setting);
            data.Add(setting);
        }
    }
 /// <summary>
 /// Creates an image downloader for DeviantArt.
 /// </summary>
 public DeviantArtPostDownloader()
 {
     SettingParser.Add(new Setting <string>(() => ClientId, new[] { "id" })
     {
         Description = $"The id of the client to get authentication from. For additional help, visit {API}.",
         IsOptional  = true,
     });
     SettingParser.Add(new Setting <string>(() => ClientSecret, new[] { "secret" })
     {
         Description = $"The secret of the client to get authentication from. For additional help, visit {API}.",
         IsOptional  = true,
     });
     SettingParser.Add(new Setting <string>(() => Tags)
     {
         Description = $"The tags to search for. For additional help, visit {SEARCH}.",
     });
     SettingParser.Add(new Setting <DeviantArtGatheringMethod>(() => GatheringMethod, new[] { "method" })
     {
         Description = $"How to gather posts. Api requies {nameof(ClientId)} and {nameof(ClientSecret)} to be set.",
     });
 }
 /// <summary>
 /// Creates an instance of <see cref="PawooPostDownloader"/>.
 /// </summary>
 public PawooPostDownloader()
 {
     //Make sure the username always has an @ in front of it
     SettingParser.Add(new Setting <string>(() => Username, new[] { "user" }, parser: TryParseId)
     {
         Description = "The user to search for. Will end up with an @ in front of it if one is not supplied.",
     });
     SettingParser.Add(new Setting <bool>(() => IncludeReplies, new[] { "replies" })
     {
         Description = "Whether to search through replies in addition to regular posts.",
         IsFlag      = true,
         IsOptional  = true,
     });
     SettingParser.Add(new Setting <string>(() => LoginUsername)
     {
         Description = "The username to login with. This is what you use to login to Pawoo regularly.",
     });
     SettingParser.Add(new Setting <string>(() => LoginPassword)
     {
         Description = "The password to login with. This is what you use to login to Pawoo regularly.",
     });
 }
 /// <summary>
 /// Returns true if there are 0 needed settings.
 /// </summary>
 /// <param name="parser"></param>
 /// <returns></returns>
 public static bool AreAllSet(this SettingParser parser)
 => parser.GetNeededSettings().Count == 0;