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


C# MemberModel.Clone方法代码示例

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


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

示例1: IsImported

        /// <summary>
        /// Check if a type is already in the file's imports
        /// Throws an Exception if the type name is ambiguous 
        /// (ie. same name as an existing import located in another package)
        /// </summary>
        /// <param name="member">Element to search in imports</param>
        /// <param name="atLine">Position in the file</param>
        public override bool IsImported(MemberModel member, int atLine)
        {
            int p = member.Name.IndexOf('#');
            if (p > 0)
            {
                member = member.Clone() as MemberModel;
                member.Name = member.Name.Substring(0, p);
            }

            FileModel cFile = ASContext.Context.CurrentModel;
            string fullName = member.Type;
            string name = member.Name;
            foreach (MemberModel import in cFile.Imports)
            {
                if (import.Name == name)
                {
                    //if (import.Type != fullName) throw new Exception(TextHelper.GetString("Info.AmbiguousType"));
                    return true;
                }
                else if (import.Name == "*" && import.Type.Replace("*", name) == fullName)
                    return true;
                else if (fullName.StartsWithOrdinal(import.Type + "."))
                    return true;
            }
            return false;
        }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:33,代码来源:Context.cs

示例2: AddAsParameter

        private static void AddAsParameter(ClassModel inClass, ScintillaNet.ScintillaControl Sci, MemberModel member, bool detach)
        {
            if (!RemoveLocalDeclaration(Sci, contextMember)) return;

            int posStart = Sci.PositionFromLine(member.LineFrom);
            int posEnd = Sci.LineEndPosition(member.LineTo);
            Sci.SetSel(posStart, posEnd);
            string selectedText = Sci.SelText;
            Regex rStart = new Regex(@"\s{1}" + member.Name + @"\s*\(([^\)]*)\)(\s*:\s*([^({{|\n|\r|\s|;)]+))?");
            Match mStart = rStart.Match(selectedText);
            if (!mStart.Success)
                return;

            int start = mStart.Index + posStart + 1;
            int end = mStart.Index + posStart + mStart.Length;

            Sci.SetSel(start, end);

            MemberModel memberCopy = (MemberModel) member.Clone();

            if (memberCopy.Parameters == null)
                memberCopy.Parameters = new List<MemberModel>();

            memberCopy.Parameters.Add(contextMember);

            string template = TemplateUtils.ToDeclarationString(memberCopy, TemplateUtils.GetTemplate("MethodDeclaration"));
            InsertCode(start, template);

            int currPos = Sci.LineEndPosition(Sci.CurrentLine);

            Sci.SetSel(currPos, currPos);
            Sci.CurrentPos = currPos;
        }
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:33,代码来源:ASGenerator.cs

示例3: IsImported

        /// <summary>
        /// Check if a type is already in the file's imports
        /// Throws an Exception if the type name is ambiguous 
        /// (ie. same name as an existing import located in another package)
        /// </summary>
        /// <param name="member">Element to search in imports</param>
        /// <param name="atLine">Position in the file</param>
        public override bool IsImported(MemberModel member, int atLine)
        {
            int p = member.Name.IndexOf('#');
            if (p > 0)
            {
                member = member.Clone() as MemberModel;
                member.Name = member.Name.Substring(0, p);
            }

            FileModel cFile = ASContext.Context.CurrentModel;
            string fullName = member.Type;
            string name = member.Name;
            int lineMin = (ASContext.Context.InPrivateSection) ? cFile.PrivateSectionIndex : 0;
            int lineMax = atLine;
            foreach (MemberModel import in cFile.Imports)
            {
                if (import.LineFrom >= lineMin && import.LineFrom <= lineMax && import.Name == name)
                {
                    if (import.Type != fullName) throw new Exception(TextHelper.GetString("Info.AmbiguousType"));
                    return true;
                }
                else if (import.Name == "*" && import.Type.Replace("*", name) == fullName)
                    return true;
            }
            return false;
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:33,代码来源:Context.cs


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