/// <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 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); }
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; } }
public StoreCallbackTextRecipeStepBuilder(IRecipeStepStore store, IRecipeStepBuilder baseBuilder) { _store = store; Id = new BuilderPropertyImpl <IRecipeStepBuilder, Guid>(this, baseBuilder.Id.Value); Text = new BuilderPropertyImpl <ITextRecipeStepBuilder, string>(this); }
public static PluginSetting ToPluginSetting(this IBuilderProperty builderProperty, PluginInfo plugin) { var pluginSettings = SerializeInternal <PluginSetting>(builderProperty); pluginSettings.PluginId = plugin.Guid; return(pluginSettings); }
public SQLiteRecipeStoreBuilder() { Connection = new BuilderPropertyImpl <ISQLiteRecipeStoreBuilder, SQLiteAsyncConnection>(this); ImageStore = new BuilderPropertyImpl <ISQLiteRecipeStoreBuilder, IImageStore>(this); IngredientStore = new BuilderPropertyImpl <ISQLiteRecipeStoreBuilder, IIngredientStore>(this); PictogramStore = new BuilderPropertyImpl <ISQLiteRecipeStoreBuilder, IPictogramStore>(this); StepStore = new BuilderPropertyImpl <ISQLiteRecipeStoreBuilder, IRecipeStepStore>(this); }
public StoreCallbackBigImageRecipeStepBuilder(IRecipeStepStore store, IRecipeStepBuilder builder) { _store = store; Id = new BuilderPropertyImpl <IRecipeStepBuilder, Guid>(this, builder.Id.Value); ImageLoader = new BuilderPropertyImpl <IBigImageRecipeStepBuilder, string>(this); ImageSource = new BuilderPropertyImpl <IBigImageRecipeStepBuilder, string>(this); }
public StoreCallbackIngredientBuilder(IIngredientStore ingredientStore) { _ingredientStore = ingredientStore; Id = new BuilderPropertyImpl <IIngredientBuilder, Guid>(this, Guid.NewGuid()); Name = new BuilderPropertyImpl <IIngredientBuilder, string>(this); ImageLoader = new BuilderPropertyImpl <IIngredientBuilder, string>(this); ImageSource = new BuilderPropertyImpl <IIngredientBuilder, string>(this); }
public StoreCallbackPictogramBuilder(IPictogramStore pictogramStore) { _pictogramStore = pictogramStore; Id = new BuilderPropertyImpl <IPictogramBuilder, Guid>(this, Guid.NewGuid()); Name = new BuilderPropertyImpl <IPictogramBuilder, string>(this); Description = new BuilderPropertyImpl <IPictogramBuilder, string>(this); ImageLoader = new BuilderPropertyImpl <IPictogramBuilder, string>(this); ImageSource = new BuilderPropertyImpl <IPictogramBuilder, string>(this); }
public StoreCallbackRecipeBuilder(IRecipeStore recipeStore) { Id = new BuilderPropertyImpl <IRecipeBuilder, Guid>(this, Guid.NewGuid()); Name = new BuilderPropertyImpl <IRecipeBuilder, string>(this); Description = new BuilderPropertyImpl <IRecipeBuilder, string>(this); RequiredTime = new BuilderPropertyImpl <IRecipeBuilder, TimeSpan>(this); ImageLoader = new BuilderPropertyImpl <IRecipeBuilder, string>(this); ImageSource = new BuilderPropertyImpl <IRecipeBuilder, string>(this); IngredientIds = new BuilderPropertyImpl <IRecipeBuilder, Guid[]>(this, new Guid[0]); PictogramIds = new BuilderPropertyImpl <IRecipeBuilder, Guid[]>(this, new Guid[0]); StepIds = new BuilderPropertyImpl <IRecipeBuilder, Guid[]>(this, new Guid[0]); _recipeStore = recipeStore; }
private void UpdateLeader() { if (BuilderProperties == null) { GroupLeaderView = null; } GroupLeaderView = (ILeaderBuilderPropertyView)BuilderPropertiesItemsControl.BuilderPropertyViews.Value.FirstOrDefault( x => x.Value.PropertyPosition.IsGroupLeader && x.Value.PropertyPosition.BuilderCategory == BuilderCategory && x.Value.PropertyPosition.BuilderGroup == BuilderGroup).Value; var builderViewModel = BuilderProperties?.FirstOrDefault(x => x.BuilderProperty.GetType() == GroupLeaderView?.BuilderProperty); if (builderViewModel != null) { GroupLeaderProperty = builderViewModel.BuilderProperty; builderViewModel.BuilderPropertyView = GroupLeaderView; } }
public BuilderPropertyViewModel(IBuilderProperty builderProperty) { BuilderProperty = builderProperty; _isEnabled = true; }
/// <summary> /// Validate the user inputs /// </summary> public InputValidationResult ValidateInput(List <IBuilderProperty> currentBuilderProperties, IBuilderProperty builderProperty) { return(ValidateInput(currentBuilderProperties, (T)builderProperty)); }
public StoreCallbackRecipeStepBuilder(IRecipeStepStore store) { _store = store; Id = new BuilderPropertyImpl <IRecipeStepBuilder, Guid>(this, Guid.NewGuid()); }
public SQLitePictogramStoreBuilder() { Connection = new BuilderPropertyImpl <ISQLitePictogramStoreBuilder, SQLiteAsyncConnection>(this); ImageStore = new BuilderPropertyImpl <ISQLitePictogramStoreBuilder, IImageStore>(this); }
public SQLiteIngredientStoreBuilder() { Connection = new BuilderPropertyImpl <ISQLiteIngredientStoreBuilder, SQLiteAsyncConnection>(this); ImageStore = new BuilderPropertyImpl <ISQLiteIngredientStoreBuilder, IImageStore>(this); }
public BuilderSettingsOverwrite(int propertyIndex, IBuilderProperty newBuilderProperty, IPlugin plugin) { PropertyIndex = propertyIndex; NewBuilderProperty = newBuilderProperty; Plugin = plugin; }
public static ClientSetting ToClientSetting(this IBuilderProperty builderProperty) { return(SerializeInternal <ClientSetting>(builderProperty)); }
/// <summary> /// Initialize a new <see cref="BuilderPropertyEntry" /> /// </summary> /// <param name="builderProperty">The builder property</param> /// <param name="builderPropertyView">The view of the builder property</param> public BuilderPropertyEntry(IBuilderProperty builderProperty, IBuilderPropertyView builderPropertyView) { BuilderProperty = builderProperty; BuilderPropertyView = builderPropertyView; }