Example #1
0
    /// <summary>
    /// Registers all workflow methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        MacroMethod passedThroughActions = new MacroMethod("PassedThroughActions", PassedThroughActions)
        {
            Comment           = "Returns true if document passed through specified actions.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TreeNode)
            }
        };

        passedThroughActions.AddParameter("document", typeof(TreeNode), "Document to check.");
        passedThroughActions.AddParameter("actions", typeof(string), "Action names separated with a semicolon");
        passedThroughActions.AddParameter("allActions", typeof(string), "If true, document must have passed through all specified actions. One of them is sufficient otherwise.");
        MacroMethods.RegisterMethod(passedThroughActions);

        MacroMethod passedThroughSteps = new MacroMethod("PassedThroughSteps", PassedThroughSteps)
        {
            Comment           = "Returns true if document passed through specified tags.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TreeNode)
            }
        };

        passedThroughSteps.AddParameter("document", typeof(TreeNode), "Document to check.");
        passedThroughSteps.AddParameter("steps", typeof(string), "Step names separated with a semicolon");
        passedThroughSteps.AddParameter("allSteps", typeof(bool), "If true, document must have passed through all specified steps. One of them is sufficient otherwise.");
        MacroMethods.RegisterMethod(passedThroughSteps);
    }
Example #2
0
    /// <summary>
    /// Registers all translation services methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get user name
        MacroMethod isTranslationReady = new MacroMethod("IsTranslationReady", IsTranslationReady)
        {
            Comment           = "Returns true if there is at least one translation submission item with target XLIFF ready to import.",
            Type              = typeof(bool),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(CMS.DocumentEngine.TreeNode), typeof(DocumentInfo)
            }
        };

        isTranslationReady.AddParameter("document", typeof(CMS.DocumentEngine.TreeNode), "Document to check.");
        MacroMethods.RegisterMethod(isTranslationReady);

        MacroMethod getTranslationPriority = new MacroMethod("GetTranslationPriority", GetTranslationPriority)
        {
            Comment           = "Returns priority name from priority integer constant.",
            Type              = typeof(string),
            MinimumParameters = 1,
        };

        getTranslationPriority.AddParameter("priorty", typeof(int), "Priority integer constant.");
        MacroMethods.RegisterMethod(getTranslationPriority);
    }
    /// <summary>
    /// Registers all automation methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        MacroMethod passedThroughActions = new MacroMethod("PassedThroughAutomationActions", PassedThroughActions)
        {
            Comment = "Returns true if process passed through specified actions.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(AutomationStateInfo) }
        };
        passedThroughActions.AddParameter("state", typeof(AutomationStateInfo), "Process instance to check.");
        passedThroughActions.AddParameter("actions", typeof(string), "Action names separated with a semicolon");
        passedThroughActions.AddParameter("allActions", typeof(string), "If true, process must have passed through all specified actions. One of them is sufficient otherwise.");
        MacroMethods.RegisterMethod(passedThroughActions);

        MacroMethod passedThroughSteps = new MacroMethod("PassedThroughAutomationSteps", PassedThroughSteps)
        {
            Comment = "Returns true if process passed through specified tags.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(AutomationStateInfo) }
        };
        passedThroughSteps.AddParameter("state", typeof(AutomationStateInfo), "Process instance to check.");
        passedThroughSteps.AddParameter("steps", typeof(string), "Step names separated with a semicolon");
        passedThroughSteps.AddParameter("allSteps", typeof(bool), "If true, process must have passed through all specified steps. One of them is sufficient otherwise.");
        MacroMethods.RegisterMethod(passedThroughSteps);
    }
 /// <summary>
 /// Registers all blog methods to macro resolver.
 /// </summary>
 public static void RegisterMethods()
 {
     // Get user name
     MacroMethod getBoardMessagesCount = new MacroMethod("GetBoardMessagesCount", GetBoardMessagesCount)
     {
         Comment = "Returns count of messages in messageboard.",
         Type = typeof(int),
         MinimumParameters = 2,
         AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
     };
     getBoardMessagesCount.AddParameter("documentId", typeof(int), "ID of the document.");
     getBoardMessagesCount.AddParameter("boardWebpartName", typeof(object), "Name of the webpart used for creating messageboard.");
     getBoardMessagesCount.AddParameter("type", typeof(object), "String constant representing the type of board 'user', 'group' or 'document' (default) are accepted.");
     MacroMethods.RegisterMethod(getBoardMessagesCount);
 }
 /// <summary>
 /// Registers all forum methods to macro resolver.
 /// </summary>
 public static void RegisterMethods()
 {
     // Get post URL
     MacroMethod getPostURL = new MacroMethod("GetPostURL", GetPostURL)
     {
         Comment = "Returns link to selected post.",
         Type = typeof(string),
         MinimumParameters = 2,
         AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
     };
     getPostURL.AddParameter("postIdPath", typeof(object), "Post ID path.");
     getPostURL.AddParameter("forumId", typeof(object), "Forum ID.");
     getPostURL.AddParameter("aliasPath", typeof(object), "Alias path.");
     MacroMethods.RegisterMethod(getPostURL);
 }
Example #6
0
    /// <summary>
    /// Returns method help (return type, name and parameters), highlites current parameter.
    /// </summary>
    /// <param name="method">Method object</param>
    /// <param name="paramNumber">Number of the parameter which should be highlighted</param>
    /// <param name="withoutFirstParam">If true, first parameter is not rendered</param>
    private static string GetMethodString(MacroMethod method, int paramNumber, bool withoutFirstParam)
    {
        string currentParamComment = "";
        string currentParamName    = "";
        string parameters          = "";

        int startParam = (withoutFirstParam ? 1 : 0);

        if (method.Parameters != null)
        {
            for (int i = startParam; i < method.Parameters.Count; i++)
            {
                MacroMethodParam p         = method.Parameters[i];
                string           paramtype = null;
                if (p.IsParams)
                {
                    paramtype = "params " + p.Type.Name + "[]";
                }
                else
                {
                    paramtype = p.Type.Name;
                }
                string param = paramtype + " " + p.Name;
                if (i >= method.MinimumParameters)
                {
                    param = "<i>" + param + "</i>";
                }
                int index = i - startParam;
                if ((index == paramNumber) || (p.IsParams && (index <= paramNumber)))
                {
                    currentParamName    = p.Name;
                    currentParamComment = p.Comment;
                    param = "<strong>" + param + "</strong>";
                }
                parameters += ", " + param;
            }
        }
        if (parameters != "")
        {
            parameters = parameters.Substring(2);
        }

        string type          = (method.Type == null ? "object" : method.Type.Name);
        string methodComment = (string.IsNullOrEmpty(method.Comment) ? "" : "<strong>" + method.Comment + "</strong><br/><br />");
        string paramComment  = (string.IsNullOrEmpty(currentParamComment) ? "" : "<br/><br/><strong>" + currentParamName + ":&nbsp;</strong>" + currentParamComment);

        return(methodComment + type + " " + method.Name + "(" + parameters + ")" + paramComment);
    }
Example #7
0
    /// <summary>
    /// Returns method help (return type, name and parameters), highlites current parameter.
    /// </summary>
    /// <param name="method">Method object</param>
    /// <param name="paramNumber">Number of the parameter which should be highlighted</param>
    /// <param name="withoutFirstParam">If true, first parameter is not rendered</param>
    private static string GetMethodString(MacroMethod method, int paramNumber, bool withoutFirstParam)
    {
        string currentParamComment = "";
        string currentParamName    = "";
        string parameters          = "";

        if (method.ParameterDefinition != null)
        {
            int stratParam = (withoutFirstParam ? 1 : 0);
            object[,] methodParameters = method.ParameterDefinition;
            for (int i = stratParam; i <= methodParameters.GetUpperBound(0); i++)
            {
                string paramtype;
                if (methodParameters[i, 1] is Type)
                {
                    paramtype = ((Type)methodParameters[i, 1]).Name;
                }
                else
                {
                    paramtype = methodParameters[i, 1].ToString();
                }
                string param = paramtype + " " + methodParameters[i, 0].ToString();
                if (i >= method.MinimumParameters)
                {
                    param = "<i>" + param + "</i>";
                }
                if (i - stratParam == paramNumber)
                {
                    currentParamName    = methodParameters[i, 0].ToString();
                    currentParamComment = methodParameters[i, 2].ToString();
                    param = "<strong>" + param + "</strong>";
                }
                parameters += ", " + param;
            }
            if (parameters != "")
            {
                parameters = parameters.Substring(2);
            }
        }

        string type          = (method.Type == null ? "object" : ((Type)method.Type).Name);
        string methodComment = (string.IsNullOrEmpty(method.Comment) ? "" : "<strong>" + method.Comment + "</strong><br/><br />");
        string paramComment  = (string.IsNullOrEmpty(currentParamComment) ? "" : "<br/><br/><strong>" + currentParamName + ":&nbsp;</strong>" + currentParamComment);

        return(methodComment + type + " " + method.Name + "(" + parameters + ")" + paramComment);
    }
    /// <summary>
    /// Registers all blog methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get user name
        MacroMethod getBoardMessagesCount = new MacroMethod("GetBoardMessagesCount", GetBoardMessagesCount)
        {
            Comment           = "Returns count of messages in messageboard.",
            Type              = typeof(int),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getBoardMessagesCount.AddParameter("documentId", typeof(int), "ID of the document.");
        getBoardMessagesCount.AddParameter("boardWebpartName", typeof(object), "Name of the webpart used for creating messageboard.");
        getBoardMessagesCount.AddParameter("type", typeof(object), "String constant representing the type of board 'user', 'group' or 'document' (default) are accepted.");
        MacroMethods.RegisterMethod(getBoardMessagesCount);
    }
    /// <summary>
    /// Registers all forum methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get post URL
        MacroMethod getPostURL = new MacroMethod("GetPostURL", GetPostURL)
        {
            Comment           = "Returns link to selected post.",
            Type              = typeof(string),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getPostURL.AddParameter("postIdPath", typeof(object), "Post ID path.");
        getPostURL.AddParameter("forumId", typeof(object), "Forum ID.");
        getPostURL.AddParameter("aliasPath", typeof(object), "Alias path.");
        MacroMethods.RegisterMethod(getPostURL);
    }
    /// <summary>
    /// Registers all translation services methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get user name
        MacroMethod isTranslationReady = new MacroMethod("IsTranslationReady", IsTranslationReady)
        {
            Comment = "Returns true if there is at least one translation submission item with target XLIFF ready to import.",
            Type = typeof(bool),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(CMS.DocumentEngine.TreeNode), typeof(DocumentInfo) }
        };
        isTranslationReady.AddParameter("document", typeof(CMS.DocumentEngine.TreeNode), "Document to check.");
        MacroMethods.RegisterMethod(isTranslationReady);

        MacroMethod getTranslationPriority = new MacroMethod("GetTranslationPriority", GetTranslationPriority)
        {
            Comment = "Returns priority name from priority integer constant.",
            Type = typeof(string),
            MinimumParameters = 1,
        };
        getTranslationPriority.AddParameter("priorty", typeof(int), "Priority integer constant.");
        MacroMethods.RegisterMethod(getTranslationPriority);
    }
    /// <summary>
    /// Registers all media library methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get media file URL
        MacroMethod getMediaFileUrl = new MacroMethod("GetMediaFileUrl", GetMediaFileUrl)
        {
            Comment           = "Returns direct URL to the media file, user permissions are not checked.",
            Type              = typeof(string),
            MinimumParameters = 5,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getMediaFileUrl.AddParameter("libraryId", typeof(object), "Media library ID.");
        getMediaFileUrl.AddParameter("filePath", typeof(object), "File path.");
        getMediaFileUrl.AddParameter("fileGuid", typeof(object), "File GUID.");
        getMediaFileUrl.AddParameter("fileName", typeof(object), "File name.");
        getMediaFileUrl.AddParameter("useSecureLinks", typeof(object), "Determines whether to generate secure link.");
        getMediaFileUrl.AddParameter("downloadlink", typeof(object), "Determines whether disposition parametr should be added to permanent link.");
        MacroMethods.RegisterMethod(getMediaFileUrl);

        // Get media file URL with check
        MacroMethod getMediaFileUrlWithCheck = new MacroMethod("GetMediaFileUrlWithCheck", GetMediaFileUrlWithCheck)
        {
            Comment           = "Returns URL to media file which is rewritten to calling GetMediaFile.aspx page where user permissions are checked.",
            Type              = typeof(string),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getMediaFileUrlWithCheck.AddParameter("fileGuid", typeof(object), "File GUID.");
        getMediaFileUrlWithCheck.AddParameter("fileName", typeof(object), "File name.");
        MacroMethods.RegisterMethod(getMediaFileUrlWithCheck);

        // Get media file direct URL
        MacroMethod getMediaFileDirectUrl = new MacroMethod("GetMediaFileDirectUrl", GetMediaFileDirectUrl)
        {
            Comment           = "Returns direct URL to the media file, user permissions are not checked.",
            Type              = typeof(string),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getMediaFileDirectUrl.AddParameter("libraryId", typeof(object), "Media library ID.");
        getMediaFileDirectUrl.AddParameter("filePath", typeof(object), "File path.");
        MacroMethods.RegisterMethod(getMediaFileDirectUrl);

        // Get media file detail URL
        MacroMethod getMediaFileDetailUrl = new MacroMethod("GetMediaFileDetailUrl", GetMediaFileDetailUrl)
        {
            Comment           = "Returns URL to detail of media file.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getMediaFileDetailUrl.AddParameter("fileId", typeof(object), "File ID.");
        getMediaFileDetailUrl.AddParameter("parameter", typeof(string), "Query parameter name (\"fileId\" by default).");
        MacroMethods.RegisterMethod(getMediaFileDetailUrl);
    }
    /// <summary>
    /// Returns method help (return type, name and parameters), highlites current parameter.
    /// </summary>
    /// <param name="method">Method object</param>
    /// <param name="paramNumber">Number of the parameter which should be highlighted</param>
    /// <param name="withoutFirstParam">If true, first parameter is not rendered</param>
    private static string GetMethodString(MacroMethod method, int paramNumber, bool withoutFirstParam)
    {
        string currentParamComment = "";
        string currentParamName = "";
        string parameters = "";

        int startParam = (withoutFirstParam ? 1 : 0);
        if (method.Parameters != null)
        {
            for (int i = startParam; i < method.Parameters.Count; i++)
            {
                MacroMethodParam p = method.Parameters[i];
                string paramtype = null;
                if (p.IsParams)
                {
                    paramtype = "params " + p.Type.Name + "[]";
                }
                else
                {
                    paramtype = p.Type.Name;
                }
                string param = paramtype + " " + p.Name;
                if (i >= method.MinimumParameters)
                {
                    param = "<i>" + param + "</i>";
                }
                int index = i - startParam;
                if ((index == paramNumber) || (p.IsParams && (index <= paramNumber)))
                {
                    currentParamName = p.Name;
                    currentParamComment = p.Comment;
                    param = "<strong>" + param + "</strong>";
                }
                parameters += ", " + param;
            }
        }
        if (parameters != "")
        {
            parameters = parameters.Substring(2);
        }

        string type = (method.Type == null ? "object" : method.Type.Name);
        string methodComment = (string.IsNullOrEmpty(method.Comment) ? "" : "<strong>" + method.Comment + "</strong><br/><br />");
        string paramComment = (string.IsNullOrEmpty(currentParamComment) ? "" : "<br/><br/><strong>" + currentParamName + ":&nbsp;</strong>" + currentParamComment);

        return methodComment + type + " " + method.Name + "(" + parameters + ")" + paramComment;
    }
    /// <summary>
    /// Registers all media library methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get media file URL
        MacroMethod getMediaFileUrl = new MacroMethod("GetMediaFileUrl", GetMediaFileUrl)
        {
            Comment = "Returns direct URL to the media file, user permissions are not checked.",
            Type = typeof(string),
            MinimumParameters = 5,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getMediaFileUrl.AddParameter("libraryId", typeof(object), "Media library ID.");
        getMediaFileUrl.AddParameter("filePath", typeof(object), "File path.");
        getMediaFileUrl.AddParameter("fileGuid", typeof(object), "File GUID.");
        getMediaFileUrl.AddParameter("fileName", typeof(object), "File name.");
        getMediaFileUrl.AddParameter("useSecureLinks", typeof(object), "Determines whether to generate secure link.");
        getMediaFileUrl.AddParameter("downloadlink", typeof(object), "Determines whether disposition parametr should be added to permanent link.");
        MacroMethods.RegisterMethod(getMediaFileUrl);

        // Get media file URL with check
        MacroMethod getMediaFileUrlWithCheck = new MacroMethod("GetMediaFileUrlWithCheck", GetMediaFileUrlWithCheck)
        {
            Comment = "Returns URL to media file which is rewritten to calling GetMediaFile.aspx page where user permissions are checked.",
            Type = typeof(string),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getMediaFileUrlWithCheck.AddParameter("fileGuid", typeof(object), "File GUID.");
        getMediaFileUrlWithCheck.AddParameter("fileName", typeof(object), "File name.");
        MacroMethods.RegisterMethod(getMediaFileUrlWithCheck);

        // Get media file direct URL
        MacroMethod getMediaFileDirectUrl = new MacroMethod("GetMediaFileDirectUrl", GetMediaFileDirectUrl)
        {
            Comment = "Returns direct URL to the media file, user permissions are not checked.",
            Type = typeof(string),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getMediaFileDirectUrl.AddParameter("libraryId", typeof(object), "Media library ID.");
        getMediaFileDirectUrl.AddParameter("filePath", typeof(object), "File path.");
        MacroMethods.RegisterMethod(getMediaFileDirectUrl);

        // Get media file detail URL
        MacroMethod getMediaFileDetailUrl = new MacroMethod("GetMediaFileDetailUrl", GetMediaFileDetailUrl)
        {
            Comment = "Returns URL to detail of media file.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getMediaFileDetailUrl.AddParameter("fileId", typeof(object), "File ID.");
        getMediaFileDetailUrl.AddParameter("parameter", typeof(string), "Query parameter name (\"fileId\" by default).");
        MacroMethods.RegisterMethod(getMediaFileDetailUrl);
    }
    /// <summary>
    /// Registers all ecommerce methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get add to shopping cart link
        MacroMethod getAddToShoppingCartLink = new MacroMethod("GetAddToShoppingCartLink", GetAddToShoppingCartLink)
        {
            Comment           = "Returns link to \"add to shoppingcart\".",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getAddToShoppingCartLink.AddParameter("productId", typeof(object), "Product ID.");
        getAddToShoppingCartLink.AddParameter("enabled", typeof(object), "Indicates whether product is enabled or not.");
        MacroMethods.RegisterMethod(getAddToShoppingCartLink);

        // Get add to wishlist link
        MacroMethod getAddToWishListLink = new MacroMethod("GetAddToWishListLink", GetAddToWishListLink)
        {
            Comment           = "Returns link to add specified product to the user's wishlist.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getAddToWishListLink.AddParameter("productId", typeof(object), "Product ID.");
        MacroMethods.RegisterMethod(getAddToWishListLink);

        // Get remove from wishlist link
        MacroMethod getRemoveFromWishListLink = new MacroMethod("GetRemoveFromWishListLink", GetRemoveFromWishListLink)
        {
            Comment           = "Returns link to remove specified product from the user's wishlist.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getRemoveFromWishListLink.AddParameter("productId", typeof(object), "Product ID.");
        MacroMethods.RegisterMethod(getRemoveFromWishListLink);

        // Get public status name
        MacroMethod gtPublicStatusName = new MacroMethod("GetPublicStatusName", GetPublicStatusName)
        {
            Comment           = "Returns the public SKU status display name.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        gtPublicStatusName.AddParameter("statusId", typeof(object), "Status ID");
        MacroMethods.RegisterMethod(gtPublicStatusName);

        // Get shopping cart URL
        MacroMethod shoppingCartURL = new MacroMethod("ShoppingCartURL", ShoppingCartURL)
        {
            Comment           = "Returns URL to the shopping cart.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        shoppingCartURL.AddParameter("siteName", typeof(string), "Site name.");
        MacroMethods.RegisterMethod(shoppingCartURL);

        // Get wishlist URL
        MacroMethod wishlistURL = new MacroMethod("WishlistURL", WishlistURL)
        {
            Comment           = "Returns URL to the wish list.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        wishlistURL.AddParameter("siteName", typeof(string), "Site name");
        MacroMethods.RegisterMethod(wishlistURL);

        // Get product URL
        MacroMethod getProductUrl = new MacroMethod("GetProductUrl", GetProductUrl)
        {
            Comment           = "Returns product URL.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getProductUrl.AddParameter("skuId", typeof(object), "SKU ID.");
        MacroMethods.RegisterMethod(getProductUrl);

        // Get product URL by GUID
        MacroMethod getProductUrlByGUID = new MacroMethod("GetProductUrlByGUID", GetProductUrlByGUID)
        {
            Comment           = "Returns user friendly URL of the specified SKU.",
            Type              = typeof(string),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getProductUrlByGUID.AddParameter("skuGuid", typeof(object), "SKU GUID.");
        getProductUrlByGUID.AddParameter("skuName", typeof(object), "SKU name.");
        getProductUrlByGUID.AddParameter("siteName", typeof(object), "Site name.");
        MacroMethods.RegisterMethod(getProductUrlByGUID);

        // Get manufacturer
        MacroMethod getManufacturer = new MacroMethod("GetManufacturer", GetManufacturer)
        {
            Comment           = "Gets object from the specified column of the manufacturer with specific ID.",
            Type              = typeof(object),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getManufacturer.AddParameter("id", typeof(int), "Manufacturer ID.");
        getManufacturer.AddParameter("column", typeof(string), "Column name.");
        MacroMethods.RegisterMethod(getManufacturer);

        // Get department
        MacroMethod getDepartment = new MacroMethod("GetDepartment", GetDepartment)
        {
            Comment           = "Gets object from the specified column of the department with specific ID.",
            Type              = typeof(object),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getDepartment.AddParameter("id", typeof(int), "Department ID.");
        getDepartment.AddParameter("column", typeof(string), "Column name.");
        MacroMethods.RegisterMethod(getDepartment);

        // Get supplier
        MacroMethod getSupplier = new MacroMethod("GetSupplier", GetSupplier)
        {
            Comment           = "Gets object from the specified column of the supplier with specific ID.",
            Type              = typeof(object),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getSupplier.AddParameter("id", typeof(int), "Supplier ID.");
        getSupplier.AddParameter("column", typeof(string), "Column name.");
        MacroMethods.RegisterMethod(getSupplier);

        // Get internal status
        MacroMethod getInternalStatus = new MacroMethod("GetInternalStatus", GetInternalStatus)
        {
            Comment           = "Gets object from the specified column of the internal status with specific ID.",
            Type              = typeof(object),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getInternalStatus.AddParameter("id", typeof(int), "Internal status ID.");
        getInternalStatus.AddParameter("column", typeof(string), "Column name.");
        MacroMethods.RegisterMethod(getInternalStatus);

        // Get public status
        MacroMethod getPublicStatus = new MacroMethod("GetPublicStatus", GetPublicStatus)
        {
            Comment           = "Gets object from the specified column of the public status with specific ID.",
            Type              = typeof(object),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getPublicStatus.AddParameter("id", typeof(int), "Public status ID.");
        getPublicStatus.AddParameter("column", typeof(string), "Column name.");
        MacroMethods.RegisterMethod(getPublicStatus);

        // Get product image
        MacroMethod getProductImage = new MacroMethod("GetProductImage", GetProductImage)
        {
            Comment           = "Returns complete HTML code of the specified resized product image, if not such image exists, default image is returned.",
            Type              = typeof(string),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getProductImage.AddParameter("imageUrl", typeof(object), "Product image url.");
        getProductImage.AddParameter("alt", typeof(object), "Image alternate text.");
        getProductImage.AddParameter("maxSideSize", typeof(object), "Max side size of the image.");
        getProductImage.AddParameter("width", typeof(object), "Width of the image.");
        getProductImage.AddParameter("height", typeof(object), "Height of the image.");
        MacroMethods.RegisterMethod(getProductImage);

        // Format price
        MacroMethod formatPrice = new MacroMethod("FormatPrice", FormatPrice)
        {
            Comment           = "Returns price rounded and formatted according to the current currency properties.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        formatPrice.AddParameter("price", typeof(double), "Price to be formatted");
        formatPrice.AddParameter("round", typeof(bool), "True - price is rounded according to the current currency settings before formatting");
        MacroMethods.RegisterMethod(formatPrice);

        // Cart items count
        MacroMethod getShoppingCartItemsCount = new MacroMethod("GetShoppingCartItemsCount", GetShoppingCartItemsCount)
        {
            Comment           = "Returns number of products in current shopping cart.",
            Type              = typeof(int),
            MinimumParameters = 0,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        MacroMethods.RegisterMethod(getShoppingCartItemsCount);
    }
    /// <summary>
    /// Registers all blog methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get user name
        MacroMethod getUserName = new MacroMethod("GetUserName", GetUserName)
        {
            Comment = "Returns user name.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getUserName.AddParameter("userId", typeof(object), "User ID.");
        MacroMethods.RegisterMethod(getUserName);

        // Get user full name
        MacroMethod getUserFullName = new MacroMethod("GetUserFullName", GetUserFullName)
        {
            Comment = "Returns user full name.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getUserFullName.AddParameter("userId", typeof(object), "User ID.");
        MacroMethods.RegisterMethod(getUserFullName);

        // Get blog comment count
        MacroMethod getBlogCommentsCount = new MacroMethod("GetBlogCommentsCount", GetBlogCommentsCount)
        {
            Comment = "Returns number of comments of given blog.",
            Type = typeof(int),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getBlogCommentsCount.AddParameter("postId", typeof(object), "Post document ID.");
        getBlogCommentsCount.AddParameter("postAliasPath", typeof(object), "Post alias path.");
        getBlogCommentsCount.AddParameter("includingTrackbacks", typeof(bool), "Indicates if trackback comments should be included (true by default).");
        MacroMethods.RegisterMethod(getBlogCommentsCount);

        // Get document tags
        MacroMethod getDocumentTags = new MacroMethod("GetDocumentTags", GetDocumentTags)
        {
            Comment = "Gets a list of links of tags assigned for the specific document pointing to the page with URL specified.",
            Type = typeof(string),
            MinimumParameters = 3,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getDocumentTags.AddParameter("documentGroupId", typeof(object), "ID of the group document tags belong to.");
        getDocumentTags.AddParameter("documentTags", typeof(object), "String containing all the tags related to the document.");
        getDocumentTags.AddParameter("documentListPageUrl", typeof(string), "URL of the page displaying other documents of the specified tag.");
        MacroMethods.RegisterMethod(getDocumentTags);
    }
Example #16
0
    /// <summary>
    /// Register all content macro methods to re
    /// </summary>
    public static void RegisterMethods()
    {
        MacroMethod isInCategories = new MacroMethod("IsInCategories", IsInCategories)
        {
            Comment           = "Returns true if document is in selected categories.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TreeNode)
            }
        };

        isInCategories.AddParameter("document", typeof(TreeNode), "Document to check.");
        isInCategories.AddParameter("categories", typeof(string), "Category names separated with a semicolon.");
        isInCategories.AddParameter("allCategories", typeof(bool), "If true, document must be in all of the specified categories.");
        MacroMethods.RegisterMethod(isInCategories);

        MacroMethod hasTags = new MacroMethod("HasTags", HasTags)
        {
            Comment           = "Returns true if document has specified tags.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TreeNode)
            }
        };

        hasTags.AddParameter("document", typeof(TreeNode), "Document to check.");
        hasTags.AddParameter("tags", typeof(string), "List of tags separated with a semicolon.");
        hasTags.AddParameter("allTags", typeof(bool), "If true, document must have all specified tags. If false, one of specified tags is sufficient.");
        MacroMethods.RegisterMethod(hasTags);

        MacroMethod isInRelationship = new MacroMethod("IsInRelationship", IsInRelationship)
        {
            Comment           = "Returns true if document has left or right relationship with specified document.",
            Type              = typeof(bool),
            MinimumParameters = 4,
            AllowedTypes      = new List <Type>()
            {
                typeof(TreeNode)
            }
        };

        isInRelationship.AddParameter("document", typeof(TreeNode), "Document to check.");
        isInRelationship.AddParameter("side", typeof(string), "Side of checked document in the relationship.");
        isInRelationship.AddParameter("relationship", typeof(string), "Relationship name.");
        isInRelationship.AddParameter("relatedDocument", typeof(string), "Related document.");
        isInRelationship.AddParameter("relatedDocumentSite", typeof(string), "Related document site name.");
        MacroMethods.RegisterMethod(isInRelationship);

        MacroMethod isTranslatedTo = new MacroMethod("IsTranslatedTo", IsTranslatedTo)
        {
            Comment           = "Returns true if document is translated to one of selected cultures.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TreeNode)
            }
        };

        isTranslatedTo.AddParameter("document", typeof(TreeNode), "Document to check.");
        isTranslatedTo.AddParameter("cultures", typeof(string), "Culture codes separated with a semicolon.");
        isTranslatedTo.AddParameter("publishedOnly", typeof(bool), "Indicates whether only published translations should be considered.");
        MacroMethods.RegisterMethod(isTranslatedTo);
    }
    /// <summary>
    /// Register all content macro methods to re
    /// </summary>
    public static void RegisterMethods()
    {
        MacroMethod isInCategories = new MacroMethod("IsInCategories", IsInCategories)
        {
            Comment = "Returns true if document is in selected categories.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TreeNode) }
        };
        isInCategories.AddParameter("document", typeof(TreeNode), "Document to check.");
        isInCategories.AddParameter("categories", typeof(string), "Category names separated with a semicolon.");
        isInCategories.AddParameter("allCategories", typeof(bool), "If true, document must be in all of the specified categories.");
        MacroMethods.RegisterMethod(isInCategories);

        MacroMethod hasTags = new MacroMethod("HasTags", HasTags)
        {
            Comment = "Returns true if document has specified tags.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TreeNode) }
        };
        hasTags.AddParameter("document", typeof(TreeNode), "Document to check.");
        hasTags.AddParameter("tags", typeof(string), "List of tags separated with a semicolon.");
        hasTags.AddParameter("allTags", typeof(bool), "If true, document must have all specified tags. If false, one of specified tags is sufficient.");
        MacroMethods.RegisterMethod(hasTags);

        MacroMethod isInRelationship = new MacroMethod("IsInRelationship", IsInRelationship)
        {
            Comment = "Returns true if document has left or right relationship with specified document.",
            Type = typeof(bool),
            MinimumParameters = 4,
            AllowedTypes = new List<Type>() { typeof(TreeNode) }
        };
        isInRelationship.AddParameter("document", typeof(TreeNode), "Document to check.");
        isInRelationship.AddParameter("side", typeof(string), "Side of checked document in the relationship.");
        isInRelationship.AddParameter("relationship", typeof(string), "Relationship name.");
        isInRelationship.AddParameter("relatedDocument", typeof(string), "Related document.");
        isInRelationship.AddParameter("relatedDocumentSite", typeof(string), "Related document site name.");
        MacroMethods.RegisterMethod(isInRelationship);

        MacroMethod isTranslatedTo = new MacroMethod("IsTranslatedTo", IsTranslatedTo)
        {
            Comment = "Returns true if document is translated to one of selected cultures.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TreeNode) }
        };
        isTranslatedTo.AddParameter("document", typeof(TreeNode), "Document to check.");
        isTranslatedTo.AddParameter("cultures", typeof(string), "Culture codes separated with a semicolon.");
        isTranslatedTo.AddParameter("publishedOnly", typeof(bool), "Indicates whether only published translations should be considered.");
        MacroMethods.RegisterMethod(isTranslatedTo);
    }
Example #18
0
    /// <summary>
    /// Returns context help (current method parameters).
    /// </summary>
    /// <param name="tokens">Lexems from lexical analysis</param>
    /// <param name="currentElement">Current lexem</param>
    /// <param name="currentElementIndex">Index of the current lexem</param>
    private string GetContext(List <MacroElement> tokens, MacroElement currentElement, int currentElementIndex)
    {
        string methodName        = "";
        int    paramNumber       = 0;
        int    brackets          = 0;
        bool   withoutFirstParam = false;

        for (int i = currentElementIndex; i >= 0; i--)
        {
            ElementType type = tokens[i].Type;

            if (brackets == 0)
            {
                // Count number of commas before current element (it's the current number of parameter)
                if (type == ElementType.Comma)
                {
                    paramNumber++;
                }

                // We need to take context to the left side of current lexem
                // It needs to preserve the structure (deepnes withing the brackets)
                if (type == ElementType.LeftBracket)
                {
                    if ((i > 0) && (tokens[i - 1].Type == ElementType.Identifier))
                    {
                        methodName = tokens[i - 1].Expression;
                        if (i > 2)
                        {
                            bool isNamespaceCall = false;
                            if (tokens[i - 3].Type == ElementType.Identifier)
                            {
                                string exprToCheck = tokens[i - 3].Expression;
                                foreach (string item in NamespacesInUse)
                                {
                                    if (item.ToLower() == exprToCheck.ToLower())
                                    {
                                        isNamespaceCall = true;
                                        break;
                                    }
                                }
                            }

                            withoutFirstParam = (tokens[i - 2].Type == ElementType.Dot) && !isNamespaceCall;
                        }
                    }
                    break;
                }
                else if (type == ElementType.LeftIndexer)
                {
                    return("Indexer: Type number or name of the element.");
                }
            }

            // Ensure correct deepnes within the brackets
            if ((type == ElementType.RightBracket) || (type == ElementType.RightIndexer))
            {
                brackets++;
            }
            else if ((type == ElementType.LeftBracket) || (type == ElementType.LeftIndexer))
            {
                brackets--;
            }
        }

        MacroMethod method = MacroMethods.GetMethod(methodName);

        if (method != null)
        {
            return(GetMethodString(method, paramNumber, withoutFirstParam));
        }

        // Method not known or there is syntax error in the expression
        return("");
    }
    /// <summary>
    /// Returns method help (return type, name and parameters), highlites current parameter.
    /// </summary>
    /// <param name="method">Method object</param>
    /// <param name="paramNumber">Number of the parameter which should be highlighted</param>
    /// <param name="withoutFirstParam">If true, first parameter is not rendered</param>
    private static string GetMethodString(MacroMethod method, int paramNumber, bool withoutFirstParam)
    {
        string currentParamComment = "";
        string currentParamName = "";
        string parameters = "";
        if (method.ParameterDefinition != null)
        {
            int stratParam = (withoutFirstParam ? 1 : 0);
            object[,] methodParameters = method.ParameterDefinition;
            for (int i = stratParam; i <= methodParameters.GetUpperBound(0); i++)
            {
                string paramtype;
                if (methodParameters[i, 1] is Type)
                {
                    paramtype = ((Type)methodParameters[i, 1]).Name;
                }
                else
                {
                    paramtype = methodParameters[i, 1].ToString();
                }
                string param = paramtype + " " + methodParameters[i, 0].ToString();
                if (i >= method.MinimumParameters)
                {
                    param = "<i>" + param + "</i>";
                }
                if (i - stratParam == paramNumber)
                {
                    currentParamName = methodParameters[i, 0].ToString();
                    currentParamComment = methodParameters[i, 2].ToString();
                    param = "<strong>" + param + "</strong>";
                }
                parameters += ", " + param;
            }
            if (parameters != "")
            {
                parameters = parameters.Substring(2);
            }
        }

        string type = (method.Type == null ? "object" : ((Type)method.Type).Name);
        string methodComment = (string.IsNullOrEmpty(method.Comment) ? "" : "<strong>" + method.Comment + "</strong><br/><br />");
        string paramComment = (string.IsNullOrEmpty(currentParamComment) ? "" : "<br/><br/><strong>" + currentParamName + ":&nbsp;</strong>" + currentParamComment);

        return methodComment + type + " " + method.Name + "(" + parameters + ")" + paramComment;
    }
    /// <summary>
    /// Registers all web analytics methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        MacroMethod isReturningVisitor = new MacroMethod("IsReturningVisitor", IsReturningVisitor)
        {
            Comment           = "Returns true if current visitor is returning.",
            Type              = typeof(bool),
            MinimumParameters = 0,
            AllowedTypes      = new List <Type>()
            {
                typeof(VisitorNamespace)
            }
        };

        MacroMethods.RegisterMethod(isReturningVisitor);

        MacroMethod isFirstTimeVisitor = new MacroMethod("IsFirstTimeVisitor", IsFirstTimeVisitor)
        {
            Comment           = "Returns true if current visitor comes to the website for the first time.",
            Type              = typeof(bool),
            MinimumParameters = 0,
            AllowedTypes      = new List <Type>()
            {
                typeof(VisitorNamespace)
            }
        };

        MacroMethods.RegisterMethod(isFirstTimeVisitor);

        MacroMethod getSearchEngineKeyword = new MacroMethod("GetSearchEngineKeyword", GetSearchEngineKeyword)
        {
            Comment           = "Returns search keywords from search engine visitor came from.",
            Type              = typeof(string),
            MinimumParameters = 0,
            AllowedTypes      = new List <Type>()
            {
                typeof(VisitorNamespace)
            }
        };

        MacroMethods.RegisterMethod(getSearchEngineKeyword);

        MacroMethod getSearchEngine = new MacroMethod("GetSearchEngine", GetSearchEngine)
        {
            Comment           = "Returns search engine visitor came from.",
            Type              = typeof(string),
            MinimumParameters = 0,
            AllowedTypes      = new List <Type>()
            {
                typeof(VisitorNamespace)
            }
        };

        MacroMethods.RegisterMethod(getSearchEngine);

        MacroMethod getUrlReferrer = new MacroMethod("GetUrlReferrer", GetUrlReferrer)
        {
            Comment           = "Returns absolute URI of the URLRefferer from current HTTP context.",
            Type              = typeof(string),
            MinimumParameters = 0,
            AllowedTypes      = new List <Type>()
            {
                typeof(VisitorNamespace)
            }
        };

        MacroMethods.RegisterMethod(getUrlReferrer);

        MacroMethod getUrlReferrerParameter = new MacroMethod("GetUrlReferrerParameter", GetUrlReferrerParameter)
        {
            Comment           = "Returns value of specified URLReferrer query string parameter.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(VisitorNamespace)
            }
        };

        getUrlReferrerParameter.AddParameter("parameterName", typeof(string), "Query string parameter name.");
        MacroMethods.RegisterMethod(getUrlReferrerParameter);

        MacroMethod getCurrentDistance = new MacroMethod("GetCurrentDistance", GetCurrentDistance)
        {
            Comment           = "Returns current distance (in kilometers) from specified location (based on Geo IP).",
            Type              = typeof(double),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(VisitorNamespace)
            }
        };

        getCurrentDistance.AddParameter("latitude", typeof(double), "Latitude of the place.");
        getCurrentDistance.AddParameter("longitude", typeof(double), "Longitude of the place.");
        MacroMethods.RegisterMethod(getCurrentDistance);
    }
    /// <summary>
    /// Registers all online marketing methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get e-mail domain method
        MacroMethod getEmailDomain = new MacroMethod("GetEmailDomain", GetEmailDomain)
        {
            Comment           = "Returns e-mail domain name.",
            Type              = typeof(string),
            MinimumParameters = 1
        };

        getEmailDomain.AddParameter("email", typeof(string), "E-mail address.");
        MacroMethods.RegisterMethod(getEmailDomain);

        // Get score method
        MacroMethod getScore = new MacroMethod("GetScore", GetScore)
        {
            Comment           = "Returns contact's points in specified score on current site.",
            Type              = typeof(int),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        getScore.AddParameter("contact", typeof(object), "Contact info object.");
        getScore.AddParameter("scoreName", typeof(string), "Name of the score to get contact's points of.");
        MacroMethods.RegisterMethod(getScore);

        // Is in contact group method
        MacroMethod isInContactGroup = new MacroMethod("IsInContactGroup", IsInContactGroup)
        {
            Comment           = "Returns true if contact is in contact group.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        isInContactGroup.AddParameter("contact", typeof(object), "Contact info object.");
        isInContactGroup.AddParameter("groupNames", typeof(string), "Name of the contact group(s) separated by semicolon to test whether contact is in.");
        isInContactGroup.AddParameter("allGroups", typeof(bool), "If true contact has to be in all specified groups, if false, it is sufficient if the contact is in any of the specified groups.");
        MacroMethods.RegisterMethod(isInContactGroup);

        // First activity of type method
        MacroMethod firstActivityOfType = new MacroMethod("FirstActivityOfType", FirstActivityOfType)
        {
            Comment           = "Returns contact's first activity of specified activity type.",
            Type              = typeof(ActivityInfo),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        firstActivityOfType.AddParameter("contact", typeof(object), "Contact info object.");
        firstActivityOfType.AddParameter("activityType", typeof(string), "Name of the activity type, optional.");
        MacroMethods.RegisterMethod(firstActivityOfType);

        // Last activity of type method
        MacroMethod lastActivityOfType = new MacroMethod("LastActivityOfType", LastActivityOfType)
        {
            Comment           = "Returns contact's last activity of specified activity type.",
            Type              = typeof(ActivityInfo),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        lastActivityOfType.AddParameter("contact", typeof(object), "Contact info object.");
        lastActivityOfType.AddParameter("activityType", typeof(string), "Name of the activity type, optional.");
        MacroMethods.RegisterMethod(lastActivityOfType);

        MacroMethod belongsToAccount = new MacroMethod("BelongsToAccount", BelongsToAccount)
        {
            Comment           = "Returns true if the contact belongs to the specified account.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        belongsToAccount.AddParameter("contact", typeof(object), "Contact info object.");
        belongsToAccount.AddParameter("accountID", typeof(int), "ID of the account.");
        MacroMethods.RegisterMethod(belongsToAccount);

        MacroMethod cameToLandingPage = new MacroMethod("CameToLandingPage", CameToLandingPage)
        {
            Comment           = "Returns true if the contact came to specified landing page.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        cameToLandingPage.AddParameter("contact", typeof(object), "Contact info object.");
        cameToLandingPage.AddParameter("page", typeof(string), "Node ID or node alias path of the landing page.");
        MacroMethods.RegisterMethod(cameToLandingPage);

        MacroMethod didActivity = new MacroMethod("DidActivity", DidActivity)
        {
            Comment           = "Returns true if the contact did a specified activity.",
            Type              = typeof(bool),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        didActivity.AddParameter("contact", typeof(object), "Contact info object.");
        didActivity.AddParameter("activityType", typeof(string), "Name of the activity to check.");
        didActivity.AddParameter("cancelActivityType", typeof(string), "Name of the activity which cancels the original activity (for example UnsubscribeNewsletter is a cancelling event for SubscribeNewsletter etc.).");
        didActivity.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        didActivity.AddParameter("whereCondition", typeof(string), "Additional WHERE condition.");
        MacroMethods.RegisterMethod(didActivity);

        MacroMethod didActivities = new MacroMethod("DidActivities", DidActivities)
        {
            Comment           = "Returns true if the contact did any/all of the specified activities.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        didActivities.AddParameter("contact", typeof(object), "Contact info object.");
        didActivities.AddParameter("activityTypes", typeof(string), "Name of the activity(ies) to check separated with semicolon.");
        didActivities.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        didActivities.AddParameter("allActivities", typeof(string), "If true, all specified types has to be found for the method to return true. If false, at least one of any specified types is sufficient to retrun true for the method.");
        MacroMethods.RegisterMethod(didActivities);

        MacroMethod isFromCountry = new MacroMethod("IsFromCountry", IsFromCountry)
        {
            Comment           = "Returns true if the contact's country matches one of the specified countries.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        isFromCountry.AddParameter("contact", typeof(object), "Contact info object.");
        isFromCountry.AddParameter("countryList", typeof(string), "List of country names separated with semicolon.");
        MacroMethods.RegisterMethod(isFromCountry);

        MacroMethod isFromState = new MacroMethod("IsFromState", IsFromState)
        {
            Comment           = "Returns true if the contact's state matches one of the specified state.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        isFromState.AddParameter("contact", typeof(object), "Contact info object.");
        isFromState.AddParameter("stateList", typeof(string), "List of state names separated with semicolon.");
        MacroMethods.RegisterMethod(isFromState);

        MacroMethod searchedForKeywords = new MacroMethod("SearchedForKeywords", SearchedForKeywords)
        {
            Comment           = "Returns true if the contact did search for specified keywords in last X days.",
            Type              = typeof(bool),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        searchedForKeywords.AddParameter("contact", typeof(object), "Contact info object.");
        searchedForKeywords.AddParameter("keywords", typeof(string), "Keywords separated with comma or semicolon (if null or empty, than method returns true iff contact did any search in last X days).");
        searchedForKeywords.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        searchedForKeywords.AddParameter("op", typeof(string), "Operator to be used in WHERE condition (use AND for all keywords match, use OR for any keword match).");
        MacroMethods.RegisterMethod(searchedForKeywords);

        MacroMethod spentMoney = new MacroMethod("SpentMoney", SpentMoney)
        {
            Comment           = "Returns true if the contact spent specified amount of money (counted by order total price in main currency) in last X days.",
            Type              = typeof(bool),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        spentMoney.AddParameter("contact", typeof(object), "Contact info object.");
        spentMoney.AddParameter("lowerBound", typeof(double), "Inclusive lower bound of the amount of money (in main currency) spent by contact.");
        spentMoney.AddParameter("upperBound", typeof(double), "Inclusive upper bound of the amount of money (in main currency) spent by contact.");
        spentMoney.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(spentMoney);

        MacroMethod purchasedNumberOfProducts = new MacroMethod("PurchasedNumberOfProducts", PurchasedNumberOfProducts)
        {
            Comment           = "Returns true if the contact purchased specified number of products in last X days.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        purchasedNumberOfProducts.AddParameter("contact", typeof(object), "Contact info object.");
        purchasedNumberOfProducts.AddParameter("lowerBound", typeof(int), "Inclusive lower bound of the number of products bought.");
        purchasedNumberOfProducts.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(purchasedNumberOfProducts);

        MacroMethod isInRoles = new MacroMethod("IsInRoles", IsInRoles)
        {
            Comment           = "Returns true if the contact is in any/all of the specified roles (i.e. if any of the user assigned to the contact is in any/all specified roles).",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        isInRoles.AddParameter("contact", typeof(object), "Contact info object.");
        isInRoles.AddParameter("roleNames", typeof(string), "Name of the roles separated with semicolon.");
        isInRoles.AddParameter("allRoles", typeof(bool), "If true, contact has to in all specified roles. If false, it is sufficient if the contact is at least in one of the roles.");
        MacroMethods.RegisterMethod(isInRoles);

        MacroMethod isInCommunityGroup = new MacroMethod("IsInCommunityGroup", IsInCommunityGroup)
        {
            Comment           = "Returns true if the contact is in any/all of the specified community groups (i.e. if any of the user assigned to the contact is in any/all specified community groups).",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        isInCommunityGroup.AddParameter("contact", typeof(object), "Contact info object.");
        isInCommunityGroup.AddParameter("groupNames", typeof(string), "Name of the groups separated with semicolon.");
        isInCommunityGroup.AddParameter("allGroups", typeof(bool), "If true, contact has to in all specified groups. If false, it is sufficient if the contact is at least in one of the groups.");
        MacroMethods.RegisterMethod(isInCommunityGroup);

        MacroMethod visitedPage = new MacroMethod("VisitedPage", VisitedPage)
        {
            Comment           = "Returns true if the contact visited specified page.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        visitedPage.AddParameter("contact", typeof(object), "Contact info object.");
        visitedPage.AddParameter("nodeAliasPath", typeof(string), "Page node alias path.");
        visitedPage.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(visitedPage);

        MacroMethod submittedForm = new MacroMethod("SubmittedForm", SubmittedForm)
        {
            Comment           = "Returns true if the contact submitted specified form.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        submittedForm.AddParameter("contact", typeof(object), "Contact info object.");
        submittedForm.AddParameter("formName", typeof(string), "Name of the on-line form.");
        submittedForm.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(submittedForm);

        MacroMethod openedNewsletter = new MacroMethod("OpenedNewsletter", OpenedNewsletter)
        {
            Comment           = "Returns true if the contact opened specified newsletter.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        openedNewsletter.AddParameter("contact", typeof(object), "Contact info object.");
        openedNewsletter.AddParameter("newsletterName", typeof(string), "Newsletter name");
        openedNewsletter.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(openedNewsletter);

        MacroMethod openedNewsletterIssue = new MacroMethod("OpenedNewsletterIssue", OpenedNewsletterIssue)
        {
            Comment           = "Returns true if the contact opened specified newsletter issue.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        openedNewsletterIssue.AddParameter("contact", typeof(object), "Contact info object.");
        openedNewsletterIssue.AddParameter("issueGuid", typeof(Guid), "Newsletter issue GUID.");
        openedNewsletterIssue.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(openedNewsletterIssue);

        MacroMethod votedInPoll = new MacroMethod("VotedInPoll", VotedInPoll)
        {
            Comment           = "Returns true if the contact voted in the poll.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        votedInPoll.AddParameter("contact", typeof(object), "Contact info object.");
        votedInPoll.AddParameter("pollName", typeof(string), "Poll name.");
        votedInPoll.AddParameter("pollAnswer", typeof(string), "Poll answer text.");
        votedInPoll.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(votedInPoll);

        MacroMethod loggedIn = new MacroMethod("LoggedIn", LoggedIn)
        {
            Comment           = "Returns true if the contact logged in.",
            Type              = typeof(bool),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        loggedIn.AddParameter("contact", typeof(object), "Contact info object.");
        loggedIn.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(loggedIn);

        MacroMethod subscribedToNewsletter = new MacroMethod("SubscribedToNewsletter", SubscribedToNewsletter)
        {
            Comment           = "Returns true if the contact subscribed for specific newsletter.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        subscribedToNewsletter.AddParameter("contact", typeof(object), "Contact info object.");
        subscribedToNewsletter.AddParameter("newsletterName", typeof(string), "Newsletter name.");
        subscribedToNewsletter.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(subscribedToNewsletter);

        MacroMethod registeredForEvent = new MacroMethod("RegisteredForEvent", RegisteredForEvent)
        {
            Comment           = "Returns true if the contact registered for specific event.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        registeredForEvent.AddParameter("contact", typeof(object), "Contact info object.");
        visitedPage.AddParameter("nodeAliasPath", typeof(string), "Page node alias path.");
        registeredForEvent.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(registeredForEvent);

        MacroMethod clickedLinkInNewsletter = new MacroMethod("ClickedLinkInNewsletter", ClickedLinkInNewsletter)
        {
            Comment           = "Returns true if the contact clicked link in specified newsletter.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        clickedLinkInNewsletter.AddParameter("contact", typeof(object), "Contact info object.");
        clickedLinkInNewsletter.AddParameter("newsletterName", typeof(string), "Name of the newsletter.");
        clickedLinkInNewsletter.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(clickedLinkInNewsletter);

        MacroMethod clickedLinkInNewsletterIssue = new MacroMethod("ClickedLinkInNewsletterIssue", ClickedLinkInNewsletterIssue)
        {
            Comment           = "Returns true if the contact clicked link in specified newsletter issue.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        clickedLinkInNewsletterIssue.AddParameter("contact", typeof(object), "Contact info object.");
        clickedLinkInNewsletterIssue.AddParameter("issueGuid", typeof(Guid), "Newsletter issue GUID.");
        clickedLinkInNewsletterIssue.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(clickedLinkInNewsletterIssue);

        MacroMethod purchasedProduct = new MacroMethod("PurchasedProduct", PurchasedProduct)
        {
            Comment           = "Returns true if the contact purchased specified product.",
            Type              = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(ContactInfo)
            }
        };

        purchasedProduct.AddParameter("contact", typeof(object), "Contact info object.");
        purchasedProduct.AddParameter("productName", typeof(string), "Name of the product.");
        purchasedProduct.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(purchasedProduct);

        MacroMethod getLastNewsletterIssue = new MacroMethod("GetLastNewsletterIssue", GetLastNewsletterIssue)
        {
            Comment           = "Returns last newsletter issue that was sent to the contact of the state.",
            Type              = typeof(IssueInfo),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(AutomationStateInfo)
            }
        };

        getLastNewsletterIssue.AddParameter("state", typeof(AutomationStateInfo), "Process instance to get last newsletter issue from.");
        MacroMethods.RegisterMethod(getLastNewsletterIssue);

        MacroMethod linkedToObject = new MacroMethod("LinkedToObject", ActivityLinkedToObject)
        {
            Comment           = "Returns if activity is linked to given object by GUID or codename.",
            Type              = typeof(bool),
            MinimumParameters = 3,
            AllowedTypes      = new List <Type>()
            {
                typeof(ActivityInfo)
            }
        };

        linkedToObject.AddParameter("activity", typeof(ActivityInfo), "Activity info object.");
        linkedToObject.AddParameter("objectType", typeof(string), "Object type.");
        linkedToObject.AddParameter("objectIdentifier", typeof(string), "Object code name or GUID.");
        MacroMethods.RegisterMethod(linkedToObject);
    }
Example #22
0
    /// <summary>
    /// Registers all blog methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get user name
        MacroMethod getUserName = new MacroMethod("GetUserName", GetUserName)
        {
            Comment           = "Returns user name.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getUserName.AddParameter("userId", typeof(object), "User ID.");
        MacroMethods.RegisterMethod(getUserName);

        // Get user full name
        MacroMethod getUserFullName = new MacroMethod("GetUserFullName", GetUserFullName)
        {
            Comment           = "Returns user full name.",
            Type              = typeof(string),
            MinimumParameters = 1,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getUserFullName.AddParameter("userId", typeof(object), "User ID.");
        MacroMethods.RegisterMethod(getUserFullName);

        // Get blog comment count
        MacroMethod getBlogCommentsCount = new MacroMethod("GetBlogCommentsCount", GetBlogCommentsCount)
        {
            Comment           = "Returns number of comments of given blog.",
            Type              = typeof(int),
            MinimumParameters = 2,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getBlogCommentsCount.AddParameter("postId", typeof(object), "Post document ID.");
        getBlogCommentsCount.AddParameter("postAliasPath", typeof(object), "Post alias path.");
        getBlogCommentsCount.AddParameter("includingTrackbacks", typeof(bool), "Indicates if trackback comments should be included (true by default).");
        MacroMethods.RegisterMethod(getBlogCommentsCount);

        // Get document tags
        MacroMethod getDocumentTags = new MacroMethod("GetDocumentTags", GetDocumentTags)
        {
            Comment           = "Gets a list of links of tags assigned for the specific document pointing to the page with URL specified.",
            Type              = typeof(string),
            MinimumParameters = 3,
            AllowedTypes      = new List <Type>()
            {
                typeof(TransformationNamespace)
            }
        };

        getDocumentTags.AddParameter("documentGroupId", typeof(object), "ID of the group document tags belong to.");
        getDocumentTags.AddParameter("documentTags", typeof(object), "String containing all the tags related to the document.");
        getDocumentTags.AddParameter("documentListPageUrl", typeof(string), "URL of the page displaying other documents of the specified tag.");
        MacroMethods.RegisterMethod(getDocumentTags);
    }
    private static void AppendMethodHelp(MacroMethod m, StringBuilder sb)
    {
        string name = m.Name;
        string comment = GetMethodString(m, -1, false);

        sb.AppendLine("mc[" + ScriptHelper.GetString(name) + "] = " + ScriptHelper.GetString(comment) + ";");
    }
    /// <summary>
    /// Registers all web analytics methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        MacroMethod isReturningVisitor = new MacroMethod("IsReturningVisitor", IsReturningVisitor)
        {
            Comment = "Returns true if current visitor is returning.",
            Type = typeof(bool),
            MinimumParameters = 0,
            AllowedTypes = new List<Type>() { typeof(VisitorNamespace) }
        };
        MacroMethods.RegisterMethod(isReturningVisitor);

        MacroMethod isFirstTimeVisitor = new MacroMethod("IsFirstTimeVisitor", IsFirstTimeVisitor)
        {
            Comment = "Returns true if current visitor comes to the website for the first time.",
            Type = typeof(bool),
            MinimumParameters = 0,
            AllowedTypes = new List<Type>() { typeof(VisitorNamespace) }
        };
        MacroMethods.RegisterMethod(isFirstTimeVisitor);

        MacroMethod getSearchEngineKeyword = new MacroMethod("GetSearchEngineKeyword", GetSearchEngineKeyword)
        {
            Comment = "Returns search keywords from search engine visitor came from.",
            Type = typeof(string),
            MinimumParameters = 0,
            AllowedTypes = new List<Type>() { typeof(VisitorNamespace) }
        };
        MacroMethods.RegisterMethod(getSearchEngineKeyword);

        MacroMethod getSearchEngine = new MacroMethod("GetSearchEngine", GetSearchEngine)
        {
            Comment = "Returns search engine visitor came from.",
            Type = typeof(string),
            MinimumParameters = 0,
            AllowedTypes = new List<Type>() { typeof(VisitorNamespace) }
        };
        MacroMethods.RegisterMethod(getSearchEngine);

        MacroMethod getUrlReferrer = new MacroMethod("GetUrlReferrer", GetUrlReferrer)
        {
            Comment = "Returns absolute URI of the URLRefferer from current HTTP context.",
            Type = typeof(string),
            MinimumParameters = 0,
            AllowedTypes = new List<Type>() { typeof(VisitorNamespace) }
        };
        MacroMethods.RegisterMethod(getUrlReferrer);

        MacroMethod getUrlReferrerParameter = new MacroMethod("GetUrlReferrerParameter", GetUrlReferrerParameter)
        {
            Comment = "Returns value of specified URLReferrer query string parameter.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(VisitorNamespace) }
        };
        getUrlReferrerParameter.AddParameter("parameterName", typeof(string), "Query string parameter name.");
        MacroMethods.RegisterMethod(getUrlReferrerParameter);

        MacroMethod getCurrentDistance = new MacroMethod("GetCurrentDistance", GetCurrentDistance)
        {
            Comment = "Returns current distance (in kilometers) from specified location (based on Geo IP).",
            Type = typeof(double),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(VisitorNamespace) }
        };
        getCurrentDistance.AddParameter("latitude", typeof(double), "Latitude of the place.");
        getCurrentDistance.AddParameter("longitude", typeof(double), "Longitude of the place.");
        MacroMethods.RegisterMethod(getCurrentDistance);
    }
    /// <summary>
    /// Registers all online marketing methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get e-mail domain method
        MacroMethod getEmailDomain = new MacroMethod("GetEmailDomain", GetEmailDomain)
        {
            Comment = "Returns e-mail domain name.",
            Type = typeof(string),
            MinimumParameters = 1
        };
        getEmailDomain.AddParameter("email", typeof(string), "E-mail address.");
        MacroMethods.RegisterMethod(getEmailDomain);

        // Get score method
        MacroMethod getScore = new MacroMethod("GetScore", GetScore)
        {
            Comment = "Returns contact's points in specified score on current site.",
            Type = typeof(int),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        getScore.AddParameter("contact", typeof(object), "Contact info object.");
        getScore.AddParameter("scoreName", typeof(string), "Name of the score to get contact's points of.");
        MacroMethods.RegisterMethod(getScore);

        // Is in contact group method
        MacroMethod isInContactGroup = new MacroMethod("IsInContactGroup", IsInContactGroup)
        {
            Comment = "Returns true if contact is in contact group.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        isInContactGroup.AddParameter("contact", typeof(object), "Contact info object.");
        isInContactGroup.AddParameter("groupNames", typeof(string), "Name of the contact group(s) separated by semicolon to test whether contact is in.");
        isInContactGroup.AddParameter("allGroups", typeof(bool), "If true contact has to be in all specified groups, if false, it is sufficient if the contact is in any of the specified groups.");
        MacroMethods.RegisterMethod(isInContactGroup);

        // First activity of type method
        MacroMethod firstActivityOfType = new MacroMethod("FirstActivityOfType", FirstActivityOfType)
        {
            Comment = "Returns contact's first activity of specified activity type.",
            Type = typeof(ActivityInfo),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        firstActivityOfType.AddParameter("contact", typeof(object), "Contact info object.");
        firstActivityOfType.AddParameter("activityType", typeof(string), "Name of the activity type, optional.");
        MacroMethods.RegisterMethod(firstActivityOfType);

        // Last activity of type method
        MacroMethod lastActivityOfType = new MacroMethod("LastActivityOfType", LastActivityOfType)
        {
            Comment = "Returns contact's last activity of specified activity type.",
            Type = typeof(ActivityInfo),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        lastActivityOfType.AddParameter("contact", typeof(object), "Contact info object.");
        lastActivityOfType.AddParameter("activityType", typeof(string), "Name of the activity type, optional.");
        MacroMethods.RegisterMethod(lastActivityOfType);

        MacroMethod belongsToAccount = new MacroMethod("BelongsToAccount", BelongsToAccount)
        {
            Comment = "Returns true if the contact belongs to the specified account.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        belongsToAccount.AddParameter("contact", typeof(object), "Contact info object.");
        belongsToAccount.AddParameter("accountID", typeof(int), "ID of the account.");
        MacroMethods.RegisterMethod(belongsToAccount);

        MacroMethod cameToLandingPage = new MacroMethod("CameToLandingPage", CameToLandingPage)
        {
            Comment = "Returns true if the contact came to specified landing page.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        cameToLandingPage.AddParameter("contact", typeof(object), "Contact info object.");
        cameToLandingPage.AddParameter("page", typeof(string), "Node ID or node alias path of the landing page.");
        MacroMethods.RegisterMethod(cameToLandingPage);

        MacroMethod didActivity = new MacroMethod("DidActivity", DidActivity)
        {
            Comment = "Returns true if the contact did a specified activity.",
            Type = typeof(bool),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        didActivity.AddParameter("contact", typeof(object), "Contact info object.");
        didActivity.AddParameter("activityType", typeof(string), "Name of the activity to check.");
        didActivity.AddParameter("cancelActivityType", typeof(string), "Name of the activity which cancels the original activity (for example UnsubscribeNewsletter is a cancelling event for SubscribeNewsletter etc.).");
        didActivity.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        didActivity.AddParameter("whereCondition", typeof(string), "Additional WHERE condition.");
        MacroMethods.RegisterMethod(didActivity);

        MacroMethod didActivities = new MacroMethod("DidActivities", DidActivities)
        {
            Comment = "Returns true if the contact did any/all of the specified activities.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        didActivities.AddParameter("contact", typeof(object), "Contact info object.");
        didActivities.AddParameter("activityTypes", typeof(string), "Name of the activity(ies) to check separated with semicolon.");
        didActivities.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        didActivities.AddParameter("allActivities", typeof(string), "If true, all specified types has to be found for the method to return true. If false, at least one of any specified types is sufficient to retrun true for the method.");
        MacroMethods.RegisterMethod(didActivities);

        MacroMethod isFromCountry = new MacroMethod("IsFromCountry", IsFromCountry)
        {
            Comment = "Returns true if the contact's country matches one of the specified countries.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        isFromCountry.AddParameter("contact", typeof(object), "Contact info object.");
        isFromCountry.AddParameter("countryList", typeof(string), "List of country names separated with semicolon.");
        MacroMethods.RegisterMethod(isFromCountry);

        MacroMethod isFromState = new MacroMethod("IsFromState", IsFromState)
        {
            Comment = "Returns true if the contact's state matches one of the specified state.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        isFromState.AddParameter("contact", typeof(object), "Contact info object.");
        isFromState.AddParameter("stateList", typeof(string), "List of state names separated with semicolon.");
        MacroMethods.RegisterMethod(isFromState);

        MacroMethod searchedForKeywords = new MacroMethod("SearchedForKeywords", SearchedForKeywords)
        {
            Comment = "Returns true if the contact did search for specified keywords in last X days.",
            Type = typeof(bool),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        searchedForKeywords.AddParameter("contact", typeof(object), "Contact info object.");
        searchedForKeywords.AddParameter("keywords", typeof(string), "Keywords separated with comma or semicolon (if null or empty, than method returns true iff contact did any search in last X days).");
        searchedForKeywords.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        searchedForKeywords.AddParameter("op", typeof(string), "Operator to be used in WHERE condition (use AND for all keywords match, use OR for any keword match).");
        MacroMethods.RegisterMethod(searchedForKeywords);

        MacroMethod spentMoney = new MacroMethod("SpentMoney", SpentMoney)
        {
            Comment = "Returns true if the contact spent specified amount of money (counted by order total price in main currency) in last X days.",
            Type = typeof(bool),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        spentMoney.AddParameter("contact", typeof(object), "Contact info object.");
        spentMoney.AddParameter("lowerBound", typeof(double), "Inclusive lower bound of the amount of money (in main currency) spent by contact.");
        spentMoney.AddParameter("upperBound", typeof(double), "Inclusive upper bound of the amount of money (in main currency) spent by contact.");
        spentMoney.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(spentMoney);

        MacroMethod purchasedNumberOfProducts = new MacroMethod("PurchasedNumberOfProducts", PurchasedNumberOfProducts)
        {
            Comment = "Returns true if the contact purchased specified number of products in last X days.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        purchasedNumberOfProducts.AddParameter("contact", typeof(object), "Contact info object.");
        purchasedNumberOfProducts.AddParameter("lowerBound", typeof(int), "Inclusive lower bound of the number of products bought.");
        purchasedNumberOfProducts.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(purchasedNumberOfProducts);

        MacroMethod isInRoles = new MacroMethod("IsInRoles", IsInRoles)
        {
            Comment = "Returns true if the contact is in any/all of the specified roles (i.e. if any of the user assigned to the contact is in any/all specified roles).",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        isInRoles.AddParameter("contact", typeof(object), "Contact info object.");
        isInRoles.AddParameter("roleNames", typeof(string), "Name of the roles separated with semicolon.");
        isInRoles.AddParameter("allRoles", typeof(bool), "If true, contact has to in all specified roles. If false, it is sufficient if the contact is at least in one of the roles.");
        MacroMethods.RegisterMethod(isInRoles);

        MacroMethod isInCommunityGroup = new MacroMethod("IsInCommunityGroup", IsInCommunityGroup)
        {
            Comment = "Returns true if the contact is in any/all of the specified community groups (i.e. if any of the user assigned to the contact is in any/all specified community groups).",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        isInCommunityGroup.AddParameter("contact", typeof(object), "Contact info object.");
        isInCommunityGroup.AddParameter("groupNames", typeof(string), "Name of the groups separated with semicolon.");
        isInCommunityGroup.AddParameter("allGroups", typeof(bool), "If true, contact has to in all specified groups. If false, it is sufficient if the contact is at least in one of the groups.");
        MacroMethods.RegisterMethod(isInCommunityGroup);

        MacroMethod visitedPage = new MacroMethod("VisitedPage", VisitedPage)
        {
            Comment = "Returns true if the contact visited specified page.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        visitedPage.AddParameter("contact", typeof(object), "Contact info object.");
        visitedPage.AddParameter("nodeAliasPath", typeof(string), "Page node alias path.");
        visitedPage.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(visitedPage);

        MacroMethod submittedForm = new MacroMethod("SubmittedForm", SubmittedForm)
        {
            Comment = "Returns true if the contact submitted specified form.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        submittedForm.AddParameter("contact", typeof(object), "Contact info object.");
        submittedForm.AddParameter("formName", typeof(string), "Name of the on-line form.");
        submittedForm.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(submittedForm);

        MacroMethod openedNewsletter = new MacroMethod("OpenedNewsletter", OpenedNewsletter)
        {
            Comment = "Returns true if the contact opened specified newsletter.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        openedNewsletter.AddParameter("contact", typeof(object), "Contact info object.");
        openedNewsletter.AddParameter("newsletterName", typeof(string), "Newsletter name");
        openedNewsletter.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(openedNewsletter);

        MacroMethod openedNewsletterIssue = new MacroMethod("OpenedNewsletterIssue", OpenedNewsletterIssue)
        {
            Comment = "Returns true if the contact opened specified newsletter issue.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        openedNewsletterIssue.AddParameter("contact", typeof(object), "Contact info object.");
        openedNewsletterIssue.AddParameter("issueGuid", typeof(Guid), "Newsletter issue GUID.");
        openedNewsletterIssue.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(openedNewsletterIssue);

        MacroMethod votedInPoll = new MacroMethod("VotedInPoll", VotedInPoll)
        {
            Comment = "Returns true if the contact voted in the poll.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        votedInPoll.AddParameter("contact", typeof(object), "Contact info object.");
        votedInPoll.AddParameter("pollName", typeof(string), "Poll name.");
        votedInPoll.AddParameter("pollAnswer", typeof(string), "Poll answer text.");
        votedInPoll.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(votedInPoll);

        MacroMethod loggedIn = new MacroMethod("LoggedIn", LoggedIn)
        {
            Comment = "Returns true if the contact logged in.",
            Type = typeof(bool),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        loggedIn.AddParameter("contact", typeof(object), "Contact info object.");
        loggedIn.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(loggedIn);

        MacroMethod subscribedToNewsletter = new MacroMethod("SubscribedToNewsletter", SubscribedToNewsletter)
        {
            Comment = "Returns true if the contact subscribed for specific newsletter.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        subscribedToNewsletter.AddParameter("contact", typeof(object), "Contact info object.");
        subscribedToNewsletter.AddParameter("newsletterName", typeof(string), "Newsletter name.");
        subscribedToNewsletter.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(subscribedToNewsletter);

        MacroMethod registeredForEvent = new MacroMethod("RegisteredForEvent", RegisteredForEvent)
        {
            Comment = "Returns true if the contact registered for specific event.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        registeredForEvent.AddParameter("contact", typeof(object), "Contact info object.");
        visitedPage.AddParameter("nodeAliasPath", typeof(string), "Page node alias path.");
        registeredForEvent.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(registeredForEvent);

        MacroMethod clickedLinkInNewsletter = new MacroMethod("ClickedLinkInNewsletter", ClickedLinkInNewsletter)
        {
            Comment = "Returns true if the contact clicked link in specified newsletter.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        clickedLinkInNewsletter.AddParameter("contact", typeof(object), "Contact info object.");
        clickedLinkInNewsletter.AddParameter("newsletterName", typeof(string), "Name of the newsletter.");
        clickedLinkInNewsletter.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(clickedLinkInNewsletter);

        MacroMethod clickedLinkInNewsletterIssue = new MacroMethod("ClickedLinkInNewsletterIssue", ClickedLinkInNewsletterIssue)
        {
            Comment = "Returns true if the contact clicked link in specified newsletter issue.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        clickedLinkInNewsletterIssue.AddParameter("contact", typeof(object), "Contact info object.");
        clickedLinkInNewsletterIssue.AddParameter("issueGuid", typeof(Guid), "Newsletter issue GUID.");
        clickedLinkInNewsletterIssue.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(clickedLinkInNewsletterIssue);

        MacroMethod purchasedProduct = new MacroMethod("PurchasedProduct", PurchasedProduct)
        {
            Comment = "Returns true if the contact purchased specified product.",
            Type = typeof(bool),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(ContactInfo) }
        };
        purchasedProduct.AddParameter("contact", typeof(object), "Contact info object.");
        purchasedProduct.AddParameter("productName", typeof(string), "Name of the product.");
        purchasedProduct.AddParameter("lastXDays", typeof(int), "Constraint for last X days (if zero or negative value is given, no constraint is applied).");
        MacroMethods.RegisterMethod(purchasedProduct);

        MacroMethod getLastNewsletterIssue = new MacroMethod("GetLastNewsletterIssue", GetLastNewsletterIssue)
        {
            Comment = "Returns last newsletter issue that was sent to the contact of the state.",
            Type = typeof(IssueInfo),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(AutomationStateInfo) }
        };
        getLastNewsletterIssue.AddParameter("state", typeof(AutomationStateInfo), "Process instance to get last newsletter issue from.");
        MacroMethods.RegisterMethod(getLastNewsletterIssue);

        MacroMethod linkedToObject = new MacroMethod("LinkedToObject", ActivityLinkedToObject)
        {
            Comment = "Returns if activity is linked to given object by GUID or codename.",
            Type = typeof(bool),
            MinimumParameters = 3,
            AllowedTypes = new List<Type>() { typeof(ActivityInfo) }
        };
        linkedToObject.AddParameter("activity", typeof(ActivityInfo), "Activity info object.");
        linkedToObject.AddParameter("objectType", typeof(string), "Object type.");
        linkedToObject.AddParameter("objectIdentifier", typeof(string), "Object code name or GUID.");
        MacroMethods.RegisterMethod(linkedToObject);
    }
Example #26
0
 public PreP(OperandParser.OperandType[] Types, MacroMethod Method)
 {
     this.Types  = Types;
     this.Method = Method;
 }
    /// <summary>
    /// Registers all ecommerce methods to macro resolver.
    /// </summary>
    public static void RegisterMethods()
    {
        // Get add to shopping cart link
        MacroMethod getAddToShoppingCartLink = new MacroMethod("GetAddToShoppingCartLink", GetAddToShoppingCartLink)
        {
            Comment = "Returns link to \"add to shoppingcart\".",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getAddToShoppingCartLink.AddParameter("productId", typeof(object), "Product ID.");
        getAddToShoppingCartLink.AddParameter("enabled", typeof(object), "Indicates whether product is enabled or not.");
        MacroMethods.RegisterMethod(getAddToShoppingCartLink);

        // Get add to wishlist link
        MacroMethod getAddToWishListLink = new MacroMethod("GetAddToWishListLink", GetAddToWishListLink)
        {
            Comment = "Returns link to add specified product to the user's wishlist.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getAddToWishListLink.AddParameter("productId", typeof(object), "Product ID.");
        MacroMethods.RegisterMethod(getAddToWishListLink);

        // Get remove from wishlist link
        MacroMethod getRemoveFromWishListLink = new MacroMethod("GetRemoveFromWishListLink", GetRemoveFromWishListLink)
        {
            Comment = "Returns link to remove specified product from the user's wishlist.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getRemoveFromWishListLink.AddParameter("productId", typeof(object), "Product ID.");
        MacroMethods.RegisterMethod(getRemoveFromWishListLink);

        // Get public status name
        MacroMethod gtPublicStatusName = new MacroMethod("GetPublicStatusName", GetPublicStatusName)
        {
            Comment = "Returns the public SKU status display name.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        gtPublicStatusName.AddParameter("statusId", typeof(object), "Status ID");
        MacroMethods.RegisterMethod(gtPublicStatusName);

        // Get shopping cart URL
        MacroMethod shoppingCartURL = new MacroMethod("ShoppingCartURL", ShoppingCartURL)
        {
            Comment = "Returns URL to the shopping cart.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        shoppingCartURL.AddParameter("siteName", typeof(string), "Site name.");
        MacroMethods.RegisterMethod(shoppingCartURL);

        // Get wishlist URL
        MacroMethod wishlistURL = new MacroMethod("WishlistURL", WishlistURL)
        {
            Comment = "Returns URL to the wish list.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        wishlistURL.AddParameter("siteName", typeof(string), "Site name");
        MacroMethods.RegisterMethod(wishlistURL);

        // Get product URL
        MacroMethod getProductUrl = new MacroMethod("GetProductUrl", GetProductUrl)
        {
            Comment = "Returns product URL.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getProductUrl.AddParameter("skuId", typeof(object), "SKU ID.");
        MacroMethods.RegisterMethod(getProductUrl);

        // Get product URL by GUID
        MacroMethod getProductUrlByGUID = new MacroMethod("GetProductUrlByGUID", GetProductUrlByGUID)
        {
            Comment = "Returns user friendly URL of the specified SKU.",
            Type = typeof(string),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getProductUrlByGUID.AddParameter("skuGuid", typeof(object), "SKU GUID.");
        getProductUrlByGUID.AddParameter("skuName", typeof(object), "SKU name.");
        getProductUrlByGUID.AddParameter("siteName", typeof(object), "Site name.");
        MacroMethods.RegisterMethod(getProductUrlByGUID);

        // Get manufacturer
        MacroMethod getManufacturer = new MacroMethod("GetManufacturer", GetManufacturer)
        {
            Comment = "Gets object from the specified column of the manufacturer with specific ID.",
            Type = typeof(object),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getManufacturer.AddParameter("id", typeof(int), "Manufacturer ID.");
        getManufacturer.AddParameter("column", typeof(string), "Column name.");
        MacroMethods.RegisterMethod(getManufacturer);

        // Get department
        MacroMethod getDepartment = new MacroMethod("GetDepartment", GetDepartment)
        {
            Comment = "Gets object from the specified column of the department with specific ID.",
            Type = typeof(object),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getDepartment.AddParameter("id", typeof(int), "Department ID.");
        getDepartment.AddParameter("column", typeof(string), "Column name.");
        MacroMethods.RegisterMethod(getDepartment);

        // Get supplier
        MacroMethod getSupplier = new MacroMethod("GetSupplier", GetSupplier)
        {
            Comment = "Gets object from the specified column of the supplier with specific ID.",
            Type = typeof(object),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getSupplier.AddParameter("id", typeof(int), "Supplier ID.");
        getSupplier.AddParameter("column", typeof(string), "Column name.");
        MacroMethods.RegisterMethod(getSupplier);

        // Get internal status
        MacroMethod getInternalStatus = new MacroMethod("GetInternalStatus", GetInternalStatus)
        {
            Comment = "Gets object from the specified column of the internal status with specific ID.",
            Type = typeof(object),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getInternalStatus.AddParameter("id", typeof(int), "Internal status ID.");
        getInternalStatus.AddParameter("column", typeof(string), "Column name.");
        MacroMethods.RegisterMethod(getInternalStatus);

        // Get public status
        MacroMethod getPublicStatus = new MacroMethod("GetPublicStatus", GetPublicStatus)
        {
            Comment = "Gets object from the specified column of the public status with specific ID.",
            Type = typeof(object),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getPublicStatus.AddParameter("id", typeof(int), "Public status ID.");
        getPublicStatus.AddParameter("column", typeof(string), "Column name.");
        MacroMethods.RegisterMethod(getPublicStatus);

        // Get product image
        MacroMethod getProductImage = new MacroMethod("GetProductImage", GetProductImage)
        {
            Comment = "Returns complete HTML code of the specified resized product image, if not such image exists, default image is returned.",
            Type = typeof(string),
            MinimumParameters = 2,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        getProductImage.AddParameter("imageUrl", typeof(object), "Product image url.");
        getProductImage.AddParameter("alt", typeof(object), "Image alternate text.");
        getProductImage.AddParameter("maxSideSize", typeof(object), "Max side size of the image.");
        getProductImage.AddParameter("width", typeof(object), "Width of the image.");
        getProductImage.AddParameter("height", typeof(object), "Height of the image.");
        MacroMethods.RegisterMethod(getProductImage);

        // Format price
        MacroMethod formatPrice = new MacroMethod("FormatPrice", FormatPrice)
        {
            Comment = "Returns price rounded and formatted according to the current currency properties.",
            Type = typeof(string),
            MinimumParameters = 1,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        formatPrice.AddParameter("price", typeof(double), "Price to be formatted");
        formatPrice.AddParameter("round", typeof(bool), "True - price is rounded according to the current currency settings before formatting");
        MacroMethods.RegisterMethod(formatPrice);

        // Cart items count
        MacroMethod getShoppingCartItemsCount = new MacroMethod("GetShoppingCartItemsCount", GetShoppingCartItemsCount)
        {
            Comment = "Returns number of products in current shopping cart.",
            Type = typeof(int),
            MinimumParameters = 0,
            AllowedTypes = new List<Type>() { typeof(TransformationNamespace) }
        };
        MacroMethods.RegisterMethod(getShoppingCartItemsCount);
    }