/// <summary> /// Initializes the feature precursor hierarchy. /// </summary> /// <param name="context">The initialization context.</param> public override void InitHierarchy(ICSharpContext context) { if (Instance.OriginalPrecursor.IsAssigned) { IPrecursorInstance Item = Instance.OriginalPrecursor.Item; ICompiledFeature PrecursorFeature = Item.Precursor.Feature; OriginalPrecursor = context.GetFeature(PrecursorFeature) as ICSharpProcedureFeature; Debug.Assert(OriginalPrecursor != null); IList <ICSharpOverload> PrecursorOverloadList = OriginalPrecursor.OverloadList; foreach (ICSharpCommandOverload Overload in OverloadList) { ICommandOverloadType ResolvedAssociatedType = Overload.Source.ResolvedAssociatedType.Item; ICSharpCommandOverload ParentPrecursorOverload = null; foreach (ICSharpCommandOverload PrecursorOverload in PrecursorOverloadList) { ICommandOverloadType PrecursorResolvedAssociatedType = PrecursorOverload.Source.ResolvedAssociatedType.Item; if (ObjectType.CommandOverloadConformToBase(ResolvedAssociatedType, PrecursorResolvedAssociatedType, ErrorList.Ignored, ErrorList.NoLocation)) { Debug.Assert(ParentPrecursorOverload == null); ParentPrecursorOverload = PrecursorOverload; } } Debug.Assert(ParentPrecursorOverload != null); Overload.SetPrecursor(ParentPrecursorOverload); } } }
private string CSharpTextProcedure(ICSharpUsingCollection usingCollection, ICSharpProcedureFeature feature) { string Result; // TODO handle several overloads. Debug.Assert(feature.OverloadList.Count > 0); ICSharpCommandOverload Overload = feature.OverloadList[0] as ICSharpCommandOverload; Debug.Assert(Overload != null); string BaseTypeText; if (BaseType != null) { BaseTypeText = EffectiveBaseType.Type2CSharpString(usingCollection, CSharpTypeFormats.AsInterface, CSharpNamespaceFormats.OneWord); } else { BaseTypeText = $"I{CSharpNames.ToCSharpIdentifier(Delegated.Owner.ValidClassName)}"; } string AgentParameters; string ParameterNameListText; if (Overload.ParameterList.Count > 0) { CSharpArgument.BuildParameterList(usingCollection, Overload.ParameterList, out string ParameterListText, out ParameterNameListText); AgentParameters = $"({BaseTypeText} agentBase, {ParameterListText})"; } else { AgentParameters = $"({BaseTypeText} agentBase)"; ParameterNameListText = string.Empty; } Result = $"{AgentParameters} => {{ agentBase.{CSharpNames.ToCSharpIdentifier(Delegated.Name)}({ParameterNameListText}); }}"; return(Result); }