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


C# Property.GetTypeName方法代码示例

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


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

示例1: GetNewDelayedPropertyDeclaration

        } // GetNewDelayedPropertyDeclaration(elementBuilder, oldProperty)

        /// <summary>
        /// Get new property declaration
        /// </summary>
        private string GetNewPropertyDeclaration(ElementBuilder elementBuilder, Property oldProperty)
        {
            string propName = oldProperty.Name;
            string typeName = oldProperty.GetTypeName();
            string fieldVariableName = CodeRush.Strings.Get("FormatFieldName", propName);

            Variable fieldVar = elementBuilder.AddVariable(null, typeName, fieldVariableName);
            fieldVar.IsStatic = oldProperty.IsStatic;
            fieldVar.Visibility = MemberVisibility.Private;

            Property newProperty = elementBuilder.AddProperty(null, typeName, propName);
            newProperty.Visibility = oldProperty.Visibility;
            newProperty.IsStatic = oldProperty.IsStatic;
            newProperty.IsVirtual = oldProperty.IsVirtual;
            newProperty.IsOverride = oldProperty.IsOverride;
            newProperty.IsExplicitInterfaceMember = oldProperty.IsExplicitInterfaceMember;
            
            if (oldProperty.HasGetter)
            {
                Get getter = elementBuilder.AddGetter(newProperty);
                elementBuilder.AddReturn(getter, fieldVariableName);
            }

            if (oldProperty.HasSetter)
            {
                Set setter = elementBuilder.AddSetter(newProperty);
                ExpressionCollection expressionCollection = new ExpressionCollection();
                expressionCollection.Add(new PrimitiveExpression(String.Format("\"{0}\"", propName)));
                expressionCollection.Add(new ArgumentDirectionExpression(ArgumentDirection.Ref,
                    new ElementReferenceExpression(fieldVariableName)));
                expressionCollection.Add(new ElementReferenceExpression("value"));
                elementBuilder.AddMethodCall(setter, "SetPropertyValue", expressionCollection, null);
            } // if

            return elementBuilder.GenerateCode();
        } // GetNewPropertyDeclaration(elementBuilder, oldProperty)
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:41,代码来源:ConvertToXPOPropertyPlugin.cs

示例2: refactoringProvider_Apply

        } // refactoringProvider_Apply(sender, ea)

        /// <summary>
        /// Get new delayed property declaration
        /// </summary>
        private string GetNewDelayedPropertyDeclaration(ElementBuilder elementBuilder, Property oldProperty)
        {
            string propName = oldProperty.Name;
            string typeName = oldProperty.GetTypeName();

            Property newProperty = elementBuilder.AddProperty(null, typeName, propName);
            newProperty.Visibility = oldProperty.Visibility;
            newProperty.IsStatic = oldProperty.IsStatic;
            newProperty.IsVirtual = oldProperty.IsVirtual;
            newProperty.IsOverride = oldProperty.IsOverride;
            newProperty.IsExplicitInterfaceMember = oldProperty.IsExplicitInterfaceMember;

            AttributeSection attrSection = elementBuilder.AddAttributeSection(newProperty);
            elementBuilder.AddAttribute(attrSection, "Delayed");

            if (oldProperty.HasGetter)
            {
                Get getter = elementBuilder.AddGetter(newProperty);
                ExpressionCollection expressionCollection = new ExpressionCollection();
                expressionCollection.Add(new PrimitiveExpression(String.Format("\"{0}\"", propName)));
                string methodName = String.Format("GetDelayedPropertyValue<{0}>", typeName);
                elementBuilder.AddReturn(getter, elementBuilder.BuildMethodCall(methodName, expressionCollection, null));
            }

            if (oldProperty.HasSetter)
            {
                Set setter = elementBuilder.AddSetter(newProperty);
                ExpressionCollection expressionCollection = new ExpressionCollection();
                expressionCollection.Add(new PrimitiveExpression(String.Format("\"{0}\"", propName)));
                expressionCollection.Add(new ElementReferenceExpression("value"));
                string methodName = String.Format("SetDelayedPropertyValue<{0}>", typeName);
                elementBuilder.AddMethodCall(setter, methodName, expressionCollection, null);
            } // if

            return elementBuilder.GenerateCode();
        } // GetNewDelayedPropertyDeclaration(elementBuilder, oldProperty)
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:41,代码来源:ConvertToXPOPropertyPlugin.cs


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