コード例 #1
0
 /// <summary>
 /// Populates keyLists
 /// </summary>
 /// <exception cref="System.ArgumentNullException">docScriptArgument can't have null value!</exception>
 internal void analyse(docScriptFlags flags)
 {
     foreach (docScriptArguments arg in Keys)
     {
         if (this[arg] == null)
         {
             if (!flags.HasFlag(docScriptFlags.ignoreArgumentValueNull))
             {
                 throw new ArgumentNullException(type.toStringSafe().add(arg.ToString(), "->"), "docScriptArgument can't have null value!");
             }
             else
             {
                 // this[arg] = "";
             }
         }
         if (this[arg] is string)
         {
             keyListForStrings.Add(arg);
         }
         else if (this[arg] is IEnumerable <string> )
         {
             keyListForStringCollections.Add(arg);
         }
         else
         {
             keyListForNonStrings.Add(arg);
         }
     }
 }
コード例 #2
0
 public docScriptInstructionCompiled(docScriptInstruction __source, docScriptFlags flags) : base(__source.type)
 {
     this.copyInto(__source);
     analyse(flags);
 }
コード例 #3
0
        /// <summary>
        /// Adds the specified ins.
        /// </summary>
        /// <param name="ins">The ins.</param>
        /// <returns></returns>
        public docScriptInstructionCompiled compile(docScriptInstruction ins, IRenderExecutionContext log, PropertyCollectionDictionary __indata, PropertyCollection __extraData, docScriptFlags flags)
        {
            docScriptInstructionCompiled instructionCompiled = new docScriptInstructionCompiled(ins, flags);

            try
            {
                PropertyCollectionDictionary indata    = __indata;
                PropertyCollection           extraData = __extraData;

                if (ins.type == appendType.x_scopeIn)
                {
                    currentDataPath = ins.getProperString(d.dsa_path);
                }
                else if (ins.type == appendType.x_scopeOut)
                {
                    currentDataPath = currentDataPath.getPathVersion(1, "\\", true);
                }

                PropertyCollection dataItem = null;
                if (indata != null)
                {
                    var tmp = indata[currentDataPath];
#pragma warning disable CS0184 // The given expression is never of the provided ('DictionaryEntry') type
                    if (tmp is DictionaryEntry)
#pragma warning restore CS0184 // The given expression is never of the provided ('DictionaryEntry') type
                    {
                        //DictionaryEntry entry = (DictionaryEntry)tmp;
                        //dataItem = entry.Value as PropertyCollection;
                    }
                    else
                    {
                        dataItem = tmp as PropertyCollection;
                    }
                }

                /// Compiling data into template
                instructionCompiled.compileTemplate(dataItem, extraData);

                if (instructionCompiled.isCompileFailed)
                {
                    string msg = scriptInstructions.Count().ToString("D4") + " " + ins.type.ToString() + " failed on: " + instructionCompiled.missingData.toCsvInLine();
                    if (flags.HasFlag(docScriptFlags.ignoreCompilationFails))
                    {
                        log.log(msg);
                    }
                    else
                    {
                        log.compileError(msg, instructionCompiled);
                    }

                    if (flags.HasFlag(docScriptFlags.allowFailedInstructions))
                    {
                        scriptInstructions.Add(instructionCompiled);
                    }
                    scriptInstructionsFailed.Add(instructionCompiled);
                }
                else
                {
                    scriptInstructions.Add(instructionCompiled);

                    if (instructionCompiled.isCompilable)
                    {
                        // log.log("--- compiled Strings(" + instructionCompiled.keyListForStrings.Count + ") and StringCollections(" + instructionCompiled.keyListForStringCollections.Count + ")");
                    }
                }

                missingData.AddRange(instructionCompiled.missingData);
            }
            catch (Exception ex)
            {
            }
            return(instructionCompiled);
        }