public void NormalizeModelProperties(CodeModelCsa serviceClient) { foreach (var modelType in serviceClient.ModelTypes) { foreach (var property in modelType.Properties) { AddNamespaceToResourceType(property.ModelType, serviceClient); } } }
private void AddNamespaceToResourceType(IModelType type, CodeModelCsa serviceClient) { // iList<SubResource> property { get; set; } => iList<Microsoft.Rest.Azure.SubResource> property { get; set; } if (type is SequenceType sequenceType) { AddNamespaceToResourceType(sequenceType.ElementType, serviceClient); } // IDictionary<string, SubResource> property { get; set; } => IDictionary<string, Microsoft.Rest.Azure.SubResource> property { get; set; } else if (type is DictionaryType dictionaryType) { AddNamespaceToResourceType(dictionaryType.ValueType, serviceClient); } }
private void AddNamespaceToResourceType(IModelType type, CodeModelCsa serviceClient) { var compositeType = type as CompositeType; var sequenceType = type as SequenceType; var dictionaryType = type as DictionaryType; // SubResource property { get; set; } => Microsoft.Rest.Azure.SubResource property { get; set; } if ((compositeType != null) && (compositeType.Name.Equals("Resource") || compositeType.Name.Equals("SubResource"))) { compositeType.Name.FixedValue = "Microsoft.Rest.Azure." + compositeType.Name; } // iList<SubResource> property { get; set; } => iList<Microsoft.Rest.Azure.SubResource> property { get; set; } else if (sequenceType != null) { AddNamespaceToResourceType(sequenceType.ElementType, serviceClient); } // IDictionary<string, SubResource> property { get; set; } => IDictionary<string, Microsoft.Rest.Azure.SubResource> property { get; set; } else if (dictionaryType != null) { AddNamespaceToResourceType(dictionaryType.ValueType, serviceClient); } }