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


C# Literal.Clone方法代码示例

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


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

示例1: VisitLiteral

    public virtual Differences VisitLiteral(Literal literal1, Literal literal2){
      Differences differences = new Differences(literal1, literal2);
      if (literal1 == null || literal2 == null){
        if (literal1 != literal2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      Literal changes = (Literal)literal2.Clone();
      Literal deletions = (Literal)literal2.Clone();
      Literal insertions = (Literal)literal2.Clone();

      if (literal1.Value == literal2.Value || (literal1.Value != null && literal1.Value.Equals(literal2.Value)))
        differences.NumberOfSimilarities++;
      else
        differences.NumberOfDifferences++;

      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,代码行数:26,代码来源:Comparer.cs

示例2: VisitLiteral

 public override Expression VisitLiteral(Literal literal)
 {
     if (literal == null) return null;
     TypeNode t = literal.Value as TypeNode;
     if (t != null)
         return new Literal(this.VisitTypeReference(t), literal.Type, literal.SourceContext);
     ArrayType at = literal.Type as ArrayType;
     if (at != null && at.ElementType is TypeNode)
     {
         TypeNode cloneType = this.VisitTypeReference(literal.Type);
         TypeNode[] val = literal.Value as TypeNode[];
         int len = val == null ? 0 : val.Length;
         TypeNode[] newVal = val == null ? null : new TypeNode[len];
         for (int i = 0; i < len; i++)
         {
             newVal[i] = this.VisitTypeReference(val[i]);
         }
         return new Literal(newVal, cloneType);
     }
     return (Literal)literal.Clone();
 }
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:21,代码来源:Duplicator.cs

示例3: VisitLiteral

 public override Expression VisitLiteral(Literal literal){
   if (literal == null) return null;
   TypeNode t = literal.Value as TypeNode;
   if (t != null && literal.Type == CoreSystemTypes.Type)
     return new Literal(this.VisitTypeReference(t), literal.Type, literal.SourceContext);
   return (Literal)literal.Clone();
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:Specializer.cs

示例4: VisitLiteral

 public override Expression VisitLiteral(Literal literal){
   if (literal == null) return null;
   TypeNode cloneType = this.VisitTypeReference(literal.Type);
   TypeNode t = literal.Value as TypeNode;
   if (t != null)
     return new Literal(this.VisitTypeReference(t), cloneType, literal.SourceContext);
   TypeNode[] tarr = literal.Value as TypeNode[];
   if (tarr != null) {
     int len = tarr == null ? 0 : tarr.Length;
     TypeNode[] newarr = tarr == null ? null : new TypeNode[len];
     for (int i = 0; i < len; i++) newarr[i] = this.VisitTypeReference(tarr[i]);
     return new Literal(newarr, cloneType);
   }
   object[] arr = literal.Value as object[];
   if (arr != null) {
     int len = arr.Length;
     object[] newarr = new object[len];
     for (int i = 0; i < len; i++) {
       Literal litelt = arr[i] as Literal;
       if (litelt != null)
         newarr[i] = VisitLiteral(litelt);
       else
         newarr[i] = arr[i];
     }
     return new Literal(newarr, cloneType);
   }
   Literal result = (Literal)literal.Clone();
   result.Type = cloneType;
   return result;
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:30,代码来源:Duplicator.cs


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