/// <summary>
        /// Write the current data stored into this object into a specific file
        /// </summary>
        /// <param name="Filename">Name of the file to use for storing data</param>
        /// <returns>True if the file has been written, false otherwise</returns>
        public bool WriteFile(String OutputFilename, String PatternFilename)
        {
            bool          Ret              = false;
            String        ReadPatternLine  = null;
            String        CheckPatternLine = null;
            int           CurrentLoop      = -1;
            List <String> PatternBlock     = null;

            if ((OutputFilename != null) && (PatternFilename != null) && (_Items.Count() > 0))
            {
                // Create the output file and open the pattern file
                TextFile PatternFile = new TextFile(PatternFilename);
                _File = new TextFile();

                if (_File != null)
                {
                    for (int i = 1; i <= PatternFile.GetSize(); i++)
                    {
                        // Check all line to change patterns into real value
                        ReadPatternLine = PatternFile.GetLine(i);

                        if (ReadPatternLine != null)
                        {
                            // Check line to remove unused char
                            CheckPatternLine = ReadPatternLine;
                            CheckPatternLine = CheckPatternLine.Replace("\t", "");

                            if (CheckPatternLine == "// LoopID = 'LOOPID'")
                            {
                                // Create the pattern block
                                PatternBlock = new List <string>();
                                CurrentLoop++;  // Update the current LoopID
                                _File.AddLine(ReadPatternLine.Replace("'LOOPID'", CurrentLoop.ToString()));
                            }

                            if (CheckPatternLine == "// StructuredFileLoopEnd")
                            {
                                if ((PatternBlock != null) && (PatternBlock.Count() > 1))
                                {
                                    // Extact values ordered by GID
                                    List <StructValueList> KeyValues = ExtractValues(CurrentLoop);
                                    if (KeyValues != null)
                                    {
                                        int PatternIterator = 1;    // The first line contains the LOOPID

                                        // Check all items and write only items from current Loop
                                        foreach (StructValueList Values in KeyValues)
                                        {
                                            // Create pattern line
                                            if (PatternIterator >= PatternBlock.Count())
                                            {
                                                PatternIterator = 1;    // The first line contains the LOOPID
                                            }
                                            string ExportLine = PatternBlock[PatternIterator];

                                            // We have found value for the current GID, we split it to add them to the specific loop
                                            string[] KeyToAdd   = Values.KeyList.Split('|');
                                            string[] ValueToAdd = Values.ValueList.Split('|');

                                            // Change the 'PATTERN_COUNTER' value
                                            ExportLine = ExportLine.Replace("'PATTERN_COUNTER'", Values.CaseID.ToString());

                                            // Write values into final string
                                            for (int j = 0; j < KeyToAdd.Length; j++)
                                            {
                                                ExportLine = ExportLine.Replace("'" + KeyToAdd[j] + "'", ValueToAdd[j]);
                                            }

                                            // Write final line
                                            _File.AddLine(ExportLine);
                                        }
                                    }
                                }

                                // Clear PatternBlock
                                PatternBlock = null;
                            }

                            if (PatternBlock == null)
                            {
                                foreach (StructuredFileKey PatternKey in _Items)
                                {
                                    if (PatternKey.GetLoopID() == -1)
                                    {
                                        ReadPatternLine = ReadPatternLine.Replace("'" + PatternKey.GetName() + "'", PatternKey.GetValue());
                                    }
                                }

                                _File.AddLine(ReadPatternLine);
                            }
                            else
                            {
                                // We are reading a pattern block, we add this line into PatternBlock
                                PatternBlock.Add(ReadPatternLine);
                            }
                        }
                    }
                }
            }

            _File.Save(OutputFilename);
            return(Ret);
        }
        //If another namespace is needed for the pattern lookup it can be written as Namespace__Key, i.e. namespace and key seperated by two underscores '_'
        public ParameterValue GetValue(EvaluationContext context)
        {
            var values = context.Parameters;


            string actualPatternKey;

            if (PatternKey.StartsWith("@"))
            {
                var parts = PatternKey.Substring(1).Split('+');
                actualPatternKey = (string)values.GetObject(parts[0]);
                if (parts.Length > 1)
                {
                    actualPatternKey += parts[1];
                }
            }
            else
            {
                actualPatternKey = PatternKey;
            }

            string ns = context.Namespace;

            int ix = actualPatternKey.IndexOf(NamespaceQualifier);

            if (ix != -1)
            {
                ns = actualPatternKey.Substring(0, ix);
                actualPatternKey = actualPatternKey.Substring(ix + NamespaceQualifier.Length);
            }

            if (actualPatternKey != null)
            {
                int i          = 0;
                var callValues = new DicitionaryParameterSet();
                foreach (var p in Parameters)
                {
                    if ((p.Key.StartsWith("\"") || p.Key.StartsWith("'")) && (p.Key.EndsWith("\"") || p.Key.EndsWith("'")))
                    {
                        callValues["" + i] = ParameterValue.Wrap(p.Key.Substring(1, p.Key.Length - 2));
                    }
                    else
                    {
                        ParameterValue v = null;
                        if (p.Value != null)
                        {
                            v = values[p.Key].Clone();
                            v.DefaultFormat = p.Value;
                        }
                        else
                        {
                            v = values[p.Key];
                        }

                        callValues[p.Key]  = v;
                        callValues["" + i] = v;
                    }
                    ++i;
                }

                return(new UnencodedParameterValue(Manager.Get(actualPatternKey, callValues,
                                                               ns: ns, language: context.Language, returnNullOnMissing: true)));
            }
            else
            {
                //The pattern key was to be looked up and wasn't in the provided values. Return null
                return(null);
            }
        }