Ejemplo n.º 1
0
 public ModuleJsRouteLibrary(
     ModuleRouteLibrary moduleRouteLibrary
     )
 {
     _moduleRouteLibrary     = moduleRouteLibrary;
     AngularModuleIdentifier = TextFormatter.Camelize(moduleRouteLibrary.ModuleFolderName);
     AngularModuleName       = "cms." + AngularModuleIdentifier;
     JsFolderPath            = _moduleRouteLibrary.ResourcePrefix + "js";
     MvcViewFolderPath       = _moduleRouteLibrary.ResourcePrefix + "mvc/views";
 }
Ejemplo n.º 2
0
        public AngularScriptRoutes(ModuleRouteLibrary moduleRouteLibrary)
        {
            AngularModuleIdentifier = TextFormatter.Camelize(moduleRouteLibrary.ModuleFolderName);
            AngularModuleName       = "cms." + AngularModuleIdentifier;

            var jsPrefix = moduleRouteLibrary.ModuleFolderName.ToLowerInvariant();

            MainScriptName     = jsPrefix;
            TemplateScriptName = jsPrefix + "_templates";
        }
Ejemplo n.º 3
0
        public static void AddToMetadata(DisplayMetadata modelMetaData, Type optionSourceType)
        {
            if (optionSourceType == null)
            {
                throw new ArgumentNullException(nameof(optionSourceType));
            }

            ICollection <ListOption> options = null;

            if (optionSourceType.IsEnum)
            {
                options = Enum
                          .GetNames(optionSourceType)
                          .Select(e => new ListOption(TextFormatter.PascalCaseToSentence(e), e))
                          .ToList();
            }
            else
            {
                if (optionSourceType.GetConstructor(Type.EmptyTypes) == null)
                {
                    var msg = "OptionSource type does not have a public parameterless constructor.";
                    throw new InvalidOperationException(msg);
                }

                var source = Activator.CreateInstance(optionSourceType);

                if (source is IListOptionApiSource apiSource)
                {
                    ValidateApiSource(optionSourceType, apiSource);

                    modelMetaData.AdditionalValues.Add("OptionsApi", apiSource.Path);
                    modelMetaData.AdditionalValues.Add("OptionName", TextFormatter.Camelize(apiSource.NameField));
                    modelMetaData.AdditionalValues.Add("OptionValue", TextFormatter.Camelize(apiSource.ValueField));
                }
                else if (source is IListOptionSource listOptionSource)
                {
                    options = listOptionSource.Create();
                }
                else
                {
                    var msg = "OptionSource type is not a valid type. Valid types are ";
                    throw new InvalidOperationException(msg);
                }
            }

            if (options != null)
            {
                modelMetaData.AdditionalValues.Add("OptionName", "text");
                modelMetaData.AdditionalValues.Add("OptionValue", "value");
                modelMetaData.AdditionalValues.Add("Options", options);
            }
        }
Ejemplo n.º 4
0
        public void Camelize_CanDoBasicConversion(string input, string expected)
        {
            var result = TextFormatter.Camelize(input);

            Assert.Equal(expected, result);
        }
Ejemplo n.º 5
0
        public void Camelize_WhenNullOrWhitespace_ReturnsEmptyString(string input)
        {
            var result = TextFormatter.Camelize(input);

            Assert.Equal(result, string.Empty);
        }