Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Programmatically adding external c# functions

$
0
0
Thanks for the quick reply burningice.

OK, I am just working through the help docs. I have a simple class below with some helper methods for the selector widget for use in datatypes and razor functions, example below. I followed the guide for creating widgets but it seemed overkill for what I wanted. This approach seems to work well but if I want to create a package installer then I need to automate registering the methods.
  1. Am I right in thinking that this would be similar to adding static data types in that I could create a startup handler that would add these methods? Are you able to point me to an example?
  2. I created a samplewidgetfunctionprovider by following the help but i'd be lying if I said I fully understood it. Again are there any examples that match my needs that I can pick apart and learn from?
public class WidgetHelper
    {

        [Function(Description = "Returns the pre defined color options available")]
        public static IEnumerable<string> GetColours()
        {
            //Get Directory
            DirectoryInfo di = new DirectoryInfo(HttpContext.Current.Server.MapPath("/frontend/ensured/css/color_scheme"));
            //Get all css files
            foreach (var fi in di.GetFiles("*.css"))
            {
                yield return Path.GetFileNameWithoutExtension(fi.Name);
            }
        }

        [Function(Description = "Returns classes to set letter spacing")]
        public static IEnumerable<string> GetLetterSpacingClasses()
        {
            int i = 0;
            while (i < 11)
            {
                yield return ".letter-spacing-" + i.ToString();
                i++;
            }
        }

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>