Ejemplo n.º 1
0
        public virtual T Clone <T>(T objectToClone) where T : class, IUpdatable
        {
            if (objectToClone == null)
            {
                return(null);
            }

            var repository = objectToClone as DataRepository;

            if (repository != null)
            {
                return(cloneDataRepository(objectToClone.DowncastTo <DataRepository>()) as T);
            }

            var formulaToClone = objectToClone as IFormula;

            if (formulaToClone != null)
            {
                return(CreateFormulaCloneFor(formulaToClone).DowncastTo <T>());
            }

            var clone = _objectBaseFactory.CreateObjectBaseFrom(objectToClone);

            copyContainerStructure(objectToClone as IContainer, clone as IContainer);

            updateUsingFormula(objectToClone as IUsingFormula, clone as IUsingFormula);
            updateParameter(objectToClone as IParameter, clone as IParameter);

            //it is necessary to update  the formula before the properties, since UpdatePropertiesFrom might use formula
            clone.UpdatePropertiesFrom(objectToClone, this);

            return(clone);
        }
 private TDistribution createDistribution <TDistribution>() where TDistribution : IDistributionFormula
 {
     return(_objectBaseFactory.CreateObjectBaseFrom <TDistribution>(typeof(TDistribution)));
 }
 protected T CreateObject <T>() where T : class, IObjectBase
 {
     return(_objectBaseFactory.CreateObjectBaseFrom <T>(typeof(T)));
 }