private MemberDeclarationSyntax CreateConstant(T entity)
        {
            var entityId = MetadataResolver.GetEntityId(entity);
            var name     = entityId.Substring(0, 1).ToUpper() + entityId.Substring(1, entityId.Length - 1);
            var value    = Literals.String(entityId);

            return(Fields.PublicConstField(name, typeof(string), value));
        }
예제 #2
0
        public void StringValidation()
        {
            var propertiesToValidate = StringPropertiesToValidate().ToArray();

            if (propertiesToValidate.Any())
            {
                Logger.LogSection($"{typeof(T).Name.Pluralize()} With Missing Values",
                                  new StringParameterVerification <T>(f => MetadataResolver.GetEntityId(f), propertiesToValidate).Validate(Entities.Keys).Select(kvp => $"{kvp.Key} {kvp.Value.Name}"));
            }
        }
예제 #3
0
        public void Operate()
        {
            var files = Directory.GetFiles(PathResolver.DataDirectory(MetadataResolver.DataDirectoryToOperateIn), "*.yaml");

            foreach (var file in files)
            {
                var fileInfo   = new FileInfo(file);
                var name       = Path.GetFileNameWithoutExtension(fileInfo.Name);
                var typeEntity = Entities.Keys.FirstOrDefault(i => MetadataResolver.GetEntityId(i).ToLower() == name.ToLower());

                if (typeEntity == null)
                {
                    Logger.Warning($"Unable to find corresponding {MetadataResolver.EntityTypeName} yaml file for {name}");
                }
                else
                {
                    var category = MetadataResolver.GetEntityCategory(typeEntity);

                    if (string.IsNullOrEmpty(category))
                    {
                        continue;
                    }

                    var targetDirectory = PathResolver.DataDirectory(MetadataResolver.DataDirectoryToOperateIn, category);
                    if (!Directory.Exists(targetDirectory))
                    {
                        Directory.CreateDirectory(targetDirectory);
                    }

                    var old  = fileInfo.FullName;
                    var newF = Path.Combine(targetDirectory, fileInfo.Name);

                    fileInfo.MoveTo(newF);

                    Logger.LogSection("Moved yaml Files", $"{old} -> {newF}");
                }
            }
        }