public void GetImplementationOrAbstractionFixture()
        {
            var list = ReflectiveEnumerator.GetInheritedFromAbstractClass <Functionality>();

            FileOperations.AppendLine("testing.log", JsonToFrom.Serialize(list));
            Assert.True(list.Count > 0);
        }
 /// <summary>
 /// Caches the character races
 /// </summary>
 private static void CacheRaces()
 {
     if (_cachedRaces == null || _cachedRaces.Count == 0)
     {
         _cachedRaces = ReflectiveEnumerator.GetEnumerableOfType <RaceBase>().ToList();
     }
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            Console.WriteLine("Hello World!");
            var token = File.ReadAllText(AppContext.BaseDirectory + "token").Trim();

            Handlers = new List <BaseHandler>()
            {
                new ConsoleWriterHandler()
            }
            .Concat(ReflectiveEnumerator.GetListOfType <BaseHandler>().Where(a => !(a is ConsoleWriterHandler)))
            .ToList();
            for (int i = 0; i < Handlers.Count - 1; i++)
            {
                Handlers[i].NextHandler = Handlers[i + 1];
            }
            _client                  = new TelegramBotClient(token);
            _client.OnMessage       += OnMessage;
            _client.OnMessageEdited += OnMessage;
            AppDomain.CurrentDomain.UnhandledException += async(object sender, UnhandledExceptionEventArgs args2) =>
            {
                await _client.SendTextMessageAsync(new ChatId(91740825), $"Unhandled exception!\n{args2.ExceptionObject}\n{(args2.ExceptionObject as Exception).InnerException?.Message}", disableNotification : true);
            };
            _client.StartReceiving(new[] { UpdateType.EditedMessage, UpdateType.Message });
            Console.ReadLine();
        }
        public CommandFactory()
        {
            Commands = new List <Command>();

            // Check to see if plugins folder exists, then try loading
            if (Directory.Exists($"{AppDomain.CurrentDomain.BaseDirectory}plugins"))
            {
                ConsoleHelper.WriteLine("Plugins folder found, attempting to load...");
                var directoryInfo = new DirectoryInfo($"{AppDomain.CurrentDomain.BaseDirectory}plugins");
                int pluginCount   = 0;
                foreach (var plugin in directoryInfo.GetFiles("*.dll"))
                {
                    var DLL = Assembly.LoadFile(plugin.FullName);

                    foreach (Type type in DLL.GetExportedTypes().Where(x => typeof(Command).IsAssignableFrom(x)))
                    {
                        var c = Activator.CreateInstance(type) as Command;
                        Commands.Add(c);
                    }

                    pluginCount++;
                }

                ConsoleHelper.WriteLine($"Added {pluginCount} plugin(s).");
            }

            var commandsEnum = ReflectiveEnumerator.GetEnumerableOfType <Command>();

            foreach (Command c in commandsEnum)
            {
                Commands.Add(c);
            }

            ConsoleHelper.WriteLine($"Added {Commands.Count} command(s).");
        }
 /// <summary>
 /// Caches the languages
 /// </summary>
 private static void CacheLanguages()
 {
     if (_cachedLanguages == null || _cachedLanguages.Count == 0)
     {
         _cachedLanguages = ReflectiveEnumerator.GetEnumerableOfType <Language>().ToList();
     }
 }
Beispiel #6
0
        public async Task MainAsync()
        {
            //idk
            commands = new Dictionary <string, Command>();
            var eee = ReflectiveEnumerator.GetEnumerableOfType <Command>();

            foreach (var command in eee)
            {
                commands.Add(command.commandname, command);
            }
            if (File.Exists(@"test.bin"))
            {
                Stream     stream    = new FileStream(@"test.bin", FileMode.Open, FileAccess.Read);
                IFormatter formatter = new BinaryFormatter();
#pragma warning disable SYSLIB0011                                   // Type or member is obsolete
                db = (DiscordDatabase)formatter.Deserialize(stream); //get f****d ms

#pragma warning restore SYSLIB0011                                   // Type or member is obsolete
            }
            else
            {
                db         = new DiscordDatabase();
                db.Servers = new Dictionary <ulong, DiscordServer>();
            }
            _client                  = new DiscordSocketClient();
            _client.Log             += Log;
            _client.MessageReceived += MessageReceivedAsync;
            String tok = File.ReadAllText("Token.txt");
            await _client.LoginAsync(TokenType.Bot, tok);

            await _client.StartAsync();

            // Block this task until the program is closed.
            await Task.Delay(-1);
        }
        public async Task GetChancesAsync(CommandContext ctx)
        {
            List <WheelOutcome> wheelOutcomes = ReflectiveEnumerator.GetEnumerableOfType <WheelOutcome>(SlaveReportsExtension.Outcome.Task)
                                                .ToList();
            DiscordEmbedBuilder builder = new DiscordEmbedBuilder();

            builder.WithDescription(
                "I've compiled the current List of Chances. First, you'll see a List of Modules (Sabrina.Entities.WheelOutcomes.XXX).\n"
                + "Under the Module Titles for each of these, is a freshly generated example, under that, you'll see the Chance for this to be chosen.\n"
                + "The Bot will add all Chance Values, and then generate a Random Number, to determine which Module will be chosen.\n\n"
                + string.Empty
                + "Under that, you'll see the Chances for what the chosen Module will output at the end.\n"
                + "If the Module does not have a fitting response (Ban can never end in an o****m for example), it will be ignored.");
            foreach (var wheelOutcome in wheelOutcomes)
            {
                builder.AddField(
                    wheelOutcome.ToString(),
                    "``" + wheelOutcome.Text + "``\n" + wheelOutcome.Chance);
            }

            // builder.AddField("Task", OrgasmWheel.TaskChance.ToString(), true);
            // builder.AddField("Denial", OrgasmWheel.DenialChance.ToString(), true);
            // builder.AddField("Ruin", OrgasmWheel.RuinChance.ToString(), true);
            // builder.AddField("O****m", OrgasmWheel.OrgasmChance.ToString(), true);
            await ctx.RespondAsync(embed : builder.Build());
        }
 /// <summary>
 /// Caches the character attributes
 /// </summary>
 private static void CacheAttributes()
 {
     if (_cachedAttributes == null || _cachedAttributes.Count == 0)
     {
         _cachedAttributes = ReflectiveEnumerator.GetEnumerableOfType <AttributeBase>(0).ToList();
     }
 }
Beispiel #9
0
        static AbstractItemAspect()
        {
            var aspects = ReflectiveEnumerator.GetEnumerableOfType <AbstractItemAspect>().ToList();

            foreach (var item in aspects)
            {
                AvailableAspects.Add(item);
            }
        }
 public TaskEditor()
 {
     types     = ReflectiveEnumerator.DerivedTypes <Task>().ToArray();
     typenames = new string[types.Length];
     for (int i = 0; i < types.Length; ++i)
     {
         typenames[i] = types[i].ToString();//.Split('.').Last();
     }
 }
 public static IEnumerable <IArmouryProtocolKB> Find()
 {
     foreach (IArmouryProtocolKB currentKBInstance in ReflectiveEnumerator.GetEnumerableOfType <IArmouryProtocolKB>())
     {
         if (currentKBInstance.DoesExistOnSystem())
         {
             yield return(currentKBInstance);
         }
     }
 }
Beispiel #12
0
 public static void InitMapping()
 {
     Mapper.Initialize(x =>
     {
         foreach (var profile in ReflectiveEnumerator.GetInstanceOfSubclasses <Profile>(true))
         {
             x.AddProfile(profile);
         }
     });
 }
        private void comboBox_paymentScheme_Loaded(object sender, RoutedEventArgs e)
        {
            var paybackSchemeList = ReflectiveEnumerator.GetChildOfType(typeof(PaybackScheme));
            var combo             = sender as ComboBox;

            combo.ItemsSource       = paybackSchemeList;
            combo.DisplayMemberPath = "Name";
            combo.SelectedValuePath = "AssemblyQualifiedName";
            combo.SelectedIndex     = 0;
        }
Beispiel #14
0
        public CommandFactory()
        {
            Commands = new List <Command>();

            var commandsEnum = ReflectiveEnumerator.GetEnumerableOfType <Command>();

            foreach (Command c in commandsEnum)
            {
                Commands.Add(c);
            }
        }
Beispiel #15
0
        public SceneManager(Game gamee)
        {
            this.game = gamee;
            IEnumerable <Scene> test = ReflectiveEnumerator.GetEnumerableOfType <Scene>();

            foreach (Scene testt in test)
            {
                Console.WriteLine(testt.name);
            }
            scenes = test;
        }
Beispiel #16
0
        private async Task <WheelOutcome> GetWheelOutcome(DiscordContext context, Users user, UserSetting.Outcome outcome)
        {
            WheelOutcome wheelOutcome = null;
            var          userItems    = await WheelItemExtension.GetUserItemsAsync(user.UserId, context);

            while (wheelOutcome == null)
            {
                try
                {
                    wheelOutcomes = ReflectiveEnumerator.GetEnumerableOfType <WheelOutcome>(outcome, UserSetting.GetAllSettings(user.UserId, context).ToDictionary(setting => (UserSetting.SettingID)setting.SettingId), userItems, _services)
                                    .ToList();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                foreach (var wheeloutcome in wheelOutcomes)
                {
                    await wheeloutcome.BuildAsync();
                }

                wheelOutcomes = wheelOutcomes.Where(e => !e.Outcome.HasFlag(UserSetting.Outcome.NotSet)).ToList();

                if (wheelOutcomes.Count < 1)
                {
                    continue;
                }

                // Choose an outcome by summing up the chance values of all possible outcomes and
                // then generating a random number inside those.
                var combinedChance = 0;

                foreach (WheelOutcome currentOutcome in wheelOutcomes)
                {
                    combinedChance += currentOutcome.Chance;
                }

                var chance    = 0;
                var minChance = Helpers.RandomGenerator.RandomInt(0, combinedChance);

                foreach (WheelOutcome currentOutcome in wheelOutcomes)
                {
                    chance += currentOutcome.Chance;
                    if (minChance < chance)
                    {
                        wheelOutcome = currentOutcome;
                        break;
                    }
                }
            }

            return(wheelOutcome);
        }
Beispiel #17
0
    public static void Main()
    {
        var sabtReqID = 0;

        var myCase = ReflectiveEnumerator.GetEnumerableOfType <Case>().FirstOrDefault(c => c.Id == sabtReqID);

        if (myCase != null)
        {
            myCase.Todo();
        }
    }
Beispiel #18
0
        public void ShouldReturnAllTypesWithIncjectedServices()
        {
            // arrange
            var provider = new Mock <IServiceProvider>();

            // act
            var steps = ReflectiveEnumerator.GetEnumerableOfType <IPipelineStep>(provider.Object);

            // assert
            Assert.Equal(4, steps.Count());
        }
Beispiel #19
0
        public SceneManager(Game game)
        {
            this._game = game;
            IEnumerable <Scene> scenes = ReflectiveEnumerator.GetEnumerableOfType <Scene>();

            foreach (Scene testt in scenes)
            {
                Console.WriteLine(testt.name);
            }
            this._scenes = scenes;
        }
Beispiel #20
0
    void InitSkills()
    {
        List <Skill> skills = ReflectiveEnumerator.GetEnumerableOfType <Skill>().ToList();

        RefreshSkillList(AllSkills, skills, s =>
        {
            InfoContainer.transform.Find("Name").GetComponent <Text>().text        = "Name: " + s.Name;
            InfoContainer.transform.Find("Target").GetComponent <Text>().text      = "Targets: " + s.Mode;
            InfoContainer.transform.Find("Cooldown").GetComponent <Text>().text    = "Cooldown: " + s.MaxCooldown;
            InfoContainer.transform.Find("Description").GetComponent <Text>().text = "Description: " + s.Description;
        });
    }
Beispiel #21
0
        public static void Initialize()
        {
            var commandClasses = ReflectiveEnumerator.GetInheritedFromInterface <ICommand>();

            foreach (var commandClass in commandClasses)
            {
                var commandAttribute = commandClass.GetType().GetCustomAttributes(typeof(Command), false).FirstOrDefault() as Command;
                if (commandAttribute == null)
                {
                    continue;
                }
                Get.Add(commandAttribute.CommandText, commandClass);
            }
        }
        private static void CatalogAvailableComponents()
        {
            ComponentsByPackage         = new Dictionary <string, List <Type> >();
            ComponentsByQualifiedName   = new Dictionary <string, Type>();
            QualifedNameByComponentType = new Dictionary <Type, string>();

            List <Type> packageList;

            foreach (Type t in ReflectiveEnumerator.GetEnumerableOfType <NoFlo_Basic.Component>())
            {
                string name          = t.GetAttributeValue((ComponentNameAttribute dna) => dna.name);
                string package       = t.GetAttributeValue((ComponentPackageAttribute dna) => dna.name);
                string qualifiedName = package + "/" + name;

                if (name == "")
                {
                    throw new Exception("Component " + t.Name + " does not have valid attribute ComponentName");
                }

                if (package == "")
                {
                    throw new Exception("Component " + t.Name + " does not have valid attribute ComponentPackage");
                }

                if (ComponentsByQualifiedName.ContainsKey(qualifiedName))
                {
                    throw new Exception("TODO");
                }

                ComponentsByQualifiedName.Add(qualifiedName, t);

                if (!ComponentsByPackage.TryGetValue(package, out packageList))
                {
                    packageList = new List <Type>();
                    ComponentsByPackage.Add(package, packageList);
                }

                if (packageList.Contains(t))
                {
                    throw new Exception("TODO");
                }

                packageList.Add(t);

                QualifedNameByComponentType.Add(t, qualifiedName);
            }

            isInitialised = true;
        }
Beispiel #23
0
        private static async Task AsyncMain()
        {
            CancellationTokenSource = new CancellationTokenSource();
            CancellationToken cancellationToken = CancellationTokenSource.Token;

            Console.CancelKeyPress += (x, y) =>
            {
                CancellationTokenSource.Cancel();
            };

            Discord = new DiscordClient(new DiscordConfiguration()
            {
                Token     = BotDetails.Token,
                TokenType = TokenType.Bot
            });

            await Discord.ConnectAsync();

            Logger.Log("Discord Connected");

            await Discord.UpdateStatusAsync(new DiscordGame(BotDetails.CommandPrefix + "doc"));

            foreach (var functionality in ReflectiveEnumerator.GetInheritedFromAbstractClass <Functionality>())
            {
                functionality.Start(Discord);
            }

            CommandConfiguration.Initialize();
            Discord.MessageCreated += async x =>
            {
                if (x.Message.Content.IndexOf(BotDetails.CommandPrefix) == 0)
                {
                    string command = GetFirstWord(x.Message.Content);
                    if (!CommandConfiguration.Get.ContainsKey(command))
                    {
                        return;
                    }
                    string reply = string.Empty;
                    try
                    {
                        reply = await CommandConfiguration.Get[command].ProcessAsync(x.Message);
                    }
                    catch { }
                    Logger.Log($"<Message: {x.Message.Content}>\t<Author: {x.Author.Id}>\t<Name: {x.Author.Username}>\t<Reply: {reply}>");
                    await x.Message.RespondAsync(reply);
                }
            };
            await Task.Delay(-1, cancellationToken);
        }
Beispiel #24
0
    public void preLoadAllCards()
    {
        IEnumerable <Card> allCards = ReflectiveEnumerator.GetEnumerableOfType <Card>();

        foreach (Card card in allCards)
        {
            //card base classes with this class name are not real cards and should be ignored
            if (card.GetType().Name.Contains("Base_"))
            {
                continue;
            }
            //this method will call this class to cash all resources the card requires to function
            card.cacheResorces();
        }
    }
Beispiel #25
0
    void OnEnable()
    {
        List <GameConfiguration> possibleconfig = ReflectiveEnumerator.GetEnumerableOfType <GameConfiguration>();

        confignames = new List <string>();
        foreach (GameConfiguration g in possibleconfig)
        {
            confignames.Add(g.GetType().ToString());
        }
        generateAtRuntime       = serializedObject.FindProperty("generateAtRuntime");
        configurationname       = serializedObject.FindProperty("configurationname");
        themepropertyname       = serializedObject.FindProperty("ThemePropertyName");
        hastheme                = serializedObject.FindProperty("hastheme");
        allowOnlyCompleteThemes = serializedObject.FindProperty("allowOnlyCompleteThemes");
    }
Beispiel #26
0
        public static bool InstanciateAllDerivedTypes()
        {
            //if (IsInitiated) return false;
            //prevent duplicate parser
            //InstanciatedParsers.Clear();
            var list = ReflectiveEnumerator.GetEnumerableOfType <Scraper>();

            InstanciatedScrapers = from scraper
                                   in list
                                   where scraper.Ignore == false
                                   select scraper;

            IsInitiated = true;
            return(true);
        }
        private void Awake()
        {
            List <AbstractImageEffect> image_effects = ReflectiveEnumerator.GetEnumerableOfType <AbstractImageEffect>().ToList();

            for (int i = 0; i < Enum.GetNames(typeof(AbstractImageEffect.ImageEffectEnum)).Length; i++)
            {
                images.Add((AbstractImageEffect.ImageEffectEnum)i, image_effects[i]);
            }

            List <AbstractTextEffect> text_effects = ReflectiveEnumerator.GetEnumerableOfType <AbstractTextEffect>().ToList();

            for (int i = 0; i < Enum.GetNames(typeof(AbstractTextEffect.TextEffectEnum)).Length; i++)
            {
                text.Add((AbstractTextEffect.TextEffectEnum)i, text_effects[i]);
            }
        }
Beispiel #28
0
        public static void ConfigureContainer()
        {
            var container = new ServiceContainer();

            container.RegisterApiControllers();
            container.EnablePerWebRequestScope();
            container.EnableWebApi(GlobalConfiguration.Configuration);

            var mi = ReflectiveEnumerator.GetGenericMethods <ServiceContainer>(nameof(ServiceContainer.Register))
                     .Where(x => x.GetParameters().Length == 0 && x.GetGenericArguments().Length == 1).ToList();

            foreach (var type in ReflectiveEnumerator.GetClassesWithInterface <IDependency>(false))
            {
                mi.First().MakeGenericMethod(type).Invoke(container, null);
            }
        }
Beispiel #29
0
    private void updatePosibleEffectsList()
    {
        IEnumerable <Effect> possibleEffectEnumerable = ReflectiveEnumerator.GetEnumerableOfType <Effect>(new object[0]);
        int possibleEffectsCount = possibleEffectEnumerable.Count();

        possibleEffectsListNames = new string[possibleEffectsCount];
        possibleEffectsList      = new EffectProperties[possibleEffectsCount];

        int index = 0;

        foreach (Effect effect in possibleEffectEnumerable)
        {
            EffectProperties properties = effect.getEffectPropertiesStructure(false);
            possibleEffectsListNames[index] = properties.effectClassName;
            possibleEffectsList[index++]    = properties;
        }
    }
Beispiel #30
0
        public MainForm()
        {
            InitializeComponent();

            var heuristics = ReflectiveEnumerator.GetOfType <Heuristic>();

            foreach (var heuristic in heuristics)
            {
                ComboHeuristic.Items.Add(heuristic);
            }

            ComboHeuristic.SelectedIndex = 0;

            ListNextStep.DataSource = null;
            ListNextStep.DataSource = StepInfo.GetSteps();

            _semaphore = new Semaphore(0, 1, "Steps");
        }