public override Dictionary <string, string> GenerateReplacementDictionary(Options options, ResourceDatabase resDb) { Dictionary <string, string> replacements = AbstractPlatform.GenerateGeneralReplacementsDictionary(options); replacements["PROJECT_GUID"] = "project guid goes here."; return(replacements); }
public LibraryNativeInvocationTranslatorProvider( Dictionary <string, LibraryMetadata> libraries, List <LibraryForExport> librariesForExport, AbstractPlatform platform) { this.libraries = libraries; this.librariesForExport = librariesForExport; this.platform = platform; }
public LibraryResourceDatabase(LibraryExporter library, AbstractPlatform platform) { this.library = library; this.exportEntities = null; this.ApplicablePlatformNames = new HashSet <string>(); while (platform != null) { this.ApplicablePlatformNames.Add(platform.Name); platform = platform.ParentPlatform; } }
public static void Run(ExportCommand command) { string vmTargetDir = new GetTargetVmExportDirectoryWorker().DoWorkImpl(command); AbstractPlatform platform = command.PlatformProvider.GetPlatform(command.VmPlatform); AssemblyMetadata[] assemblyMetadataList = new AssemblyFinder().AssemblyFlatList; Dictionary <string, FileOutput> fileOutputContext = new Dictionary <string, FileOutput>(); new ExportStandaloneVmSourceCodeForPlatformWorker().DoWorkImpl(fileOutputContext, platform, assemblyMetadataList, vmTargetDir, command); new EmitFilesToDiskWorker().DoWorkImpl(fileOutputContext, vmTargetDir); }
public LibraryResourceDatabase(LibraryExporter library, AbstractPlatform platform) { this.library = library; this.exportEntities = null; this.ApplicablePlatformNamesMostGeneralFirst = new List <string>(); while (platform != null) { this.ApplicablePlatformNamesMostGeneralFirst.Add(platform.Name); platform = platform.ParentPlatform; } this.ApplicablePlatformNamesMostGeneralFirst.Reverse(); }
/// <summary> /// Initializes broker for startup. /// </summary> /// <param name="platform">Platform implementations</param> public Broker(AbstractPlatform platform) { Platform = platform; _sha256 = new SHA256(); KeyPair = new KeyPair(".broker.key"); KeyPair.Load(Platform.FileSystem); DsId = "broker-" + UrlBase64.Encode(_sha256.ComputeHash(KeyPair.EncodedPublicKey)); ClientHandler = new ClientHandler(); HttpHandler = new HttpHandler(this); BrokerTree = new BrokerTree(this); Handshake = new Handshake(this); }
public AwarenessNotifyIconController(AbstractPlatform platform, AwarenessController controller) { Platform = platform; Platform.ApplicationWillQuit += ApplicationWillQuit; Controller = controller; Controller.BreakTimer.BreakChecked += BreakChecked; Controller.BreakTimer.BreakSuggested += BreakSuggested; Icon = new NotifyIcon { Visible = true, ContextMenu = BuildContextMenu(), Icon = new Icon(Platform.ResourceNamed("bowl.ico")) }; Icon.DoubleClick += (sender, args) => DoubleClick.Raise(this); Icon.BalloonTipClicked += BalloonTipClicked; }
private static AbstractPlatform configurationPlatform() { AbstractPlatform _platform; IGUIFactory _gUIFactory; string _osName = Environment.OSVersion.ToString(); if (_osName.Contains("mac")) { _gUIFactory = new MacOSFactory(); _platform = new AbstractPlatform(_gUIFactory); } else { _gUIFactory = new WindowsFactory(); _platform = new AbstractPlatform(_gUIFactory); } return(_platform); }
private bool CheckDllVersion(AbstractPlatform Platform, string DllPath, int Major, int Minor, int Build) { string FileVersion = Platform.GetFileVersionInfo(ModuleDirectory, DllPath); string[] BuildVersions = FileVersion.Split(' '); string ProductVersion = BuildVersions[0]; string[] ProductVersions = ProductVersion.Split('.'); int FileMajor = int.Parse(ProductVersions[0]); int FileMinor = int.Parse(ProductVersions[1]); int DllBuild = int.Parse(BuildVersions[BuildVersions.Length - 1]); bool Match = FileMajor == Major && FileMinor == Minor && DllBuild == Build; if (Debug && !Match) { Console.WriteLine(string.Format("Version {0}.{1}.{2} of \"{3}\" does not match expected version of Build file {4}.{5}.{6}", FileMajor, FileMinor, DllBuild, Path.GetFileName(DllPath), Major, Minor, Build)); } return(Match); }
public AwarenessForm() { InitializeComponent(); Platform = new WindowsPlatform(this); BackgroundImage = Image.FromFile(Platform.ResourceNamed("splash.jpg")); Height = BackgroundImage.Height + 35; Width = BackgroundImage.Width + 12; Controller = new AwarenessController(Platform); Controller.BreakTimer.BreakChecked += BreakChecked; NotifyIconController = new AwarenessNotifyIconController(Platform, Controller); NotifyIconController.DoubleClick += NotifyIcon_DoubleClicked; // Want to get form *not* to show, but best we can do is minimize. if (!Platform.Preferences.IsFirstRun) { WindowState = FormWindowState.Minimized; } }
public static void ExportJavaLibraries( AbstractPlatform platform, TemplateStorage templates, string srcPath, IList <LibraryForExport> libraries, Dictionary <string, FileOutput> output, string[] extraImports) { List <string> defaultImports = new List <string>() { "import java.util.ArrayList;", "import java.util.HashMap;", "import org.crayonlang.interpreter.FastList;", "import org.crayonlang.interpreter.Interpreter;", "import org.crayonlang.interpreter.LibraryFunctionPointer;", "import org.crayonlang.interpreter.TranslationHelper;", "import org.crayonlang.interpreter.VmGlobal;", "import org.crayonlang.interpreter.structs.*;", }; defaultImports.AddRange(extraImports); defaultImports.Sort(); foreach (LibraryForExport library in libraries) { if (library.HasPastelCode) { TranspilerContext ctx = library.PastelContext.GetTranspilerContext(); List <string> libraryCode = new List <string>() { "package org.crayonlang.libraries." + library.Name.ToLower() + ";", "", }; libraryCode.AddRange(defaultImports); libraryCode.AddRange(new string[] { "", "public final class LibraryWrapper {", " private LibraryWrapper() {}", "", }); libraryCode.Add(templates.GetCode("library:" + library.Name + ":manifestfunc")); libraryCode.Add(templates.GetCode("library:" + library.Name + ":functions")); libraryCode.Add("}"); libraryCode.Add(""); string libraryPath = srcPath + "/org/crayonlang/libraries/" + library.Name.ToLower(); output[libraryPath + "/LibraryWrapper.java"] = new FileOutput() { Type = FileOutputType.Text, TextContent = string.Join(platform.NL, libraryCode), }; foreach (string structKey in templates.GetTemplateKeysWithPrefix("library:" + library.Name + ":struct:")) { string structName = templates.GetName(structKey); string structCode = templates.GetCode(structKey); structCode = WrapStructCodeWithImports(platform.NL, structCode); // This is kind of a hack. // TODO: better. structCode = structCode.Replace( "package org.crayonlang.interpreter.structs;", "package org.crayonlang.libraries." + library.Name.ToLower() + ";"); output[libraryPath + "/" + structName + ".java"] = new FileOutput() { Type = FileOutputType.Text, TextContent = structCode, }; } foreach (ExportEntity supFile in library.ExportEntities["COPY_CODE"]) { string path = supFile.Values["target"].Replace("%LIBRARY_PATH%", libraryPath); output[path] = supFile.FileOutput; } } } }
static void Main(string[] args) { AbstractPlatform _platform = configurationPlatform(); _platform.Paint(); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== Stragery ==============================="); var reports = new List <DeveloperReport> { new DeveloperReport { Id = 1, Name = "Dev1", Level = DeveloperLevel.Senior, HourlyRate = 30.5, WorkingHours = 160 }, new DeveloperReport { Id = 2, Name = "Dev2", Level = DeveloperLevel.Junior, HourlyRate = 20, WorkingHours = 120 }, new DeveloperReport { Id = 3, Name = "Dev3", Level = DeveloperLevel.Senior, HourlyRate = 32.5, WorkingHours = 130 }, new DeveloperReport { Id = 4, Name = "Dev4", Level = DeveloperLevel.Junior, HourlyRate = 24.5, WorkingHours = 140 } }; var calculatorContext = new SalaryCalculator(new JuniorDevSalaryCalculator()); var juniorTotal = calculatorContext.Calculate(reports); Console.WriteLine($"Total amount for junior salaries is: {juniorTotal}"); calculatorContext.SetCalculator(new SeniorDevSalaryCalculator()); var seniorTotal = calculatorContext.Calculate(reports); Console.WriteLine($"Total amount for senior salaries is: {seniorTotal}"); Console.WriteLine($"Total cost for all the salaries is: {juniorTotal + seniorTotal}"); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== IoC ==============================="); BussinessLogic _bussinessLogic = new BussinessLogic(); _bussinessLogic.Task1(); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== Flyweight ==============================="); // The client code usually creates a bunch of pre-populated // flyweights in the initialization stage of the application. var factory = new FlyweightFactory( new Car { Company = "Chevrolet", Model = "Camaro2018", Color = "pink" }, new Car { Company = "Mercedes Benz", Model = "C300", Color = "black" }, new Car { Company = "Mercedes Benz", Model = "C500", Color = "red" }, new Car { Company = "BMW", Model = "M5", Color = "red" }, new Car { Company = "BMW", Model = "X6", Color = "white" } ); factory.listFlyweights(); addCarToPoliceDatabase(factory, new Car { Number = "CL234IR", Owner = "James Doe", Company = "BMW", Model = "M5", Color = "red" }); addCarToPoliceDatabase(factory, new Car { Number = "CL234IR", Owner = "James Doe", Company = "BMW", Model = "X1", Color = "red" }); factory.listFlyweights(); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== Proxy ==============================="); MathProxy _mathProxy = new MathProxy(); Console.Write("Input num1 and num2: "); var x = Convert.ToDouble(Console.ReadLine()); var y = Convert.ToDouble(Console.ReadLine()); Console.WriteLine($"{x} + {y} = {_mathProxy.Add(x, y)}"); Console.WriteLine($"{x} - {y} = {_mathProxy.Sub(x, y)}"); Console.WriteLine($"{x} * {y} = {_mathProxy.Mul(x, y)}"); Console.WriteLine($"{x} / {y} = {_mathProxy.Div(x, y)}"); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== ProxyWithBank ==============================="); Credit _credit = new Credit(); bool Income = false; _credit.Cash(400, ref Income); Income = true; Console.WriteLine($"Income {_credit.Cash(5000000.0, ref Income)} vnd"); Income = false; Console.WriteLine($"Outcome {_credit.Cash(100000.0, ref Income)} vnd"); _credit.CheckAccount(); Console.WriteLine("-------------------------------------------------------------------------------"); Console.WriteLine("----------------------------------- Transfer ----------------------------------"); Console.WriteLine("----------------------------------- Local -------------------------------------"); Income = false; _credit.LocalTransfer(6000000.0, "VND", "01231111441", "8912121231", ref Income); Income = true; Console.WriteLine($" Income local: " + $"{_credit.LocalTransfer(700000.0, "VND", "719273981723", "1125412311", ref Income)}"); _credit.CheckAccount(); Income = false; Console.WriteLine($" Outcome local: " + $"{_credit.LocalTransfer(70000.0, "VND", "719273981723", "1125412311", ref Income)}"); _credit.CheckAccount(); Console.WriteLine("----------------------------------- Overcome ----------------------------------"); Income = true; Console.WriteLine($"Income overcome: " + $"{_credit.OvercomeTransfer(500, "USD", "VND", "113311131", "719273981723", ref Income)} VND"); _credit.CheckAccount(); Income = false; Console.WriteLine($"Outcome overcome TWD: " + $"{_credit.OvercomeTransfer(5000000.0, "VND", "TWD", "719273981723", "115533315441", ref Income)} TWD"); _credit.CheckAccount(); Console.WriteLine("================================ CompositePattern ====================================="); CompositePattern.IEmployee employee_0000 = new Cashier(0, "Thu Tran", 7000000); CompositePattern.IEmployee employee_0001 = new Cashier(1, "Khoi Nguyen", 7000000); CompositePattern.IEmployee employee_0010 = new BankManager(0, "Ning Chang", 9000000); employee_0010.Add(employee_0000); employee_0010.Add(employee_0001); employee_0010.Print(); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== Stragery - Ver2 ==============================="); SortedList _studentRecords = new SortedList(); _studentRecords.Add("Samual"); _studentRecords.Add("Jimmy"); _studentRecords.Add("Sandra"); _studentRecords.Add("Vivek"); _studentRecords.Add("Anna"); Console.WriteLine("------------------------------------------------------------------------------------"); _studentRecords.SetSortStrategy(new QuickSort()); _studentRecords.Sort(); Console.WriteLine("------------------------------------------------------------------------------------"); _studentRecords.SetSortStrategy(new ShellSort()); _studentRecords.Sort(); Console.WriteLine("------------------------------------------------------------------------------------"); _studentRecords.SetSortStrategy(new MergeSort()); _studentRecords.Sort(); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== Decorator ==============================="); Console.WriteLine("-------------------------------------------------------------------------------"); Book _book0000 = new Book("Worley", "Inside ASP.NET", 10); _book0000.Display(); Console.WriteLine("-------------------------------------------------------------------------------"); Video _video0000 = new Video("Winifred Hervey", "Steve Harvey Show", 1, 512); _video0000.Display(); Console.WriteLine("-------------------------------------------------------------------------------"); Borrowable _borrower0000 = new Borrowable(_book0000); _borrower0000.BorrowItem("Khoi Nguyen Tan"); _borrower0000.BorrowItem("Ning Chang"); Borrowable _borrower0001 = new Borrowable(_video0000); _borrower0001.BorrowItem("Thu Tran"); _borrower0001.BorrowItem("Nguyen Lam Bao Ngoc"); _borrower0000.Display(); _borrower0001.Display(); AlertStateContext stateContext = new AlertStateContext(); stateContext.alert(); stateContext.alert(); stateContext.SetState(new Silent()); stateContext.alert(); stateContext.alert(); stateContext.alert(); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== AbstractFactoryVer2 ==============================="); Console.WriteLine("-------------------------------------------------------------------------------"); ///client class AnimalWorld animalWorld = new AnimalWorld(new AmericaFactory()); animalWorld.AnimalEatOthers(); animalWorld = new AnimalWorld(new AfricaFactory()); animalWorld.AnimalEatOthers(); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== Template ==============================="); Console.WriteLine("-------------------------------------------------------------------------------"); Game game = new Cricket(); game.Play(); game = new Football(); game.Play(); DataAccessObject dataAccessObject = new Categories(); dataAccessObject.Run(); dataAccessObject = new Products(); dataAccessObject.Run(); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== Adapter ==============================="); Console.WriteLine("-------------------------------------------------------------------------------"); var xmlConverter = new XmlConverter(); var adapter = new XmlToJsonAdapter(xmlConverter); adapter.ConvertXMLToJson(); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== Template Ver 3 ==============================="); Console.WriteLine("-------------------------------------------------------------------------------"); DAO @object = new Person(); @object.Connect(); @object.GetAll(); @object.Process(); @object.Disconnect(); Console.WriteLine("==========================================================================="); Console.WriteLine("================================== ChainOfReposibility ==============================="); Console.WriteLine("-------------------------------------------------------------------------------"); // Setup Chain of Responsibility Approver larry = new Director(); Approver sam = new VicePresident(); Approver tammy = new President(); larry.SetSuccessor(sam); sam.SetSuccessor(tammy); // Generate and process purchase requests Purchase p = new Purchase(2034, 350.00, "Assets"); larry.ProcessRequest(p); p = new Purchase(2035, 32590.10, "Project X"); larry.ProcessRequest(p); p = new Purchase(2036, 122100.00, "Project Y"); larry.ProcessRequest(p); }
public JavaScriptAppTranslator(AbstractPlatform platform) : base(platform) { }
public static void ExportJavaLibraries( AbstractPlatform platform, string srcPath, IList <LibraryForExport> libraries, Dictionary <string, FileOutput> output, ILibraryNativeInvocationTranslatorProvider libraryNativeInvocationTranslatorProviderForPlatform, string[] extraImports) { List <string> defaultImports = new List <string>() { "import java.util.ArrayList;", "import java.util.HashMap;", "import org.crayonlang.interpreter.Interpreter;", "import org.crayonlang.interpreter.TranslationHelper;", "import org.crayonlang.interpreter.VmGlobal;", "import org.crayonlang.interpreter.structs.*;", }; defaultImports.AddRange(extraImports); defaultImports.Sort(); foreach (LibraryForExport library in libraries) { if (library.ManifestFunction != null) { platform.Translator.CurrentLibraryFunctionTranslator = libraryNativeInvocationTranslatorProviderForPlatform.GetTranslator(library.Name); List <string> libraryCode = new List <string>() { "package org.crayonlang.libraries." + library.Name.ToLower() + ";", "", }; libraryCode.AddRange(defaultImports); libraryCode.AddRange(new string[] { "", "public final class LibraryWrapper {", " private LibraryWrapper() {}", "", }); platform.Translator.TabDepth = 1; libraryCode.Add(platform.GenerateCodeForFunction(platform.Translator, library.ManifestFunction)); foreach (FunctionDefinition fnDef in library.Functions) { libraryCode.Add(platform.GenerateCodeForFunction(platform.Translator, fnDef)); } platform.Translator.TabDepth = 0; libraryCode.Add("}"); libraryCode.Add(""); string libraryPath = srcPath + "/org/crayonlang/libraries/" + library.Name.ToLower(); output[libraryPath + "/LibraryWrapper.java"] = new FileOutput() { Type = FileOutputType.Text, TextContent = string.Join(platform.NL, libraryCode), }; foreach (ExportEntity supFile in library.ExportEntities["COPY_CODE"]) { string path = supFile.Values["target"].Replace("%LIBRARY_PATH%", libraryPath); output[path] = supFile.FileOutput; } } } }
public JavaScriptTranslator(AbstractPlatform platform) : base(platform, "\t", "\n", true) { }
public static void ExportJavaLibraries( AbstractPlatform platform, string srcPath, IList <LibraryForExport> libraries, Dictionary <string, FileOutput> output, ILibraryNativeInvocationTranslatorProvider libraryNativeInvocationTranslatorProviderForPlatform, string[] extraImports) { List <string> defaultImports = new List <string>() { "import java.util.ArrayList;", "import java.util.HashMap;", "import org.crayonlang.interpreter.FastList;", "import org.crayonlang.interpreter.Interpreter;", "import org.crayonlang.interpreter.LibraryFunctionPointer;", "import org.crayonlang.interpreter.TranslationHelper;", "import org.crayonlang.interpreter.VmGlobal;", "import org.crayonlang.interpreter.structs.*;", }; defaultImports.AddRange(extraImports); defaultImports.Sort(); foreach (LibraryForExport library in libraries) { if (library.ManifestFunction != null) { platform.Translator.CurrentLibraryFunctionTranslator = libraryNativeInvocationTranslatorProviderForPlatform.GetTranslator(library.Name); List <string> libraryCode = new List <string>() { "package org.crayonlang.libraries." + library.Name.ToLower() + ";", "", }; libraryCode.AddRange(defaultImports); libraryCode.AddRange(new string[] { "", "public final class LibraryWrapper {", " private LibraryWrapper() {}", "", }); platform.Translator.TabDepth = 1; libraryCode.Add(platform.GenerateCodeForFunction(platform.Translator, library.ManifestFunction)); string reflectionCalledPrefix = "lib_" + library.Name.ToLower() + "_function_"; foreach (FunctionDefinition fnDef in library.Functions) { string name = fnDef.NameToken.Value; bool isFunctionPointerObject = name.StartsWith(reflectionCalledPrefix); string functionCode = platform.GenerateCodeForFunction(platform.Translator, fnDef); if (isFunctionPointerObject) { functionCode = functionCode.Replace("public static Value v_" + name + "(Value[] ", "public Value invoke(Value[] "); functionCode = " " + functionCode.Replace("\n", "\n ").TrimEnd(); functionCode = " public static class FP_" + name + " extends LibraryFunctionPointer {\n" + functionCode + "\n }\n"; libraryCode.Add(functionCode); } else { libraryCode.Add(functionCode); } } platform.Translator.TabDepth = 0; libraryCode.Add("}"); libraryCode.Add(""); string libraryPath = srcPath + "/org/crayonlang/libraries/" + library.Name.ToLower(); output[libraryPath + "/LibraryWrapper.java"] = new FileOutput() { Type = FileOutputType.Text, TextContent = string.Join(platform.NL, libraryCode), }; foreach (StructDefinition structDef in library.Structs) { string structCode = platform.GenerateCodeForStruct(structDef); // This is kind of a hack. // TODO: better. structCode = structCode.Replace( "package org.crayonlang.interpreter.structs;", "package org.crayonlang.libraries." + library.Name.ToLower() + ";"); output[libraryPath + "/" + structDef.NameToken.Value + ".java"] = new FileOutput() { Type = FileOutputType.Text, TextContent = structCode, }; } foreach (ExportEntity supFile in library.ExportEntities["COPY_CODE"]) { string path = supFile.Values["target"].Replace("%LIBRARY_PATH%", libraryPath); output[path] = supFile.FileOutput; } } } }
public PlatformUtilities() { _platform = InitPlatform(); RealInstance = this; }
public BreakTimeTextFieldController(AbstractPlatform platform, NSTextField field) : base(platform, field, "Break time") { }
public iTunes(AbstractPlatform platform) { Platform = platform; iTunesGoQuietScript = Platform.ResourceNamed("iTunesGoQuiet.as"); }
public TimeTextFieldController(AbstractPlatform platform, NSTextField field, string name) { Platform = platform; Field = field; Name = name; }
public static IDictionary <NSTextField, TimeTextFieldController> BuildControllers(AbstractPlatform platform, NSTextField work, NSTextField break_) { var breakController = new BreakTimeTextFieldController(platform, break_); var workController = new WorkTimeTextFieldController(platform, work); breakController.Other = workController; workController.Other = breakController; return(new Dictionary <NSTextField, TimeTextFieldController> { { work, workController }, { break_, breakController } }); }
public override Dictionary <string, string> GenerateReplacementDictionary(Options options, ResourceDatabase resDb) { return(AbstractPlatform.GenerateGeneralReplacementsDictionary(options)); }
public override Dictionary <string, string> GenerateReplacementDictionary( ExportProperties exportProperties, BuildData buildData) { return(AbstractPlatform.GenerateGeneralReplacementsDictionary(exportProperties)); }