private static T SerializeInternal <T>(IBuilderProperty builderProperty) where T : ClientSetting, new() { var propertyType = builderProperty.GetType(); var settings = new T { Properties = new List <PropertyNameValue>(), SettingsType = propertyType.GetClientSettingTypeName() }; foreach (var propertyInfo in propertyType.GetProperties()) { if (propertyInfo.GetCustomAttribute(typeof(XmlIgnoreAttribute)) != null) { continue; } settings.Properties.Add(new PropertyNameValue { Name = propertyInfo.Name, Value = propertyInfo.GetValue(builderProperty) }); } return(settings); }
/// <summary> /// Apply a list of <see cref="PropertyNameValue" /> on a <see cref="IBuilderProperty" /> /// </summary> /// <param name="builderProperty">The builder property the settings should be applied on</param> /// <param name="properties">The properties</param> public static void ApplyProperties(IBuilderProperty builderProperty, List <PropertyNameValue> properties) { var builderPropertyType = builderProperty.GetType(); foreach (var propertyNameValue in properties) { var property = builderPropertyType.GetProperty(propertyNameValue.Name); if (property == null) #if DEBUG { throw new Exception("Property " + propertyNameValue.Name + " not found"); } #else { continue; } #endif object value = propertyNameValue.Value; if (property.GetCustomAttributes(false).OfType <SerializeAsUtcAttribute>().Any()) { var dateTime = propertyNameValue.Value as DateTime?; if (dateTime.HasValue) { value = dateTime.Value.ToLocalTime(); } } property.SetValue(builderProperty, value, null); } }
private void OnShowBuilderProperty(object sender, IBuilderProperty builderProperty) { var builderPropertyViews = BuilderPropertiesItemsControl.GetCachedBuilderPropertyViews(this); var builderPropertyView = builderPropertyViews.FirstOrDefault(x => x.BuilderProperty == builderProperty.GetType()); if (builderPropertyView == null) { return; } switch (builderPropertyView.PropertyPosition.BuilderCategory) { case BuilderCategory.GeneralSettings: MainTabControl.SelectedIndex = 0; break; case BuilderCategory.Connection: MainTabControl.SelectedIndex = 1; break; case BuilderCategory.Protection: MainTabControl.SelectedIndex = 2; break; case BuilderCategory.Installation: MainTabControl.SelectedIndex = 3; break; case BuilderCategory.Assembly: MainTabControl.SelectedIndex = 4; break; } }