internal void GenerateForClass(CSharpWriter stream, UmlAttributeNode attributeNode) { stream.WriteSummary(attributeNode.Documentation); var visibility = CSharpHelper.ConvertVisibility(attributeNode.Visibility, true, true); var attrType = CSharpHelper.ResolveType(attributeNode); if (attributeNode.IsReadOnly) { stream.WriteCodeLine($"{visibility} {attrType} {attributeNode.Name} {{ get; private set; }}"); } else { stream.WriteCodeLine($"{visibility} {attrType} {attributeNode.Name} {{ get; set; }}"); } }
internal static string ResolveType(UmlAttributeNode attributeNode) { if (attributeNode.Type.IsNodeReference) { var sourceNamespaceParts = GetNamespaceForNode(attributeNode.Parent); var targetNamespaceParts = GetNamespaceForNode(attributeNode.Type.NodeReference); if (sourceNamespaceParts.Count < targetNamespaceParts.Count) {// some inner namespace targetNamespaceParts.RemoveRange(0, targetNamespaceParts.Count - sourceNamespaceParts.Count); return($"{string.Join(".", targetNamespaceParts)}.{attributeNode.Type.NodeReference.Name}"); } else { return(attributeNode.Type.NodeReference.Name); } } else { return(attributeNode.Type.Name); } }
private void WriteAttributeAsProperty(CSharpWriter stream, UmlAttributeNode attr) { var propertyGenerator = new PropertyGenerator(); propertyGenerator.GenerateForClass(stream, attr); }