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


C# IPropertyDefinition.GetHiddenBaseProperty方法代码示例

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


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

示例1: WritePropertyDefinition

        private void WritePropertyDefinition(IPropertyDefinition property)
        {
            bool isInterfaceProp = property.ContainingTypeDefinition.IsInterface;
            IMethodDefinition accessor = null;
            IMethodDefinition getter = null;
            IMethodDefinition setter = null;
            if (property.Getter != null)
            {
                getter = property.Getter.ResolvedMethod;
                if (!_filter.Include(getter))
                    getter = null;
                accessor = getter;
            }

            if (property.Setter != null)
            {
                setter = property.Setter.ResolvedMethod;
                if (!_filter.Include(setter))
                    setter = null;
                if (accessor == null)
                    accessor = setter;
            }

            if (accessor == null)
                return;

            bool isIndexer = accessor.ParameterCount > (accessor == setter ? 1 : 0);

            if (isIndexer)
            {
                string id = property.Name.Value;
                int index = id.LastIndexOf(".");
                if (index >= 0)
                    id = id.Substring(index + 1);

                if (id != "Item")
                {
                    WriteFakeAttribute("System.Runtime.CompilerServices.IndexerName", "\"" + id + "\"");
                }
            }

            WriteAttributes(property.Attributes);

            if (!isInterfaceProp)
            {
                if (!accessor.IsExplicitInterfaceMethod())
                    WriteVisibility(property.Visibility);

                // Getter and Setter modifiers should be the same
                WriteMethodModifiers(accessor);
            }
            if (property.GetHiddenBaseProperty(_filter) != Dummy.Property)
                WriteKeyword("new");

            WriteTypeName(property.Type);
            if (isIndexer)
            {
                int index = property.Name.Value.LastIndexOf(".");
                if (index >= 0)
                    WriteIdentifier(property.Name.Value.Substring(0, index + 1) + "this", false); // +1 to include the '.'
                else
                    WriteIdentifier("this", false);

                var parameters = new List<IParameterDefinition>(accessor.Parameters);
                if (accessor == setter) // If setter remove value parameter.
                    parameters.RemoveAt(parameters.Count - 1);
                WriteParameters(parameters, true);
            }
            else
            {
                WriteIdentifier(property.Name);
            }
            WriteSpace();
            WriteSymbol("{");

            //get
            if (getter != null)
            {
                WriteAccessorDefinition(property, getter, "get");
            }
            //set
            if (setter != null)
            {
                WriteAccessorDefinition(property, setter, "set");
            }
            WriteSpace();
            WriteSymbol("}");
        }
开发者ID:pgavlin,项目名称:ApiTools,代码行数:88,代码来源:CSDeclarationWriter.Properties.cs


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