当前位置: 首页>>代码示例>>C#>>正文


C# MemberModel.ParametersString方法代码示例

本文整理汇总了C#中MemberModel.ParametersString方法的典型用法代码示例。如果您正苦于以下问题:C# MemberModel.ParametersString方法的具体用法?C# MemberModel.ParametersString怎么用?C# MemberModel.ParametersString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MemberModel的用法示例。


在下文中一共展示了MemberModel.ParametersString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateClass

        private static void GenerateClass(ScintillaNet.ScintillaControl Sci, String className, ClassModel inClass)
        {
            AddLookupPosition(); // remember last cursor position for Shift+F4

            List<FunctionParameter> parameters = ParseFunctionParameters(Sci, Sci.WordEndPosition(Sci.CurrentPos, true));
            List<MemberModel> constructorArgs = new List<MemberModel>();
            List<String> constructorArgTypes = new List<String>();
            MemberModel paramMember = new MemberModel();
            for (int i = 0; i < parameters.Count; i++)
            {
                FunctionParameter p = parameters[i];
                constructorArgs.Add(new MemberModel(p.param, p.paramType, FlagType.ParameterVar, 0));
                constructorArgTypes.Add(CleanType(getQualifiedType(p.paramQualType, inClass)));
            }
            
            paramMember.Parameters = constructorArgs;

            IProject project = PluginBase.CurrentProject;
            if (String.IsNullOrEmpty(className)) className = "Class";
            string projFilesDir = Path.Combine(PathHelper.TemplateDir, "ProjectFiles");
            string projTemplateDir = Path.Combine(projFilesDir, project.GetType().Name);
            string paramsString = paramMember.ParametersString(true);
            Hashtable info = new Hashtable();
            info["className"] = className;
            info["templatePath"] = Path.Combine(projTemplateDir, "Class.as.fdt");
            info["inDirectory"] = Path.GetDirectoryName(inClass.InFile.FileName);
            info["constructorArgs"] = paramsString.Length > 0 ? paramsString : null;
            info["constructorArgTypes"] = constructorArgTypes;
            DataEvent de = new DataEvent(EventType.Command, "ProjectManager.CreateNewFile", info);
            EventManager.DispatchEvent(null, de);
            if (de.Handled) return;
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:32,代码来源:ASGenerator.cs

示例2: GenerateOverride

        static public void GenerateOverride(ScintillaNet.ScintillaControl Sci, ClassModel ofClass, MemberModel member, int position)
        {
            ContextFeatures features = ASContext.Context.Features;
            List<string> typesUsed = new List<string>();
            bool isProxy = (member.Namespace == "flash_proxy");
            if (isProxy) typesUsed.Add("flash.utils.flash_proxy");
            bool isAS2Event = ASContext.Context.Settings.LanguageId == "AS2" && member.Name.StartsWith("on");
            bool isObjectMethod = ofClass.QualifiedName == "Object";

            int line = Sci.LineFromPosition(position);
            string currentText = Sci.GetLine(line);
            int startPos = currentText.Length;
            GetStartPos(currentText, ref startPos, features.privateKey);
            GetStartPos(currentText, ref startPos, features.protectedKey);
            GetStartPos(currentText, ref startPos, features.internalKey);
            GetStartPos(currentText, ref startPos, features.publicKey);
            GetStartPos(currentText, ref startPos, features.staticKey);
            GetStartPos(currentText, ref startPos, features.overrideKey);
            startPos += Sci.PositionFromLine(line);

            FlagType flags = member.Flags;
            string acc = "";
            string decl = "";
            if (features.hasNamespaces && member.Namespace != null
                && member.Namespace.Length > 0 && member.Namespace != "internal")
                acc = member.Namespace;
            else if ((member.Access & Visibility.Public) > 0) acc = features.publicKey;
            else if ((member.Access & Visibility.Internal) > 0) acc = features.internalKey;
            else if ((member.Access & Visibility.Protected) > 0) acc = features.protectedKey;
            else if ((member.Access & Visibility.Private) > 0) acc = features.privateKey;

            bool isStatic = (flags & FlagType.Static) > 0;
            if (isStatic) acc = features.staticKey + " " + acc;

            if (!isAS2Event && !isObjectMethod)
                acc = features.overrideKey + " " + acc;

            if ((flags & (FlagType.Getter | FlagType.Setter)) > 0)
            {
                string type = member.Type;
                string name = member.Name;
                if (member.Parameters != null && member.Parameters.Count > 0)
                    type = member.Parameters[0].Type;
                type = FormatType(type);
                if (type == null)
                {
                    string message = String.Format(TextHelper.GetString("Info.TypeDeclMissing"), member.Name);
                    ErrorManager.ShowInfo(message);
                    return;
                }

                if (ofClass.Members.Search(name, FlagType.Getter, 0) != null)
                {
                    decl += String.Format(GetTemplate("Getter"),
                        acc, name, type, "super." + name);
                }
                if (ofClass.Members.Search(name, FlagType.Setter, 0) != null)
                {
                    string tpl = GetTemplate("Setter");
                    if (decl.Length > 0)
                    {
                        decl += "\n\n";
                        tpl = tpl.Replace("$(EntryPoint)", "");
                    }
                    decl += String.Format(tpl,
                        acc, name, type, "super." + name, ASContext.Context.Features.voidKey ?? "void");
                }
            }
            else
            {
                string type = FormatType(member.Type);
                if (type == null)
                {
                    string message = String.Format(TextHelper.GetString("Info.TypeDeclMissing"), member.Name);
                    ErrorManager.ShowInfo(message);
                    return;
                }
                if (acc.Length > 0) acc += " ";
                decl = acc + features.functionKey + " ";
                bool noRet = type.Equals("void", StringComparison.OrdinalIgnoreCase);
                type = (noRet) ? ASContext.Context.Features.voidKey : type;
                if (!noRet) typesUsed.Add(getQualifiedType(type, ofClass));
                string action = (isProxy || isAS2Event) ? "" : GetSuperCall(member, typesUsed, ofClass);
                decl += member.Name
                    + String.Format(GetTemplate("MethodOverride"), member.ParametersString(true), type, action);
            }

            Sci.BeginUndoAction();
            try
            {
                if (ASContext.Context.Settings.GenerateImports && typesUsed.Count > 0)
                {
                    int offset = AddImportsByName(typesUsed, line);
                    position += offset;
                    startPos += offset;
                }

                Sci.SetSel(startPos, position + member.Name.Length);
                InsertCode(startPos, decl);
            }
//.........这里部分代码省略.........
开发者ID:heon21st,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs

示例3: GenerateFunctionJob


//.........这里部分代码省略.........
                AddLookupPosition();
                lookupPosition = -1;

                DockContent dc = ASContext.MainForm.OpenEditableDocument(funcResult.relClass.InFile.FileName, true);
                Sci = ASContext.CurSciControl;
                isOtherClass = true;

                FileModel fileModel = new FileModel();
                ASFileParser parser = new ASFileParser();
                parser.ParseSrc(fileModel, Sci.Text);

                foreach (ClassModel cm in fileModel.Classes)
                {
                    if (cm.QualifiedName.Equals(funcResult.relClass.QualifiedName))
                    {
                        funcResult.relClass = cm;
                        break;
                    }
                }
                latest = FindLatest(FlagType.Function, funcVisi, funcResult.relClass);
                inClass = funcResult.relClass;

                ASContext.Context.UpdateContext(inClass.LineFrom);
            }


            // if we generate function in current class..
            if (!isOtherClass)
            {
                if (member == null)
                {
                    detach = false;
                    lookupPosition = -1;
                    position = Sci.WordStartPosition(Sci.CurrentPos, true);
                    Sci.SetSel(position, Sci.WordEndPosition(position, true));
                }
                else
                {
                    position = Sci.PositionFromLine(member.LineTo + 1) - ((Sci.EOLMode == 0) ? 2 : 1);
                    Sci.SetSel(position, position);
                }
            }
            else // if we generate function in another class..
            {
                if (latest != null)
                {
                    position = Sci.PositionFromLine(latest.LineTo + 1) - ((Sci.EOLMode == 0) ? 2 : 1);
                }
                else
                {
                    position = GetBodyStart(inClass.LineFrom, inClass.LineTo, Sci);
                    detach = false;
                }
                Sci.SetSel(position, position);
            }


            // add imports to function argument types
            if (functionParameters.Count > 0)
            {
                List<string> l = new List<string>();
                foreach (FunctionParameter fp in functionParameters)
                {
                    try
                    {
                        l.Add(fp.paramQualType);
                    }
                    catch (Exception)
                    {
                    }
                }
                int o = AddImportsByName(l, Sci.LineFromPosition(position));
                position += o;
                if (latest == null)
                {
                    Sci.SetSel(position, Sci.WordEndPosition(position, true));
                }
                else
                {
                    Sci.SetSel(position, position);
                }
            }


            
            MemberModel m = new MemberModel();
            m.Parameters = new List<MemberModel>();
            for (int i = 0; i < functionParameters.Count; i++)
            {
                string name = functionParameters[i].param;
                string type = functionParameters[i].paramType;
                m.Parameters.Add(new MemberModel(name, type, FlagType.ParameterVar, 0));
            }
            string par = m.ParametersString(true);

            GenerateFunction(
                NewMember(contextToken, isStatic, FlagType.Function,
                        funcVisi),
                position, detach, par, inClass);
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs


注:本文中的MemberModel.ParametersString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。