本文整理汇总了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;
}
示例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();
}
示例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();
}
示例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;
}