private void ReplaceCommon(Replacer replacer, Type type) { replacer.Replace(DefinedPlaceholder.PROJECT_ROOTNAMESPACE, _configuration.ProjectNamespaceRoot); replacer.Replace(DefinedPlaceholder.DOMAIN_ROOTNAMESPACE, _configuration.DomainNamespaceRoot); replacer.Replace(DefinedPlaceholder.DOMAIN_ASSEMBLYNAME, GetAssemblyName(type)); replacer.Replace(DefinedPlaceholder.DOMAIN_QUALIFIEDCLASSTYPENAME, GetTypeName(type)); replacer.Replace(DefinedPlaceholder.ROOT_TEMPLATE_DIR, _configuration.TemplateRoot); replacer.Replace(DefinedPlaceholder.ROOT_TARGET_DIR, _configuration.TargetRoot); replacer.Replace(DefinedPlaceholder.WEB_CLIENT_GUID, Guid.NewGuid().ToString()); replacer.Replace(_configuration.ProjectReplaceInfos); }
private void BuildGlobalFiles(ClassInfo[] classInfos, EnumInfo[] enumInfos) { foreach (Configuration.FileInfo fileInfo in _configuration.AllGlobalFileInfos) { string templateFileName = Path.Combine(_configuration.TemplateRoot, fileInfo.template); string targetFileName = Path.Combine(_configuration.TargetRoot, fileInfo.target); targetFileName = Replacer.Replace(_configuration.ProjectReplaceInfos, targetFileName); CheckExistenceTemplateFile(templateFileName); CheckExistenceDestinationFile(targetFileName, fileInfo.overwrite); IBusinessObjectClass[] businessObjectClasses = new IBusinessObjectClass[classInfos.Length]; for (int index = 0; index < classInfos.Length; index++) { businessObjectClasses[index] = classInfos[index].objectClass; } Replacer replacer = new Replacer(templateFileName); // for each class replacer.Include( DefinedPlaceholder.INCLUDE_FOREACHCLASS, GetClassInfos(businessObjectClasses)); replacer.Repeat( DefinedPlaceholder.REPEAT_FOREACHCLASS_BEGIN, DefinedPlaceholder.REPEAT_FOREACHCLASS_END, GetClassInfos(businessObjectClasses)); // for each enum replacer.Include( DefinedPlaceholder.INCLUDE_FOREACHENUM, GetEnumInfos(enumInfos)); replacer.Repeat( DefinedPlaceholder.REPEAT_FOREACHENUM_BEGIN, DefinedPlaceholder.REPEAT_FOREACHENUM_END, GetEnumInfos(enumInfos)); // common ReplaceCommon(replacer, classInfos[0].type); replacer.Save(targetFileName); } }
private void BuildClassFile(Type type, IBusinessObjectClass businessObjectClass, IBusinessObjectProperty[] properties) { foreach (Configuration.FileInfo fileInfo in _configuration.ClassFileInfos) { string name = GetName(businessObjectClass.Identifier); string templateFileName = Path.Combine(_configuration.TemplateRoot, fileInfo.template); string targetFileName = Path.Combine(_configuration.TargetRoot, Replace(fileInfo.target, DefinedPlaceholder.DOMAIN_CLASSNAME, name)); targetFileName = Replacer.Replace(_configuration.ProjectReplaceInfos, targetFileName); CheckExistenceTemplateFile(templateFileName); CheckExistenceDestinationFile(targetFileName, fileInfo.overwrite); Replacer replacer = new Replacer(templateFileName); // for each property replacer.Include( DefinedPlaceholder.INCLUDE_FOREACHPROPERTY, GetPropertyInfos(businessObjectClass, properties)); replacer.Repeat( DefinedPlaceholder.REPEAT_FOREACHPROPERTY_BEGIN, DefinedPlaceholder.REPEAT_FOREACHPROPERTY_END, GetPropertyInfos(businessObjectClass, properties)); replacer.Repeat( DefinedPlaceholder.REPEAT_FOREACHREFERENCEDPROPERTY_BEGIN, DefinedPlaceholder.REPEAT_FOREACHREFERENCEDPROPERTY_END, GetReferencedPropertyInfos(businessObjectClass, properties, true), "isList=true"); replacer.Repeat( DefinedPlaceholder.REPEAT_FOREACHREFERENCEDPROPERTY_BEGIN, DefinedPlaceholder.REPEAT_FOREACHREFERENCEDPROPERTY_END, GetReferencedPropertyInfos(businessObjectClass, properties, false), "isList=false"); // common replacer.Replace(DefinedPlaceholder.DOMAIN_CLASSNAME, name); ReplaceCommon(replacer, type); replacer.Save(targetFileName); } }
private Replacer.ReplaceInfo[] GetPropertyInfos(IBusinessObjectClass businessObjectClass, IBusinessObjectProperty[] properties) { Replacer.ReplaceInfo[] propertyInfos = new Replacer.ReplaceInfo[properties.Length]; for (int index = 0; index < properties.Length; index++) { IBusinessObjectProperty property = properties[index]; bool found = false; foreach (Configuration.ControlInfo controlMapping in _configuration.ControlMappings) { if (HasInterface(property.GetType(), controlMapping.propertyType) && property.IsList == controlMapping.isList) { ApplicationConfiguration.ReplaceInfo[] additionalReplaceInfos = new ApplicationConfiguration.ReplaceInfo[] { new ApplicationConfiguration.ReplaceInfo(Placeholder.ToString(DefinedPlaceholder.DOMAIN_PROPERTYNAME), property.Identifier) }; string additionalAttributes = Replacer.Replace(additionalReplaceInfos, controlMapping.additionalAttributes); string additionalElements = Replacer.Replace(additionalReplaceInfos, controlMapping.additionalElements); propertyInfos[index].replaceInfos = new string[] { Placeholder.ToString(DefinedPlaceholder.DOMAIN_PROPERTYNAME), property.Identifier, Placeholder.ToString(DefinedPlaceholder.CONTROLTYPE), controlMapping.controlName, Placeholder.ToString(DefinedPlaceholder.ADDITIONALATTRIBUTES), additionalAttributes, Placeholder.ToString(DefinedPlaceholder.ADDITIONALELEMENTS), additionalElements }; found = true; break; } } if (!found) { propertyInfos[index].replaceInfos = null; _warnings.AddWarning(WarningCode.MissingControlMapping, businessObjectClass.Identifier + "." + property.Identifier + " (" + property.GetType().ToString() + ")"); } } return(propertyInfos); }
private void ReplaceCommon(Replacer replacer, Type type) { replacer.Replace(DefinedPlaceholder.PROJECT_ROOTNAMESPACE, _configuration.ProjectNamespaceRoot); replacer.Replace(DefinedPlaceholder.DOMAIN_ROOTNAMESPACE, _configuration.DomainNamespaceRoot); replacer.Replace(DefinedPlaceholder.DOMAIN_ASSEMBLYNAME, GetAssemblyName(type)); replacer.Replace(DefinedPlaceholder.DOMAIN_QUALIFIEDCLASSTYPENAME, GetTypeName(type)); replacer.Replace(DefinedPlaceholder.ROOT_TEMPLATE_DIR, _configuration.TemplateRoot); replacer.Replace(DefinedPlaceholder.ROOT_TARGET_DIR, _configuration.TargetRoot); replacer.Replace (DefinedPlaceholder.WEB_CLIENT_GUID, Guid.NewGuid().ToString()); replacer.Replace(_configuration.ProjectReplaceInfos); }
private void BuildGlobalFiles(ClassInfo[] classInfos, EnumInfo[] enumInfos) { foreach (Configuration.FileInfo fileInfo in _configuration.AllGlobalFileInfos) { string templateFileName = Path.Combine(_configuration.TemplateRoot, fileInfo.template); string targetFileName = Path.Combine(_configuration.TargetRoot, fileInfo.target); targetFileName = Replacer.Replace(_configuration.ProjectReplaceInfos, targetFileName); CheckExistenceTemplateFile(templateFileName); CheckExistenceDestinationFile(targetFileName, fileInfo.overwrite); IBusinessObjectClass[] businessObjectClasses = new IBusinessObjectClass[classInfos.Length]; for (int index = 0; index < classInfos.Length; index++) businessObjectClasses[index] = classInfos[index].objectClass; Replacer replacer = new Replacer(templateFileName); // for each class replacer.Include( DefinedPlaceholder.INCLUDE_FOREACHCLASS, GetClassInfos(businessObjectClasses)); replacer.Repeat( DefinedPlaceholder.REPEAT_FOREACHCLASS_BEGIN, DefinedPlaceholder.REPEAT_FOREACHCLASS_END, GetClassInfos(businessObjectClasses)); // for each enum replacer.Include( DefinedPlaceholder.INCLUDE_FOREACHENUM, GetEnumInfos(enumInfos)); replacer.Repeat( DefinedPlaceholder.REPEAT_FOREACHENUM_BEGIN, DefinedPlaceholder.REPEAT_FOREACHENUM_END, GetEnumInfos(enumInfos)); // common ReplaceCommon(replacer, classInfos[0].type); replacer.Save(targetFileName); } }
private void BuildEnumFile(EnumInfo enumInfo) { foreach (Configuration.FileInfo fileInfo in _configuration.EnumFileInfos) { string name = enumInfo.type.Name; string templateFileName = Path.Combine(_configuration.TemplateRoot, fileInfo.template); string targetFileName = Path.Combine(_configuration.TargetRoot, Replace(fileInfo.target, DefinedPlaceholder.DOMAIN_ENUMNAME, name)); targetFileName = Replacer.Replace(_configuration.ProjectReplaceInfos, targetFileName); CheckExistenceTemplateFile(templateFileName); CheckExistenceDestinationFile(targetFileName, fileInfo.overwrite); Replacer replacer = new Replacer(templateFileName); // for each enum value /* --- still not needed at the moment --- */ // common replacer.Replace(DefinedPlaceholder.DOMAIN_ENUMNAME, name); ReplaceCommon(replacer, enumInfo.type); replacer.Save(targetFileName); } }