/// <summary> /// Creates either C# to Ruby or VB.NET to Ruby converter based on the filename extension that is to be converted. /// </summary> /// <returns>Null if the file cannot be converted.</returns> public static NRefactoryToRubyConverter Create(string fileName, Dom.ParseInformation parseInfo) { if (CanConvert(fileName)) { if (parseInfo == null) { throw new ArgumentNullException("parseInfo"); } return new NRefactoryToRubyConverter(GetSupportedLanguage(fileName), parseInfo); } return null; }
public NRefactoryToRubyConverter(SupportedLanguage language, Dom.ParseInformation parseInfo) { this.language = language; this.parseInfo = parseInfo; }
string GetParameterNameStringForMethod(Dom.IMethod method) { StringBuilder parameters = new StringBuilder(); for (int i = 0; i < method.Parameters.Count; ++i) { Dom.IParameter parameter = method.Parameters[i]; if (i > 0) { parameters.Append(", "); } parameters.Append(parameter.Name); } return parameters.ToString(); }
string GetParameterNameStringForMethod(Dom.IClass c, string methodName) { if (c != null) { foreach (Dom.IMethod method in c.Methods) { if (methodName == method.Name) { return GetParameterNameStringForMethod(method); } } } return String.Empty; }
int GetMemberImageIndex(Dom.IMember member) { // Missing: different icons for private/public member if (member is Dom.IMethod) return 1; if (member is Dom.IProperty) return 2; if (member is Dom.IField) return 3; if (member is Dom.IEvent) return 6; return 3; }
/// <summary> /// Converts a member to text. /// Returns the declaration of the member as C# code, e.g. /// "public void MemberName(string parameter)" /// </summary> string GetDescription(Dom.IDecoration entity) { return GetCSharpText(entity) + Environment.NewLine + entity.Documentation; }
string GetCSharpText(Dom.IDecoration entity) { if (entity is Dom.IMethod) return Dom.CSharp.CSharpAmbience.Instance.Convert(entity as Dom.IMethod); if (entity is Dom.IProperty) return Dom.CSharp.CSharpAmbience.Instance.Convert(entity as Dom.IProperty); if (entity is Dom.IEvent) return Dom.CSharp.CSharpAmbience.Instance.Convert(entity as Dom.IEvent); if (entity is Dom.IField) return Dom.CSharp.CSharpAmbience.Instance.Convert(entity as Dom.IField); if (entity is Dom.IClass) return Dom.CSharp.CSharpAmbience.Instance.Convert(entity as Dom.IClass); // unknown entity: return entity.ToString(); }