Esempio n. 1
0
        private static void CalculateNullableAverage(RewriteDesign design, TypeBridge elementType, TypedValueBridge selectionValue, LocalVariable sumVariable)
        {
            var inlinedValue = selectionValue.Reusable(design);

            design.ForAdd(If(inlinedValue.IsEqual(null), Continue()));
            design.ForAdd(sumVariable.AddAssign(inlinedValue.Cast(elementType)));
            design.Indexer = null;

            if (design.Unchecked)
            {
                design.ResultAdd(sumVariable.Cast(design.ReturnType.Type) / design.Indexer);
            }
            else
            {
                design.ResultAdd(Return(SyntaxFactory.ConditionalExpression(design.Indexer.IsEqual(0),
                                                                            Null, sumVariable.Cast(design.ReturnType.Type) / design.Indexer)));
            }
        }