public static EntityManagementValues ToModel(MainViewModel viewModel) { EntityManagementValues model = new EntityManagementValues(); model.Name = viewModel.EntityName; model.PropertyManagementMode = viewModel.EntityManagementMode; model.SelectedProperties.AddRange(viewModel.EntityManagedProperties); foreach (var instanceViewModel in viewModel.Instances) { InstanceManagementValues instanceModel = new InstanceManagementValues(); instanceModel.Name = instanceViewModel.Name; instanceModel.PropertyManagementMode = instanceViewModel.PropertyManagementMode; instanceModel.SelectedProperties.AddRange( instanceViewModel.SelectedProperties); model.InstanceManagementValuesList.Add( instanceModel); } return(model); }
private static void AddInstanceManagementValuesFor(EntityManagementValues values, NamedObjectSave instance) { var instanceValues = new InstanceManagementValues(); instanceValues.Name = instance.InstanceName; UpdateInstanceValuesToInstance(instanceValues, instance); values.InstanceManagementValuesList.Add(instanceValues); }
private static void UpdateInstanceValuesToInstance(InstanceManagementValues instanceValues, NamedObjectSave instance) { if (instance.IsManuallyUpdated) { instanceValues.PropertyManagementMode = Enums.PropertyManagementMode.SelectManagedProperties; } else { instanceValues.PropertyManagementMode = Enums.PropertyManagementMode.FullyManaged; } instanceValues.IsContainer = instance.IsContainer; }
public override ICodeBlock GenerateActivity(ICodeBlock codeBlock, IElement element) { EntityManagementValues managementValues; managementValues = Values?.EntityManagementValueList?.FirstOrDefault(item => item.Name == element.Name); if (managementValues != null) { var entitySave = element as EntitySave; if (entitySave != null && managementValues.PropertyManagementMode == Enums.PropertyManagementMode.SelectManagedProperties) { GenerateVariableActivityFor(codeBlock, entitySave, managementValues.SelectedProperties); } foreach (var namedObject in element.AllNamedObjects) { var isManuallyUpdated = namedObject.IsManuallyUpdated; InstanceManagementValues instanceManagementValues = null; if (isManuallyUpdated) { instanceManagementValues = managementValues.InstanceManagementValuesList.FirstOrDefault(item => item.Name == namedObject.InstanceName); } var shouldGenerateForThisObject = // Don't generate if it's a container, use the main entity's values namedObject.IsContainer == false && instanceManagementValues?.SelectedProperties?.Count > 0; if (shouldGenerateForThisObject) { GenerateVariableActivityFor(codeBlock, namedObject, instanceManagementValues); } } } return(codeBlock); }
private void GenerateNamedObjectUpdateDependencies(ICodeBlock codeBlock, IElement element, EntityManagementValues managementValues) { foreach (var namedObject in element.AllNamedObjects) { var isManuallyUpdated = namedObject.IsManuallyUpdated; InstanceManagementValues instanceManagementValues = null; if (isManuallyUpdated) { instanceManagementValues = managementValues.InstanceManagementValuesList.FirstOrDefault(item => item.Name == namedObject.InstanceName); } var shouldGenerateUpdateDependenciesForObject = namedObject.IsContainer == false && instanceManagementValues?.SelectedProperties?.Count > 0; if (shouldGenerateUpdateDependenciesForObject) { GenerateVariableUpdateDependenciesFor(codeBlock, namedObject, instanceManagementValues); } } }
public static bool Has(this InstanceManagementValues values, string propertyName) { return(values.SelectedProperties.Contains(propertyName)); }
private void GeneratePositionedObjectVariableUpdateDependenciesFor(ICodeBlock codeBlock, string name, InstanceManagementValues instanceManagementValues) { if (instanceManagementValues.Has("Attachment")) { codeBlock.Line($"{name}.UpdateDependencies(FlatRedBall.TimeManager.CurrentTime);"); } }
private void GenerateVariableUpdateDependenciesFor(ICodeBlock codeBlock, NamedObjectSave namedObject, InstanceManagementValues instanceManagementValues) { var name = namedObject.FieldName; var ati = namedObject.GetAssetTypeInfo(); GeneratePositionedObjectVariableUpdateDependenciesFor(codeBlock, name, instanceManagementValues); if (ati?.RuntimeTypeName == "Text") { GenerateTextVariableUpdateDependenciesFor(codeBlock, name, instanceManagementValues.SelectedProperties); } else if (ati?.RuntimeTypeName == "Sprite") { GenerateSpriteVariableUpdateDependenciesFor(codeBlock, name, instanceManagementValues.SelectedProperties); } }
private void GenerateVariableActivityFor(ICodeBlock codeBlock, NamedObjectSave namedObject, InstanceManagementValues instanceManagementValues) { var name = namedObject.FieldName; var assetTypeInfo = namedObject.GetAssetTypeInfo(); GenerateActivityFor(codeBlock, instanceManagementValues.SelectedProperties, name, assetTypeInfo); }