コード例 #1
0
 /// <summary>
 /// Manually registers the given expression provider using the given key.
 /// </summary>
 /// <param name="replacementKey">The unique key for the replacement provider (e.g. 'each' in {{each foo in bar}}</param>
 /// <param name="provider">The provider to register</param>
 /// <param name="allowOverrideExistingKeys">If true, allow this provider to replace an existing provider registered with the same key .  If false, an exception will be thrown if a conflict is found.</param>
 public void RegisterReplacementExpressionProvider(string replacementKey, IDocumentExpressionProvider provider, bool allowOverrideExistingKeys = false)
 {
     if (this.expressionProviders.ContainsKey(replacementKey))
     {
         if (allowOverrideExistingKeys)
         {
             this.expressionProviders[replacementKey] = provider;
         }
         else
         {
             throw new ArgumentException("A replacement expression provider withe key '" + replacementKey + "' already exists.  Use the allowOverrideExistingKeys flag to allow overriding the key");
         }
     }
     else
     {
         this.expressionProviders.Add(replacementKey, provider);
     }
 }
コード例 #2
0
 /// <summary>
 /// Manually registers the given expression provider using the given key.  
 /// </summary>
 /// <param name="replacementKey">The unique key for the replacement provider (e.g. 'each' in {{each foo in bar}}</param>
 /// <param name="provider">The provider to register</param>
 /// <param name="allowOverrideExistingKeys">If true, allow this provider to replace an existing provider registered with the same key .  If false, an exception will be thrown if a conflict is found.</param>
 public void RegisterReplacementExpressionProvider(string replacementKey, IDocumentExpressionProvider provider, bool allowOverrideExistingKeys = false)
 {
     if(this.expressionProviders.ContainsKey(replacementKey))
     {
         if (allowOverrideExistingKeys)
         {
             this.expressionProviders[replacementKey] = provider;
         }
         else
         {
             throw new ArgumentException("A replacement expression provider withe key '" + replacementKey + "' already exists.  Use the allowOverrideExistingKeys flag to allow overriding the key");
         }
     }
     else
     {
         this.expressionProviders.Add(replacementKey, provider);
     }
 }