public override SyntaxToken VisitToken(SyntaxToken token)
        {
            token = base.VisitToken(token);
            if (token.IsMissing)
            {
                return(token);
            }

            if (!token.IsKind(SyntaxKind.CloseBraceToken))
            {
                return(token);
            }

            SyntaxToken nextToken = token.GetNextToken(includeSkipped: true);

            int  tokenLine             = syntaxTree.GetText().Lines.IndexOf(token.Span.Start);
            int  nextTokenLine         = syntaxTree.GetText().Lines.IndexOf(nextToken.Span.Start);
            bool nextTokenIsCloseBrace = nextToken.IsKind(SyntaxKind.CloseBraceToken);

            int expectedDiff = nextTokenIsCloseBrace ? 1 : 2;

            if (nextTokenLine == tokenLine + expectedDiff)
            {
                return(token);
            }

            System.Collections.Generic.IEnumerable <SyntaxTrivia> nonNewLineTrivia = token.TrailingTrivia.Where(t => !t.IsKind(SyntaxKind.EndOfLineTrivia));
            System.Collections.Generic.IEnumerable <SyntaxTrivia> newTrivia        = nonNewLineTrivia.Concat(Enumerable.Repeat(SyntaxFactory.EndOfLine("\r\n"), expectedDiff));

            return(token.WithTrailingTrivia(SyntaxFactory.TriviaList(newTrivia)));
        }
Exemplo n.º 2
0
        public static byte[] Decode(string s)
        {
            //Contract.Requires<ArgumentNullException>(s != null);
            //Contract.Ensures(Contract.Result<byte[]>() != null);

            // Decode Base58 string to BigInteger
            BigInteger intData = 0;

            for (var i = 0; i < s.Length; i++)
            {
                var digit = Digits.IndexOf(s[i]); //Slow
                if (digit < 0)
                {
                    throw new FormatException(string.Format("Invalid Base58 character `{0}` at position {1}", s[i], i));
                }
                intData = intData * 58 + digit;
            }

            // Encode BigInteger to byte[]
            // Leading zero bytes get encoded as leading `1` characters
            var leadingZeroCount = s.TakeWhile(c => c == '1').Count();

            System.Collections.Generic.IEnumerable <byte> leadingZeros             = Enumerable.Repeat((byte)0, leadingZeroCount);
            System.Collections.Generic.IEnumerable <byte> bytesWithoutLeadingZeros =
                intData.ToByteArray()
                .Reverse()               // to big endian
                .SkipWhile(b => b == 0); //strip sign byte
            var result = leadingZeros.Concat(bytesWithoutLeadingZeros).ToArray();

            return(result);
        }
Exemplo n.º 3
0
        public void Add(SessionDescriptionLine line)
        {
            //Ensure not the same type
            if (line.m_Type == m_Type)
            {
                throw new System.InvalidOperationException("Line Type cannot be the same as LineGroup Type.");
            }

            //Should check if allowed at this level

            //Concat the line with the GroupedLines and assign again.
            GroupedLines = GroupedLines.Concat(line);
        }
Exemplo n.º 4
0
        public PrivateMessageControl(string name)
        {
            InitializeComponent();
            ChatBox.Font                 = Program.Conf.ChatFont;
            Name                         = name;
            UserName                     = name;
            ChatBox.MouseUp             += autoscrollRichTextBox1_MouseUp;
            ChatBox.FocusInputRequested += (s, e) => GoToSendBox();
            ChatBox.ChatBackgroundColor  = TextColor.background; //same as Program.Conf.BgColor but TextWindow.cs need this.
            ChatBox.IRCForeColor         = 14;                   //mirc grey. Unknown use

            HistoryManager.InsertLastLines(UserName, ChatBox);

            VisibleChanged += PrivateMessageControl_VisibleChanged;
            Program.TasClient.BattleUserJoined += TasClient_BattleUserJoined;
            Program.TasClient.UserAdded        += TasClient_UserAdded;
            Program.TasClient.UserRemoved      += TasClient_UserRemoved;

            var extras = new BitmapButton();

            extras.Text   = "Extras";
            extras.Click += (s, e) => { ContextMenus.GetPrivateMessageContextMenu(this).Show(extras, new Point(0, 0)); };
            ChatBox.Controls.Add(extras);

            sendBox.CompleteWord += (word) => //autocomplete of username
            {
                var      w           = word.ToLower();
                string[] nameInArray = new string[1] {
                    name
                };
                System.Collections.Generic.IEnumerable <string> firstResult = nameInArray
                                                                              .Where(x => x.ToLower().StartsWith(w))
                                                                              .Union(nameInArray.Where(x => x.ToLower().Contains(w)));;
                if (true)
                {
                    ChatControl zkChatArea = Program.MainWindow.navigationControl.ChatTab.GetChannelControl("zk");
                    if (zkChatArea != null)
                    {
                        System.Collections.Generic.IEnumerable <string> extraResult = zkChatArea.playerBox.GetUserNames()
                                                                                      .Where(x => x.ToLower().StartsWith(w))
                                                                                      .Union(zkChatArea.playerBox.GetUserNames().Where(x => x.ToLower().Contains(w)));
                        firstResult = firstResult.Concat(extraResult); //Reference: http://stackoverflow.com/questions/590991/merging-two-ienumerablets
                    }
                }
                return(firstResult);
            };
        }
Exemplo n.º 5
0
        public static void RegisterComponents(bool repos = true, bool queries = true, bool mappers = true)
        {
            if (Application.container == null)
            {
                var builder = new ContainerBuilder();

                var assemblyPattern = new Regex($"{nameof(SiliconeTrader)}.*.dll");
                System.Collections.Generic.IEnumerable<Assembly> loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => assemblyPattern.IsMatch(Path.GetFileName(a.Location)));
                string dynamicAssembliesPath = new Uri(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location)).LocalPath;
                System.Collections.Generic.IEnumerable<string> dynamicAssemblies = Directory.EnumerateFiles(dynamicAssembliesPath, "*.dll", SearchOption.AllDirectories)
                           .Where(filename => assemblyPattern.IsMatch(Path.GetFileName(filename)) &&
                           !loadedAssemblies.Any(a => Path.GetFileName(a.Location) == Path.GetFileName(filename)));

                System.Collections.Generic.IEnumerable<Assembly> allAssemblies = loadedAssemblies.Concat(dynamicAssemblies.Select(Assembly.LoadFrom)).Distinct();

                builder.RegisterAssemblyModules(allAssemblies.ToArray());
                Application.container = builder.Build();
            }
        }