Skip to content

Int32 is persisted as Int64  #49

Open
@sstainba

Description

@sstainba

I have several int properties I am storing, but when I get them back out, they are returned as Int64.

int myInt = 12;
localSettings.Store("myInt", myInt);

myInt = localSettings.Get("myInt");  //this fails as the value returned is an Int64

The save method for my settings...

public void Save(string propertyName)
{
    if(!isLoaded) return;
    var prop = this.GetType().GetProperty(propertyName);
    if (prop == null) return;
    var val = prop.GetValue(this);
    localSettings.Store(propertyName, val);
}

The load method...

public Settings() {
     isLoaded = false;
     localSettings.Load();
     var props = typeof(Settings).GetProperties().Where(p => p.CanWrite);

     foreach (var k in localSettings.Keys())
     {
         var p = props.FirstOrDefault(x => x.Name == k);
         if (p == null) continue;

         var val = localSettings.Get(k);

         p.SetValue(this, localSettings.Get(k));
     }
     isLoaded = true;
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions