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


C# Property.Clone方法代码示例

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


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

示例1: ConvertProperty

        private void ConvertProperty(TextDocument textDocument, Property property)
        {
            if (textDocument == null || property == null)
                return;

            Property propertyClone = (Property)property.Clone();
            string newPropertyCode = ChangeProperty(propertyClone);

            SourceRange propertyRange = property.Range.Clone();
            textDocument.DeleteText(propertyRange);
            SourceRange newPropertyRange = textDocument.InsertText(propertyRange.Start, newPropertyCode);
            textDocument.Format(newPropertyRange);

        }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:14,代码来源:ConvertPropertyPlugIn.cs

示例2: ConvertProperty

        private void ConvertProperty(TextDocument textDocument, Property property, bool baseClassVersion, LanguageElement classExpression)
        {
            if (textDocument == null || property == null)
                return;

            Property propertyClone = (Property)property.Clone();
            string newPropertyCode = ChangeProperty(propertyClone, baseClassVersion, classExpression);

            SourceRange propertyRange = property.Range.Clone();
            textDocument.DeleteText(propertyRange);
            SourceRange newPropertyRange = textDocument.InsertText(propertyRange.Start, newPropertyCode);
            textDocument.Format(newPropertyRange);

        }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:14,代码来源:ConvertPropertyPlugIn.cs

示例3: VisitProperty

    public virtual Differences VisitProperty(Property property1, Property property2){
      Differences differences = this.GetMemberDifferences(property1, property2);
      if (differences == null){Debug.Assert(false); differences = new Differences(property1, property2);}
      if (differences.NumberOfDifferences > 0 || differences.NumberOfSimilarities > 0) return differences;
      if (property1 == null || property2 == null){
        if (property1 != property2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      Property changes = (Property)property2.Clone();
      Property deletions = (Property)property2.Clone();
      Property insertions = (Property)property2.Clone();

      AttributeList attrChanges, attrDeletions, attrInsertions;
      Differences diff = this.VisitAttributeList(property1.Attributes, property2.Attributes, out attrChanges, out attrDeletions, out attrInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Attributes = attrChanges;
      deletions.Attributes = attrDeletions;
      insertions.Attributes = attrInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (property1.Flags == property2.Flags) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      diff = this.VisitMethod(property1.Getter, property2.Getter);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Getter = diff.Changes as Method;
      deletions.Getter = diff.Deletions as Method;
      insertions.Getter = diff.Insertions as Method;
      Debug.Assert(diff.Changes == changes.Getter && diff.Deletions == deletions.Getter && diff.Insertions == insertions.Getter);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      TypeNodeList typeChanges, typeDeletions, typeInsertions;
      diff = this.VisitTypeNodeList(property1.ImplementedTypes, property2.ImplementedTypes, out typeChanges, out typeDeletions, out typeInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.ImplementedTypes = typeChanges;
      deletions.ImplementedTypes = typeDeletions;
      insertions.ImplementedTypes = typeInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitIdentifier(property1.Name, property2.Name);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Name = diff.Changes as Identifier;
      deletions.Name = diff.Deletions as Identifier;
      insertions.Name = diff.Insertions as Identifier;
      Debug.Assert(diff.Changes == changes.Name && diff.Deletions == deletions.Name && diff.Insertions == insertions.Name);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      MethodList methChanges, methDeletions, methInsertions;
      diff = this.VisitMethodList(property1.OtherMethods, property2.OtherMethods, out methChanges, out methDeletions, out methInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.OtherMethods = methChanges;
      deletions.OtherMethods = methDeletions;
      insertions.OtherMethods = methInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (property1.OverridesBaseClassMember == property2.OverridesBaseClassMember) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      ParameterList parChanges, parDeletions, parInsertions;
      diff = this.VisitParameterList(property1.Parameters, property2.Parameters, out parChanges, out parDeletions, out parInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Parameters = parChanges;
      deletions.Parameters = parDeletions;
      insertions.Parameters = parInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitMethod(property1.Setter, property2.Setter);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Setter = diff.Changes as Method;
      deletions.Setter = diff.Deletions as Method;
      insertions.Setter = diff.Insertions as Method;
      Debug.Assert(diff.Changes == changes.Setter && diff.Deletions == deletions.Setter && diff.Insertions == insertions.Setter);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:90,代码来源:Comparer.cs

示例4: Clone_MakeClone_ReturnsNewObjectWithSameValue

		public void Clone_MakeClone_ReturnsNewObjectWithSameValue() {
			var context = new Context("context");
			var prop = new Property<MyDummyClass1>("propertyname", context, CultureInfo.InvariantCulture);
			var dummyObject = new MyDummyClass1("my dummy object");
			prop.Value = dummyObject;
			var newProp = (Property<MyDummyClass1>)prop.Clone();
			Assert.AreNotSame(prop, newProp);
			Assert.AreEqual("my dummy object", newProp.Value.MyString);
		}
开发者ID:aelveborn,项目名称:njupiter,代码行数:9,代码来源:PropertyTests.cs


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