private static void ReplaceLookupFormulaComponent(Dictionary<FqnFormulaComponent, object> fqnValues,
                                                          FormulaComponentBase formulaComponent)
        {
            var lookupComponent = formulaComponent as LookupFormulaComponent;
            bool componentIsFormulaLookupWithFqns = lookupComponent != null &&
                                                    lookupComponent.LookupValue is FqnFormulaComponent;
            if (componentIsFormulaLookupWithFqns)
            {
                string fullyQualifiedName = ((FqnFormulaComponent) lookupComponent.LookupValue).FullyQualifiedName;
                object lookupValue = GetValue(fqnValues, (FqnFormulaComponent) lookupComponent.LookupValue);
                
                lookupComponent.LookupValue = CreateNewFormulaComponent(lookupValue, fullyQualifiedName);

            }
        }
        /// <summary>
        /// Insert an Formula component at a specific location.
        /// </summary>
        /// <param name="component">
        /// The component.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        public void Insert(FormulaComponentBase component, int index)
        {
            var operatorFormulaComponent = component as OperatorFormulaComponent;
            if (operatorFormulaComponent != null)
            {
                switch (operatorFormulaComponent.Operator)
                {
                    case OperatorType.And:
                    case OperatorType.Or:
                    case OperatorType.Xor:
                        this.formulaComponents.Insert(index++, new BracketFormulaComponent { OpenClose = OpenClose.Open });
                        this.formulaComponents.Insert(index++, new BracketFormulaComponent { OpenClose = OpenClose.Close });
                        this.formulaComponents.Insert(index++, component);
                        this.formulaComponents.Insert(index++, new BracketFormulaComponent { OpenClose = OpenClose.Open });
                        this.formulaComponents.Insert(index, new BracketFormulaComponent { OpenClose = OpenClose.Close });
                        return;
                    case OperatorType.Contains:
                    case OperatorType.In:
                        this.formulaComponents.Insert(index++, component);
                        this.formulaComponents.Insert(index++, new BracketFormulaComponent { OpenClose = OpenClose.Open });
                        this.formulaComponents.Insert(index++, new ConstantFormulaComponent { Constant = ConstantType.Comma });
                        this.formulaComponents.Insert(index, new BracketFormulaComponent { OpenClose = OpenClose.Close });
                        return;
                    case OperatorType.Not:
                    case OperatorType.IsEmpty:
                        this.formulaComponents.Insert(index++, component);
                        this.formulaComponents.Insert(index++, new BracketFormulaComponent { OpenClose = OpenClose.Open });
                        this.formulaComponents.Insert(index, new BracketFormulaComponent { OpenClose = OpenClose.Close });
                        return;
                    case OperatorType.If:
                    case OperatorType.Substring:
                    case OperatorType.Split:
                        this.formulaComponents.Insert(index++, component);
                        this.formulaComponents.Insert(index++, new BracketFormulaComponent { OpenClose = OpenClose.Open });
                        this.formulaComponents.Insert(index++, new ConstantFormulaComponent { Constant = ConstantType.Comma });
                        this.formulaComponents.Insert(index++, new ConstantFormulaComponent { Constant = ConstantType.Comma });
                        this.formulaComponents.Insert(index, new BracketFormulaComponent { OpenClose = OpenClose.Close });
                        return;
                }
            }

            this.formulaComponents.Insert(index, component);
        }