コード例 #1
0
ファイル: RightShift.cs プロジェクト: anddudek/anjlab.fx
 public override CodeStatementCollection BuildOperation(CodeGenerationContext ctx, ICodeGeneratorNode element, CodeVariableReferenceExpression value)
 {
     CodeStatementCollection statemets = new CodeStatementCollection();
     statemets.Add(new CodeSnippetExpression(
         string.Format("{0} = ({2})((int){0} >> {1})", value.VariableName, Value, GetValueType(element.MappedProperty).FullName)));
     return statemets;
 }
コード例 #2
0
        public CodeMemberMethod NewElementMappingMethod(CodeGenerationContext ctx, ICodeGeneratorNode element)
        {
            CodeMemberMethod method = AddNewMethod();

            element.GenerateMappingCode(ctx, method);
            return(method);
        }
コード例 #3
0
        public override void GenerateMappingCode(CodeGenerationContext ctx, CodeMemberMethod method)
        {
            if (!string.IsNullOrEmpty(_key))
            {
                ICodeGeneratorNode element = ctx.MapInfo.GetNamedMapping(_key);

                Guard.NotNull(element, "Named mapping '{0}' not found for {1}", _key, ctx.MappedObjectType.FullName);

                element.To = To;
                element.GenerateMappingCode(ctx, method);
            }
        }
コード例 #4
0
        public virtual CodeStatementCollection BuildOperation(CodeGenerationContext ctx, ICodeGeneratorNode element, CodeVariableReferenceExpression value)
        {
            CodeStatementCollection statemets = new CodeStatementCollection();

            if (!string.IsNullOrEmpty(_property))
            {
                CodeExpression rightExpression = new CodePropertyReferenceExpression(ctx.MappedObject, _property);
                if (_index != null && element.MappedProperty.PropertyType.IsArray)
                {
                    rightExpression = new CodeIndexerExpression(rightExpression, new CodePrimitiveExpression(_index.Value));
                }

                statemets.Add(new CodeAssignStatement(value, new CodeCastExpression(GetValueType(element.MappedProperty),
                                                                                    new CodeBinaryOperatorExpression(value, OperationType, rightExpression))));
            }

            if (Value != null)
            {
                statemets.Add(new CodeAssignStatement(value, new CodeCastExpression(element.MappedProperty.PropertyType,
                                                                                    new CodeBinaryOperatorExpression(value, OperationType, new CodePrimitiveExpression(Value)))));
            }

            return(statemets);
        }
コード例 #5
0
        public override CodeStatementCollection BuildOperation(CodeGenerationContext ctx, ICodeGeneratorNode element, CodeVariableReferenceExpression value)
        {
            CodeStatementCollection statemets = new CodeStatementCollection();

            statemets.Add(new CodeSnippetExpression(
                              string.Format("{0} = ({2})((int){0} >> {1})", value.VariableName, Value, GetValueType(element.MappedProperty).FullName)));
            return(statemets);
        }