예제 #1
0
		public static TwUser LoadCredentials()
		{
			TwUser twiUser = new TwUser();
			if (!File.Exists(s_configFile))
			{
				Console.WriteLine("Enter Twitter username...");
				twiUser.Username = Console.ReadLine();

				Console.WriteLine("Enter Twitter password...");
				twiUser.Password = Console.ReadLine();
			}
			else
			{
				twiUser = Deserialize();
			}

			if (string.IsNullOrEmpty(twiUser.OAuthToken) || string.IsNullOrEmpty(twiUser.OAuthTokenSecret))
				twiUser.SetOAuthCredentials();

			return twiUser;
		}
예제 #2
0
파일: TwUser.cs 프로젝트: AminBK/shelltwit
        static TwUser Deserialize()
        {
            TwUser twiUser = null;

            try
            {
                using (FileStream file = File.Open(s_configFile, FileMode.Open))
                {
                    DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(TwUser));
                    twiUser = (TwUser)jsonSerializer.ReadObject(file);
                }
            }
            catch (SerializationException)
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(TwUser));
                using (StreamReader reader = new StreamReader(s_configFile))
                    twiUser = (TwUser)deserializer.Deserialize(reader);

                twiUser.Serialize();
            }
            return(twiUser);
        }
예제 #3
0
파일: TwUser.cs 프로젝트: AminBK/shelltwit
        public static TwUser LoadCredentials()
        {
            TwUser twiUser = new TwUser();

            if (!File.Exists(s_configFile))
            {
                Console.WriteLine("Enter Twitter username...");
                twiUser.Username = Console.ReadLine();

                Console.WriteLine("Enter Twitter password...");
                twiUser.Password = Console.ReadLine();
            }
            else
            {
                twiUser = Deserialize();
            }

            if (string.IsNullOrEmpty(twiUser.OAuthToken) || string.IsNullOrEmpty(twiUser.OAuthTokenSecret))
            {
                twiUser.SetOAuthCredentials();
            }

            return(twiUser);
        }