示例#1
0
 public static IshtarObject *FReadLine(CallFrame current, IshtarObject **args)
 => IshtarMarshal.ToIshtarObject(In.ReadLine());
示例#2
0
 /// Read a line from the input stream
 public string ReadLine()
 {
     return(In.ReadLine());
 }
示例#3
0
 public static String ReadLine()
 {
     return In.ReadLine();
 }
示例#4
0
        internal void Clear()
        {
            var    args   = Environment.GetCommandLineArgs();
            string url    = null;
            bool   forced = false;

            if (args.Length <= 2)
            {
                if (!StandardInputIsTty)
                {
                    _context.Trace.WriteLine("standard input is not TTY, abandoning prompt.");

                    return;
                }

                _context.Trace.WriteLine("prompting user for url.");

                WriteLine(" Target Url:");
                url = In.ReadLine();
            }
            else
            {
                url = args[2];

                if (args.Length > 3)
                {
                    bool.TryParse(args[3], out forced);
                }
            }

            Uri uri;

            if (Uri.TryCreate(url, UriKind.Absolute, out uri))
            {
                _context.Trace.WriteLine($"converted '{url}' to '{uri.AbsoluteUri}'.");

                OperationArguments operationArguments = new OperationArguments(_context);

                operationArguments.SetTargetUri(uri);

                if (operationArguments.TargetUri is null)
                {
                    var inner = new ArgumentNullException(nameof(operationArguments.TargetUri));
                    throw new ArgumentException(inner.Message, nameof(operationArguments), inner);
                }

                Task.Run(async() =>
                {
                    await LoadOperationArguments(operationArguments);
                    EnableTraceLogging(operationArguments);

                    if (operationArguments.PreserveCredentials && !forced)
                    {
                        _context.Trace.WriteLine("attempting to delete preserved credentials without force, prompting user for interactivity.");

                        if (!StandardInputIsTty || !StandardErrorIsTty)
                        {
                            _context.Trace.WriteLine("standard input is not TTY, abandoning prompt.");
                            return;
                        }

                        WriteLine(" credentials are protected by preserve flag, clear anyways? [Y]es, [N]o.");

                        ConsoleKeyInfo key;
                        while ((key = ReadKey(true)).Key != ConsoleKey.Escape)
                        {
                            if (key.KeyChar == 'N' || key.KeyChar == 'n')
                            {
                                return;
                            }

                            if (key.KeyChar == 'Y' || key.KeyChar == 'y')
                            {
                                break;
                            }
                        }
                    }

                    await DeleteCredentials(operationArguments);
                }).Wait();
            }
            else
            {
                _context.Trace.WriteLine($"unable to parse input '{url}'.");
            }
        }
示例#5
0
        public static void Main(string[] args)
        {
            OutputEncoding = Encoding.UTF8;
            Out.WriteLine("input screen_name");
            string screenName = In.ReadLine();

            using (var context = new TwitterContext()) {
                long?_id = context.Users.FirstOrDefault(x => x.ScreenName == screenName)?.Id;
                if (_id == null)
                {
                    Out.WriteLine("not found screen_name");
                }
                long id     = _id.Value;
                var  users  = new Dictionary <long, int>();
                var  replys = new Dictionary <long, int>();
                // 自分がフォロー +100
                // ふぁぼ +3 あんふぁぼ -3
                // RT or Quote +1
                // リプライ + 10 リプライイベント数差 -5
                foreach (var following in context.Followings.Where(x => x.UserId == id))
                {
                    users.PutOrAdd(following.FollowingId, 100);
                }
                foreach (var reactive in context.ReactiveEvents.Where(x => x.TargetUserId == id))
                {
                    if (reactive.EventType == ReacteveEventType.Favorite)
                    {
                        users.PutOrAdd(reactive.UserId, 3);
                    }
                    else if (reactive.EventType == ReacteveEventType.Reply)
                    {
                        users.PutOrAdd(reactive.UserId, 10);
                        replys.PutOrAdd(reactive.UserId, 1);
                    }
                    else
                    {
                        users.PutOrAdd(reactive.UserId, 1);
                    }
                }
                foreach (var reactive in context.ReactiveEvents.Where(x => x.UserId == id))
                {
                    if (reactive.EventType == ReacteveEventType.Favorite)
                    {
                        users.PutOrAdd(reactive.TargetUserId, 3);
                    }
                    else if (reactive.EventType == ReacteveEventType.Reply)
                    {
                        users.PutOrAdd(reactive.TargetUserId, 10);
                        replys.PutOrAdd(reactive.TargetUserId, -1);
                    }
                    else
                    {
                        users.PutOrAdd(reactive.TargetUserId, 1);
                    }
                }
                foreach (var delete in context.DeleteEvents.Where(x => x.TargetUserId == id))
                {
                    if (delete.EventType == DeleteEventType.Favorite)
                    {
                        users.PutOrAdd(delete.UserId, -3);
                    }
                }
                foreach (var delete in context.DeleteEvents.Where(x => x.UserId == id))
                {
                    if (delete.EventType == DeleteEventType.Favorite && delete.TargetUserId != null)
                    {
                        users.PutOrAdd(delete.TargetUserId.Value, -3);
                    }
                }
                foreach (var reply in replys)
                {
                    users.PutOrAdd(reply.Key, Math.Abs(reply.Value) * (-5));
                }
                foreach (var user in users.OrderByDescending(x => x.Value))
                {
                    var relationUser = context.Users.FirstOrDefault(x => x.Id == user.Key);
                    if (relationUser == null)
                    {
                        continue;
                    }
                    Out.WriteLine($"ScreenName: {relationUser.ScreenName} Name: {relationUser.Name} Point: {user.Value}");
                }
            }
        }
示例#6
0
 public void ReadLineAbsoluteWindowsPath()
 {
     string currentDirectory = Directory.GetCurrentDirectory();
      string fullPath = Path.Combine(currentDirectory, "InTest.txt");
      using (In inObject = new In(fullPath))
      {
     int expectedIndex = 0;
     while (!inObject.IsEmpty())
     {
        string s = inObject.ReadLine();
        Assert.IsTrue(expectedIndex < InUnitTests.InTestLines.Length);
        Assert.AreEqual(InUnitTests.InTestLines[expectedIndex++], s);
     }
      }
 }
示例#7
0
 public void ReadLineFromUrl()
 {
     using (In inObject = new In(UrlName))
      {
     int expectedIndex = 0;
     while (!inObject.IsEmpty())
     {
        string s = inObject.ReadLine();
        Assert.IsTrue(expectedIndex < InUnitTests.InTestLines.Length);
        Assert.AreEqual(InUnitTests.InTestLines[expectedIndex++], s);
     }
      }
 }
示例#8
0
        public void ReadLineFromRelativePath()
        {
            string relativeFile = string.Format(
            CultureInfo.InvariantCulture,
            "..\\{0}\\InTest.txt",
            Path.GetFileName(Directory.GetCurrentDirectory()));

             using (In inObject = new In(relativeFile))
             {
            int expectedIndex = 0;
            while (!inObject.IsEmpty())
            {
               string s = inObject.ReadLine();
               Assert.IsTrue(expectedIndex < InUnitTests.InTestLines.Length);
               Assert.AreEqual(InUnitTests.InTestLines[expectedIndex++], s);
            }
             }
        }
示例#9
0
 public void ReadLineFromCurrentDirectory()
 {
     using (In inObject = new In("./InTest.txt"))
      {
     while (!inObject.IsEmpty())
     {
        int expectedIndex = 0;
        while (!inObject.IsEmpty())
        {
           string s = inObject.ReadLine();
           Assert.IsTrue(expectedIndex < InUnitTests.InTestLines.Length);
           Assert.AreEqual(InUnitTests.InTestLines[expectedIndex++], s);
        }
     }
      }
 }