private bool typeCheck(Join join) { var imp = join.Import; var exp = join.Export; var impType = imp.ContractType; var expType = exp.ContractType; var importItem = imp.ImportItemType; var importId = imp.AllowMany ? "Import item" : "Import"; if (!_context.IsOfType(expType, importItem)) { setError(imp, string.Format("{0} is of type {1}, so it cannot accept export of type {2}", importId, importItem.TypeName, expType.TypeName)); setWarning(exp, "Export contract doesn't provide type safe identification"); join.IsErrorJoin = true; return(false); } return(true); }
/// <summary> /// find exports which satisfies import from exportsProvider (exportsProvider has been instatiated and its exports has to match into import) /// found exports are added into storage /// /// provide type checking of join, on fail set errors and return false /// </summary> /// <param name="component"></param> /// <param name="import"></param> /// <param name="exportsProvider"></param> private bool satisfyImport(ComponentRef component, Import import, ComponentRef exportsProvider) { Debug.Assert(exportsProvider.IsConstructed, "candidate has to be constructed before providing exports"); var importPoint = component.GetPoint(import); foreach (var exportPoint in exportsProvider.ExportPoints) { if (match(import, exportPoint)) { var join = new Join(importPoint, exportPoint); _joins.Add(join); if (!typeCheck(join)) { return(false); } _storage.Add(importPoint, exportPoint); } } return(true); }