public static IEnumerable <CodeStatement> EnumerateUpdateContextStatements(DMLibTransferDirection transferDirection) { CodeFieldReferenceExpression sourceType = new CodeFieldReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibDataType)), transferDirection.SourceType.ToString()); CodeFieldReferenceExpression destType = new CodeFieldReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibDataType)), transferDirection.DestType.ToString()); CodeFieldReferenceExpression copyMethod = new CodeFieldReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibCopyMethod)), transferDirection.CopyMethod.ToString()); CodePropertyReferenceExpression sourceTypeProperty = new CodePropertyReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibTestContext)), "SourceType"); CodePropertyReferenceExpression destTypeProperty = new CodePropertyReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibTestContext)), "DestType"); CodePropertyReferenceExpression copyMethodProperty = new CodePropertyReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibTestContext)), "CopyMethod"); yield return(new CodeAssignStatement(sourceTypeProperty, sourceType)); yield return(new CodeAssignStatement(destTypeProperty, destType)); yield return(new CodeAssignStatement(copyMethodProperty, copyMethod)); }
internal override IEnumerable <TestMethodDirection> ExtractDirections() { if (this.DestType == DMLibDataType.Unspecified) { foreach (DMLibDataType sourceType in this.SourceType.Extract()) { DMLibTransferDirection transferDirection = new DMLibTransferDirection( sourceType, sourceType, this.IsAsync, new List <string>(this.Tags)); yield return(transferDirection); } } else { foreach (DMLibDataType sourceType in this.SourceType.Extract()) { foreach (DMLibDataType destType in this.DestType.Extract()) { DMLibTransferDirection transferDirection = new DMLibTransferDirection( sourceType, destType, this.IsAsync, new List <string>(this.Tags)); yield return(transferDirection); } } } }
public override bool Filter(TestMethodDirection direction) { DMLibTransferDirection DMLibDirection = direction as DMLibTransferDirection; if (DMLibDirection == null) { throw new ArgumentException("DMLibDirectionFilter is only applicable to DMLibTransferDirection.", "direction"); } if (this.CopyMethod != null && this.CopyMethod != DMLibDirection.CopyMethod) { return(false); } if (this.SourceType != DMLibDataType.Unspecified && !this.SourceType.HasFlag(DMLibDirection.SourceType)) { return(false); } if (this.DestType != DMLibDataType.Unspecified && !this.DestType.HasFlag(DMLibDirection.DestType)) { return(false); } return(true); }
public static IEnumerable <CodeStatement> EnumerateUpdateContextStatements(DMLibTransferDirection transferDirection) { CodeFieldReferenceExpression sourceType = new CodeFieldReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibDataType)), transferDirection.SourceType.ToString()); CodeFieldReferenceExpression destType = new CodeFieldReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibDataType)), transferDirection.DestType.ToString()); CodePropertyReferenceExpression sourceTypeProperty = new CodePropertyReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibTestContext)), "SourceType"); CodePropertyReferenceExpression destTypeProperty = new CodePropertyReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibTestContext)), "DestType"); CodePropertyReferenceExpression isAsyncProperty = new CodePropertyReferenceExpression( new CodeTypeReferenceExpression(typeof(DMLibTestContext)), "IsAsync"); yield return(new CodeAssignStatement(sourceTypeProperty, sourceType)); yield return(new CodeAssignStatement(destTypeProperty, destType)); yield return(new CodeAssignStatement(isAsyncProperty, new CodePrimitiveExpression(transferDirection.IsAsync))); }
public override bool Equals(object obj) { DMLibTransferDirection other = obj as DMLibTransferDirection; if (other == null) { return(false); } return(this.SourceType == other.SourceType && this.DestType == other.DestType && this.IsAsync == other.IsAsync); }