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


C# MemberModel.ToDeclarationString方法代码示例

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


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

示例1: GetDeclaration

 static private string GetDeclaration(MemberModel member, bool addModifiers)
 {
     // modifiers
     string modifiers = TemplateUtils.GetStaticExternOverride(member);
     if (addModifiers) modifiers += TemplateUtils.GetModifiers(member);
     
     // signature
     FlagType ft = member.Flags;
     if ((ft & FlagType.Getter) > 0)
         return String.Format("{0}function get {1}", modifiers, member.ToDeclarationString());
     else if ((ft & FlagType.Setter) > 0)
         return String.Format("{0}function set {1}", modifiers, member.ToDeclarationString());
     else if (ft == FlagType.Function)
         return String.Format("{0}function {1}", modifiers, member.ToDeclarationString());
     else if (((ft & FlagType.Constant) > 0) && ASContext.Context.Settings.LanguageId != "AS2")
         return String.Format("{0}const {1}", modifiers, member.ToDeclarationString());
     else
         return String.Format("{0}var {1}", modifiers, member.ToDeclarationString());
 }
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:19,代码来源:ASGenerator.cs

示例2: GetDeclaration

 static private string GetDeclaration(MemberModel member, bool addModifiers)
 {
     // modifiers
     FlagType ft = member.Flags;
     Visibility acc = member.Access;
     string modifiers = "";
     if ((ft & FlagType.Extern) > 0)
         modifiers += "extern ";
     if ((ft & FlagType.Static) > 0)
         modifiers += "static ";
     if ((acc & Visibility.Private) > 0 && addModifiers)
         modifiers += "private ";
     else if ((acc & Visibility.Public) > 0 && addModifiers)
         modifiers += "public ";
     else if ((acc & Visibility.Protected) > 0 && addModifiers)
         modifiers += "protected ";
     else if ((acc & Visibility.Internal) > 0 && addModifiers)
         modifiers += "internal ";
     // signature
     if ((ft & FlagType.Getter) > 0)
         return String.Format("{0}function get {1}", modifiers, member.ToDeclarationString());
     else if ((ft & FlagType.Setter) > 0)
         return String.Format("{0}function set {1}", modifiers, member.ToDeclarationString());
     else if ((ft & FlagType.Function) > 0)
         return String.Format("{0}function {1}", modifiers, member.ToDeclarationString());
     else if (((ft & FlagType.Constant) > 0) && ASContext.Context.Settings.LanguageId != "AS2")
         return String.Format("{0}const {1}", modifiers, member.ToDeclarationString());
     else
         return String.Format("{0}var {1}", modifiers, member.ToDeclarationString());
 }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:30,代码来源:ASGenerator.cs

示例3: MemberDeclaration

        static public string MemberDeclaration(MemberModel member, bool preventVisibility)
        {
            // modifiers
            FlagType ft = member.Flags;
            Visibility acc = member.Access;
            string modifiers = "";
            if ((ft & FlagType.Intrinsic) > 0)
            {
                if ((ft & FlagType.Extern) > 0) modifiers += "extern ";
                else modifiers += "intrinsic ";
            }
            else if (!string.IsNullOrEmpty(member.Namespace) 
                && member.Namespace != "internal")
            {
                if ((ft & FlagType.Interface) == 0)
                    modifiers = member.Namespace + " ";
            }
            else if (!preventVisibility)
            {
                if ((member.Flags & FlagType.Interface) == 0)
                {
                    if ((acc & Visibility.Public) > 0) modifiers += "public ";
                //  else if ((acc & Visibility.Internal) > 0) modifiers += "internal "; // AS3 default
                    else if ((acc & Visibility.Protected) > 0) modifiers += "protected ";
                    else if ((acc & Visibility.Private) > 0) modifiers += "private ";
                }
            }

            if ((ft & FlagType.Final) > 0)
                modifiers += "final ";

            if ((ft & FlagType.Enum) > 0)
            {
                return member.ToString();
            }
            else if ((ft & FlagType.Class) > 0)
            {
                if ((ft & FlagType.Dynamic) > 0)
                    modifiers += "dynamic ";
                string classType = "class";
                if ((member.Flags & FlagType.Interface) > 0) classType = "interface";
                else if ((member.Flags & FlagType.Enum) > 0) classType = "enum";
                else if ((member.Flags & FlagType.Abstract) > 0) classType = "abstract";
                else if ((member.Flags & FlagType.TypeDef) > 0) classType = "typedef";
                else if ((member.Flags & FlagType.Struct) > 0) classType = "struct";
                else if ((member.Flags & FlagType.Delegate) > 0) classType = "delegate";
                return String.Format("{0}{1} {2}", modifiers, classType, member.Type);
            }
            else if ((ft & FlagType.Enum) == 0)
            {
                if ((ft & FlagType.Native) > 0)
                    modifiers += "native ";
                if ((ft & FlagType.Static) > 0)
                    modifiers += "static ";
            }

            // signature
            if ((ft & FlagType.Namespace) > 0)
            {
                return String.Format("{0}namespace {1}", modifiers, member.Name);
            }
            else if ((ft & FlagType.Variable) > 0)
            {
                if ((ft & FlagType.LocalVar) > 0) modifiers = "local ";
                if ((ft & FlagType.Constant) > 0)
                {
                    if (member.Value == null)
                        return String.Format("{0}const {1}", modifiers, member.ToDeclarationString());
                    else
                        return String.Format("{0}const {1} = {2}", modifiers, member.ToDeclarationString(), member.Value);
                }
                else return String.Format("{0}var {1}", modifiers, member.ToDeclarationString());
            }
            else if ((ft & (FlagType.Getter | FlagType.Setter)) > 0)
                return String.Format("{0}property {1}", modifiers, member.ToString());
            else if ((ft & FlagType.Delegate) > 0)
                return String.Format("{0}delegate {1}", modifiers, member.ToString());
            else if ((ft & FlagType.Function) > 0)
                return String.Format("{0}function {1}", modifiers, member.ToString());
            else if (ft == FlagType.Package)
                return String.Format("Package {0}", member.Type);
            else if (ft == FlagType.Template)
                return String.Format("Template {0}", member.Type);
            else if (ft == FlagType.Declaration)
                return String.Format("Declaration {0}", member.Type);
            else
                return String.Format("{0}type {1}", modifiers, member.Type);
        }
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:88,代码来源:ClassModel.cs

示例4: AddInterfaceDefJob

        private static void AddInterfaceDefJob(ClassModel inClass, ScintillaNet.ScintillaControl Sci, MemberModel member)
        {
            ClassModel aType = ASContext.Context.ResolveType(contextParam, ASContext.Context.CurrentModel);
            if (aType.IsVoid()) return;

            FileModel fileModel = ASFileParser.ParseFile(aType.InFile.FileName, ASContext.Context);
            foreach (ClassModel cm in fileModel.Classes)
            {
                if (cm.QualifiedName.Equals(aType.QualifiedName))
                {
                    aType = cm;
                    break;
                }
            }

            StringBuilder snippet = new StringBuilder();


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

            MemberModel latest = FindLatest(FlagType.Function, aType);
            int position;
            if (latest == null)
            {
                position = GetBodyStart(aType.LineFrom, aType.LineTo, Sci);
            }
            else
            {
                position = Sci.PositionFromLine(latest.LineTo + 1) - ((Sci.EOLMode == 0) ? 1 : 0);
                snippet.Append(NewLine);
            }
            Sci.SetSel(position, position);
            Sci.CurrentPos = position;

            List<MemberModel> parms = member.Parameters;
            snippet.Append("function ")
                .Append(member.ToDeclarationString())
                .Append(";");

            List<string> importsList = new List<string>();
            string t;
            if (parms != null && parms.Count > 0)
            {
                for (int i = 0; i < parms.Count; i++)
                {
                    if (parms[i].Type != null)
                    {
                        t = getQualifiedType(parms[i].Type, inClass); 
                        importsList.Add(t);
                    }
                }
            }

            if (member.Type != null)
            {
                t = getQualifiedType(member.Type, inClass);
                importsList.Add(t);
            }

            if (importsList.Count > 0)
            {
                int o = AddImportsByName(importsList, Sci.LineFromPosition(position));
                position += o;
                Sci.SetSel(position, position);
            }

            InsertCode(position, snippet.ToString());

            Sci.CurrentPos = position;
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:71,代码来源:ASGenerator.cs


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