/// <summary>
/// Resolves the type by mapping the known Objective-C type information to .NET types.
/// </summary>
/// <returns>
/// The number of unresolved types still remaining.
/// </returns>
/// <param name='type'>
/// The NSObjectTypeInfo that contains the known Objective-C type information.
/// Typically this will be the result of NSObjectInfoService.ParseHeader().
/// </param>
/// <param name='provider'>
/// A CodeDom provider which is used to make sure type names don't conflict with language keywords.
/// </param>
/// <param name='defaultNamespace'>
/// The default namespace used when forcing type resolution.
/// </param>
public void ResolveObjcToCli (IProgressMonitor monitor, NSObjectTypeInfo type, CodeDomProvider provider, string defaultNamespace)
{
NSObjectTypeInfo resolved;
// Resolve our base type
if (type.BaseCliType == null) {
if (TryResolveObjcToCli (type.BaseObjCType, out resolved)) {
type.BaseCliType = resolved.CliName;
} else {
type.BaseCliType = defaultNamespace + "." + provider.CreateValidIdentifier (type.BaseObjCType);
monitor.ReportWarning (string.Format ("Failed to resolve Objective-C type {0} to CLI type on type {1}",
type.BaseObjCType, type.ObjCName));
}
}
// Resolve [Outlet] types
foreach (var outlet in type.Outlets) {
if (outlet.CliType != null)
continue;
if (TryResolveObjcToCli (outlet.ObjCType, out resolved)) {
outlet.CliType = resolved.CliName;
} else {
outlet.CliType = defaultNamespace + "." + provider.CreateValidIdentifier (outlet.ObjCType);
monitor.ReportWarning (string.Format ("Failed to resolve Objective-C type {0} to CLI type on outlet {1} on type {2}",
outlet.ObjCType, outlet.ObjCName, type.ObjCName));
}
}
// Resolve [Action] param types
foreach (var action in type.Actions) {
foreach (var param in action.Parameters) {
if (param.CliType != null)
continue;
if (TryResolveObjcToCli (param.ObjCType, out resolved)) {
param.CliType = resolved.CliName;
} else {
param.CliType = defaultNamespace + "." + provider.CreateValidIdentifier (param.ObjCType);
monitor.ReportWarning (string.Format ("Failed to resolve Objective-C type {0} to CLI type on action parameter {1} for action {2} on type {3}",
param.ObjCType, param.Name, action.ObjCName, type.ObjCName));
}
}
}
}