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


C# Property.AddNode方法代码示例

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


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

示例1: ChangeProperty

        private string ChangeProperty(Property propertyClone)
        {
            if (propertyClone == null)
                return String.Empty;

            ElementBuilder eb = CodeRush.Language.GetActiveElementBuilder();

            // convert auto-implemented property...
            if (propertyClone.IsAutoImplemented)
            {
                // so it's no longer an auto-implemented property....
                propertyClone.IsAutoImplemented = false;
                // remove all nodes and create new ones...
                propertyClone.RemoveAllNodes();

                // create a field variable...
                string varName = CodeRush.Strings.Get("FormatFieldName", propertyClone.Name);
                Variable var = eb.BuildVariable(propertyClone.MemberTypeReference, varName);

                // add property getter...
                Get getter = GetGetter(eb, varName);
                propertyClone.AddNode(getter);

                // create property setter...
                Set setter = GetSetter(eb, propertyClone, varName);
                propertyClone.AddNode(setter);

                return CodeRush.Language.GenerateElement(var) + CodeRush.Language.GenerateElement(propertyClone);
            }
            else
            {
                Set setter = propertyClone.Setter;
                if (setter == null)
                    return String.Empty;

                Assignment assignment = setter.Nodes[0] as Assignment;
                if (assignment == null)
                    return String.Empty;

                string varName = assignment.LeftSide.Name;
                propertyClone.RemoveNode(setter);

                // recreate setter...
                Set newSetter = GetSetter(eb, propertyClone, varName);
                propertyClone.AddNode(newSetter);
            }
            return CodeRush.Language.GenerateElement(propertyClone);
        }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:48,代码来源:ConvertPropertyPlugIn.cs

示例2: TryAddMemberAsProperty

    /// <summary>
    /// Tries to add member as a property.
    /// </summary>
    /// <param name="contractClass">The contract class.</param>
    /// <param name="member">The member.</param>
    /// <returns>
    ///   <c>true</c> if the member was a property and added; otherwise <c>false</c>
    /// </returns>
    private bool TryAddMemberAsProperty(Class contractClass, Member member)
    {
      Contract.Requires(contractClass != null, "contractClass is null.");
      Contract.Requires(member != null, "member is null.");

      var interfaceProperty = member as Property;
      if (interfaceProperty == null)
      {
        return false;
      }

      var contractProperty = new Property();
      this.SetupMemberDeclaration(contractProperty, interfaceProperty);
      contractProperty.AddNode(this.CreateGetter(interfaceProperty));
      contractProperty.AddNode(CreateSetter(interfaceProperty));

      contractClass.CloneDocComment(interfaceProperty);
      contractClass.AddNode(contractProperty);
      return true;
    }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:28,代码来源:ContractClassBuilder.cs


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