private void AddSimpleDataTypeDefaultValue(PimDefaultValuesList newDefValuesList, String baseName, Boolean IsArray, String FieldName, int arraySize) { String additionalInfo = ""; if ((IsArray)) { if (arraySize > 0) { additionalInfo = "[" + arraySize.ToString() + "]"; } else { additionalInfo = "*"; } } PimDefaultValue defValue = PimFabric.GetInstance().CreatePimDefaultValue(); defValue.DefaultValue = ""; defValue.FieldGuid = Guid.Empty; if (baseName.Length > 0) { defValue.Name = baseName + "." + FieldName + additionalInfo; } else { defValue.Name = FieldName + additionalInfo; } newDefValuesList.Add(defValue); }
public void UpdateDefaultValues() { this.Name = Defenition.Name; PimDefaultValuesList newDefValuesList = new PimDefaultValuesList(); /* Create new list */ object datatype = AutosarApplication.GetInstance().GetDataType(Defenition.DatatypeGuid); if (datatype != null) { if ((datatype is BaseDataType) || (datatype is SimpleDataType) || (datatype is EnumDataType) || (datatype is ArrayDataType)) { AddSimpleDataTypeDefaultValue(newDefValuesList, "", false, Name, 0); } else if (datatype is ComplexDataType) { ComplexDataType compDataType = (ComplexDataType)datatype; foreach (ComplexDataTypeField field in compDataType.Fields) { if (AutosarApplication.GetInstance().IsDataTypeComlex(field.DataTypeGUID)) { AddComplexDataTypeFields(newDefValuesList, Name + "." + field.Name, field); } else { AddComplexDataTypeFieldDefaultValue(newDefValuesList, Name, field); } } } } /* Remove unexists */ for (int i = DefaultValues.Count - 1; i >= 0; i--) { if (FindName(newDefValuesList, DefaultValues[i].Name) == false) { DefaultValues.RemoveAt(i); } } /* Add new */ { foreach (PimDefaultValue pimDefValue in newDefValuesList) { if (FindName(DefaultValues, pimDefValue.Name) == false) { DefaultValues.Add(pimDefValue); } } } }
private void AddComplexDataTypeFieldDefaultValue(PimDefaultValuesList newDefValuesList, String baseName, ComplexDataTypeField cmplfield) { String additionalInfo = ""; if (cmplfield.IsPointer) { additionalInfo = "*"; } PimDefaultValue defValue = PimFabric.GetInstance().CreatePimDefaultValue(); defValue.DefaultValue = ""; defValue.FieldGuid = cmplfield.GUID; if (baseName.Length > 0) { defValue.Name = baseName + "." + cmplfield.Name + additionalInfo; } else { defValue.Name = cmplfield.Name + additionalInfo; } newDefValuesList.Add(defValue); }