示例#1
0
        private static void BuildResultListNoResult(ICSharpUsingCollection usingCollection, IList <ICSharpParameter> resultList, ref string parameterListText, ref string parameterNameListText, out string resultTypeText)
        {
            resultTypeText = "void";

            foreach (ICSharpParameter Result in resultList)
            {
                ICSharpScopeAttributeFeature ResultAttribute = Result.Feature;
                ICSharpType       ParameterType   = ResultAttribute.Type;
                CSharpTypeFormats ParameterFormat = ParameterType.HasInterfaceText ? CSharpTypeFormats.AsInterface : CSharpTypeFormats.Normal;

                string TypeString      = ParameterType.Type2CSharpString(usingCollection, ParameterFormat, CSharpNamespaceFormats.None);
                string AttributeString = CSharpNames.ToCSharpIdentifier(Result.Name);

                if (parameterListText.Length > 0)
                {
                    parameterListText += ", ";
                }
                if (parameterNameListText.Length > 0)
                {
                    parameterNameListText += ", ";
                }

                parameterListText     += $"out {TypeString} {AttributeString}";
                parameterNameListText += $"out {AttributeString}";
            }
        }
示例#2
0
        /// <summary>
        /// Builds a list of parameters, with and without their type.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="parameterList">The list of parameters.</param>
        /// <param name="parameterListText">The list of parameters with type upon return.</param>
        /// <param name="parameterNameListText">The list of parameters without type upon return.</param>
        public static void BuildParameterList(ICSharpUsingCollection usingCollection, IList <ICSharpParameter> parameterList, out string parameterListText, out string parameterNameListText)
        {
            parameterListText     = string.Empty;
            parameterNameListText = string.Empty;

            foreach (ICSharpParameter Parameter in parameterList)
            {
                if (parameterListText.Length > 0)
                {
                    parameterListText += ", ";
                }
                if (parameterNameListText.Length > 0)
                {
                    parameterNameListText += ", ";
                }

                string      ParameterName = Parameter.Name;
                ICSharpType ParameterType = Parameter.Feature.Type;

                CSharpTypeFormats ParameterFormat = ParameterType.HasInterfaceText ? CSharpTypeFormats.AsInterface : CSharpTypeFormats.Normal;

                string ParameterText     = ParameterType.Type2CSharpString(usingCollection, ParameterFormat, CSharpNamespaceFormats.None);
                string ParameterNameText = CSharpNames.ToCSharpIdentifier(ParameterName);

                parameterListText     += $"{ParameterText} {ParameterNameText}";
                parameterNameListText += ParameterNameText;
            }
        }
        /// <summary>
        /// Get the name of a type.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="cSharpTypeFormat">The type format.</param>
        /// <param name="cSharpNamespaceFormat">The namespace format.</param>
        public override string Type2CSharpString(ICSharpUsingCollection usingCollection, CSharpTypeFormats cSharpTypeFormat, CSharpNamespaceFormats cSharpNamespaceFormat)
        {
            SetUsedInCode();

            string Result;

            if (OriginatingTypedef != null)
            {
                // TODO
                string DelegateName = CSharpNames.ToCSharpIdentifier(OriginatingTypedef.Name);

                Result = PropertyType2CSharpString(DelegateName);
            }
            else
            {
                string BaseTypeText   = BaseType.Type2CSharpString(usingCollection, CSharpTypeFormats.AsInterface, CSharpNamespaceFormats.None);
                string EntityTypeText = EntityType.Type2CSharpString(usingCollection, CSharpTypeFormats.AsInterface, CSharpNamespaceFormats.None);

                Result = $"Func<{BaseTypeText}, {EntityTypeText}>";

                usingCollection.AddUsing(nameof(System));
            }

            return(Result);
        }
示例#4
0
        /// <summary>
        /// Builds a list of parameters, with and without their type.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="parameterList">The list of parameters.</param>
        /// <param name="resultList">The list of results.</param>
        /// <param name="featureTextType">The write mode.</param>
        /// <param name="parameterListText">The list of parameters with type upon return.</param>
        /// <param name="parameterNameListText">The list of parameters without type upon return.</param>
        /// <param name="resultTypeText">The type text upon return.</param>
        public static void BuildParameterList(ICSharpUsingCollection usingCollection, IList <ICSharpParameter> parameterList, IList <ICSharpParameter> resultList, CSharpFeatureTextTypes featureTextType, out string parameterListText, out string parameterNameListText, out string resultTypeText)
        {
            parameterListText     = string.Empty;
            parameterNameListText = string.Empty;

            foreach (ICSharpParameter Parameter in parameterList)
            {
                if (parameterListText.Length > 0)
                {
                    parameterListText += ", ";
                }
                if (parameterNameListText.Length > 0)
                {
                    parameterNameListText += ", ";
                }

                string      ParameterName = Parameter.Name;
                ICSharpType ParameterType = Parameter.Feature.Type;

                CSharpTypeFormats ParameterFormat = ParameterType.HasInterfaceText ? CSharpTypeFormats.AsInterface : CSharpTypeFormats.Normal;

                string ParameterText     = ParameterType.Type2CSharpString(usingCollection, ParameterFormat, CSharpNamespaceFormats.None);
                string ParameterNameText = CSharpNames.ToCSharpIdentifier(ParameterName);

                parameterListText     += $"{ParameterText} {ParameterNameText}";
                parameterNameListText += ParameterNameText;
            }

            if (resultList.Count == 1)
            {
                BuildResultListSingle(usingCollection, resultList, out resultTypeText);
            }
            else
            {
                int ResultIndex = -1;
                for (int i = 0; i < resultList.Count; i++)
                {
                    ICSharpParameter Result = resultList[i];
                    if (Result.Name == nameof(BaseNode.Keyword.Result))
                    {
                        ResultIndex = i;
                        break;
                    }
                }

                if (ResultIndex < 0)
                {
                    BuildResultListNoResult(usingCollection, resultList, ref parameterListText, ref parameterNameListText, out resultTypeText);
                }
                else
                {
                    BuildResultListWithResult(usingCollection, resultList, ResultIndex, ref parameterListText, ref parameterNameListText, out resultTypeText);
                }
            }
        }
示例#5
0
        private static void BuildResultListSingle(ICSharpUsingCollection usingCollection, IList <ICSharpParameter> resultList, out string resultTypeText)
        {
            Debug.Assert(resultList.Count == 1);

            ICSharpParameter             Result          = resultList[0];
            ICSharpScopeAttributeFeature ResultAttribute = Result.Feature;

            /*if (FeatureTextType == FeatureTextTypes.Interface)
             *  ResultType = CSharpTypes.Type2CSharpString(ResultAttribute.ResolvedFeatureType.Item, Context, CSharpTypeFormats.AsInterface);
             * else
             *  ResultType = CSharpTypes.Type2CSharpString(ResultAttribute.ResolvedFeatureType.Item, Context, CSharpTypeFormats.None);*/
            resultTypeText = ResultAttribute.Type.Type2CSharpString(usingCollection, CSharpTypeFormats.AsInterface, CSharpNamespaceFormats.None);
        }
示例#6
0
        /// <summary>
        /// Gets the singleton text corresponding to this type, if any.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="cSharpTypeFormat">The type format.</param>
        /// <param name="cSharpNamespaceFormat">The namespace format.</param>
        /// <param name="text">The singleton text upon return, if successful.</param>
        public override bool GetSingletonString(ICSharpUsingCollection usingCollection, CSharpTypeFormats cSharpTypeFormat, CSharpNamespaceFormats cSharpNamespaceFormat, out string text)
        {
            text = null;

            if (Class.Source.Cloneable != BaseNode.CloneableStatus.Single)
            {
                return(false);
            }

            string ClassTypeText = Type2CSharpString(usingCollection, cSharpTypeFormat, cSharpNamespaceFormat);

            text = $"{ClassTypeText}.Singleton";
            return(true);
        }
        /// <summary>
        /// Gets the source code corresponding to the qualified name.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="skippedAtEnd">Number of identifiers to skip at the end.</param>
        public string CSharpText(ICSharpUsingCollection usingCollection, int skippedAtEnd)
        {
            string Result;
            int    i = 0;

            /*
             * if (Context.AttachmentAliasTable.ContainsKey(ValidPath.Item[i].ValidText.Item))
             * {
             *  Result = Context.AttachmentAliasTable[ValidPath.Item[i].ValidText.Item];
             *  i++;
             * }
             * else*/
            Result = string.Empty;

            for (; i + skippedAtEnd < Source.ValidPath.Item.Count; i++)
            {
                if (Result.Length > 0)
                {
                    Result += ".";
                }

                IIdentifier  Item      = Source.ValidPath.Item[i];
                ICSharpClass ItemClass = i < ClassPath.Count ? ClassPath[i] : null;
                string       ItemText  = Item.ValidText.Item;

                if (i == 0 && usingCollection.AttachmentMap.ContainsKey(Item.ValidText.Item))
                {
                    ItemText = usingCollection.AttachmentMap[ItemText];
                }
                else
                {
                    ItemText = CSharpNames.ToCSharpIdentifier(ItemText);
                }

                if (ItemClass != null)
                {
                    if (ItemClass.IsUnparameterizedSingleton && ItemClass.ValidSourceName != "Microsoft .NET")
                    {
                        string TypeText = ItemClass.Type.Type2CSharpString(usingCollection, CSharpTypeFormats.Normal, CSharpNamespaceFormats.None);
                        ItemText = $"{TypeText}.Singleton";
                    }
                }

                Result += ItemText;
            }

            return(Result);
        }
        /// <summary>
        /// Gets the source code corresponding to the qualified name.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="skippedAtEnd">Number of identifiers to skip at the end.</param>
        public string DecoratedCSharpText(ICSharpUsingCollection usingCollection, int skippedAtEnd)
        {
            string Result = null;

            string QueryText = CSharpText(usingCollection, skippedAtEnd);

            if (Discrete != null)
            {
                Result = QueryText;
            }
            else
            {
                switch (Feature)
                {
                case ICSharpPropertyFeature AsPropertyFeature:
                    if (AsPropertyFeature.HasSideBySideAttribute || InheritBySideAttribute)
                    {
                        Result = $"_{QueryText}";
                    }
                    else
                    {
                        Result = QueryText;
                    }
                    break;

                case ICSharpAttributeFeature AsAttributeFeature:
                case ICSharpConstantFeature AsConstantFeature:
                case ICSharpScopeAttributeFeature AsScopeAttributeFeature:
                    Result = QueryText;
                    break;

                case ICSharpFunctionFeature AsFunctionFeature:
                case ICSharpCreationFeature AsCreationFeature:
                case ICSharpProcedureFeature AsProcedureFeature:
                    Result = $"{QueryText}()";
                    break;
                }
            }

            Debug.Assert(Result != null);

            return(Result);
        }
示例#9
0
        private string CSharpTextProperty(ICSharpUsingCollection usingCollection, ICSharpPropertyFeature feature)
        {
            string Result;

            string BaseTypeText;

            if (BaseType != null)
            {
                BaseTypeText = EffectiveBaseType.Type2CSharpString(usingCollection, CSharpTypeFormats.AsInterface, CSharpNamespaceFormats.OneWord);
            }
            else
            {
                BaseTypeText = $"I{CSharpNames.ToCSharpIdentifier(Delegated.Owner.ValidClassName)}";
            }

            Result = $"({BaseTypeText} agentBase) => {{ return agentBase.{CSharpNames.ToCSharpIdentifier(Delegated.Name)}; }}";

            return(Result);
        }
        /// <summary>
        /// Gets the source code corresponding to the qualified name setter.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        public string CSharpSetter(ICSharpUsingCollection usingCollection)
        {
            string StartText;

            if (Source.ValidPath.Item.Count > 1)
            {
                StartText  = CSharpText(usingCollection, 1);
                StartText += ".";
            }
            else
            {
                StartText = string.Empty;
            }

            IIdentifier Item       = Source.ValidPath.Item[0];
            string      ItemText   = CSharpNames.ToCSharpIdentifier(Item.ValidText.Item);
            string      SetterText = $"{StartText}Set_{ItemText}";

            return(SetterText);
        }
示例#11
0
        private string CSharpTextFunction(ICSharpUsingCollection usingCollection, ICSharpFunctionFeature feature)
        {
            string Result;

            // TODO handle several overloads.

            Debug.Assert(feature.OverloadList.Count > 0);
            ICSharpQueryOverload Overload = feature.OverloadList[0] as ICSharpQueryOverload;

            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} => {{ return agentBase.{CSharpNames.ToCSharpIdentifier(Delegated.Name)}({ParameterNameListText}); }}";

            return(Result);
        }
示例#12
0
        private static void BuildResultListWithResult(ICSharpUsingCollection usingCollection, IList <ICSharpParameter> resultList, int resultIndex, ref string parameterListText, ref string parameterNameListText, out string resultTypeText)
        {
            resultTypeText = null;

            for (int i = 0; i < resultList.Count; i++)
            {
                ICSharpParameter             Result          = resultList[i];
                ICSharpScopeAttributeFeature ResultAttribute = Result.Feature;
                ICSharpType       ParameterType   = ResultAttribute.Type;
                CSharpTypeFormats ParameterFormat = ParameterType.HasInterfaceText ? CSharpTypeFormats.AsInterface : CSharpTypeFormats.Normal;

                string TypeString      = ParameterType.Type2CSharpString(usingCollection, ParameterFormat, CSharpNamespaceFormats.None);
                string AttributeString = CSharpNames.ToCSharpIdentifier(Result.Name);

                if (i == resultIndex)
                {
                    resultTypeText = TypeString;
                }
                else
                {
                    if (parameterListText.Length > 0)
                    {
                        parameterListText += ", ";
                    }
                    if (parameterNameListText.Length > 0)
                    {
                        parameterNameListText += ", ";
                    }

                    parameterListText     += $"out {TypeString} {AttributeString}";
                    parameterNameListText += $"out {AttributeString}";
                }
            }

            Debug.Assert(resultTypeText != null);
        }
示例#13
0
        /// <summary>
        /// Get the name of a type.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="cSharpTypeFormat">The type format.</param>
        /// <param name="cSharpNamespaceFormat">The namespace format.</param>
        public override string Type2CSharpString(ICSharpUsingCollection usingCollection, CSharpTypeFormats cSharpTypeFormat, CSharpNamespaceFormats cSharpNamespaceFormat)
        {
            SetUsedInCode();

            string Result;

            // TODO: detect delegate call parameters to select the proper overload

            if (OriginatingTypedef != null)
            {
                string DelegateName = CSharpNames.ToCSharpIdentifier(OriginatingTypedef.Name);

                Result = CommandOverloadType2CSharpString(DelegateName, Source.OverloadList[0]);
            }
            else
            {
                ICSharpCommandOverloadType OverloadType = OverloadTypeList[0];

                string ActionArgumentText = BaseType.Type2CSharpString(usingCollection, CSharpTypeFormats.AsInterface, CSharpNamespaceFormats.None);

                foreach (ICSharpParameter Parameter in OverloadType.ParameterList)
                {
                    ICSharpType       ParameterType   = Parameter.Feature.Type;
                    CSharpTypeFormats ParameterFormat = ParameterType.HasInterfaceText ? CSharpTypeFormats.AsInterface : CSharpTypeFormats.Normal;
                    string            ParameterText   = ParameterType.Type2CSharpString(usingCollection, ParameterFormat, CSharpNamespaceFormats.None);

                    ActionArgumentText += $", {ParameterText}";
                }

                Result = $"Action<{ActionArgumentText}>";

                usingCollection.AddUsing(nameof(System));
            }

            return(Result);
        }
示例#14
0
        /// <summary>
        /// Gets the string corresponding to the enumeration of C# generic arguments.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="typeArgumentList">The list of arguments.</param>
        /// <param name="isWithInterface">If true, include the interface type.</param>
        /// <param name="isWithImplementation">If true, include the implementation type.</param>
        protected static string TypeArguments2CSharpName(ICSharpUsingCollection usingCollection, IList <ICSharpType> typeArgumentList, bool isWithInterface, bool isWithImplementation)
        {
            Debug.Assert(isWithInterface || isWithImplementation);

            string GenericNames = string.Empty;

            foreach (ICSharpType TypeArgument in typeArgumentList)
            {
                if (GenericNames.Length > 0)
                {
                    GenericNames += ", ";
                }

                if (isWithInterface)
                {
                    GenericNames += TypeArgument.Type2CSharpString(usingCollection, CSharpTypeFormats.AsInterface, CSharpNamespaceFormats.None);
                }

                if (isWithImplementation)
                {
                    if (isWithInterface)
                    {
                        GenericNames += "," + " ";
                    }

                    GenericNames += TypeArgument.Type2CSharpString(usingCollection, CSharpTypeFormats.Normal, CSharpNamespaceFormats.None);
                }
            }

            if (GenericNames.Length > 0)
            {
                GenericNames = "<" + GenericNames + ">";
            }

            return(GenericNames);
        }
示例#15
0
        /// <summary>
        /// Get the name of a type.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="cSharpTypeFormat">The type format.</param>
        /// <param name="cSharpNamespaceFormat">The namespace format.</param>
        public override string Type2CSharpString(ICSharpUsingCollection usingCollection, CSharpTypeFormats cSharpTypeFormat, CSharpNamespaceFormats cSharpNamespaceFormat)
        {
            SetUsedInCode();

            Debug.Assert(Class != null);
            Debug.Assert(Class.Source != null);

            Guid   BaseClassGuid = Class.Source.ClassGuid;
            bool   AsInterface   = cSharpTypeFormat == CSharpTypeFormats.AsInterface;
            bool   TypeArgumentsWithInterface      = true;
            bool   TypeArgumentsWithImplementation = false;
            string Result = null;

            if (BaseClassGuid == LanguageClasses.BitFieldEnumeration.Guid)
            {
                Result = CSharpNames.ToCSharpIdentifier(Class.ValidClassName);
            }
            else if (BaseClassGuid == LanguageClasses.DetachableReference.Guid)
            {
                Result = "DetachableReference" + TypeArguments2CSharpName(usingCollection, TypeArgumentList, TypeArgumentsWithInterface, TypeArgumentsWithImplementation);
            }
            else if (BaseClassGuid == LanguageClasses.Hashtable.Guid)
            {
                Result = "Hashtable" + TypeArguments2CSharpName(usingCollection, TypeArgumentList, TypeArgumentsWithInterface, TypeArgumentsWithImplementation);
            }
            else if (BaseClassGuid == LanguageClasses.KeyValuePair.Guid)
            {
                Result = "KeyValuePair" + TypeArguments2CSharpName(usingCollection, TypeArgumentList, TypeArgumentsWithInterface, TypeArgumentsWithImplementation);
            }
            else if (BaseClassGuid == LanguageClasses.List.Guid)
            {
                string ClassName;

                if (AsInterface)
                {
                    ClassName = "IList";
                }
                else
                {
                    ClassName = "List";
                }

                Result = ClassName + TypeArguments2CSharpName(usingCollection, TypeArgumentList, TypeArgumentsWithInterface, TypeArgumentsWithImplementation);

                usingCollection.AddUsing("System.Collections.Generic");
            }
            else if (BaseClassGuid == LanguageClasses.OnceReference.Guid)
            {
                Result = "OnceReference" + TypeArguments2CSharpName(usingCollection, TypeArgumentList, TypeArgumentsWithInterface, TypeArgumentsWithImplementation);
            }
            else if (BaseClassGuid == LanguageClasses.OptionalReference.Guid)
            {
                Result = "OptionalReference" + TypeArguments2CSharpName(usingCollection, TypeArgumentList, TypeArgumentsWithInterface, TypeArgumentsWithImplementation);
            }
            else if (BaseClassGuid == LanguageClasses.OverLoopSource.Guid)
            {
                Result = "Enumerable" + TypeArguments2CSharpName(usingCollection, TypeArgumentList, TypeArgumentsWithInterface, TypeArgumentsWithImplementation);
            }
            else if (BaseClassGuid == LanguageClasses.SealableHashtable.Guid)
            {
                Result = "Hashtable" + TypeArguments2CSharpName(usingCollection, TypeArgumentList, TypeArgumentsWithInterface, TypeArgumentsWithImplementation);
            }
            else if (BaseClassGuid == LanguageClasses.SpecializedTypeEntity.Guid)
            {
                Result = "SpecializedTypeEntity" + TypeArguments2CSharpName(usingCollection, TypeArgumentList, false, true);
            }
            else if (BaseClassGuid == LanguageClasses.StableReference.Guid)
            {
                Result = "StableReference" + TypeArguments2CSharpName(usingCollection, TypeArgumentList, TypeArgumentsWithInterface, TypeArgumentsWithImplementation);
            }
            else if (LanguageClasses.GuidToName.ContainsKey(BaseClassGuid))
            {
                Result = null;

                if (BaseClassGuid == LanguageClasses.Number.Guid)
                {
                    Debug.Assert(Source.NumberKind != NumberKinds.NotChecked && Source.NumberKind != NumberKinds.NotApplicable);

                    if (Source.NumberKind == NumberKinds.Integer)
                    {
                        Result = "int";
                    }
                    else if (Source.NumberKind == NumberKinds.Real)
                    {
                        Result = "double";
                    }
                }

                if (Result == null)
                {
                    Result = CSharpLanguageClasses.GuidToName[BaseClassGuid];
                }

                if (CSharpLanguageClasses.NameUsingTable.ContainsKey(Result))
                {
                    string UsingDirective = CSharpLanguageClasses.NameUsingTable[Result];
                    usingCollection.AddUsing(UsingDirective);
                }
            }
            else
            {
                string ClassName;

                if (Class.Source.IsEnumeration)
                {
                    cSharpTypeFormat = CSharpTypeFormats.Normal;
                }
                ClassName = Class.BasicClassName2CSharpClassName(usingCollection, cSharpTypeFormat, cSharpNamespaceFormat);

                Result = ClassName + TypeArguments2CSharpName(usingCollection, TypeArgumentList, true, true);
            }

            return(Result);
        }
        /// <summary>
        /// Get the name of a type.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="cSharpTypeFormat">The type format.</param>
        /// <param name="cSharpNamespaceFormat">The namespace format.</param>
        public override string Type2CSharpString(ICSharpUsingCollection usingCollection, CSharpTypeFormats cSharpTypeFormat, CSharpNamespaceFormats cSharpNamespaceFormat)
        {
            SetUsedInCode();

            string Result;

            if (OriginatingTypedef != null)
            {
                // TODO: detect delegate call parameters to select the proper overload
                string DelegateName = CSharpNames.ToCSharpIdentifier(OriginatingTypedef.Name);

                Result = QueryOverloadType2CSharpString(DelegateName, Source.OverloadList[0]);
            }
            else
            {
                ICSharpQueryOverloadType OverloadType = OverloadTypeList[0];

                string ActionArgumentText = BaseType.Type2CSharpString(usingCollection, CSharpTypeFormats.AsInterface, CSharpNamespaceFormats.None);

                foreach (ICSharpParameter Parameter in OverloadType.ParameterList)
                {
                    ICSharpType       ParameterType   = Parameter.Feature.Type;
                    CSharpTypeFormats ParameterFormat = ParameterType.HasInterfaceText ? CSharpTypeFormats.AsInterface : CSharpTypeFormats.Normal;
                    string            ParameterText   = ParameterType.Type2CSharpString(usingCollection, ParameterFormat, CSharpNamespaceFormats.None);

                    ActionArgumentText += $", {ParameterText}";
                }

                Debug.Assert(OverloadType.ResultList.Count >= 1);

                if (OverloadType.ResultList.Count == 1)
                {
                    ICSharpParameter  Parameter    = OverloadType.ResultList[0];
                    ICSharpType       ResultType   = Parameter.Feature.Type;
                    CSharpTypeFormats ResultFormat = ResultType.HasInterfaceText ? CSharpTypeFormats.AsInterface : CSharpTypeFormats.Normal;
                    string            ResultText   = ResultType.Type2CSharpString(usingCollection, ResultFormat, CSharpNamespaceFormats.None);

                    ActionArgumentText += $", {ResultText}";
                }
                else
                {
                    string FuncResultText = string.Empty;

                    foreach (ICSharpParameter Parameter in OverloadType.ResultList)
                    {
                        if (FuncResultText.Length > 0)
                        {
                            FuncResultText += ", ";
                        }

                        ICSharpType       ResultType   = Parameter.Feature.Type;
                        CSharpTypeFormats ResultFormat = ResultType.HasInterfaceText ? CSharpTypeFormats.AsInterface : CSharpTypeFormats.Normal;
                        string            ResultText   = ResultType.Type2CSharpString(usingCollection, ResultFormat, CSharpNamespaceFormats.None);

                        FuncResultText += $", {ResultText}";
                    }

                    ActionArgumentText += $", Tuple<{FuncResultText}>";
                }

                Result = $"Func<{ActionArgumentText}>";

                usingCollection.AddUsing(nameof(System));
            }

            return(Result);
        }
        /// <summary>
        /// Get the name of a type.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="cSharpTypeFormat">The type format.</param>
        /// <param name="cSharpNamespaceFormat">The namespace format.</param>
        public override string Type2CSharpString(ICSharpUsingCollection usingCollection, CSharpTypeFormats cSharpTypeFormat, CSharpNamespaceFormats cSharpNamespaceFormat)
        {
            SetUsedInCode();

            return("<Not Supported>");
        }
示例#18
0
 /// <summary>
 /// Gets the singleton text corresponding to this type, if any.
 /// </summary>
 /// <param name="usingCollection">The collection of using directives.</param>
 /// <param name="cSharpTypeFormat">The type format.</param>
 /// <param name="cSharpNamespaceFormat">The namespace format.</param>
 /// <param name="text">The singleton text upon return, if successful.</param>
 public virtual bool GetSingletonString(ICSharpUsingCollection usingCollection, CSharpTypeFormats cSharpTypeFormat, CSharpNamespaceFormats cSharpNamespaceFormat, out string text)
 {
     text = null;
     return(false);
 }
示例#19
0
 /// <summary>
 /// Get the name of a type.
 /// </summary>
 /// <param name="usingCollection">The collection of using directives.</param>
 /// <param name="cSharpTypeFormat">The type format.</param>
 /// <param name="cSharpNamespaceFormat">The namespace format.</param>
 public abstract string Type2CSharpString(ICSharpUsingCollection usingCollection, CSharpTypeFormats cSharpTypeFormat, CSharpNamespaceFormats cSharpNamespaceFormat);
示例#20
0
        /// <summary>
        /// Get the name of a type.
        /// </summary>
        /// <param name="usingCollection">The collection of using directives.</param>
        /// <param name="cSharpTypeFormat">The type format.</param>
        /// <param name="cSharpNamespaceFormat">The namespace format.</param>
        public override string Type2CSharpString(ICSharpUsingCollection usingCollection, CSharpTypeFormats cSharpTypeFormat, CSharpNamespaceFormats cSharpNamespaceFormat)
        {
            SetUsedInCode();

            return(((cSharpTypeFormat == CSharpTypeFormats.AsInterface) ? "I" : string.Empty) + CSharpNames.ToCSharpIdentifier(Generic.Name));
        }