コード例 #1
0
        protected override void AfterParse()
        {
            // parse ENV["RUBYOPT"] options, they follow command line options:
            // TODO: how do args get split, quoting?
            string rubyopt = Platform.GetEnvironmentVariable("RUBYOPT");

            if (!String.IsNullOrEmpty(rubyopt))
            {
                string[] additionalArgs = rubyopt.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                int i = 0;
                while (i < additionalArgs.Length)
                {
                    ParseRubyOptArgument(additionalArgs[i], () => (i + 1 < additionalArgs.Length) ? additionalArgs[++i] : null);
                    i++;
                }
            }

            var existingSearchPaths =
                LanguageOptions.GetSearchPathsOption(LanguageSetup.Options) ??
                LanguageOptions.GetSearchPathsOption(RuntimeSetup.Options);

            if (existingSearchPaths != null)
            {
                _loadPaths.InsertRange(0, existingSearchPaths);
            }

            try {
                string rubylib = Platform.GetEnvironmentVariable("RUBYLIB");
                if (rubylib != null)
                {
                    _loadPaths.AddRange(GetPaths(rubylib));
                }
            } catch (SecurityException) {
                // nop
            }

            LanguageSetup.Options["SearchPaths"] = _loadPaths;

            if (!_disableRubyGems)
            {
                _requiredPaths.Insert(0, "gem_prelude.rb");
            }

            LanguageSetup.Options["RequiredPaths"] = _requiredPaths;

#if DEBUG
            // Can be set to nl-BE, ja-JP, etc
            string culture = Platform.GetEnvironmentVariable("IR_CULTURE");
            if (culture != null)
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture, false);
            }
#endif
            if (ConsoleOptions.DisplayVersion && ConsoleOptions.Command == null && ConsoleOptions.FileName == null)
            {
                ConsoleOptions.PrintVersion = true;
                ConsoleOptions.Exit         = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Get partial templates.
        /// </summary>
        /// <param name="language">Language option.</param>
        /// <returns>Partial templates.</returns>
        protected override IDictionary <string, string> GetPartialTemplates(
            LanguageOptions language = LanguageOptions.CSharp)
        {
            EntitiesTemplateFiles.TryGetValue(Constants.EntityTypeCtorTemplate, out TemplateFileInfo ctorFile);
            var ctorTemplateFile = FileService.RetrieveTemplateFileContents(
                ctorFile.RelativeDirectory, ctorFile.FileName);

            EntitiesTemplateFiles.TryGetValue(Constants.EntityTypeImportTemplate, out TemplateFileInfo importFile);
            var importTemplateFile = FileService.RetrieveTemplateFileContents(
                importFile.RelativeDirectory, importFile.FileName);

            EntitiesTemplateFiles.TryGetValue(Constants.EntityTypePropertyTemplate, out TemplateFileInfo propertyFile);
            var propertyTemplateFile = FileService.RetrieveTemplateFileContents(
                propertyFile.RelativeDirectory, propertyFile.FileName);

            var templates = new Dictionary <string, string>
            {
                {
                    Constants.EntityTypeCtorTemplate.ToLower(CultureInfo.InvariantCulture),
                    ctorTemplateFile
                },
                {
                    Constants.EntityTypeImportTemplate.ToLower(CultureInfo.InvariantCulture),
                    importTemplateFile
                },
                {
                    Constants.EntityTypePropertyTemplate.ToLower(CultureInfo.InvariantCulture),
                    propertyTemplateFile
                },
            };

            return(templates);
        }
コード例 #3
0
        public DynamicProxyFactoryOptions()
        {
            this.lang = LanguageOptions.CS;
            this.mode = FormatModeOptions.Auto;

            this.codeModifier = null;
        }
コード例 #4
0
        protected void bindToLanguageOptions(Dictionary <String, Object> protoOptions)
        {
            var searchPathBuilder = new StringBuilder();
            var userPathnames     = LanguageOptions.GetSearchPathsOption(protoOptions);

            if (userPathnames != null)
            {
                foreach (var pathname in userPathnames)
                {
                    searchPathBuilder.Append(Environment.ExpandEnvironmentVariables(pathname));
                    searchPathBuilder.Append(Path.PathSeparator);
                }
            }
            ObjectSpace.EssenceSharpPath = LanguageOptions.GetOption(protoOptions, EssenceSharpOptions.essenceSharpPathKey, ESFileUtility.defaultEssenceSharpPath());
            searchPathBuilder.Append(ObjectSpace.SharedScriptsPath);
            protoOptions[EssenceSharpOptions.scriptSearchPathsKey] = searchPathBuilder.ToString();

            options = new EssenceSharpOptions(protoOptions);
            options.assemblyNameBindingsDo((qualifiedNsName, assemblyName) => ObjectSpace.bindNamespaceToAssemblyNamed(qualifiedNsName, assemblyName));
            options.assemblyPathBindingsDo((qualifiedNsName, assemblyPath) => ObjectSpace.bindNamespaceToAssemblyAt(qualifiedNsName, new FileInfo(assemblyPath)));

            foreach (var pathnamePrefix in options.LibrarySearchPaths)
            {
                ObjectSpace.LibraryPathBinder.searchPathAddLastIfAbsent(pathnamePrefix);
            }

            foreach (var pathnamePrefix in options.SearchPaths)
            {
                ObjectSpace.ScriptPathBinder.searchPathAddLastIfAbsent(pathnamePrefix);
            }
        }
コード例 #5
0
        /// <summary>
        /// Get DbContext partial templates.
        /// </summary>
        /// <param name="language">Language option.</param>
        /// <returns>Partial templates.</returns>
        protected override IDictionary <string, string> GetPartialTemplates(
            LanguageOptions language = LanguageOptions.CSharp)
        {
            DbContextTemplateFiles.TryGetValue(Constants.DbContextImportTemplate, out TemplateFileInfo importFile);
            var importTemplateFile = FileService.RetrieveTemplateFileContents(
                importFile.RelativeDirectory, importFile.FileName);

            DbContextTemplateFiles.TryGetValue(Constants.DbContextCtorTemplate, out TemplateFileInfo ctorFile);
            var ctorTemplateFile = FileService.RetrieveTemplateFileContents(
                ctorFile.RelativeDirectory, ctorFile.FileName);

            DbContextTemplateFiles.TryGetValue(Constants.DbContextDbSetsTemplate, out TemplateFileInfo propertyFile);
            var propertyTemplateFile = FileService.RetrieveTemplateFileContents(
                propertyFile.RelativeDirectory, propertyFile.FileName);

            var templates = new Dictionary <string, string>
            {
                {
                    Constants.DbContextImportTemplate.ToLower(),
                importTemplateFile
                },
                {
                    Constants.DbContextCtorTemplate.ToLower(),
                ctorTemplateFile
                },
                {
                    Constants.DbContextDbSetsTemplate.ToLower(),
                propertyTemplateFile
                },
            };

            return(templates);
        }
コード例 #6
0
 private static void InsertSearchPaths(IDictionary <string, object> options, ICollection <string> paths)
 {
     if (options != null && paths != null && paths.Count > 0)
     {
         var existingPaths = new List <string>(LanguageOptions.GetSearchPathsOption(options) ?? (IEnumerable <string>)ArrayUtils.EmptyStrings);
         existingPaths.InsertRange(0, paths);
         options["SearchPaths"] = existingPaths;
     }
 }
コード例 #7
0
        /// <summary>
        /// Compile the DbContext template.
        /// </summary>
        /// <param name="language">Language option.</param>
        /// <returns>DbContext template.</returns>
        protected virtual Func <object, string> CompileDbContextTemplate(
            LanguageOptions language = LanguageOptions.CSharp)
        {
            DbContextTemplateFiles.TryGetValue(Constants.DbContextTemplate, out TemplateFileInfo contextFile);
            var contextTemplateFile = FileService.RetrieveTemplateFileContents(
                contextFile.RelativeDirectory, contextFile.FileName);
            var contextTemplate = HandlebarsLib.Compile(contextTemplateFile);

            return(contextTemplate);
        }
 /// <summary>
 ///     <para>
 ///         Registers the Handlebars scaffolding generator as a service in the <see cref="IServiceCollection" />.
 ///         This allows you to customize generated DbContext and entity type classes by modifying the Handlebars
 ///         templates in the CodeTemplates folder.
 ///     </para>
 ///     <para>
 ///         Has <paramref name="options" /> that allow you to choose whether to generate only the DbContext class,
 ///         only entity type classes, or both DbContext and entity type classes (the default).
 ///     </para>
 /// </summary>
 /// <param name="services"> The <see cref="IServiceCollection" /> to add services to. </param>
 /// <param name="options">Options for reverse engineering classes from an existing database.</param>
 /// <param name="language">Language option.</param>
 /// <returns>The same service collection so that multiple calls can be chained.</returns>
 public static IServiceCollection AddHandlebarsScaffolding(this IServiceCollection services,
                                                           ReverseEngineerOptions options = ReverseEngineerOptions.DbContextAndEntities,
                                                           LanguageOptions language       = LanguageOptions.CSharp)
 {
     return(services.AddHandlebarsScaffolding(scaffoldingOptions =>
     {
         scaffoldingOptions.ReverseEngineerOptions = options;
         scaffoldingOptions.LanguageOptions = language;
     }));
 }
        /// <summary>
        /// Compile entity type template.
        /// </summary>
        /// <param name="language">Language option.</param>
        /// <returns>Entity type template.</returns>
        protected virtual Func <object, string> CompileEntityTypeTemplate(
            LanguageOptions language = LanguageOptions.CSharp)
        {
            EntitiesTemplateFiles.TryGetValue(Constants.EntityTypeTemplate, out TemplateFileInfo classFile);
            var entityTemplateFile = FileService.RetrieveTemplateFileContents(
                classFile.RelativeDirectory, classFile.FileName);
            var entityTemplate = HandlebarsLib.Compile(entityTemplateFile);

            return(entityTemplate);
        }
コード例 #10
0
        protected override void AfterParse()
        {
            var existingSearchPaths =
                LanguageOptions.GetSearchPathsOption(LanguageSetup.Options) ??
                LanguageOptions.GetSearchPathsOption(RuntimeSetup.Options);

            if (existingSearchPaths != null)
            {
                _loadPaths.InsertRange(0, existingSearchPaths);
            }

#if !SILVERLIGHT
            try {
                string rubylib = Environment.GetEnvironmentVariable("RUBYLIB");
                if (rubylib != null)
                {
                    _loadPaths.AddRange(GetPaths(rubylib));
                }
            } catch (SecurityException) {
                // nop
            }
#endif
            LanguageSetup.Options["SearchPaths"] = _loadPaths;

            if (!_disableRubyGems)
            {
                _requiredPaths.Insert(0, "gem_prelude.rb");
            }

            LanguageSetup.Options["RequiredPaths"] = _requiredPaths;

            LanguageSetup.Options["DefaultEncoding"] = _defaultEncoding;
            LanguageSetup.Options["LocaleEncoding"]  = _defaultEncoding ??
#if SILVERLIGHT
                                                       RubyEncoding.UTF8;
#else
                                                       RubyEncoding.GetRubyEncoding(Console.InputEncoding);
#endif

#if DEBUG && !SILVERLIGHT
            // Can be set to nl-BE, ja-JP, etc
            string culture = Environment.GetEnvironmentVariable("IR_CULTURE");
            if (culture != null)
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture, false);
            }
#endif
            if (ConsoleOptions.DisplayVersion && ConsoleOptions.Command == null && ConsoleOptions.FileName == null)
            {
                ConsoleOptions.PrintVersion = true;
                ConsoleOptions.Exit         = true;
            }
        }
コード例 #11
0
ファイル: OptionsScript.cs プロジェクト: JoppeMin/PushBoat
    public void HandleInputData(int value)
    {
        switch (value)
        {
        case (int)LanguageOptions.English:
            LocalisationScript.language = LocalisationScript.Language.English;
            break;

        case (int)LanguageOptions.Français:
            LocalisationScript.language = LocalisationScript.Language.French;
            break;

        case (int)LanguageOptions.Español:
            LocalisationScript.language = LocalisationScript.Language.Spanish;
            break;

        case (int)LanguageOptions.усский:
            LocalisationScript.language = LocalisationScript.Language.Russian;
            break;

        case (int)LanguageOptions.日本語:
            LocalisationScript.language = LocalisationScript.Language.Japanese;
            break;

        case (int)LanguageOptions.한국어:
            LocalisationScript.language = LocalisationScript.Language.Korean;
            break;

        case (int)LanguageOptions.中文:
            LocalisationScript.language = LocalisationScript.Language.Chinese;
            break;

        case (int)LanguageOptions.Italiano:
            LocalisationScript.language = LocalisationScript.Language.Italian;
            break;

        case (int)LanguageOptions.Deutsch:
            LocalisationScript.language = LocalisationScript.Language.German;
            break;

        default:
            LocalisationScript.language = LocalisationScript.Language.English;
            break;
        }

        activeLanguage = (LanguageOptions)value;

        LocalizeTextMesh[] toBeLocalized = FindObjectsOfType <LocalizeTextMesh>();
        foreach (LocalizeTextMesh text in toBeLocalized)
        {
            text.updateLocalization();
        }
    }
コード例 #12
0
        protected override void AfterParse()
        {
            var existingSearchPaths =
                LanguageOptions.GetSearchPathsOption(LanguageSetup.Options) ??
                LanguageOptions.GetSearchPathsOption(RuntimeSetup.Options);

            if (existingSearchPaths != null)
            {
                _loadPaths.InsertRange(0, existingSearchPaths);
            }

            LanguageSetup.Options["SearchPaths"] = _loadPaths;
        }
コード例 #13
0
        /// <summary>
        /// Get DbContext partial templates.
        /// </summary>
        /// <param name="language">Language option.</param>
        /// <returns>Partial templates.</returns>
        protected override IDictionary <string, string> GetPartialTemplates(
            LanguageOptions language = LanguageOptions.CSharp)
        {
            var templates = new Dictionary <string, string>();

            foreach (var item in DbContextTemplateFiles)
            {
                if (item.Value.RelativeDirectory == Constants.CSharpTemplateDirectories.DbContextPartialsDirectory)
                {
                    templates.Add(item.Key, FileService.RetrieveTemplateFileContents(item.Value.RelativeDirectory, item.Value.FileName));
                }
            }
            return(templates);
        }
コード例 #14
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var set = parameter as Set;

            if (parameter != null)
            {
                EditMode = true;
                TermsDefinitions.Clear();

                foreach (var term in set.Terms)
                {
                    var termAndDef = new TermDefinitionViewModel()
                    {
                        Definition = term.Definition,
                        Term       = term.TermText,
                        Valid      = true,
                    };

                    TermsDefinitions.Add(termAndDef);
                    TermIds.Add(term.Id);
                }

                Title = set.Title;

                if (set.Visibility == "public")
                {
                    EveryoneOrMe = true;
                }
                else
                {
                    EveryoneOrMe = false;
                }

                SetId = set.Id;

                var termLang = LanguageOptions.
                               Where(x => x.CountryCode == set.LangTerms)
                               .SingleOrDefault();

                var defLang = LanguageOptions.
                              Where(x => x.CountryCode == set.LangDefinitions)
                              .SingleOrDefault();

                SelectedDefinitionLanguage = defLang;
                SelectedTermLanguage       = termLang;
            }

            await Task.CompletedTask;
        }
コード例 #15
0
 public DynamicProxyFactoryOptions()
 {
     this.lang = LanguageOptions.CS;
     this.mode = FormatModeOptions.Auto;
     this.codeModifier = null;
 }
        /// <summary>
        ///     <para>
        ///         Registers the Handlebars scaffolding generator as a service in the <see cref="IServiceCollection" />.
        ///         This allows you to customize generated DbContext and entity type classes by modifying the Handlebars
        ///         templates in the CodeTemplates folder.
        ///     </para>
        ///     <para>
        ///         Has <paramref name="options" /> that allow you to choose whether to generate only the DbContext class,
        ///         only entity type classes, or both DbContext and entity type classes (the default).
        ///         This can be useful when placing model classes in a separate class library.
        ///     </para>
        /// </summary>
        /// <param name="services"> The <see cref="IServiceCollection" /> to add services to. </param>
        /// <param name="options">Options for reverse engineering classes from an existing database.</param>
        /// <param name="language">Language option.</param>
        /// <returns>The same service collection so that multiple calls can be chained.</returns>
        public static IServiceCollection AddHandlebarsScaffolding(this IServiceCollection services,
                                                                  ReverseEngineerOptions options = ReverseEngineerOptions.DbContextAndEntities,
                                                                  LanguageOptions language       = LanguageOptions.CSharp)
        {
            Type dbContextGeneratorImpl;
            var  dbContextGeneratorType = typeof(ICSharpDbContextGenerator);

            if (options == ReverseEngineerOptions.DbContextOnly ||
                options == ReverseEngineerOptions.DbContextAndEntities)
            {
                dbContextGeneratorImpl = typeof(HbsCSharpDbContextGenerator);
            }
            else
            {
                dbContextGeneratorImpl = typeof(NullCSharpDbContextGenerator);
            }
            services.AddSingleton(dbContextGeneratorType, dbContextGeneratorImpl);

            Type entityGeneratorImpl;
            var  entityGeneratorType = typeof(ICSharpEntityTypeGenerator);

            if (options == ReverseEngineerOptions.EntitiesOnly ||
                options == ReverseEngineerOptions.DbContextAndEntities)
            {
                if (language == LanguageOptions.TypeScript)
                {
                    entityGeneratorImpl = typeof(HbsTypeScriptEntityTypeGenerator);
                }
                else
                {
                    entityGeneratorImpl = typeof(HbsCSharpEntityTypeGenerator);
                }
            }
            else
            {
                entityGeneratorImpl = typeof(NullCSharpEntityTypeGenerator);
            }
            services.AddSingleton(entityGeneratorType, entityGeneratorImpl);

            if (language == LanguageOptions.TypeScript)
            {
                services.AddSingleton <ITypeScriptHelper, TypeScriptHelper>();
                services.AddSingleton <IModelCodeGenerator, HbsTypeScriptModelGenerator>();
                services.AddSingleton <ITemplateLanguageService, TypeScriptTemplateLanguageService>();
            }
            else
            {
                services.AddSingleton <IModelCodeGenerator, HbsCSharpModelGenerator>();
                services.AddSingleton <ITemplateLanguageService, CSharpTemplateLanguageService>();
            }

            services.AddSingleton <ITemplateFileService, FileSystemTemplateFileService>();
            services.AddSingleton <IDbContextTemplateService, HbsDbContextTemplateService>();
            services.AddSingleton <IEntityTypeTemplateService, HbsEntityTypeTemplateService>();
            services.AddSingleton <IReverseEngineerScaffolder, HbsReverseEngineerScaffolder>();
            services.AddSingleton <IEntityTypeTransformationService, HbsEntityTypeTransformationService>();
            services.AddSingleton <IHbsHelperService, HbsHelperService>(provider =>
            {
                var helpers = new Dictionary <string, Action <TextWriter, Dictionary <string, object>, object[]> >
                {
                    { Constants.SpacesHelper, HandlebarsHelpers.SpacesHelper }
                };
                return(new HbsHelperService(helpers));
            });
            services.AddSingleton <IHbsBlockHelperService, HbsBlockHelperService>(provider =>
            {
                var helpers = new Dictionary <string, Action <TextWriter, HelperOptions, Dictionary <string, object>, object[]> >();
                return(new HbsBlockHelperService(helpers));
            });
            return(services);
        }
コード例 #17
0
ファイル: Tutorial.cs プロジェクト: VitorOrtiz/WizardColor
 // Start is called before the first frame update
 void Start()
 {
     language = GameController.controller.language;
     //SetText(0);
     StartTutorial(Id);
 }
コード例 #18
0
 /// <summary>
 /// Get partial templates.
 /// </summary>
 /// <param name="language">Language option.</param>
 /// <returns>Partial templates.</returns>
 protected abstract IDictionary <string, string> GetPartialTemplates(
     LanguageOptions language = LanguageOptions.CSharp);