예제 #1
0
        public List <FeatureDto> ListAllFeatures()
        {
            var features = _featureManager.GetAll();

            List <FeatureDto> dtos = features.Select(
                feature => new FeatureDto()
            {
                Name        = feature.Name,
                DisplayName = _localizationManager.GetString((LocalizableString)feature.DisplayName)
            }).ToList();

            return(dtos);
        }
예제 #2
0
 public void Should_Get_Defined_Features()
 {
     _featureManager.Get(SampleFeatureProvider.Names.Contacts).ShouldNotBe(null);
     _featureManager.Get(SampleFeatureProvider.Names.MaxContactCount).ShouldNotBe(null);
     _featureManager.GetAll().Count.ShouldBe(2);
 }
예제 #3
0
        public async Task <QueryMultipleResult <IEnumerable <FeatureViewModel>, FeatureViewModel> > GetAll()
        {
            var featureModels = await _featureManager.GetAll();

            return(_mapper.Map <QueryMultipleResult <IEnumerable <FeatureViewModel>, FeatureViewModel> >(featureModels));
        }
        public async Task<string> GetScriptAsync()
        {
            var allFeatures = _featureManager.GetAll().ToList();
            Dictionary<string, string> currentTenantValues = null;

            if (AbpSession.TenantId.HasValue) //TODO: Get TenantId independent from the session.
            {
                currentTenantValues = new Dictionary<string, string>();
                foreach (var feature in allFeatures)
                {
                    currentTenantValues[feature.Name] = await _featureChecker.GetValueAsync(AbpSession.GetTenantId(), feature.Name);
                }
            }

            var script = new StringBuilder();

            script.AppendLine("(function() {");

            script.AppendLine();

            script.AppendLine("    abp.features = abp.features || {};");

            script.AppendLine();

            script.AppendLine("    abp.features.allFeatures = {");

            for (var i = 0; i < allFeatures.Count; i++)
            {
                var feature = allFeatures[i];
                script.AppendLine("        '" + feature.Name.Replace("'", @"\'") + "': {");

                if (currentTenantValues != null)
                {
                    script.AppendLine("             value: '" + currentTenantValues[feature.Name].Replace(@"\", @"\\").Replace("'", @"\'") + "',");
                }
                else
                {
                    script.AppendLine("             value: " + "'',");
                }

                //TODO: Other feature properties and custom attributes

                //TODO: Consider to remove inputType since it's only needed while editing!
                script.AppendLine("            inputType: " + JsonHelper.ConvertToJson(feature.InputType, true, true));
                
                script.Append("        }");

                if (i < allFeatures.Count - 1)
                {
                    script.AppendLine(",");
                }
                else
                {
                    script.AppendLine();
                }
            }

            script.AppendLine("    };");

            script.AppendLine();
            script.Append("})();");

            return script.ToString();
        }