public void Reset(string compilerPath)
 {
     CompilerPath       = compilerPath;
     oldPocoLibrary     = PocoLibrary.Clone();
     oldClientLibrary   = ClientLibrary.Clone();
     oldPortableLibrary = PortableLibrary.Clone();
     oldPhpSource       = PhpSource.Clone();
     oldWpfLibrary      = WpfLibrary.Clone();
     oldPostgresLibrary = PostgresLibrary.Clone();
     oldOracleLibrary   = OracleLibrary.Clone();
 }
 public CompileTargets()
 {
     PocoLibrary     = new LibraryInfo("Poco", "dotnet_poco", PocoDependencies);
     ClientLibrary   = new LibraryInfo("Client", "dotnet_client", PocoDependencies);
     PortableLibrary = new LibraryInfo("Portable", "dotnet_portable", new string[0]);
     PhpSource       = new LibraryInfo("Php", "php_client", new string[0], true, ".php");
     WpfLibrary      = new LibraryInfo("Wpf", "wpf", WpfDependencies);
     PostgresLibrary = new LibraryInfo("Postgres", "dotnet_server_postgres", RevenjDependencies);
     OracleLibrary   = new LibraryInfo("Oracle", "dotnet_server_oracle", RevenjDependencies);
     Targets         = new[] { PocoLibrary, ClientLibrary, PortableLibrary, PhpSource, WpfLibrary, PostgresLibrary, OracleLibrary };
 }
 private void Compile(LibraryInfo info, Dictionary <string, string> files, bool filter)
 {
     if (!info.Compile)
     {
         return;
     }
     var references =
         info.References
         .Concat(Directory.GetFiles(info.DependenciesPath, "*.dll"))
         .Except(new[] { Path.Combine(info.DependenciesPath, info.Name + ".dll") });
     var sources  = files.Select(it => it.Value).ToArray();
     var target   = Path.Combine(info.TargetPath, info.Name + ".dll");
     var assembly = Compiler.GenerateAssembly(target, sources, references);
 }
        private void CopySource(LibraryInfo info, Dictionary <string, string> files, bool filter)
        {
            if (!info.Compile)
            {
                return;
            }
            var sources =
                (from f in files
                 let name = filter ? f.Key.Substring(1) : f.Key + info.Extension
                            select new { Key = name, f.Value })
                .ToDictionary(it => it.Key, it => it.Value);

            DumpToDisk(info.TargetPath, sources, 3);
        }
 private void ReadInfo(LibraryInfo info, IPropertyBag pBag)
 {
     info.CompileOption = TryReadBool(info.Type + ".Compile", pBag);
     if (!info.SourceOnly)
     {
         info.Name = TryReadString(info.Type + ".Name", pBag) ?? info.Name;
     }
     info.Target               = TryReadString(info.Type + ".Target", pBag) ?? info.Target;
     info.Dependencies         = TryReadString(info.Type + ".Dependencies", pBag) ?? info.Dependencies;
     info.Namespace            = TryReadString(info.Type + ".Namespace", pBag) ?? info.Namespace;
     info.WithActiveRecord     = TryReadBool(info.Type + ".ActiveRecord", pBag, info.WithActiveRecord);
     info.WithHelperMethods    = TryReadBool(info.Type + ".HelperMethods", pBag, info.WithHelperMethods);
     info.WithManualJson       = TryReadBool(info.Type + ".WithManualJson", pBag, info.WithManualJson);
     info.UseUtc               = TryReadBool(info.Type + ".UseUtc", pBag, info.UseUtc);
     info.Legacy               = TryReadBool(info.Type + ".Legacy", pBag, info.Legacy);
     info.MinimalSerialization = TryReadBool(info.Type + ".MinimalSerialization", pBag, info.MinimalSerialization);
     info.NoPrepareExecute     = TryReadBool(info.Type + ".NoPrepareExecute", pBag, info.NoPrepareExecute);
 }
        private Either <Dictionary <string, string> > RunCompiler(string dslCompiler, LibraryInfo target, List <string> dsls)
        {
            var sb = new StringBuilder();

            sb.Append("target=").Append(target.CompilerName);
            if (target.WithActiveRecord)
            {
                sb.Append(" settings=active-record");
            }
            if (!target.WithHelperMethods)
            {
                sb.Append(" settings=no-helpers");
            }
            if (target.WithManualJson)
            {
                sb.Append(" settings=manual-json");
            }
            if (target.UseUtc)
            {
                sb.Append(" settings=utc");
            }
            if (target.MinimalSerialization)
            {
                sb.Append(" settings=minimal-serialization");
            }
            if (target.NoPrepareExecute)
            {
                sb.Append(" settings=no-prepare-execute");
            }
            if (target.Legacy)
            {
                sb.Append(" settings=legacy");
            }
            sb.Append(" format=xml");
            var result = Compiler.CompileDsl(sb, dsls, null, cms => XElement.Load(cms));

            if (result.Success)
            {
                var dict =
                    (from x in result.Value.Elements()
                     let elem = x.Elements()
                                select new { key = elem.First().Value, value = elem.Last().Value })
                    .ToDictionary(it => it.key, it => it.value);
                return(Either.Success(dict));
            }
            else
            {
                return(Either <Dictionary <string, string> > .Fail(result.Error));
            }
        }
        private void WriteInfo(LibraryInfo info, IPropertyBag pBag)
        {
            var    reference = new LibraryInfo(info.Type, null, null);
            object val;

            if (reference.CompileOption != info.CompileOption)
            {
                val = info.CompileOption.ToString();
                pBag.Write(info.Type + ".Compile", ref val);
            }
            if (reference.Name != info.Name)
            {
                val = info.Name;
                pBag.Write(info.Type + ".Name", ref val);
            }
            if (reference.Target != info.Target)
            {
                val = info.Target;
                pBag.Write(info.Type + ".Target", ref val);
            }
            if (reference.Dependencies != info.Dependencies)
            {
                val = info.Dependencies;
                pBag.Write(info.Type + ".Dependencies", ref val);
            }
            if (reference.Namespace != info.Namespace)
            {
                val = info.Namespace;
                pBag.Write(info.Type + ".Namespace", ref val);
            }
            if (reference.WithActiveRecord != info.WithActiveRecord)
            {
                val = info.WithActiveRecord.ToString();
                pBag.Write(info.Type + ".ActiveRecord", ref val);
            }
            if (reference.WithHelperMethods != info.WithHelperMethods)
            {
                val = info.WithHelperMethods.ToString();
                pBag.Write(info.Type + ".HelperMethods", ref val);
            }
            if (reference.WithManualJson != info.WithManualJson)
            {
                val = info.WithManualJson.ToString();
                pBag.Write(info.Type + ".WithManualJson", ref val);
            }
            if (reference.UseUtc != info.UseUtc)
            {
                val = info.UseUtc.ToString();
                pBag.Write(info.Type + ".UseUtc", ref val);
            }
            if (reference.Legacy != info.Legacy)
            {
                val = info.Legacy.ToString();
                pBag.Write(info.Type + ".Legacy", ref val);
            }
            if (reference.MinimalSerialization != info.MinimalSerialization)
            {
                val = info.MinimalSerialization.ToString();
                pBag.Write(info.Type + ".MinimalSerialization", ref val);
            }
            if (reference.NoPrepareExecute != info.NoPrepareExecute)
            {
                val = info.NoPrepareExecute.ToString();
                pBag.Write(info.Type + ".NoPrepareExecute", ref val);
            }
        }