Ejemplo n.º 1
0
    /// <summary>
    /// Builds and returns the list of object types that can contain macros.
    /// </summary>
    /// <param name="include">Object types to include in the list</param>
    /// <param name="exclude">Object types to exclude from the list</param>
    /// <remarks>
    /// Excludes the object types that cannot contain macros.
    /// </remarks>
    private IEnumerable <string> GetObjectTypesWithMacros(IEnumerable <string> include, IEnumerable <string> exclude)
    {
        // Get the system object types
        var objectTypes = ObjectTypeLists.AllObjectTypes.AsEnumerable();

        // Include custom table object types
        objectTypes = objectTypes.Union(DataClassInfoProvider.GetCustomTableClasses(null, null, 0, "ClassName").Tables[0].Select().Select(r => r["ClassName"].ToString()));

        // Include biz form object types
        objectTypes = objectTypes.Union(BizFormInfoProvider.GetAllBizForms().Tables[0].Select().Select(r => "bizformitem.bizform." + r["FormName"].ToString()));

        // Include object types
        if (include != null)
        {
            objectTypes = objectTypes.Union(include);
        }

        // Exclude object types
        if (exclude != null)
        {
            objectTypes = objectTypes.Except(exclude);
        }

        // Exclude object types that do not contain macros
        objectTypes = objectTypes.Except(new[] {
            PredefinedObjectType.STATISTICS,

            EmailObjectType.EMAIL,

            LicenseObjectType.LICENSEKEY,

            PredefinedObjectType.ACTIVITY,
            "om.pagevisit",
            "om.search",

            PredefinedObjectType.CHATONLINEUSER,
            PredefinedObjectType.EVENT,

            ResourceObjectType.RESOURCESTRING,
            ResourceObjectType.RESOURCETRANSLATION,
            ResourceObjectType.RESOURCETRANSLATED,

            "cms.objectsettings",

            SiteObjectType.USERROLELIST,
            SiteObjectType.MEMBERSHIPLIST,

            DocumentObjectType.USERDOCUMENTSLIST,

            "temp.file"
        });

        objectTypes = objectTypes.Where(t =>
        {
            try
            {
                var typeInfo = TranslationHelper.GetReadOnlyObject(t).TypeInfo;
                return(!typeInfo.Inherited && !typeInfo.IsBinding);
            }
            catch (Exception)
            {
                return(false);
            }
        });

        return(objectTypes);
    }