示例#1
0
        public override void Copy(IMap mapObject)
        {
            ICodeMap codeMap = (ICodeMap)mapObject;

            codeMap.Code         = this.Code;
            codeMap.CodeLanguage = this.CodeLanguage;
        }
示例#2
0
        public override void DeepCopy(IMap mapObject)
        {
            ICodeMap codeMap = (ICodeMap)mapObject;

            Copy(codeMap);
            DoDeepCopy(codeMap);
        }
示例#3
0
        private string InsertCodeMap(string code, IClassMap classMap, ICodeMap codeMap)
        {
            string declaration = GetClassDeclaration(classMap, codeMap);
            int    pos         = code.IndexOf(declaration);

            if (pos > 0)
            {
                InsertCode(pos, codeMap, ref code);
            }
            return(code);
        }
示例#4
0
 private string GetNamespaceDeclaration(IDomainMap domainMap, ICodeMap codeMap)
 {
     if (codeMap.CodeLanguage == CodeLanguage.CSharp)
     {
         return("namespace " + domainMap.RootNamespace + " {");
     }
     if (codeMap.CodeLanguage == CodeLanguage.VB)
     {
         return("Namespace " + domainMap.RootNamespace);
     }
     throw new IAmOpenSourcePleaseImplementMeException("");
 }
示例#5
0
 private string GetClassDeclaration(IClassMap classMap, ICodeMap codeMap)
 {
     if (codeMap.CodeLanguage == CodeLanguage.CSharp)
     {
         return("public class " + classMap.GetName());
     }
     if (codeMap.CodeLanguage == CodeLanguage.VB)
     {
         return("Public Class " + classMap.GetName());
     }
     throw new IAmOpenSourcePleaseImplementMeException("");
 }
示例#6
0
 private string GetNamespaceEndDeclaration(ICodeMap codeMap)
 {
     if (codeMap.CodeLanguage == CodeLanguage.CSharp)
     {
         return("}");
     }
     if (codeMap.CodeLanguage == CodeLanguage.VB)
     {
         return("End Namespace");
     }
     throw new IAmOpenSourcePleaseImplementMeException("");
 }
示例#7
0
 private string GetDomainCodeMap(IDomainMap domainMap, ICodeMap codeMap)
 {
     if (codeMap.Code.Length > 0)
     {
         if (domainMap.RootNamespace.Length > 0)
         {
             string declaration    = GetNamespaceDeclaration(domainMap, codeMap);
             string endDeclaration = GetNamespaceEndDeclaration(codeMap);
             return(AddCode(declaration, endDeclaration, codeMap));
         }
     }
     return("");
 }
示例#8
0
        private static void InsertCode(int pos, ICodeMap codeMap, ref string code)
        {
            //int pos2 = code.Substring(pos).IndexOf("{");
            int pos2 = code.Substring(pos).IndexOf("\r\n");

            if (pos2 > 0)
            {
                //int breakAt = pos + pos2 + 3;
                int    breakAt    = pos + pos2;
                string codeLeft   = code.Substring(0, breakAt);
                string codeRight  = code.Substring(breakAt);
                string codeMiddle = Environment.NewLine + Environment.NewLine + codeMap.Code;
                code = codeLeft + codeMiddle + codeRight;
            }
        }
示例#9
0
        public override bool Compare(IMap compareTo)
        {
            if (compareTo == null)
            {
                return(false);
            }
            ICodeMap codeMap = (ICodeMap)compareTo;

            if (!(codeMap.Code == this.Code))
            {
                return(false);
            }
            if (!(codeMap.CodeLanguage == this.CodeLanguage))
            {
                return(false);
            }
            return(true);
        }
 private string GetClassDeclaration(IClassMap classMap, ICodeMap codeMap)
 {
     if (codeMap.CodeLanguage == CodeLanguage.CSharp)
         return "public class " + classMap.GetName();
     if (codeMap.CodeLanguage == CodeLanguage.VB)
         return "Public Class " + classMap.GetName();
     throw new IAmOpenSourcePleaseImplementMeException("");
 }
 public virtual void Visit(ICodeMap codeMap)
 {
     VerifyCodeMap(codeMap);
 }
 public virtual void VerifyCodeMap(ICodeMap codeMap)
 {
     ;
 }
 public static IApplicationBuilder UseErrorHandling(this IApplicationBuilder app, ICodeMap codeMap)
 => app.UseErrorHandling(codeMap.MapErrorCode);
 private string GetNamespaceEndDeclaration(ICodeMap codeMap)
 {
     if (codeMap.CodeLanguage == CodeLanguage.CSharp)
         return "}" ;
     if (codeMap.CodeLanguage == CodeLanguage.VB)
         return "End Namespace";
     throw new IAmOpenSourcePleaseImplementMeException("");
 }
		protected virtual string SerializeCodeMap(ICodeMap codeMap)
		{
			StringBuilder xml = new StringBuilder();
			xml.Append("    <code language=\"" + codeMap.CodeLanguage.ToString() + "\"><![CDATA[" + codeMap.Code + "]]></code>\r\n"); // do not localize
			return xml.ToString();				
		}
示例#16
0
 protected virtual void DoDeepCopy(ICodeMap codeMap)
 {
 }
 private string GetDomainCodeMap(IDomainMap domainMap, ICodeMap codeMap)
 {
     if (codeMap.Code.Length > 0)
     {
         if (domainMap.RootNamespace.Length > 0)
         {
             string declaration = GetNamespaceDeclaration(domainMap, codeMap);
             string endDeclaration = GetNamespaceEndDeclaration(codeMap);
             return AddCode(declaration, endDeclaration, codeMap);
         }
     }
     return "";
 }
 private string InsertCodeMap(string code, IClassMap classMap, ICodeMap codeMap)
 {
     string declaration = GetClassDeclaration(classMap, codeMap);
     int pos = code.IndexOf(declaration);
     if (pos > 0)
     {
         InsertCode(pos, codeMap, ref code);
     }
     return code;
 }
示例#19
0
 private static string AddCode(string declaration, string endDeclaration, ICodeMap codeMap)
 {
     return(declaration + Environment.NewLine + codeMap.Code + Environment.NewLine + endDeclaration + Environment.NewLine);
 }
 private static void InsertCode(int pos, ICodeMap codeMap, ref string code)
 {
     //int pos2 = code.Substring(pos).IndexOf("{");
     int pos2 = code.Substring(pos).IndexOf("\r\n");
     if (pos2 > 0)
     {
         //int breakAt = pos + pos2 + 3;
         int breakAt = pos + pos2;
         string codeLeft = code.Substring(0, breakAt);
         string codeRight = code.Substring(breakAt);
         string codeMiddle = Environment.NewLine + Environment.NewLine + codeMap.Code;
         code = codeLeft + codeMiddle + codeRight;
     }
 }
 private string GetNamespaceDeclaration(IDomainMap domainMap, ICodeMap codeMap)
 {
     if (codeMap.CodeLanguage == CodeLanguage.CSharp)
         return "namespace " + domainMap.RootNamespace + " {";
     if (codeMap.CodeLanguage == CodeLanguage.VB)
         return "Namespace " + domainMap.RootNamespace;
     throw new IAmOpenSourcePleaseImplementMeException("");
 }
示例#22
0
 protected virtual void DoDeepCopy(ICodeMap codeMap)
 {
 }
 public void Visit(ICodeMap codeMap)
 {
     ;
 }
 public void Visit(ICodeMap codeMap)
 {
     ;
 }
 private static string AddCode(string declaration, string endDeclaration, ICodeMap codeMap)
 {
     return declaration + Environment.NewLine + codeMap.Code + Environment.NewLine + endDeclaration + Environment.NewLine;
 }