示例#1
0
        private ClassInformation CreateFile(XElement f, Dictionary <string, string> parameters, Dictionary <string, List <String> > multipleObjects)
        {
            var classInformation = new ClassInformation();

            var fileName  = new StringBuilder(f.Descendants("Name").FirstOrDefault().Value);
            var extension = f.Descendants("Extension").FirstOrDefault().Value;

            classInformation.FileName = ReplaceParameters(fileName, parameters).ToString().Trim() + extension.Trim();

            var implementation = f.Descendants("Implementation").FirstOrDefault();
            var multiTemplate  = f.Descendants("MultiTemplate").FirstOrDefault();

            var classFile = new StringBuilder(implementation.Value);

            if (multiTemplate != null)
            {
                var multiTemplateValue = multiTemplate.Value;
                var multiTemplateName  = multiTemplate.Attribute("name").Value;
                var multiTemplateBind  = multiTemplate.Attribute("bind").Value;
                var multipleObjectList = multipleObjects[multiTemplateBind];
                var templateBuilder    = new StringBuilder();

                templateBuilder = multipleObjectList.Aggregate(templateBuilder, (current, obj) => current.Append(multiTemplateValue).Replace(multiTemplateBind, obj));

                classFile = classFile.Replace(multiTemplateName, templateBuilder.ToString());
            }
            classFile = ReplaceParameters(classFile, parameters);
            classInformation.Content = classFile.ToString();
            return(classInformation);
        }
示例#2
0
        private ClassInformation CreateFile(XElement f, Dictionary <string, string> parameters, String bindedObject,
                                            String bindedObjectValue)
        {
            var classInformation = new ClassInformation();

            var fileName  = new StringBuilder(f.Descendants("Name").FirstOrDefault().Value);
            var extension = f.Descendants("Extension").FirstOrDefault().Value;

            classInformation.FileName = ReplaceParameters(fileName, parameters).Replace(bindedObject, bindedObjectValue).ToString().Trim() + extension.Trim();

            var implementation = f.Descendants("Implementation").FirstOrDefault();

            var classFile = new StringBuilder(implementation.Value);

            classFile = classFile.Replace(bindedObject, bindedObjectValue);

            classFile = ReplaceParameters(classFile, parameters);
            classInformation.Content = classFile.ToString();

            return(classInformation);
        }