public T CloneBuildingBlock <T>(T buildingBlock) where T : class, IBuildingBlock
        {
            var formulaCache = new FormulaCache();
            var clone        = Clone(buildingBlock, formulaCache);

            formulaCache.Each(clone.AddFormula);
            return(clone);
        }
        public T CloneBuidingBlock <T>(T toClone) where T : class, IBuildingBlock
        {
            var formulaCache = new FormulaCache();
            var copy         = _cloneManagerForBuildingBlock.Clone(toClone, formulaCache);

            formulaCache.Each(copy.AddFormula);
            return(copy);
        }
        public T CloneBuidingBlockInfo <T>(T toClone) where T : class, IBuildingBlockInfo, new()
        {
            var formulaCache = new FormulaCache();
            var copy         = new T {
                UntypedBuildingBlock = CloneBuidingBlock(toClone.UntypedBuildingBlock)
            };

            formulaCache.Each(copy.UntypedBuildingBlock.AddFormula);
            copy.TemplateBuildingBlockId = toClone.TemplateBuildingBlockId;
            copy.SimulationChanges       = toClone.SimulationChanges;
            return(copy);
        }
Exemple #4
0
        private void updateFormulaCacheOfClone(IBuildingBlock originBuildingBlock, IBuildingBlock cloneBuildingBlock, FormulaCache formulaCache)
        {
            //reset formula cache of cloneManager at that stage
            _cloneManagerForBuildingBlock.FormulaCache = new FormulaCache();

            //  add a clone of each formula that is not present in the clone by name
            originBuildingBlock.FormulaCache
            .Where(f => !formulaCache.ExistsByName(f.Name))
            .Each(f => formulaCache.Add(_cloneManagerForBuildingBlock.Clone(f)));

            // we nee to add the Formulas to the clones of BuildingBlockWithFormulaCaches Formula cache
            formulaCache.Each(cloneBuildingBlock.AddFormula);
        }
 public override void AcceptVisitor(IVisitor visitor)
 {
     base.AcceptVisitor(visitor);
     FormulaCache.Each(formula => formula.AcceptVisitor(visitor));
 }