Ejemplo n.º 1
0
        public void LoadFromFile()
        {
            System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(this.GetType());
            String tokenFile = Path.GetFullPath(asm.Location) + ".apiToken";

            if (!File.Exists(tokenFile))
            {
                return;
            }

            String         jData = File.ReadAllText(tokenFile, Encoding.UTF8);
            APIAccessToken item  = IAMUserClass.Deserialize <APIAccessToken>(jData);

            this.access_token = item.access_token;
            this.create_time  = item.create_time;
            this.expires_in   = item.expires_in;
        }
Ejemplo n.º 2
0
        public void SaveToFile()
        {
            if (create_time == 0)
            {
                var utc0      = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                var issueTime = DateTime.Now;

                create_time = (int)issueTime.Subtract(utc0).TotalSeconds;
            }

            String jData = IAMUserClass.Serialize <APIAccessToken>(this);

            System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(this.GetType());
            String tokenFile = Path.GetFullPath(asm.Location) + ".apiToken";

            File.WriteAllText(tokenFile, jData, Encoding.UTF8);
        }