Пример #1
0
 public void Assign(ProfileSettings settings)
 {
     foreach (var property in this.GetType().GetProperties())
     {
         property.SetValue(this, typeof(ProfileSettings).GetProperty(property.Name).GetValue(settings));
     }
 }
Пример #2
0
        public static ProfileSettings GetSettings()
        {
            var settings = new ProfileSettings();

            foreach (var property in settings.GetType().GetProperties())
            {
                var fieldname = property.Name;
                if (fieldname == "AuthType")
                {
                    fieldname = "acc";
                }
                if (fieldname == "Username")
                {
                    fieldname = "email";
                }
                if (fieldname == "DefaultLatitude")
                {
                    fieldname = "latitude";
                }
                if (fieldname == "DefaultLongitude")
                {
                    fieldname = "longitude";
                }
                if (fieldname == "DefaultAltitude")
                {
                    fieldname = "altitude";
                }
                if (fieldname == "MaxWalkingRadiusInMeters")
                {
                    fieldname = "radius";
                }
                try {
                    property.SetValue(settings, typeof(GlobalVars)
                                      .GetField(fieldname).GetValue(null));
                } catch (Exception ex1) {
                    Logger.ExceptionInfo($"setting {fieldname}: {ex1.ToString()}");
                }
            }
            return(settings);
        }