private doCS.Models.AccessType ConvertAccessType(doCS.Extractor.AccessType accessType) { switch (accessType) { case doCS.Extractor.AccessType.Public: return doCS.Models.AccessType.Public; case doCS.Extractor.AccessType.Protected: return doCS.Models.AccessType.Protected; case doCS.Extractor.AccessType.Private: return doCS.Models.AccessType.Private; default: return doCS.Models.AccessType.Unknown; } }
public static string GetNameFor(doCS.Models.Type type) { if (type.Name == "Int32") return "int"; else if (type.Name == "String") return "string"; else if (type.GenericArguments.Count == 0) return type.Name; StringBuilder stringBuilder = new StringBuilder(type.Name); stringBuilder.Append('<'); foreach (var genericParam in type.GenericArguments) { stringBuilder.Append(genericParam.Name); if (genericParam != type.GenericArguments.Last()) stringBuilder.Append(", "); } stringBuilder.Append('>'); return stringBuilder.ToString(); }
public Property FindOrCreateProperty(string propertyName, doCS.Models.Type type, Action<Property> propertyAction) { //if the property is current then return it var property = _CurrentProperties.FirstOrDefault(x => x.Type == type && x.Name == propertyName); if (property != null) return property; property = type.Properties.FirstOrDefault(x => x.Name == propertyName); if (property == null) property = new Property(); propertyAction(property); _CurrentProperties.Add(property); return property; }
private void UpdateProperties(TypeData typeData, doCS.Models.Type type, ExtractorData extractorData) { foreach (PropertyData propertyData in typeData.Properties) { //TODO: Skipping generic properties for now (properties with no name) if (!string.IsNullOrEmpty(propertyData.TypeName)) { var result = extractorData.ProjectUpdater.FindOrCreateProperty(propertyData.Name, type, (Property property) => { property.Name = propertyData.Name; property.DeclaringType = type; property.Type = GetOrCreateType(propertyData.TypeName, extractorData); property.GetAccessType = ConvertAccessType(propertyData.GetAccessType); property.SetAccessType = ConvertAccessType(propertyData.SetAccessType); property.IsAbstract = propertyData.IsAbstract; property.IsStatic = propertyData.IsStatic; property.IsVirtual = propertyData.IsVirtual; if (property.XmlDocumentation == null) property.XmlDocumentation = new XmlDocumentation(); property.XmlDocumentation.XmlComments = propertyData.XmlComments; //TODO: update overrides and shadows here }); } } }
private void UpdateInterfaces(doCS.Models.Type type, List<doCS.Models.Type> newInterfaces) { //if any type have been added then add the relation foreach (var interfaceType in newInterfaces) { if (!type.Interfaces.Contains(interfaceType)) type.Interfaces.Add(interfaceType); } //if any types have been removed then remove the relation List<doCS.Models.Type> removedInterfaces = new List<doCS.Models.Type>(); foreach (var interfaceType in type.Interfaces) { if (!newInterfaces.Contains(interfaceType)) removedInterfaces.Add(interfaceType); } type.Interfaces.RemoveAll(removedInterfaces); }
private void UpdateGenericArguments(doCS.Models.Type type, TypeData typeData) { if (type.GenericArguments.Count == 0 && typeData.GenericArguments.Count == 0) return; if (type.GenericArguments.Count > 0 && typeData.GenericArguments.Count == 0) { type.GenericArguments.Clear(); return; } //make sure the list is the correct length for (int excess = typeData.GenericArguments.Count; excess < type.GenericArguments.Count; excess++) type.GenericArguments.Remove(type.GenericArguments.ElementAt(excess)); for (int incess = type.GenericArguments.Count; incess < typeData.GenericArguments.Count; incess++) type.GenericArguments.Add(new GenericArgument()); int i = 0; for (i = 0; i < typeData.GenericArguments.Count && i < type.GenericArguments.Count; i++) { var genericParamterData = typeData.GenericArguments[i]; var genericParamter = type.GenericArguments.ElementAt(i); genericParamter.Type = type; genericParamter.Name = genericParamterData.Name; genericParamter.ArgumentOrder = (short)i; } }