Example #1
0
        public static void Configure(string[] args)
        {
            Ports            = args.FirstOrDefault(a => a.StartsWith("-ports="))?.Substring("-ports=".Length);
            Password         = args.FirstOrDefault(a => a.StartsWith("-password="******"-password="******"-sudopwd="))?.Substring("-sudopwd=".Length);
            Upgrade          = args.Any(a => a == "-upgrade");
            Manual           = args.Any(a => a == "-manual") && !Upgrade;
            NoSudo           = args.Any(a => a == "-nosudo") || Upgrade;
            Home             = args.FirstOrDefault(a => a.StartsWith("-home="))?.Substring("-home=".Length) ?? Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            TerminalTemplate = args.FirstOrDefault(a => a.StartsWith("-termtempl="))?.Substring("-termtempl=".Length);
            switch (TerminalTemplate)
            {
            case "gnome": TerminalTemplate = "gnome-terminal -e {0}"; break;

            case "xfce4": TerminalTemplate = "xfce4-terminal -e {0}"; break;

            case "kde": TerminalTemplate = "kde-terminal -e {0}"; break;

            default: break;
            }
            if (Manual)
            {
                Setup = Setups.Manual;
            }
        }
Example #2
0
        public Runmode(ILoggerFactory loggerFactory, BaseConfig baseConfig, Func <RunmodeConfig> configLoader)
        {
            RunmodeConfig runmodeConfig = configLoader();

            _logger    = loggerFactory.CreateLogger <Runmode>();
            _stopToken = new StopToken();
            Setups.Databases repos = Setups.SetUpRepositories(_logger, baseConfig);
            (_broadcastServer, _overlayConnection) = Setups.SetUpOverlayServer(loggerFactory);
            _modeBase = new ModeBase(loggerFactory, repos, baseConfig, _stopToken, _overlayConnection, ProcessMessage);
            _modeBase.InstallAdditionalCommand(new Command("reloadinputconfig", _ =>
            {
                ReloadConfig(configLoader().InputConfig);
                return(Task.FromResult(new CommandResult {
                    Response = "input config reloaded"
                }));
            }));

            // TODO felk: this feels a bit messy the way it is done right now,
            //            but I am unsure yet how I'd integrate the individual parts in a cleaner way.
            InputConfig inputConfig = runmodeConfig.InputConfig;

            _inputParser      = inputConfig.ButtonsProfile.ToInputParser();
            _inputBufferQueue = new InputBufferQueue <QueuedInput>(CreateBufferConfig(inputConfig));
            _anarchyInputFeed = CreateInputFeedFromConfig(inputConfig);
            _inputServer      = new InputServer(loggerFactory.CreateLogger <InputServer>(),
                                                runmodeConfig.InputServerHost, runmodeConfig.InputServerPort,
                                                _anarchyInputFeed);
        }
Example #3
0
        public static void Install()
        {
            if (OS.Runtime.IsWindows)
            {
                Window.OpenDialog("Cannot install server on Windows.");
            }
            else
            {
                Sudo(SudoPassword);

                if (Password == null && Ports == null)
                {
                    var win = Window.OpenDialog(@"MonoDebugger Setup
=======================




|    Server Password:         <*Password>                           </*Password>
|    (Blank for no password) 

|    Server Ports:            <Ports>                           </Ports>

|    (You must specify three comma separated ports,
|    or leave blank for default.)



<!Service>[  Start as Service  ]</!Service>      <&Manual>[  Start manually  ]</&Manual>      <~Cancel>[  Cancel  ]</~Cancel> 
", new { Password = "", Ports = "" });
                    Ports    = win.Ports.Value;
                    Password = win.Password.Value;
                    if (win.Service.Selected)
                    {
                        Setup = Setups.Service;
                    }
                    else if (win.Manual.Selected)
                    {
                        Setup = Setups.Manual;
                    }
                    else
                    {
                        Setup = Setups.Cancel;
                    }
                }
                if (Setup == Setups.Cancel)
                {
                    return;
                }
                InstallSelf();
                InstallScript();
                if (Setup == Setups.Service)
                {
                    InstallSession();
                }
                Help();
            }
            UI.Clear();
        }
Example #4
0
        public DualcoreMode(ILoggerFactory loggerFactory, BaseConfig baseConfig)
        {
            _logger    = loggerFactory.CreateLogger <DualcoreMode>();
            _stopToken = new StopToken();
            Setups.Databases  repos = Setups.SetUpRepositories(_logger, baseConfig);
            OverlayConnection overlayConnection;

            (_broadcastServer, overlayConnection) = Setups.SetUpOverlayServer(loggerFactory);
            _modeBase = new ModeBase(loggerFactory, repos, baseConfig, _stopToken, overlayConnection);
        }
Example #5
0
        private ScreenshotFileInfoDto GenerateFileInfo(Setup setup)
        {
            int setupNum = Setups.IndexOf(setup);

            if (setupNum < 0)
            {
                throw new InvalidOperationException();
            }
            var dto = new ScreenshotFileInfoDto(
                @"Setup\",
                CutForFileName(string.Format("{0}-{1}", (setupNum + 1).ToString("D2"), setup.Text)));

            return(dto);
        }
        private async Task CheckNewThread(SocketMessage arg)
        {
            if (arg.Author.IsBot)
            {
                return;
            }
            if (arg.Channel.GetType() == typeof(SocketDMChannel))
            {
                if (BlockedUsers.Any(x => x == arg.Author.Id))
                {
                    return;
                }
                if (CurrentTickets.Any(x => x.DMChannelID == arg.Channel.Id))
                {
                    var ticket = CurrentTickets.Find(x => x.DMChannelID == arg.Channel.Id);
                    ticket.DMTyping.Typing = false;
                    if (ticket.DMTyping.TypingObject != null)
                    {
                        ticket.DMTyping.TypingObject.Dispose();
                    }
                    string msg    = $"**[Ticketer] {arg.Author}** - {arg.Content}";
                    var    tkchan = client.GetGuild(Global.SwissGuildId).GetTextChannel(ticket.TicketChannel);
                    await tkchan.SendMessageAsync(msg);

                    if (arg.Attachments.Count > 0)
                    {
                        foreach (var attc in arg.Attachments)
                        {
                            var bt = new WebClient().DownloadData(new Uri(attc.ProxyUrl));
                            File.WriteAllBytes(Environment.CurrentDirectory + $"{Path.DirectorySeparatorChar}{attc.Filename}", bt);
                            await tkchan.SendFileAsync(Environment.CurrentDirectory + $"{Path.DirectorySeparatorChar}{attc.Filename}", $"**[Ticketer]**");
                        }
                    }
                }
                else if (!Setups.ContainsKey(arg.Author.Id))
                {
                    var msg = await arg.Channel.SendMessageAsync("Hello " + arg.Author.Mention + ", if you want to open a support ticket please click the checkmark, otherwise to delete this message click the X");

                    await msg.AddReactionsAsync(new IEmote[] { new Emoji("✅"), new Emoji("❌") });

                    Setups.Add(arg.Channel.Id, new KeyValuePair <ulong, string>(msg.Id, arg.Content));
                }
            }
            else if (CurrentTickets.Any(x => x.TicketChannel == arg.Channel.Id))
            {
                //check snippets
                await SnippetHandler(arg);
            }
        }
Example #7
0
 public Matchmode(ILoggerFactory loggerFactory, BaseConfig baseConfig, MatchmodeConfig matchmodeConfig)
 {
     _matchmodeConfig = matchmodeConfig;
     _loggerFactory = loggerFactory;
     _logger = loggerFactory.CreateLogger<Matchmode>();
     _stopToken = new StopToken();
     Setups.Databases repos = Setups.SetUpRepositories(_logger, baseConfig);
     _pokeyenBank = repos.PokeyenBank;
     _userRepo = repos.UserRepo;
     (_broadcastServer, _overlayConnection) = Setups.SetUpOverlayServer(loggerFactory);
     _modeBase = new ModeBase(loggerFactory, repos, baseConfig, _stopToken, _overlayConnection);
     var bettingCommands = new BettingCommands(() => _bettingPeriod);
     foreach (Command command in bettingCommands.Commands)
         _modeBase.InstallAdditionalCommand(command);
 }
        public void RegisterSetup <TData>(Func <ISetupContext, TData> action)
            where TData : class
        {
            var dataType = typeof(TData);

            if (_dataTypes.Contains(dataType))
            {
                var message = $"More than one setup action have been registered that accepts data of type '{dataType.FullName}'.";
                throw new CakeException(message);
            }

            _dataTypes.Add(dataType);
            Setups.Add(context =>
            {
                _data.Add(action(context));
            });
        }
        private async Task CheckNewThread(SocketMessage arg)
        {
            if (arg.Author.IsBot)
            {
                return;
            }
            if (arg.Channel.GetType() == typeof(SocketDMChannel))
            {
                if (BlockedUsers.Any(x => x == arg.Author.Id))
                {
                    return;
                }
                if (CurrentTickets.Any(x => x.DMChannelID == arg.Channel.Id))
                {
                    var ticket = CurrentTickets.Find(x => x.DMChannelID == arg.Channel.Id);
                    ticket.DmTyping.Typing = false;
                    if (ticket.DmTyping.TypingObject != null)
                    {
                        ticket.DmTyping.TypingObject.Dispose();
                    }
                    string msg = $"**[Ticketer] {arg.Author}** - {arg.Content}";
                    if (arg.Attachments.Count > 0)
                    {
                        foreach (var attc in arg.Attachments)
                        {
                            msg += $"\n**Attachment** - {attc.Url}";
                        }
                    }
                    await client.GetGuild(Global.SwissGuildId).GetTextChannel(ticket.TicketChannel).SendMessageAsync(msg);
                }
                else if (!Setups.ContainsKey(arg.Author.Id))
                {
                    var msg = await arg.Channel.SendMessageAsync("Hello " + arg.Author.Mention + ", if you want to open a support ticket please click the checkmark, otherwise to delete this message click the X");

                    await msg.AddReactionsAsync(new IEmote[] { new Emoji("✅"), new Emoji("❌") });

                    Setups.Add(arg.Channel.Id, new KeyValuePair <ulong, string>(msg.Id, arg.Content));
                }
            }
            else if (CurrentTickets.Any(x => x.TicketChannel == arg.Channel.Id))
            {
                //check snippets
                await SnippetHandler(arg);
            }
        }
Example #10
0
        protected override string Execute(EnterArgs args)
        {
            var setupName = args.SetupName.ToLower();

            var setup = Setups.GetSetupByName(args.SetupName);

            if (setup == null)
            {
                return("we didn't have this setup...");
            }
            else
            {
                //set current setup
                this.CommandManager.CurrentSetup = setup;

                return(setup.SetupOutputDetails);
            }
        }
Example #11
0
        public ModeBase(ILoggerFactory loggerFactory, BaseConfig baseConfig, StopToken stopToken)
        {
            PokedexData pokedexData = PokedexData.Load();

            Setups.Databases repos      = Setups.SetUpRepositories(baseConfig);
            ArgsParser       argsParser = Setups.SetUpArgsParser(repos.UserRepo, pokedexData);

            var chats       = new Dictionary <string, IChat>();
            var chatFactory = new ChatFactory(loggerFactory, SystemClock.Instance, repos.UserRepo);

            foreach (ConnectionConfig connectorConfig in baseConfig.Chat.Connections)
            {
                IChat chat = chatFactory.Create(connectorConfig);
                if (chats.ContainsKey(chat.Name))
                {
                    throw new ArgumentException($"chat name '{chat.Name}' was used multiple times. It must be unique.");
                }
                chats[chat.Name] = chat;
            }
            _chats = chats.ToImmutableDictionary();
            foreach (IChat chat in _chats.Values)
            {
                chat.IncomingMessage += MessageReceived;
            }
            _commandResponders = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => (ICommandResponder) new CommandResponder(c));
            _commandProcessors = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => Setups.SetUpCommandProcessor(loggerFactory, argsParser, repos, stopToken, baseConfig.Chat, c, c, pokedexData.KnownSpecies));

            _messagequeueRepo           = repos.MessagequeueRepo;
            _messagelogRepo             = repos.MessagelogRepo;
            _forwardUnprocessedMessages = baseConfig.Chat.ForwardUnprocessedMessages;
            _clock = SystemClock.Instance;
        }
Example #12
0
    private void Start()
    {
        if (transperantMat == null)
        {
            this.transperantMat   = Resources.Load("Materials/transperantMat", typeof(Material)) as Material;
            this.inputPanelPrefab = Resources.Load("Prefabs/WorldSpaceCanvases/ConstantCanvasPrefab", typeof(GameObject)) as GameObject;
            this.resultAndVariablesPanelPrefab = Resources.Load("Prefabs/WorldSpaceCanvases/ResultCanvasPrefab", typeof(GameObject)) as GameObject;
            this.worldSpaceTextPrefab          = Resources.Load("Prefabs/WorldSpaceCanvases/WorldSpaceTextPrefab", typeof(GameObject)) as GameObject;
        }

        this.spellcraftParent = new GameObject("Spellcraft Parent");
        this.persistantParent = new GameObject("Persistant Parent");

        this.connTracker = new ConnectionsTracker(this);

        //Rotation of class nodes implementation that wull be replaced
        this.rotatorGO = new GameObject("Rotator");
        this.rotatorGO.transform.SetParent(this.spellcraftParent.transform);
        //...

        //Parented
        this.drawer = new LineDrawer(this);
        this.drawer.DrawBox(SpellcraftConstants.HalfSize, SpellcraftConstants.Thickness, SpellcraftConstants.BoxCenter);
        this.myCamera          = GameObject.Find("Camera").GetComponent <Camera>();
        this.camHandling       = this.myCamera.gameObject.AddComponent <SpellcraftCam>();
        this.myCamera2         = GameObject.Find("Camera2").GetComponent <Camera>();
        this.camHandling2      = this.myCamera2.gameObject.AddComponent <SpellMenuDragCam>();
        this.myCamera2.enabled = false;

        this.procUI = this.GetComponent <SpellcraftProcUI>();
        this.procUI.Setup(this.myCamera2, this.connTracker, 0.035f);

        // Procedural SpellCraftUI
        float YY = 1000;

        this.procUI.SetCanvasPosition(new Vector3(0, YY, -1000));
        this.procUIAnchor = new GameObject("ProcUIAnchor");
        this.procUIAnchor.transform.position = new Vector3(0, YY, -2000);

        GameObject center = new GameObject("Center");

        center.transform.SetParent(this.spellcraftParent.transform);
        this.camHandling.Setup(center);
        this.classVisualisation = new ClassVisualisation(this);
        this.resultCanvas       = new ResultCanvas(this.resultAndVariablesPanelPrefab, this.myCamera, this.connTracker, this.persistantParent.transform);
        this.resultCanvas.SetPosition(new Vector3(0, 0, -25));
        this.resultCanvas.SetScale(new Vector3(0.02f, 0.02f, 0.02f));
        this.resultCanvas.Hide();
        this.inputCanvas = new InputCanvas(this.myCamera, this.inputPanelPrefab, this.persistantParent.transform);

        //Extract that somewhere
        this.resultGO      = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        this.resultGO.name = "Result GO";
        this.resultGO.transform.SetParent(this.persistantParent.transform);
        this.resultGO.transform.position = new Vector3(0, -15, 0);
        this.resultNode = this.resultGO.AddComponent <ResultNode>();
        //...

        this.connRegisterer           = new ConnectionsRegisterer(this.connTracker, this.inputCanvas, this.drawer, this.resultNode);
        this.infoCanvas               = new InfoCanvas(this.worldSpaceTextPrefab, this.myCamera, this.spellcraftParent.transform);
        this.levels                   = new Setups(this.resultCanvas, this.inputCanvas, this.connRegisterer, this, this.resultNode, this.classVisualisation);
        this.resultCanvasVantigePoint = new GameObject("VantigePoint");
        this.resultCanvasVantigePoint.transform.position = new Vector3(0, 0, -30);
        this.resultCanvasVantigePoint.transform.SetParent(this.spellcraftParent.transform);

        this.dynamicSetup = new DynamicSetup(this.classVisualisation, this, this.resultCanvas, this.inputCanvas);

        //this.levels.JustTwoAddMethod(true);
        if (LoadLevel)
        {
            this.levels.LineDestroyer(false);
        }
        else
        {
            this.connTracker.RegisterBundle(null);
        }

        this.spellcraftParent.transform.position = this.position;
        this.persistantParent.transform.position = this.position;
    }
 public void RegisterSetup(Action <ISetupContext> action)
 {
     Setups.Add(action);
 }
Example #14
0
        public ModeBase(
            ILoggerFactory loggerFactory,
            Setups.Databases repos,
            BaseConfig baseConfig,
            StopToken stopToken,
            OverlayConnection overlayConnection,
            ProcessMessage?processMessage = null)
        {
            IClock clock = SystemClock.Instance;

            _logger = loggerFactory.CreateLogger <ModeBase>();
            PokedexData pokedexData = PokedexData.Load();
            ArgsParser  argsParser  = Setups.SetUpArgsParser(repos.UserRepo, pokedexData);

            _processMessage = processMessage ?? (_ => Task.FromResult(false));

            var chats       = new Dictionary <string, IChat>();
            var chatFactory = new ChatFactory(loggerFactory, clock,
                                              repos.UserRepo, repos.TokensBank, repos.SubscriptionLogRepo, repos.LinkedAccountRepo,
                                              overlayConnection);

            foreach (ConnectionConfig connectorConfig in baseConfig.Chat.Connections)
            {
                IChat chat = chatFactory.Create(connectorConfig);
                if (chats.ContainsKey(chat.Name))
                {
                    throw new ArgumentException($"chat name '{chat.Name}' was used multiple times. It must be unique.");
                }
                chats[chat.Name] = chat;
            }
            _chats = chats.ToImmutableDictionary();
            foreach (IChat chat in _chats.Values)
            {
                chat.IncomingMessage += MessageReceived;
            }
            _commandResponders = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => (ICommandResponder) new CommandResponder(c));
            _commandProcessors = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => Setups.SetUpCommandProcessor(loggerFactory, argsParser, repos, stopToken, c, c,
                                                  pokedexData.KnownSpecies));

            _messagequeueRepo           = repos.MessagequeueRepo;
            _messagelogRepo             = repos.MessagelogRepo;
            _forwardUnprocessedMessages = baseConfig.Chat.ForwardUnprocessedMessages;
            _clock = SystemClock.Instance;

            ILogger <Moderator> moderatorLogger = loggerFactory.CreateLogger <Moderator>();

            IImmutableList <IModerationRule> availableRules = ImmutableList.Create <IModerationRule>(
                new BannedUrlsRule(),
                new SpambotRule(),
                new EmoteRule(),
                new CopypastaRule(clock),
                new UnicodeCharacterCategoryRule()
                );

            foreach (string unknown in baseConfig.DisabledModbotRules.Except(availableRules.Select(rule => rule.Id)))
            {
                moderatorLogger.LogWarning("unknown modbot rule '{UnknownRule}' marked as disabled", unknown);
            }
            IImmutableList <IModerationRule> rules = availableRules
                                                     .Where(rule => !baseConfig.DisabledModbotRules.Contains(rule.Id))
                                                     .ToImmutableList();

            _moderators = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => (IModerator) new Moderator(moderatorLogger, c, rules, repos.ModLogRepo, clock));
        }
 public void AddSetup(CallChain chain)
 {
     Setups.Add(chain);
 }
Example #16
0
 public AbilitySetupEntry Ability(AbilityEntry entry)
 {
     return(Setups.GetOrAdd(entry, new AbilitySetupEntry(entry)));
 }
Example #17
0
        private async Task CheckInitThread(Cacheable<IUserMessage, ulong> arg1, ISocketMessageChannel arg2, SocketReaction arg3)
        {
            var usr = await arg2.GetUserAsync(arg3.UserId);
            if (usr.IsBot)
                return;

            if (Setups.ContainsKey(arg2.Id))
            {
                var msg = await arg2.GetMessageAsync(Setups[arg2.Id].Key);

                //checkmark
                if (arg3.Emote.Equals(new Emoji("✅")))
                {
                    if (client.GetGuild(Global.SwissGuildId).Users.Any(x => x.Id == usr.Id))
                    {
                        if (BlockedUsers.Any(x => x == usr.Id))
                        {
                            await arg2.SendMessageAsync("", false, new EmbedBuilder()
                            {
                                Title = "You are blocked!",
                                Description = "Looks like your blocked from creating support tickets :/",
                                Color = Color.Red
                            }.Build());
                            Setups.Remove(arg2.Id);
                            await msg.DeleteAsync();
                            return;
                        }
                        else
                        {
                            await msg.DeleteAsync();
                            var tmpmsg = await arg2.SendMessageAsync("**Creating support ticket with the staff team...**");
                            await CreateNewTicket(arg2, usr, Setups[arg2.Id].Value);
                            await tmpmsg.ModifyAsync(x => x.Embed = new EmbedBuilder()
                            {
                                Title = "Congrats! You are now talking with staff!",
                                Description = "Please note staff **Can** take moderation action for anything you say in a ticket. The same rules apply as the server.\n_This ticket may also be archived and used for training purposes._",
                                Color = Color.Green
                            }.Build());
                        }
                    }
                    else
                    {
                        await usr.SendMessageAsync("", false, new EmbedBuilder()
                        {
                            Title = "Sorry... :(",
                            Description = "The staff team does not accept tickets from users who are not in the server.",
                            Color = Color.Red
                        }.Build());
                    }

                }
                else if (arg3.Emote.Equals(new Emoji("❌"))) // xmark
                {
                    Setups.Remove(arg2.Id);
                    await msg.DeleteAsync();
                }
            }
            else if (closingState.Keys.Any(x => x.Key == arg2.Id))
            {
                var o = closingState.First(x => x.Key.Key == arg2.Id);
                var msg = await arg2.GetMessageAsync(o.Key.Value);

                if (arg3.Emote.Equals(new Emoji("❌")))
                {
                    o.Value.Stop();
                    o.Value.Dispose();
                    closingState.Remove(o.Key);
                    await msg.DeleteAsync();
                }
            }
            else if (WelcomeMessages.Contains(arg3.MessageId))
            {
                if (arg3.Emote.Equals(new Emoji("❌")))
                {
                    var msg = await arg2.GetMessageAsync(arg3.MessageId);
                    await msg.DeleteAsync();
                }
                if (arg3.Emote.Equals(new Emoji("✅")))
                {
                    var ticket = CurrentTickets.Find(x => x.TicketChannel == arg2.Id);
                    var msg = await arg2.GetMessageAsync(arg3.MessageId);
                    var dmchan = await client.GetUser(ticket.UserID).GetOrCreateDMChannelAsync();
                    var gusr = usr as SocketGuildUser;
                    await msg.DeleteAsync();
                    string tmsg = $"**[Staff] {(gusr.Nickname == null ? usr.ToString() : gusr.Nickname)}** - Hello! Swiss001 Support! How May I help you?";
                    await arg2.SendMessageAsync(tmsg);
                    await dmchan.SendMessageAsync(tmsg);
                }
            }
        }
Example #18
0
        public void ApplySetupReturns <T, TReturn>(Expression <Func <T, TReturn> > expression, TReturn returnValue)
        {
            // we already know we're not null here. courtesy of the caller.
            var methodCallExpression = expression.Body as MethodCallExpression;

            var methodName = methodCallExpression.Method.Name;
            var arguments  = methodCallExpression.Arguments.ToArray();

            if (this.IsApplySetupReturnsInProgess)
            {
                throw new InvalidOperationException("There is already an evaluation of the arguments pending for a property set. There might be a bug in Moqingbirt. Were you using multithreading by any chance ?");
            }

            this.IsApplySetupReturnsInProgess = true;

            // build a list of predicated of all the available parameters.
            MatchIt.RecordMatches = true;
            foreach (var argument in arguments)
            {
                var recordedMatches  = MatchIt.LastMatch.Count;
                var compiledArgument = Expression.Lambda(argument).Compile();
                var specifiedValue   = compiledArgument.DynamicInvoke();
                if (recordedMatches == MatchIt.LastMatch.Count)
                {
                    // Nothing has been added in MatchIt by It.IsAny or It.Is : It was not a predicate, but a real value : handle accordingly.
                    MatchIt.LastMatch.Add(o => o.Equals(specifiedValue));
                }
            }
            MatchIt.RecordMatches = false;

            //IEnumerable<Func<object, bool>> evaluatedArgs = arguments.ForEach()
            //    arg =>
            //        {
            //            var c = Expression.Lambda(arg).Compile();
            //            var specifiedValue = c.DynamicInvoke();
            //            return new Func<object, bool>(o => o.Equals(specifiedValue));
            //            //return specifiedValue;
            //        });

            var oldSetups = this.Setups.ToArray();

            var c = expression.Compile();

            c.DynamicInvoke(new object[] { this });

            var addedSetups = this.Setups.Except(oldSetups);

            var addedSetup = addedSetups.Single();

            // addedSetup.Item3 = returnValue;

            // FIXME : replace this dodgy implementation with a proper class which is not immutable.
            var setupWithReturnValue = new Tuple <string, Func <object, bool>[], object>(addedSetup.Item1, addedSetup.Item2, returnValue);

            Setups.Remove(addedSetup);
            Setups.Add(setupWithReturnValue);

            //var evargs = evaluatedArgs.ToArray();

            // FIXME : use IEnumerable instead of arrays if arrays are not needed.
            //var configEntry = new Tuple<string, Func<object, bool>[], object>(methodName,/* evaluatedArgs.ToArray()*/ evargs, returnValue);
            //this.Setups.Add(configEntry);
            MatchIt.LastMatch.Clear();
            this.IsApplySetupReturnsInProgess = false;
        }