/// <summary> /// Creates a Typescript type union /// </summary> /// <param name="name">The name used for the type</param> /// <param name="directory">The <see cref="TsDir" /> where the resulting file should be placed.</param> /// <param name="filters">The filters used to find the types used in the union.</param> /// <returns></returns> public UnionTypeDefinition UnionType(string name, TsDir directory = null, params Func <Type, bool>[] filters) { var typesForUnion = new List <TypedFile>(); foreach (var type in _allTypes.Where(t => filters.Any(f => f(t)))) { TypedFile typeForUnion; if (InterfaceFiles.ContainsKey(type)) { typeForUnion = Interface(type); } else if (ClassFiles.ContainsKey(type)) { typeForUnion = Class(type); } else if (type.IsInterface) { typeForUnion = Interface(type); } else { typeForUnion = Class(type); } typesForUnion.Add(typeForUnion); } return(UnionType(name, directory, typesForUnion.ToArray())); }
public void SetUp() { kernel = new Kernel(null, null, null, null); tsDir = new TsDir(); logger = new Logger(kernel, "LOG", false, null); dir = string.Format("{0}\\TestDir", tsDir.Src); }
public void GeneratesValidPaths() { var expected = Directory.GetCurrentDirectory(); var subject = TsDir.Create(expected); var actual = subject.ToPath(); Assert.Equal(expected, actual); }
public void GeneratesValidPath_with_filename() { var expected = Directory.GetCurrentDirectory(); var subject = TsDir.Create(expected); var actual = subject.ToPath("test.ts"); Assert.Equal(Path.Combine(expected, "test.ts"), actual); }
public UnionTypeDefinition UnionType(string name, TsDir directory = null, params TypedFile[] files) { var unionTypeDefinition = new UnionTypeDefinition(name, directory ?? RootDir); unionTypeDefinition.TypesForUnion.AddRange(files); UnionTypeDefinitions.Add(unionTypeDefinition); return(unionTypeDefinition); }
public Initialization2() { var tsDir = new TsDir(); //var tsOption = new TsOption(tsDir); //var manageDir = tsDir.Src + "\\TestDir"; //TmpDir2 = string.Format("{0}/../../TestDir", Directory.GetCurrentDirectory()); var optionDef = tsDir.Src + "\\Option.def"; //Docs Docs = new List<string>(); var lines = File.ReadAllLines(optionDef, Encoding.GetEncoding(932)); foreach (MlDocKind docKind in Enum.GetValues(typeof(MlDocKind))) { var tag = string.Format("MEMO=Ml\b{0}Document=", docKind.ToString().ToLower()); bool hit = false; foreach (var l in lines) { if (l.IndexOf(tag) == 0) { Docs.Add(l.Substring(tag.Length)); hit = true; break; } } if (!hit) { Docs.Add(""); } } Kernel = new Kernel(null, null, null, null); Logger = Kernel.CreateLogger("LOG", true, null); domainList = new List<string>() { "example.com" }; MlAddr = new MlAddr(mlName, domainList); var mailQueue = new MailQueue(tsDir.Src + "TestDir"); var oneOption = new Option(Kernel,"",""); var mailBox = new MailBox(Kernel, oneOption); MailSave = new MailSave(Kernel,mailBox,Logger,mailQueue,"",domainList); MlOption = CreateMlOption(); //MlUserList = CreateMlUsers(); Ml = new Ml(Kernel, Logger, MailSave, MlOption, mlName, domainList); //30件のメールを保存 for (int i = 0; i < 30; i++) { var mail = new Mail(null); mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了) mail.AddHeader("subject", string.Format("[{0}:{1:D5}]TITLE", mlName, i + 1)); mail.Init(Encoding.ASCII.GetBytes("1\r\n"));//本文 mail.Init(Encoding.ASCII.GetBytes("2\r\n"));//本文 mail.Init(Encoding.ASCII.GetBytes("3\r\n"));//本文 Ml.Save(mail); } }
private TsDir CreateTestingTree() { var currentDir = TsDir.Create(Directory.GetCurrentDirectory()); currentDir .Down("types") .Down("models") .Down("a") .Up() .Down("b") .Up() .Up() .Down("controllers") .Up() .Down("services"); return(currentDir); }
MlOption CreateMlOption() { const int maxSummary = 20; const int maxGet = 20; const bool autoRegistration = true; //自動登録 var tsDir = new TsDir(); const int titleKind = 1; var memberList = new Dat(); memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, "")); //読者・投稿 memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, "")); //読者 × memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER6", "*****@*****.**", false, false, true, "")); //× 投稿 (Disable) memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, "")); //× 投稿 memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN", "*****@*****.**", true, false, true, "123")); //× 投稿 memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456")); //読者 投稿 memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN3", "*****@*****.**", true, true, true, "789")); //読者 投稿 (Disable) return(new MlOption(null, maxSummary, maxGet, autoRegistration, titleKind, Docs, tsDir.Src + "\\TestDir", memberList)); }
public TypeBuilder(params Assembly[] additionalAssemblies) { RootDir = TsDir.Create(Directory.GetCurrentDirectory()).Down("Types"); _allTypes = Assembly.GetExecutingAssembly() .GetReferencedAssemblies() .Select(Assembly.Load) .Union(new[] { Assembly.GetExecutingAssembly(), Assembly.GetCallingAssembly(), Assembly.GetEntryAssembly() }) .Union(Assembly.GetCallingAssembly().GetReferencedAssemblies().Select(Assembly.Load)) .Union(Assembly.GetEntryAssembly().GetReferencedAssemblies().Select(Assembly.Load)) .Union(additionalAssemblies) .SelectMany(x => x.GetTypes()) .ToArray(); //todo move all .net types into definitions, to do this we need a way to indicate a type that doesn't necessarily need to be imported. That way a user could swap out all instances of a type (like DateTime) with a specific typescript/javascript type or even a type from a library import. Should also change it so that a type can have multiple associated files with it, files would associate back to a type so you could do file->type->files[] }
public void SetUp() { var tsDir = new TsDir(); _tsOption = new TsOption(tsDir); _tsOption.Set("FOLDER", "MailBox", "dir", string.Format("{0}\\MailBox", tsDir.Src)); //user1,user2,user3 _tsOption.Set("DAT", "MailBox", "user", "user1\tpass\buser2\tpass\buser3\tpass"); var kernel = new Kernel(null, null, null, null); var logger = new Logger(kernel, "LOG", false, null); var manageDir = tsDir.Src + "\\TestDir"; //MailQueue _mailQueue = new MailQueue(tsDir.Src + "\\MailQueue"); var oneOption = kernel.ListOption.Get("MailBox"); _mailBox = new MailBox(kernel, oneOption); var mailSave = new MailSave(kernel, _mailBox, logger, _mailQueue, "", _domainList);//モック var memberList = new Dat(); memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, "")); //一般・読者・投稿 memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, "")); //一般・読者・× memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, "")); //一般・×・投稿 //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER6" , "*****@*****.**" , false, false, true, ""));//一般・×・投稿 (Disable) //memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN" , "*****@*****.**" , true, false, true, "123"));//管理者・×・投稿 //memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456"));//管理者・読者・投稿 //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN3", "*****@*****.**", true, true, true, "789"));//管理者・読者・投稿 (Disable) var docs = (from object o in Enum.GetValues(typeof(MLDocKind)) select "").ToList(); const int maxSummary = 10; const int getMax = 10; const bool autoRegistration = true; const int titleKind = 1; var mlOption = new MlOption(maxSummary, getMax, autoRegistration, titleKind, docs, manageDir, memberList); _ml = new Ml(kernel, logger, mailSave, mlOption, _mlName, _domainList); }
public void SetUp() { var tsDir = new TsDir(); _tsOption = new TsOption(tsDir); _tsOption.Set("FOLDER", "MailBox", "dir", string.Format("{0}\\MailBox", tsDir.Src)); //user1,user2,user3 _tsOption.Set("DAT", "MailBox", "user", "user1\tpass\buser2\tpass\buser3\tpass"); var kernel = new Kernel(null, null, null, null); var logger = new Logger(kernel, "LOG", false, null); var manageDir = tsDir.Src + "\\TestDir"; //MailQueue _mailQueue = new MailQueue(tsDir.Src + "\\MailQueue"); var oneOption = kernel.ListOption.Get("MailBox"); _mailBox = new MailBox(kernel, oneOption); var mailSave = new MailSave(kernel, _mailBox, logger, _mailQueue, "", _domainList);//モック var memberList = new Dat(); memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, "")); //一般・読者・投稿 memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, ""));//一般・読者・× memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, ""));//一般・×・投稿 //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER6" , "*****@*****.**" , false, false, true, ""));//一般・×・投稿 (Disable) //memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN" , "*****@*****.**" , true, false, true, "123"));//管理者・×・投稿 //memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456"));//管理者・読者・投稿 //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN3", "*****@*****.**", true, true, true, "789"));//管理者・読者・投稿 (Disable) var docs = (from object o in Enum.GetValues(typeof(MLDocKind)) select "").ToList(); const int maxSummary = 10; const int getMax = 10; const bool autoRegistration = true; const int titleKind = 1; var mlOption = new MlOption(maxSummary, getMax, autoRegistration, titleKind, docs, manageDir, memberList); _ml = new Ml(kernel, logger, mailSave, mlOption, _mlName, _domainList); }
MlOption CreateMlOption() { const int maxSummary = 20; const int maxGet = 20; const bool autoRegistration = true; //自動登録 var tsDir = new TsDir(); const int titleKind = 1; var memberList = new Dat(); memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, "")); //読者・投稿 memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, ""));//読者 × memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER6", "*****@*****.**", false, false, true, ""));//× 投稿 (Disable) memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, ""));//× 投稿 memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN", "*****@*****.**", true, false, true, "123"));//× 投稿 memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456"));//読者 投稿 memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN3", "*****@*****.**", true, true, true, "789"));//読者 投稿 (Disable) return new MlOption(null,maxSummary, maxGet, autoRegistration,titleKind,Docs,tsDir.Src + "\\TestDir",memberList); }
public Initialization2() { var tsDir = new TsDir(); //var tsOption = new TsOption(tsDir); //var manageDir = tsDir.Src + "\\TestDir"; //TmpDir2 = string.Format("{0}/../../TestDir", Directory.GetCurrentDirectory()); var optionDef = tsDir.Src + "\\Option.def"; //Docs Docs = new List <string>(); var lines = File.ReadAllLines(optionDef, Encoding.GetEncoding(932)); foreach (MlDocKind docKind in Enum.GetValues(typeof(MlDocKind))) { var tag = string.Format("MEMO=Ml\b{0}Document=", docKind.ToString().ToLower()); bool hit = false; foreach (var l in lines) { if (l.IndexOf(tag) == 0) { Docs.Add(l.Substring(tag.Length)); hit = true; break; } } if (!hit) { Docs.Add(""); } } Kernel = new Kernel(null, null, null, null); Logger = Kernel.CreateLogger("LOG", true, null); domainList = new List <string>() { "example.com" }; MlAddr = new MlAddr(mlName, domainList); var mailQueue = new MailQueue(tsDir.Src + "TestDir"); var oneOption = new Option(Kernel, "", ""); var mailBox = new MailBox(Kernel, oneOption); MailSave = new MailSave(Kernel, mailBox, Logger, mailQueue, "", domainList); MlOption = CreateMlOption(); //MlUserList = CreateMlUsers(); Ml = new Ml(Kernel, Logger, MailSave, MlOption, mlName, domainList); //30件のメールを保存 for (int i = 0; i < 30; i++) { var mail = new Mail(null); mail.Init(Encoding.ASCII.GetBytes("\r\n")); //区切り行(ヘッダ終了) mail.AddHeader("subject", string.Format("[{0}:{1:D5}]TITLE", mlName, i + 1)); mail.Init(Encoding.ASCII.GetBytes("1\r\n")); //本文 mail.Init(Encoding.ASCII.GetBytes("2\r\n")); //本文 mail.Init(Encoding.ASCII.GetBytes("3\r\n")); //本文 Ml.Save(mail); } }
public static UnionTypeDefinition UnionType <TBaseClass>(this TypeBuilder builder, string nameOverride = null, TsDir directory = null, params Func <Type, bool>[] additionalFilters) { var result = builder.UnionType(string.IsNullOrWhiteSpace(nameOverride) ? typeof(TBaseClass).Name : nameOverride, directory, additionalFilters.Union(new Func <Type, bool>[] { t => t.IsSubclassOf(typeof(TBaseClass)) }).ToArray()); return(result); }