private CodeGenUtil() { NamespaceImports = new CodeNamespaceImport[] { new CodeNamespaceImport("System"), new CodeNamespaceImport("System.Collections.Generic"), new CodeNamespaceImport("System.Text"), new CodeNamespaceImport("Avro"), new CodeNamespaceImport("Avro.Specific") }; FileComment = new CodeCommentStatement( @"------------------------------------------------------------------------------ <auto-generated> Generated by " + System.AppDomain.CurrentDomain.FriendlyName + ", version " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version + @" Changes to this file may cause incorrect behavior and will be lost if code is regenerated </auto-generated> ------------------------------------------------------------------------------"); // Visual Studio 2010 http://msdn.microsoft.com/en-us/library/x53a06bb.aspx ReservedKeywords = new HashSet<string>() { "abstract","as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while", "value", "partial" }; }
public override void GenerateCode(Span target, CodeGeneratorContext context) { // Try to find the namespace in the existing imports string ns = Namespace; if (!String.IsNullOrEmpty(ns) && Char.IsWhiteSpace(ns[0])) { ns = ns.Substring(1); } CodeNamespaceImport import = context.Namespace .Imports .OfType<CodeNamespaceImport>() .Where(i => String.Equals(i.Namespace, ns.Trim(), StringComparison.Ordinal)) .FirstOrDefault(); if (import == null) { // It doesn't exist, create it import = new CodeNamespaceImport(ns); context.Namespace.Imports.Add(import); } // Attach our info to the existing/new import. import.LinePragma = context.GenerateLinePragma(target); }
static CodeNamespace BuildProgram() { // namespaceの作成 var ns = new CodeNamespace("MetaWorld"); // import編成 var systemImport = new CodeNamespaceImport("System"); // class作成 var programClass = new CodeTypeDeclaration("Program"); // mainメソッドの定義 var methodMain = new CodeMemberMethod() { Attributes = MemberAttributes.Static, Name = "Main" }; methodMain.Statements.Add( new CodeMethodInvokeExpression( new CodeSnippetExpression("Console"), "WriteLine", new CodePrimitiveExpression("Hello World") ) ); // コード構造の編成 programClass.Members.Add(methodMain); ns.Imports.Add(systemImport); ns.Types.Add(programClass); return ns; }
public void Add(CodeNamespaceImport value) { if (!this.keys.ContainsKey(value.Namespace)) { this.keys[value.Namespace] = value; this.data.Add(value); } }
public SqlTypesSchemaImporterExtensionHelper(string name, string targetNamespace, string[] references, CodeNamespaceImport[] namespaceImports, string destinationType, bool direct) { Init(name, targetNamespace, references, namespaceImports, destinationType, direct); }
public void Add(CodeNamespaceImport value) { if (!_keys.ContainsKey(value.Namespace)) { _keys[value.Namespace] = value; _data.Add(value); } }
public void Constructor1_Deny_Unrestricted () { CodeNamespaceImport cni = new CodeNamespaceImport ("mono"); Assert.IsNull (cni.LinePragma, "LinePragma"); cni.LinePragma = new CodeLinePragma (String.Empty, Int32.MinValue); Assert.AreEqual ("mono", cni.Namespace, "Namespace"); cni.Namespace = String.Empty; }
void IXamlFileGenerationData.addImports(CodeNamespace ns) { CodeNamespaceImport anImport; if (this.isRegularWindow) anImport = new CodeNamespaceImport("System.Windows"); else anImport = new CodeNamespaceImport("System.Windows.Navigation"); ns.Imports.Add(anImport); }
private static CodeNamespace AddNamespace(CodeCompileUnit compileUnit) { var codeNamespace = new CodeNamespace("Scripts"); var systemImport = new CodeNamespaceImport("System"); codeNamespace.Imports.Add(systemImport); compileUnit.Namespaces.Add(codeNamespace); return codeNamespace; }
public void AddRange(CodeNamespaceImport[] value) { if (value == null) { throw new ArgumentNullException("value"); } foreach (CodeNamespaceImport import in value) { this.Add(import); } }
public void AddRange(CodeNamespaceImport[] value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } foreach (CodeNamespaceImport c in value) { Add(c); } }
public void Constructor1 () { string ns = "mono"; CodeNamespaceImport cni = new CodeNamespaceImport (ns); Assert.IsNull (cni.LinePragma, "#1"); Assert.IsNotNull (cni.Namespace, "#2"); Assert.AreSame (ns, cni.Namespace, "#3"); cni = new CodeNamespaceImport ((string) null); Assert.IsNotNull (cni.Namespace, "#4"); Assert.AreEqual (string.Empty, cni.Namespace, "#5"); }
public CodeNamespaceImport this [int index] { get { return((CodeNamespaceImport)data[index]); } set { CodeNamespaceImport oldImport = (CodeNamespaceImport)data [index]; CodeNamespaceImport newImport = (CodeNamespaceImport)value; keys.Remove(oldImport.Namespace); data[index] = value; keys [newImport.Namespace] = newImport; } }
public static CodeNamespace GenerateFactoryClass(IClassMap classMap) { CodeNamespace domainNamespace = new CodeNamespace(classMap.DomainMap.RootNamespace + ".Factories" ) ; CodeTypeDeclaration classDecl = new CodeTypeDeclaration(GetFactoryClassName(classMap)) ; CodeNamespaceImport import = new CodeNamespaceImport(classMap.GetFullNamespace()) ; CodeNamespaceImport importNPersist = new CodeNamespaceImport("Puzzle.NPersist.Framework") ; domainNamespace.Imports.Add(import); domainNamespace.Imports.Add(importNPersist); classDecl.IsClass = true; GenerateConstructor(classDecl); GenerateContextField(classDecl); GenerateFactoryMethods(classMap, classDecl); domainNamespace.Types.Add(classDecl); return domainNamespace; }
// // Methods // public void Add(CodeNamespaceImport value) { if (value == null) { throw new NullReferenceException(); } // perform case-insensitive check to see if the namespace of the // entry to add is not already in the collection foreach (CodeNamespaceImport import in this) { if (string.Compare(import.Namespace, value.Namespace, true) == 0) { // skip duplicate namespaces return; } } namespaceImports.Add(value); }
private void Generate() { _codeBase = new CodeCompileUnit(); CodeNamespace Namespace = new CodeNamespace(_class.Namespace); CodeTypeDeclaration Class = new CodeTypeDeclaration(_class.ClassName); // if (_class.Interface != null) // Class.BaseTypes.Add(_class.Interface); Class.CustomAttributes.Add(new CodeAttributeDeclaration("Serializable")); Class.BaseTypes.Add("IData"); Namespace.Types.Add(Class); _codeBase.Namespaces.Add(Namespace); _codeBase.Namespaces[0].Imports.Add(new CodeNamespaceImport("System.Collections.Generic")); _codeBase.Namespaces[0].Imports.Add(new CodeNamespaceImport("RaidBot.Common.IO")); foreach (string import in _class.Import) { System.CodeDom.CodeNamespaceImport Import = new System.CodeDom.CodeNamespaceImport(import); _codeBase.Namespaces[0].Imports.Add(Import); } foreach (GameDataVariable var in _class.Variables) { AddClassVariableToCodeBase(var); } if (_class.Parent != "" && _class.Parent != null) { Class.BaseTypes.Insert(0, new CodeTypeReference(_class.Parent)); } AddSampleConstructor(); //AddConstructor(); }
protected virtual void BuildNamespace (CodeNamespace codeNamespace) { CodeTypeDeclaration codeType = new CodeTypeDeclaration { Name = GeneratedTypeName, IsClass = true }; foreach (ParsedValue<string> item in this.parser.Namespaces) { CodeNamespaceImport import = new CodeNamespaceImport (item.Value); if (item.FileName != null) import.LinePragma = new CodeLinePragma (item.FileName, item.LineNumber); codeNamespace.Imports.Add (import); } BuildPageClass (codeType); codeNamespace.Types.Add (codeType); }
public void AddRange () { CodeNamespaceImport ni1 = new CodeNamespaceImport ("A"); CodeNamespaceImport ni2 = new CodeNamespaceImport ("B"); CodeNamespaceImport ni3 = new CodeNamespaceImport ("b"); CodeNamespaceImport ni4 = new CodeNamespaceImport ("B"); CodeNamespaceImport ni5 = new CodeNamespaceImport ("C"); CodeNamespaceImportCollection coll = new CodeNamespaceImportCollection (); coll.AddRange (new CodeNamespaceImport[] {ni1, ni2}); Assert.AreEqual (2, coll.Count, "#1"); Assert.AreEqual (0, ((IList) coll).IndexOf (ni1), "#2"); Assert.AreEqual (1, ((IList) coll).IndexOf (ni2), "#3"); coll.AddRange (new CodeNamespaceImport[] { ni3, ni4, ni5 }); Assert.AreEqual (3, coll.Count, "#4"); Assert.AreEqual (0, ((IList) coll).IndexOf (ni1), "#5"); Assert.AreEqual (1, ((IList) coll).IndexOf (ni2), "#6"); Assert.AreEqual (-1, ((IList) coll).IndexOf (ni3), "#7"); Assert.AreEqual (-1, ((IList) coll).IndexOf (ni4), "#8"); Assert.AreEqual (2, ((IList) coll).IndexOf (ni5), "#9"); }
public void Constructor0 () { CodeNamespaceImport cni = new CodeNamespaceImport (); Assert.IsNull (cni.LinePragma, "#1"); Assert.IsNotNull (cni.Namespace, "#2"); Assert.AreEqual (string.Empty, cni.Namespace, "#3"); CodeLinePragma linePragma = new CodeLinePragma ("a", 5); cni.LinePragma = linePragma; Assert.IsNotNull (cni.LinePragma, "#4"); Assert.AreSame (linePragma, cni.LinePragma, "#5"); cni.LinePragma = null; Assert.IsNull (cni.LinePragma, "#6"); string ns = "mono"; cni.Namespace = ns; Assert.AreSame (ns, cni.Namespace, "#7"); cni.Namespace = null; Assert.IsNotNull (cni.Namespace, "#8"); Assert.AreEqual (string.Empty, cni.Namespace, "#9"); }
private void Init(string name, string targetNamespace, string[] references, CodeNamespaceImport[] namespaceImports, string destinationType, bool direct) { this.m_name = name; this.m_targetNamespace = targetNamespace; if (references == null) { this.m_references = new string[] { "System.Data.dll" }; } else { this.m_references = references; } if (namespaceImports == null) { this.m_namespaceImports = new CodeNamespaceImport[] { new CodeNamespaceImport("System.Data"), new CodeNamespaceImport("System.Data.SqlTypes") }; } else { this.m_namespaceImports = namespaceImports; } this.m_destinationType = destinationType; this.m_direct = direct; }
public void Add () { CodeNamespaceImport ni1 = new CodeNamespaceImport ("A"); CodeNamespaceImport ni2 = new CodeNamespaceImport ("B"); CodeNamespaceImport ni3 = new CodeNamespaceImport ("b"); CodeNamespaceImport ni4 = new CodeNamespaceImport ("B"); CodeNamespaceImportCollection coll = new CodeNamespaceImportCollection (); coll.Add (ni1); Assert.AreEqual (1, coll.Count, "#1"); Assert.AreEqual (0, ((IList) coll).IndexOf (ni1), "#2"); coll.Add (ni2); Assert.AreEqual (2, coll.Count, "#3"); Assert.AreEqual (1, ((IList) coll).IndexOf (ni2), "#4"); coll.Add (ni3); Assert.AreEqual (2, coll.Count, "#5"); Assert.AreEqual (-1, ((IList) coll).IndexOf (ni3), "#6"); coll.Add (ni4); Assert.AreEqual (2, coll.Count, "#7"); Assert.AreEqual (-1, ((IList) coll).IndexOf (ni4), "#8"); }
private void Init(string name, string targetNamespace, string[] references, CodeNamespaceImport[] namespaceImports, string destinationType, bool direct) { m_name = name; m_targetNamespace = targetNamespace; if (references == null) { m_references = new string[1]; m_references[0] = "System.Data.dll"; } else { m_references = references; } if (namespaceImports == null) { m_namespaceImports = new CodeNamespaceImport[2]; m_namespaceImports[0] = new CodeNamespaceImport("System.Data"); m_namespaceImports[1] = new CodeNamespaceImport("System.Data.SqlTypes"); } else { m_namespaceImports = namespaceImports; } m_destinationType = destinationType; m_direct = direct; }
protected override void GenerateNamespaceImport (CodeNamespaceImport e) { }
protected override void GenerateNamespaceImport (CodeNamespaceImport import) { TextWriter output = Output; output.Write ("Imports "); output.Write (import.Namespace); output.WriteLine (); }
protected override void GenerateNamespaceImport (CodeNamespaceImport i) { Output.Write ("IMPORT"); }
private bool BuildSourceDataTree() { _compilParams = Parser.CompilParams; _codeCompileUnit = new CodeCompileUnit(); _codeCompileUnit.UserData["AllowLateBound"] = !Parser.FStrict; _codeCompileUnit.UserData["RequireVariableDeclaration"] = Parser.FExplicit; // Set a flag indicating if we're using the VJS compiler. See comment in BuildExtractMethod for more information. _usingVJSCompiler = (_codeDomProvider.FileExtension == ".jsl"); _sourceDataNamespace = new CodeNamespace(Parser.GeneratedNamespace); string generatedClassName = GetGeneratedClassName(); if (Parser.BaseTypeName != null) { Debug.Assert(Parser.CodeFileVirtualPath != null); // This is the case where the page has a CodeFile attribute CodeNamespace intermediateNamespace = new CodeNamespace(Parser.BaseTypeNamespace); _codeCompileUnit.Namespaces.Add(intermediateNamespace); _intermediateClass = new CodeTypeDeclaration(Parser.BaseTypeName); // Specify the base class in the UserData in case the CodeDom provider needs // to reflect on it when generating code from the CodeCompileUnit (VSWhidbey 475294) // In design mode, use the default base type (e.g. Page or UserControl) to avoid // ending up with a type that can't be serialized to the Venus domain (VSWhidbey 545535) if (_designerMode) _intermediateClass.UserData["BaseClassDefinition"] = Parser.DefaultBaseType; else _intermediateClass.UserData["BaseClassDefinition"] = Parser.BaseType; intermediateNamespace.Types.Add(_intermediateClass); // Generate a partial class _intermediateClass.IsPartial = true; // Unless we're precompiling for updatable deployment, create the derived class if (!PrecompilingForUpdatableDeployment) { _sourceDataClass = new CodeTypeDeclaration(generatedClassName); // VSWhidbey 411701. Always use global type reference for the baseType // when codefile is present. _sourceDataClass.BaseTypes.Add(CodeDomUtility.BuildGlobalCodeTypeReference( Util.MakeFullTypeName(Parser.BaseTypeNamespace, Parser.BaseTypeName))); _sourceDataNamespace.Types.Add(_sourceDataClass); } } else { // The page is not using code besides _intermediateClass = new CodeTypeDeclaration(generatedClassName); _intermediateClass.BaseTypes.Add(CodeDomUtility.BuildGlobalCodeTypeReference(Parser.BaseType)); _sourceDataNamespace.Types.Add(_intermediateClass); // There is only one class, so make both fields point to the same thing _sourceDataClass = _intermediateClass; } // Add the derived class namespace after the base partial class so C# parser // can still parse the code correctly in case the derived class contains error. // VSWhidbey 397646 _codeCompileUnit.Namespaces.Add(_sourceDataNamespace); // We don't generate any code during updatable precompilation of a single (inline) page, // except for global.asax if (PrecompilingForUpdatableDeployment && Parser.CodeFileVirtualPath == null) return false; // Add metadata attributes to the class GenerateClassAttributes(); // In VB, always import Microsoft.VisualBasic (VSWhidbey 256475) if (_codeDomProvider is Microsoft.VisualBasic.VBCodeProvider) _sourceDataNamespace.Imports.Add(new CodeNamespaceImport("Microsoft.VisualBasic")); // Add all the namespaces if (Parser.NamespaceEntries != null) { foreach (NamespaceEntry entry in Parser.NamespaceEntries.Values) { // Create a line pragma if available CodeLinePragma linePragma; if (entry.VirtualPath != null) { linePragma = CreateCodeLinePragma(entry.VirtualPath, entry.Line); } else { linePragma = null; } CodeNamespaceImport nsi = new CodeNamespaceImport(entry.Namespace); nsi.LinePragma = linePragma; _sourceDataNamespace.Imports.Add(nsi); } } if (_sourceDataClass != null) { // We need to generate a global reference to avoid ambiguities (VSWhidbey 284936) string fullClassName = Util.MakeFullTypeName(_sourceDataNamespace.Name, _sourceDataClass.Name); CodeTypeReference classTypeRef = CodeDomUtility.BuildGlobalCodeTypeReference(fullClassName); // Since this is needed in several places, store it in a member variable _classTypeExpr = new CodeTypeReferenceExpression(classTypeRef); } // Add the implemented interfaces GenerateInterfaces(); // Build various properties, fields, methods BuildMiscClassMembers(); // Build the default constructors if (!_designerMode && _sourceDataClass != null) { _ctor = new CodeConstructor(); AddDebuggerNonUserCodeAttribute(_ctor); _sourceDataClass.Members.Add(_ctor); BuildDefaultConstructor(); } return true; }
protected abstract void GenerateNamespaceImport (CodeNamespaceImport i);
private bool GenerateOutput() { string shortClassName, classNamespace; int dot = className.LastIndexOf('.'); if (dot >= 0) { classNamespace = className.Substring(0, dot); shortClassName = className.Substring(dot + 1); } else { classNamespace = null; shortClassName = className; } bool isPrivate = false; if (classModifier != null) { string publicModifier = null, privateModifier = null; if (typeAttributesConverter != null || typeAttributesConverter.CanConvertTo(typeof(string))) { try { publicModifier = typeAttributesConverter.ConvertTo(TypeAttributes.Public, typeof(string)) as string; privateModifier = typeAttributesConverter.ConvertTo(TypeAttributes.NotPublic, typeof(string)) as string; } catch (NotSupportedException) { } } if (string.Equals(classModifier, privateModifier, StringComparison.OrdinalIgnoreCase)) { isPrivate = true; } else if (!string.Equals(classModifier, publicModifier, StringComparison.OrdinalIgnoreCase)) { LogError(classModifierLineNumber, 1503, "Language '" + Language + "' does not support x:ClassModifier '" + classModifier + "'."); return false; } } var unit = new CodeCompileUnit(); var ns = new CodeNamespace(classNamespace); unit.Namespaces.Add(ns); foreach (string importName in importedNamespaces) { var import = new CodeNamespaceImport(importName); if (importedNamespacesLineNumber != 0) { import.LinePragma = new CodeLinePragma(InputFileName.ItemSpec, importedNamespacesLineNumber); } ns.Imports.Add(import); } var type = new CodeTypeDeclaration { Name = shortClassName, IsPartial = true, BaseTypes = { typeof(ILambdaConverterProvider) } }; ns.Types.Add(type); if (isPrivate) { type.TypeAttributes &= ~TypeAttributes.Public; } var method = new CodeMemberMethod { Name = "GetConverterForLambda", PrivateImplementationType = new CodeTypeReference(typeof(ILambdaConverterProvider)), ReturnType = new CodeTypeReference(typeof(LambdaConverter)), Parameters = { new CodeParameterDeclarationExpression { Name = "lambda__", Type = new CodeTypeReference(typeof(string)) } }, CustomAttributes = { new CodeAttributeDeclaration(new CodeTypeReference(typeof(GeneratedCodeAttribute))) { Arguments = { new CodeAttributeArgument(new CodePrimitiveExpression(ToolName)), new CodeAttributeArgument(new CodePrimitiveExpression(typeof(ExtractLambdasFromXaml).Assembly.GetName().Version.ToString())) } } } }; type.Members.Add(method); foreach (var lambda in lambdas) { var cond = new CodeConditionStatement { Condition = new CodeBinaryOperatorExpression { Operator = CodeBinaryOperatorType.ValueEquality, Left = new CodeArgumentReferenceExpression("lambda__"), Right = new CodePrimitiveExpression(lambda.Code) }, TrueStatements = { new CodeMethodReturnStatement { Expression = new CodeMethodInvokeExpression { Method = new CodeMethodReferenceExpression { TargetObject = new CodeTypeReferenceExpression(typeof(LambdaConverter)), MethodName = "Create" }, Parameters = { new CodeSnippetExpression(lambda.Code) } }, LinePragma = new CodeLinePragma { FileName = InputFileName.ItemSpec, LineNumber = lambda.LineNumber } } } }; method.Statements.Add(cond); } method.Statements.Add( new CodeThrowExceptionStatement { ToThrow = new CodeObjectCreateExpression { CreateType = new CodeTypeReference(typeof(ArgumentOutOfRangeException)), Parameters = { new CodePrimitiveExpression("lambda__") } } }); try { using (var writer = File.CreateText(OutputFileName.ItemSpec)) { var options = new CodeGeneratorOptions(); codeDomProvider.GenerateCodeFromCompileUnit(unit, writer, options); } } catch (IOException ex) { LogError(2002, ex.Message); return false; } return true; }
public void Add(CodeNamespaceImport value) { }
public CodeNamespaceImport AddImport(string nameSpace) { CodeNamespaceImport cni = new CodeNamespaceImport(nameSpace); this.Imports.Add(cni); return cni; }
protected override void GenerateNamespaceImport(System.CodeDom.CodeNamespaceImport e) { Output.Write(e.Namespace); }
/// <include file='doc\CSharpCodeProvider.uex' path='docs/doc[@for="CSharpCodeGenerator.GenerateNamespaceImport"]/*' /> /// <devdoc> /// <para> /// Generates code for the specified CodeDom based namespace import /// representation. /// </para> /// </devdoc> protected override void GenerateNamespaceImport(CodeNamespaceImport e) { Output.Write("using "); OutputIdentifier(e.Namespace); Output.WriteLine(";"); }
public void Add(CodeNamespaceImport value) { Contract.Requires(value != null); }
protected override void GenerateNamespaceImport(CodeNamespaceImport e) { base.Output.Write("Imports "); this.OutputIdentifier(e.Namespace); base.Output.WriteLine(""); }
public void Add(CodeNamespaceImport value) { throw new NotImplementedException(); }
// Add a new namespace import to this collection. public void Add(CodeNamespaceImport value) { list.Add(value); }
protected override void GenerateNamespaceImport(CodeNamespaceImport e) { Output.WriteLine("[CodeNamespaceImport: {0}]", e.ToString()); }
public IEnumerable<ZipEntry> Generate(IClassConfiguration configuration) { var files = new List<IFileConfiguration>(); var initializeMethod = new CodeMemberMethod() { Name = "Initialize", Attributes = MemberAttributes.Public, ReturnType = new CodeTypeReference(typeof(void)) }; var testBaseClass = new CodeTypeDeclaration("Describe_" + configuration.Name) { Attributes = MemberAttributes.Public | MemberAttributes.Abstract, Members = { initializeMethod } }; var classSpace = new CodeNamespace("Logics"); classSpace.Imports.Add(new CodeNamespaceImport("System")); files.Add(new FileConfiguration(configuration.Name, classSpace)); var targetClass = new CodeTypeDeclaration(configuration.Name) { IsClass = true, TypeAttributes = TypeAttributes.Public | TypeAttributes.Sealed }; var targetInterface = new CodeTypeDeclaration("I" + configuration.Name) { IsInterface = true }; targetClass.BaseTypes.Add(targetInterface.Name); var members = GenerateConstructor(configuration, classSpace, testBaseClass, files); targetClass.Members.AddRange(members.ToArray()); targetInterface.Members.AddRange(members.ToArray()); var methods = AddMethods(configuration, files); foreach (var method in methods) { targetClass.Members.Add(method); targetInterface.Members.Add(method); } foreach (var methodConfiguration in configuration.Methods.Where(m => m.MethodType == MethodTypes.Dependent)) { var import = new CodeNamespaceImport("I" + methodConfiguration.Name + "Arguments = " + "I" + targetClass.Name + methodConfiguration.Name + "Arguments"); classSpace.Imports.Add(import); } foreach (var methodConfiguration in configuration.Methods.Where(m => m.ReturnType.Type == ReturnTypes.Normal.Type)) { var import = new CodeNamespaceImport("I" + methodConfiguration.Name + "Results = " + "I" + targetClass.Name + methodConfiguration.Name + "Results"); classSpace.Imports.Add(import); import = new CodeNamespaceImport("I" + methodConfiguration.Name + "ResultsFactory = " + "I" + targetClass.Name + methodConfiguration.Name + "ResultsFactory"); classSpace.Imports.Add(import); } if (configuration.ClassType == ClassTypes.Dependent) classSpace.Imports.Add(new CodeNamespaceImport("IDependencies = I" + configuration.Name + "Dependencies")); classSpace.Types.Add(targetInterface); classSpace.Types.Add(targetClass); var provider = CodeDomProvider.CreateProvider("CSharp"); var options = new CodeGeneratorOptions { BracingStyle = "C" }; foreach (var fileConfiguration in files) { var compileUnit = new CodeCompileUnit { Namespaces = { fileConfiguration.Namespace } }; var zipEntry = new ZipEntry { FileName = fileConfiguration.Name + ".cs" }; using (var writer = new StreamWriter(zipEntry.Stream)) { provider.GenerateCodeFromCompileUnit(compileUnit, writer, options); } yield return zipEntry; } }