public static CodeBlockMappingExpression DeleteCode(this IModificationMappingExpression exp) { CodeBlockMappingExpression lastCodeBlockExp = null; foreach (var codeByAddedCode in ( from cb in exp.Queryable <CodeBlock>() join m in exp.Queryable <Modification>() on cb.ModificationID equals m.ID join f in exp.Queryable <ProjectFile>() on m.FileID equals f.ID let addedCodeID = cb.Size < 0 ? cb.TargetCodeBlockID : cb.ID where f.ID == exp.CurrentEntity <ProjectFile>().ID group cb.Size by addedCodeID ) ) { double currentCodeSize = codeByAddedCode.Sum(); if (currentCodeSize != 0) { if (lastCodeBlockExp == null) { lastCodeBlockExp = exp.Code(-currentCodeSize); } else { lastCodeBlockExp = lastCodeBlockExp.Code(-currentCodeSize); } lastCodeBlockExp.ForCodeAddedInitiallyInRevision( RevisionCodeBlockWasInitiallyAddedIn(exp, codeByAddedCode.Key ?? 0) ); } } return(lastCodeBlockExp); }
private static CodeBlockMappingExpression RemoveCodeBlock( IModificationMappingExpression expression, string revision, double codeSize) { if (codeSize != 0) { var newExp = expression.Code(-codeSize); newExp.ForCodeAddedInitiallyInRevision(revision); return(newExp); } return(null); }
private static CodeBlockMappingExpression CopyCodeBlock( IModificationMappingExpression expression, string revision, double codeSize) { if (codeSize != 0) { var newExp = expression.Code(codeSize); newExp.CopiedFrom(revision); return(newExp); } return(null); }