本文整理汇总了C#中Conversion类的典型用法代码示例。如果您正苦于以下问题:C# Conversion类的具体用法?C# Conversion怎么用?C# Conversion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Conversion类属于命名空间,在下文中一共展示了Conversion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CustomConversionRule
/// <summary>
/// Constructs a custom conversion rule.
/// </summary>
/// <param name="conversion">The conversion operation.</param>
public CustomConversionRule(Conversion conversion)
{
if (conversion == null)
throw new ArgumentNullException("conversion");
this.conversion = conversion;
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:11,代码来源:CustomConversionRule.cs
示例2: BinaryOperatorAnalysisResult
private BinaryOperatorAnalysisResult(OperatorAnalysisResultKind kind, BinaryOperatorSignature signature, Conversion leftConversion, Conversion rightConversion)
{
this.Kind = kind;
this.Signature = signature;
this.LeftConversion = leftConversion;
this.RightConversion = rightConversion;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:7,代码来源:BinaryOperatorAnalysisResult.cs
示例3: ForEachEnumeratorInfo
private ForEachEnumeratorInfo(
TypeSymbol collectionType,
TypeSymbol elementType,
MethodSymbol getEnumeratorMethod,
MethodSymbol currentPropertyGetter,
MethodSymbol moveNextMethod,
bool needsDisposeMethod,
Conversion collectionConversion,
Conversion currentConversion,
Conversion enumeratorConversion,
BinderFlags location)
{
Debug.Assert((object)collectionType != null, "Field 'collectionType' cannot be null");
Debug.Assert((object)elementType != null, "Field 'elementType' cannot be null");
Debug.Assert((object)getEnumeratorMethod != null, "Field 'getEnumeratorMethod' cannot be null");
Debug.Assert((object)currentPropertyGetter != null, "Field 'currentPropertyGetter' cannot be null");
Debug.Assert((object)moveNextMethod != null, "Field 'moveNextMethod' cannot be null");
this.CollectionType = collectionType;
this.ElementType = elementType;
this.GetEnumeratorMethod = getEnumeratorMethod;
this.CurrentPropertyGetter = currentPropertyGetter;
this.MoveNextMethod = moveNextMethod;
this.NeedsDisposeMethod = needsDisposeMethod;
this.CollectionConversion = collectionConversion;
this.CurrentConversion = currentConversion;
this.EnumeratorConversion = enumeratorConversion;
this.Location = location;
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:29,代码来源:ForEachEnumeratorInfo.cs
示例4: ConversationWrapper
public ConversationWrapper(Conversion conv, Operand op, Type @from, Type to)
{
_conv = conv;
_op = op;
_to = to;
_from = @from;
}
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:7,代码来源:ConversationWrapper.cs
示例5: ProcessConversion
public void ProcessConversion(Expression expression, ResolveResult result, Conversion conversion, IType targetType)
{
if (!nodesWithConversions.Add(expression))
throw new InvalidOperationException("Duplicate ProcessConversion() call");
if (!conversion.IsValid && !allowErrors) {
Console.WriteLine("Compiler error at " + fileName + ":" + expression.StartLocation + ": Cannot convert from " + result + " to " + targetType);
}
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:8,代码来源:ResolverTest.cs
示例6: Main
static void Main()
{
Conversion conversions = new Conversion();
double fahr = 62;
double celc = 30;
Console.WriteLine("140 fahrenheit is " + conversions.FarToCel(fahr));
Console.WriteLine("30 celcius is " + conversions.CelToFar(celc));
}
开发者ID:George-Lee,项目名称:uniwork,代码行数:8,代码来源:temperature.cs
示例7: ConversionResolveResult
public ConversionResolveResult(IType targetType, ResolveResult input, Conversion conversion)
: base(targetType)
{
if (input == null)
throw new ArgumentNullException("input");
this.Input = input;
this.Conversion = conversion;
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:8,代码来源:ConversionResolveResult.cs
示例8: CreateConversion
protected BoundExpression CreateConversion(
BoundExpression source,
Conversion conversion,
TypeSymbol destination,
DiagnosticBag diagnostics)
{
return CreateConversion(source.Syntax, source, conversion, isCast: false, destination: destination, diagnostics: diagnostics);
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:8,代码来源:Binder_Conversions.cs
示例9: TestCast
void TestCast(Type targetType, ResolveResult input, Conversion expectedConversion)
{
IType type = targetType.ToTypeReference().Resolve(context);
ResolveResult rr = resolver.ResolveCast(type, input);
AssertType(targetType, rr);
Assert.AreEqual(typeof(ConversionResolveResult), rr.GetType());
var crr = (ConversionResolveResult)rr;
Assert.AreEqual(expectedConversion, crr.Conversion, "ConversionResolveResult.Conversion");
Assert.AreSame(input, crr.Input, "ConversionResolveResult.Input");
}
开发者ID:sbeparey,项目名称:ILSpy,代码行数:10,代码来源:CastTests.cs
示例10: SelectsConversion
public void SelectsConversion()
{
var spec = new IntegerGreaterThanZero();
var converter = (Expression<Func<double, int>>)(d => Math.Sign(d));
var convertedSpec = new Conversion<double, int>(spec, converter);
Assert.That(convertedSpec.IsSatisfiedBy(1), Is.True);
Assert.That(convertedSpec.IsSatisfiedBy(0), Is.False);
Assert.That(convertedSpec.IsSatisfiedBy(-1), Is.False);
}
开发者ID:awhatley,项目名称:specks,代码行数:10,代码来源:ConversionTestFixture.cs
示例11: TestOperator
void TestOperator(ResolveResult condition, ResolveResult trueExpr, ResolveResult falseExpr,
Conversion conditionConv, Conversion trueConv, Conversion falseConv,
Type expectedResultType)
{
var corr = (ConditionalOperatorResolveResult)resolver.ResolveConditional(condition, trueExpr, falseExpr);
AssertType(expectedResultType, corr);
AssertConversion(corr.Condition, condition, conditionConv, "Condition Conversion");
AssertConversion(corr.True, trueExpr, trueConv, "True Conversion");
AssertConversion(corr.False, falseExpr, falseConv, "False Conversion");
}
开发者ID:jiguixin,项目名称:ILSpy,代码行数:10,代码来源:ConditionalOperatorTests.cs
示例12: TestCast
void TestCast(Type targetType, ResolveResult input, Conversion expectedConversion)
{
IType type = compilation.FindType(targetType);
ResolveResult rr = resolver.ResolveCast(type, input);
AssertType(targetType, rr);
Assert.AreEqual(typeof(ConversionResolveResult), rr.GetType());
var crr = (ConversionResolveResult)rr;
Assert.AreEqual(expectedConversion, crr.Conversion, "ConversionResolveResult.Conversion");
Assert.AreSame(input, crr.Input, "ConversionResolveResult.Input");
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:10,代码来源:CastTests.cs
示例13: Is
public static Conversion Is(this Tuple<Measurement, Measurement> conversion, decimal absolute)
{
decimal scalar = absolute / conversion.Item1.Value;
var result = new Conversion(conversion.Item1.Unit, conversion.Item2.Unit);
result.AddStep(new ScalingConversion(scalar));
return result;
}
开发者ID:hartez,项目名称:Convertinator,代码行数:10,代码来源:Conversions.cs
示例14: MakeAsOperator
private BoundExpression MakeAsOperator(
BoundAsOperator oldNode,
CSharpSyntaxNode syntax,
BoundExpression rewrittenOperand,
BoundTypeExpression rewrittenTargetType,
Conversion conversion,
TypeSymbol rewrittenType)
{
// TODO: Handle dynamic operand type and target type
Debug.Assert(rewrittenTargetType.Type.Equals(rewrittenType));
// target type cannot be a non-nullable value type
Debug.Assert(!rewrittenType.IsValueType || rewrittenType.IsNullableType());
if (!_inExpressionLambda)
{
ConstantValue constantValue = Binder.GetAsOperatorConstantResult(rewrittenOperand.Type, rewrittenType, conversion.Kind, rewrittenOperand.ConstantValue);
if (constantValue != null)
{
Debug.Assert(constantValue.IsNull);
BoundExpression result = rewrittenType.IsNullableType() ? new BoundDefaultOperator(syntax, rewrittenType) : MakeLiteral(syntax, constantValue, rewrittenType);
if (rewrittenOperand.ConstantValue != null)
{
// No need to preserve any side-effects from the operand.
// We also can keep the "constant" notion of the result, which
// enables some optimizations down the road.
return result;
}
return new BoundSequence(
syntax: syntax,
locals: ImmutableArray<LocalSymbol>.Empty,
sideEffects: ImmutableArray.Create<BoundExpression>(rewrittenOperand),
value: result,
type: rewrittenType);
}
if (conversion.IsImplicit)
{
// Operand with bound implicit conversion to target type.
// We don't need a runtime check, generate a conversion for the operand instead.
return MakeConversionNode(syntax, rewrittenOperand, conversion, rewrittenType, @checked: false);
}
}
return oldNode.Update(rewrittenOperand, rewrittenTargetType, conversion, rewrittenType);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:49,代码来源:LocalRewriter_AsOperator.cs
示例15: UserDefinedConversionAnalysis
private UserDefinedConversionAnalysis(
UserDefinedConversionAnalysisKind kind,
MethodSymbol op,
Conversion sourceConversion,
Conversion targetConversion,
TypeSymbol fromType,
TypeSymbol toType)
{
this.Kind = kind;
this.Operator = op;
this.SourceConversion = sourceConversion;
this.TargetConversion = targetConversion;
this.FromType = fromType;
this.ToType = toType;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:15,代码来源:UserDefinedConversionAnalysis.cs
示例16: Lifted
public static UserDefinedConversionAnalysis Lifted(
MethodSymbol op,
Conversion sourceConversion,
Conversion targetConversion,
TypeSymbol fromType,
TypeSymbol toType)
{
return new UserDefinedConversionAnalysis(
UserDefinedConversionAnalysisKind.ApplicableInLiftedForm,
op,
sourceConversion,
targetConversion,
fromType,
toType);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:15,代码来源:UserDefinedConversionAnalysis.cs
示例17: Conversions
public IEnumerable<Conversion> Conversions()
{
XPathNavigator nav = document.CreateNavigator();
foreach (XPathNavigator n in nav.Select("ucumTests/conversion/case"))
{
Conversion conversion = new Conversion();
conversion.Id = n.SelectSingleNode("@id").Value;
conversion.Value = n.SelectSingleNode("@value").Value;
conversion.SourceUnit = n.SelectSingleNode("@srcUnit").Value;
conversion.DestUnit = n.SelectSingleNode("@dstUnit").Value;
conversion.Outcome = n.SelectSingleNode("@outcome").Value;
//validation.Reason = = n.SelectSingleNode("unit").Value ;
yield return conversion;
}
}
开发者ID:nagyistoce,项目名称:Fhir.Metrics,代码行数:16,代码来源:UcumTestReader.cs
示例18: GetAngle
private float GetAngle(Vector3 vec, Conversion axis)
{
switch (axis)
{
case Conversion.X:
return vec.x;
case Conversion.Y:
return vec.y;
case Conversion.Z:
return vec.z;
case Conversion.nX:
return -vec.x;
case Conversion.nY:
return -vec.y;
case Conversion.nZ:
return -vec.z;
default:
return 0;
}
}
开发者ID:vildninja,项目名称:gyro,代码行数:20,代码来源:CopyPhoneTransform.cs
示例19: ConvertsCriteria
public void ConvertsCriteria()
{
var spec = new IntegerPredicate(i => i == 0);
var converter = (Expression<Func<double, int>>)(d => Math.Sign(d));
var criteria = spec.Criteria;
var convertedSpec = new Conversion<double, int>(spec, converter);
var convertedCriteria = convertedSpec.Criteria;
Assert.That(convertedCriteria.Body, Is.AssignableTo<BinaryExpression>());
var binary = (BinaryExpression)convertedCriteria.Body;
Assert.That(binary.NodeType, Is.EqualTo(ExpressionType.Equal));
Assert.That(binary.Left, Is.EqualTo(converter.Body));
Assert.That(binary.Right, Is.EqualTo(((BinaryExpression)criteria.Body).Right));
Assert.That(binary.Method, Is.Null);
Assert.That(binary.IsLifted, Is.False);
Assert.That(binary.IsLiftedToNull, Is.False);
Assert.That(binary.Conversion, Is.Null);
ExpressionWriter.Write(convertedCriteria);
}
开发者ID:awhatley,项目名称:specks,代码行数:22,代码来源:ConversionTestFixture.cs
示例20: MakeAsOperator
private BoundExpression MakeAsOperator(
BoundAsOperator oldNode,
CSharpSyntaxNode syntax,
BoundExpression rewrittenOperand,
BoundTypeExpression rewrittenTargetType,
Conversion conversion,
TypeSymbol rewrittenType)
{
// TODO: Handle dynamic operand type and target type
Debug.Assert(rewrittenTargetType.Type.Equals(rewrittenType));
// target type cannot be a non-nullable value type
Debug.Assert(!rewrittenType.IsValueType || rewrittenType.IsNullableType());
if (!inExpressionLambda)
{
ConstantValue constantValue = Binder.GetAsOperatorConstantResult(rewrittenOperand.Type, rewrittenType, conversion.Kind, rewrittenOperand.ConstantValue);
Debug.Assert(constantValue == null || constantValue.IsNull);
if (conversion.IsImplicit)
{
// Operand with bound implicit conversion to target type.
// We don't need a runtime check, generate a conversion for the operand instead.
return MakeConversion(syntax, rewrittenOperand, conversion, rewrittenType, @checked: false, constantValueOpt: constantValue);
}
else if (constantValue != null)
{
return new BoundSequence(
syntax: syntax,
locals: ImmutableArray<LocalSymbol>.Empty,
sideEffects: ImmutableArray.Create<BoundExpression>(rewrittenOperand),
value: MakeLiteral(syntax, constantValue, rewrittenType),
type: rewrittenType);
}
}
return oldNode.Update(rewrittenOperand, rewrittenTargetType, conversion, rewrittenType);
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:38,代码来源:LocalRewriter_AsOperator.cs
注:本文中的Conversion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论