Ejemplo n.º 1
0
		public ModelProcessorResult Process()
		{
			ModelProcessorResult result = new ModelProcessorResult();
			result.Success = true;

			log = new LoggerWrapper(Logger, result);

			log.Info("Processing " + filename + " ...");

			var model = GetModel();

			foreach (var type in model.Types)
			{
				if (type.Immutable)
				{
					AddIfNotNull(result.EditableFilenames,
					             CreateFileIfNotExits(type, "ImmutableClassExtended", type.Name, false));
					result.NotToChangeFilenames.Add(CreateFile(type, "ImmutableClass", type.ImplementationName,
					                                           true));
					result.NotToChangeFilenames.Add(CreateFile(type, "BuilderClass", type.Name + "Builder", true));
				}
				else
				{
					AddIfNotNull(result.EditableFilenames,
					             CreateFileIfNotExits(type, "MutableClassExtended", type.Name, false));
					result.NotToChangeFilenames.Add(CreateFile(type, "MutableClass", type.ImplementationName, true));
				}
			}
			log.Info("... Done");
			log.Info("");

			log = null;

			return result;
		}
Ejemplo n.º 2
0
        private string CreateFileIfNotExits(TypeInfo type, string templateName, string className,
                                            bool markAsGenerated)
        {
            var relativeName = Path.Combine(GetPackageDir(type), className + ".cs");
            var fullname     = Path.Combine(BaseOutputPath, relativeName);

            if (new FileInfo(fullname).Exists)
            {
                if (!overrideFiles && !IsMarkedToOverride(fullname))
                {
                    log.Info("Skipped (because already exists and was edited) file " + relativeName);
                    return(null);
                }

                log.Info("Overriding file " + relativeName);
            }

            return(CreateFile(type, templateName, className, markAsGenerated));
        }
Ejemplo n.º 3
0
        public ModelProcessorResult Process()
        {
            ModelProcessorResult result = new ModelProcessorResult();

            result.Success = true;

            log = new LoggerWrapper(Logger, result);

            log.Info("Processing " + filename + " ...");

            var model = GetModel();

            foreach (var type in model.Types)
            {
                if (type.Immutable)
                {
                    AddIfNotNull(result.EditableFilenames,
                                 CreateFileIfNotExits(type, "ImmutableClassExtended", type.Name, false));
                    result.NotToChangeFilenames.Add(CreateFile(type, "ImmutableClass", type.ImplementationName,
                                                               true));
                    result.NotToChangeFilenames.Add(CreateFile(type, "BuilderClass", type.Name + "Builder", true));
                }
                else
                {
                    AddIfNotNull(result.EditableFilenames,
                                 CreateFileIfNotExits(type, "MutableClassExtended", type.Name, false));
                    result.NotToChangeFilenames.Add(CreateFile(type, "MutableClass", type.ImplementationName, true));
                }
            }
            log.Info("... Done");
            log.Info("");

            log = null;

            return(result);
        }