Ejemplo n.º 1
0
 public RaceGen(List<IMythology> mythologies, ILanguage commonTongue)
 {
     CommonTongue = commonTongue;
     Mythologies = mythologies;
     Random = new Random(Guid.NewGuid().GetHashCode());
     Names = new NameGen();
 }
 public BaseLanguageWriter(ILanguage language, IFormatter formatter, IExceptionFormatter exceptionFormatter, bool writeExceptionsAsComments)
 {
     this.Language = language;
     this.formatter = formatter;
     this.exceptionFormatter = exceptionFormatter;
     this.WriteExceptionsAsComments = writeExceptionsAsComments;
 }
        protected BlockStatement RunInternal(MethodBody body, BlockStatement block, ILanguage language)
        {
            try
            {
                if (body.Instructions.Count != 0 || body.Method.IsJustDecompileGenerated)
                {
                    foreach (IDecompilationStep step in steps)
                    {
                        if (language != null && language.IsStopped)
                        {
                            break;
                        }

                        block = step.Process(Context, block);
                    }
                }
            }
            finally
            {
                if (Context.MethodContext.IsMethodBodyChanged)
                {
                    body.Method.RefreshBody();
                }
            }

            return block;
        }
Ejemplo n.º 4
0
        public void AddCustomTranslations(ILanguage sourceLanguage, ILanguage destLanguage, IDictionary<string,string>customTranslations)
        {
            if (sourceLanguage == null) { throw new ArgumentNullException("soureLanguage"); }
            if (destLanguage == null) { throw new ArgumentNullException("destLanguage"); }
            if (customTranslations == null) { throw new ArgumentNullException("customTranslations"); }

            // TODO: This could be done Async

            IList<BingTranslatorService.Translation> translationList = new List<BingTranslatorService.Translation>();
            foreach (string key in customTranslations.Keys) {
                if (!string.IsNullOrWhiteSpace(key)) {
                    BingTranslatorService.Translation translation = new BingTranslatorService.Translation();
                    translation.OriginalText = key;
                    translation.TranslatedText = customTranslations[key];
                    // make it less than 5 because that is the max value for machine translations
                    translation.Rating = this.CustomTranslationRating;
                    translation.RatingSpecified = true;
                    translation.Sequence = 0;
                    translation.SequenceSpecified = true;
                    translationList.Add(translation);
                }
            }

            // TODO: We should batch these into 100 because according to http://msdn.microsoft.com/en-us/library/ff512409.aspx that is the limit

            using (BingTranslatorService.SoapService client = new BingTranslatorService.SoapService()) {
                client.AddTranslationArray(this.ApiKey, translationList.ToArray(), sourceLanguage.Language, destLanguage.Language, this.TranslateOptions);
            }
        }
Ejemplo n.º 5
0
        public void AddDictionaryItem(string resourceName, string defaultValue,  ILanguage language)
        {
            var arr = resourceName.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
               if (arr.Length == 0)
               return;
               if (arr.Length == 1)
               {
               SetDictionaryValue(resourceName, defaultValue,  language);
               return;
               }

               var parentName = string.Join(".", arr.Take(arr.Length - 1));
               if (!_localizationService.DictionaryItemExists(parentName))
               {
               AddDictionaryItem(parentName, "", language);
               }

               var parentDic = _localizationService.GetDictionaryItemByKey(parentName);
               var dicItem = new DictionaryItem(resourceName);
               dicItem.ParentId = parentDic.Key;
               dicItem.Translations = new List<IDictionaryTranslation>
                {
                    new DictionaryTranslation(language, defaultValue)

                };
               _localizationService.Save(dicItem);
        }
		protected virtual string FormatAndColorize(string value, ILanguage language = null)
		{
			var output = new StringBuilder();

            string[] sz = value.Split(new[] { "\n" }, StringSplitOptions.None);
            List<string> ls = new List<string>();

            foreach (string s in sz)
            {
                if (!s.StartsWith(CodeBlockMarker))
                    ls.Add(s);
            }


            //foreach (var line in value.Split(new[] { "\n" }, StringSplitOptions.None).Where(s => !s.StartsWith(CodeBlockMarker)))
            foreach (var line in ls)
			{
				if(language == null)
					output.Append(new string(' ', 4));

				if(line == "\n")
					output.AppendLine();
				else
					output.AppendLine(line);
			}

            ls.Clear();
            ls = null;

			return language != null
				? _syntaxHighlighter.Colorize(output.ToString().Trim(), language)
				: output.ToString();
		}
        public virtual Projects.Items.Item ImportItem(IProject project, Data.Items.Item item, ILanguage language, [ItemNotNull] IEnumerable<string> excludedFields)
        {
            var itemBuilder = new ItemBuilder(Factory)
            {
                DatabaseName = item.Database.Name,
                Guid = item.ID.ToString(),
                ItemName = item.Name,
                TemplateIdOrPath = item.Template.InnerItem.Paths.Path,
                ItemIdOrPath = item.Paths.Path
            };

            var versions = item.Versions.GetVersions(true);
            var sharedFields = item.Fields.Where(f => f.Shared && !excludedFields.Contains(f.Name, StringComparer.OrdinalIgnoreCase) && !f.ContainsStandardValue && !string.IsNullOrEmpty(f.Value)).ToList();
            var unversionedFields = versions.SelectMany(i => i.Fields.Where(f => !f.Shared && f.Unversioned && !excludedFields.Contains(f.Name, StringComparer.OrdinalIgnoreCase) && !f.ContainsStandardValue && !string.IsNullOrEmpty(f.Value))).ToList();
            var versionedFields = versions.SelectMany(i => i.Fields.Where(f => !f.Shared && !f.Unversioned && !excludedFields.Contains(f.Name, StringComparer.OrdinalIgnoreCase) && !f.ContainsStandardValue && !string.IsNullOrEmpty(f.Value))).ToList();

            // shared fields
            foreach (var field in sharedFields.OrderBy(f => f.Name))
            {
                var value = ImportFieldValue(field, item, language);
                var fieldBuilder = new FieldBuilder(Factory)
                {
                    FieldName = field.Name,
                    Value = value
                };

                itemBuilder.Fields.Add(fieldBuilder);
            }

            // unversioned fields
            foreach (var field in unversionedFields.OrderBy(f => f.Name))
            {
                var value = ImportFieldValue(field, item, language);
                var fieldBuilder = new FieldBuilder(Factory)
                {
                    FieldName = field.Name,
                    Value = value,
                    Language = field.Language.Name
                };

                itemBuilder.Fields.Add(fieldBuilder);
            }

            // versioned fields
            foreach (var field in versionedFields.OrderBy(f => f.Name))
            {
                var value = ImportFieldValue(field, item, language);
                var fieldBuilder = new FieldBuilder(Factory)
                {
                    FieldName = field.Name,
                    Value = value,
                    Language = field.Language.Name,
                    Version = field.Item.Version.Number
                };

                itemBuilder.Fields.Add(fieldBuilder);
            }

            return itemBuilder.Build(project, TextNode.Empty);
        }
Ejemplo n.º 8
0
 public Translation(ILanguage sourceLang, ILanguage destLanguage, string stringToTranslate,string translatedString)
 {
     this.SourceLanguage = sourceLang;
     this.DestLanguage = destLanguage;
     this.StringToTranslate = stringToTranslate;
     this.TrnaslatedString = translatedString;
 }
		public override WriterContext GetWriterContext(IMemberDefinition member, ILanguage language)
		{
			TypeDefinition type = Utilities.GetDeclaringTypeOrSelf(member);

            Dictionary<FieldDefinition, PropertyDefinition> fieldToPropertyMap = type.GetFieldToPropertyMap(language);
            IEnumerable<FieldDefinition> propertyFields = fieldToPropertyMap.Keys;
            HashSet<PropertyDefinition> autoImplementedProperties = new HashSet<PropertyDefinition>(fieldToPropertyMap.Values);
			HashSet<EventDefinition> autoImplementedEvents = GetAutoImplementedEvents(type);

			TypeSpecificContext typeContext = new TypeSpecificContext(type) { AutoImplementedProperties = autoImplementedProperties, AutoImplementedEvents = autoImplementedEvents };

			TypeDefinition declaringType = Utilities.GetDeclaringTypeOrSelf(member);

			Dictionary<string, string> renamedNamespacesMap = new Dictionary<string, string>();
			MemberRenamingData memberReanmingData = GetMemberRenamingData(declaringType.Module, language);

			ModuleSpecificContext moduleContext =
				new ModuleSpecificContext(declaringType.Module, new List<string>(), new Dictionary<string, List<string>>(), new Dictionary<string, HashSet<string>>(), 
					renamedNamespacesMap, memberReanmingData.RenamedMembers, memberReanmingData.RenamedMembersMap);			

			return new WriterContext(
				new AssemblySpecificContext(),
				moduleContext,
				typeContext,
				new Dictionary<string, MethodSpecificContext>(), 
				GetDecompiledStatements(member, language, propertyFields));
		}
        internal WinRTSolutionWriter(AssemblyDefinition assembly, TargetPlatform targetPlatform, string targetDir, string solutionFileName, 
			Dictionary<ModuleDefinition, string> modulesProjectsRelativePaths, Dictionary<ModuleDefinition, Guid> modulesProjectsGuids,
            VisualStudioVersion visualStudioVersion, ILanguage language, IEnumerable<string> platforms)
            : base(assembly, targetPlatform, targetDir, solutionFileName, modulesProjectsRelativePaths, modulesProjectsGuids, visualStudioVersion, language)
        {
            this.platforms = platforms;
        }
        /// <summary>
        /// 处理过程方法
        /// </summary>
        /// <param name="code">输入的代码</param>
        /// <param name="lang">指定的语言</param>
        /// <returns>返回高亮的代码片段</returns>
        public static List<CodePiece> Process(string code, ILanguage lang)
        {
            var regexes = lang.Regexes.Keys.ToArray();
            var matches = new Match[regexes.Length];

            int index = 0;
            var codePieces = new List<CodePiece>();
            while (index < code.Length)
            {
                int i = 0;
                for (; i < matches.Length; i++)
                {
                    // 是否需要匹配
                    if (matches[i] != null && matches[i].Index >= index)
                        continue;

                    matches[i] = regexes[i].Match(code, index);
                }

                // 取最前的匹配
                i = GetFirstMatch(matches);
                if (i == -1)
                    break;

                // 添加到代码片段
                codePieces.Add(
                    new CodePiece(lang.Regexes[regexes[i]], matches[i])
                );

                // 更新Index,继续迭代
                index = matches[i].Index + matches[i].Length;
            }

            return codePieces;
        }
 public ToolTipContentCreatorContext(IImageManager imageManager, IDotNetImageManager dotNetImageManager, ILanguage language, ICodeToolTipSettings codeToolTipSettings)
 {
     this.imageManager = imageManager;
     this.dotNetImageManager = dotNetImageManager;
     this.language = language;
     this.codeToolTipSettings = codeToolTipSettings;
 }
Ejemplo n.º 13
0
        internal SolutionWriter(AssemblyDefinition assembly, TargetPlatform targetPlatform, string targetDir, string solutionFileName, 
			Dictionary<ModuleDefinition, string> modulesProjectsRelativePaths, Dictionary<ModuleDefinition, Guid> modulesProjectsGuids,
            VisualStudioVersion visualStudioVersion, ILanguage language)
        {
            this.assembly = assembly;
            this.targetPlatform = targetPlatform;
            this.targetDir = targetDir;
            this.solutionFileName = solutionFileName;
            this.modulesProjectsRelativePaths = modulesProjectsRelativePaths;
            this.modulesProjectsGuids = modulesProjectsGuids;
            if (language is ICSharp)
            {
                this.languageGuid = new Guid(WinRTProjectBuilder.CSharpGUID);
            }
            else if (language is IVisualBasic)
            {
                this.languageGuid = new Guid(WinRTProjectBuilder.VisualBasicGUID);
            }
            else
            {
                throw new NotSupportedException();
            }

            this.visualStudioVersion = visualStudioVersion;
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Changes the language.
 /// </summary>
 /// <param name="Language">The language.</param>
 public void ChangeLanguage(ILanguage Language)
 {
     foreach (var item in Language.GetTranslationDictionary())
     {
         var itemKey = item.Key;
         var itemValue = item.Value;
         var menuItem = Variables.Menu.Item(itemKey);
         try
         {
             if (menuItem != null)
             {
                 menuItem.DisplayName = itemValue;
             }
             else
             {
                 LogHelper.AddToLog(new LogItem("Language_Module", "Could Not Translate: "+ itemKey + " with " + itemValue, LogSeverity.Warning));
             }
         }
         catch (Exception e)
         {
             LogHelper.AddToLog(new LogItem("Language_Module", e, LogSeverity.Warning));
         }
         
     }
 }
		public DefaultFilePathsAnalyzer(Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<TypeDefinition>> userDefinedTypes, 
			Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<Resource>> resources, ILanguage language)
		{
			this.userDefinedTypes = userDefinedTypes;
			this.resources = resources;
			this.sourceExtension = language.VSCodeFileExtension;
		}
        public void Load(ILanguage language)
        {
            Guard.ArgNotNull(language, "language");

            if (string.IsNullOrEmpty(language.Id))
                throw new ArgumentException("The language identifier must not be null or empty.", "language");

            lock (loadLock)
            {
                loadedLanguages[language.Id] = language;
            }

            /*
            loadLock.EnterWriteLock();

            try
            {
                loadedLanguages[language.Id] = language;
            }
            finally
            {
                loadLock.ExitWriteLock();
            }
            */
        }
Ejemplo n.º 17
0
		private string DecompileMethod(MethodDefinition definition, ILanguage language)
		{
			var str = new StringWriter();
			var writer = language.GetWriter(new PlainTextFormatter(str));
			writer.Write (definition);
			return str.ToString ();
		}
 public TestWinRTProjectBuilder(string assemblyPath, AssemblyDefinition assembly,
     Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<TypeDefinition>> userDefinedTypes,
     Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<Resource>> resources,
     string targetPath, ILanguage language, IDecompilationPreferences preferences, VisualStudioVersion visualStudioVersion, ProjectGenerationSettings projectGenerationSettings = null)
     : base(assemblyPath, assembly, userDefinedTypes, resources, targetPath, language, preferences, NoCacheAssemblyInfoService.Instance, visualStudioVersion, projectGenerationSettings)
 {
 }
        /// <summary>
        /// Colorizes source code using the specified language, formatter, and 
        /// style sheet.
        /// </summary>
        /// <param name="sourceCode">The source code to colorize.</param>
        /// <param name="language">The language to use to colorize the source 
        /// code.</param>
        /// <param name="formatter">The formatter to use to colorize the source 
        /// code.</param>
        /// <param name="styleSheet">The style sheet to use to colorize the 
        /// source code.</param>
        public void Colorize(string sourceCode, ILanguage language, IFormatter formatter, IStyleSheet styleSheet)
        {
            Guard.ArgNotNull(language, "language");
            Guard.ArgNotNull(formatter, "formatter");
            Guard.ArgNotNull(styleSheet, "styleSheet");

            languageParser.Parse(sourceCode, language, (parsedSourceCode, captures) => formatter.Write(parsedSourceCode, captures, styleSheet));
        }
Ejemplo n.º 20
0
		void Decompile(ModuleDef module, BamlDocument document, ILanguage lang,
			ITextOutput output, out string ext, CancellationToken token) {
			var decompiler = new XamlDecompiler();
			var xaml = decompiler.Decompile(module, document, token, BamlDecompilerOptions.Create(lang), null);

			output.Write(xaml.ToString(), TextTokenKind.Text);
			ext = ".xml";
		}
Ejemplo n.º 21
0
    public void Parse(string sourceCode, ILanguage language, Action<string, IList<Scope>> parseHandler)
    {
      if (string.IsNullOrEmpty(sourceCode))
        return;

      CompiledLanguage compiledLanguage = languageCompiler.Compile(language);
      Parse(sourceCode, compiledLanguage, parseHandler);
    }
Ejemplo n.º 22
0
 public SharePointContext(SPContext context, ILanguage language, Console console)
 {
     _language = language;
       _console = console;
       language.SetVar("Console", _console);
       language.SetVar("__site__", context.Site);
       language.SetVar("__web__", context.Web);
 }
Ejemplo n.º 23
0
 public CaesarCryptoanalysis(ILanguage language = null)
 {
     if (language == null)
     {
         this.language = new English();
     }
     this.fitnessFunction = new FitnessFunction(this.language);
 }
Ejemplo n.º 24
0
        protected string GetFlag(ILanguage language, IEditUrlManager editUrlManager)
        {
            string flagUrl = language.FlagUrl;
            if (string.IsNullOrEmpty(flagUrl))
                return string.Format(editUrlManager.ResolveResourceUrl("{ManagementUrl}/Resources/Img/Flags/{0}.png"), language.LanguageCode);

            return flagUrl;
        }
 public WinRTProjectBuilder(string assemblyPath, string targetPath, ILanguage language,
     IDecompilationPreferences preferences, IFileGenerationNotifier notifier,
     IAssemblyInfoService assemblyInfoService, VisualStudioVersion visualStudioVersion = VisualStudioVersion.VS2010,
     ProjectGenerationSettings projectGenerationSettings = null)
     : base(assemblyPath, targetPath, language, null, preferences, notifier, assemblyInfoService, visualStudioVersion, projectGenerationSettings)
 {
     Initialize();
 }
Ejemplo n.º 26
0
		public static bool CanShow(IMemberRef member, ILanguage language) {
			var property = member as PropertyDef;
			if (property == null)
				return false;

			return !language.ShowMember(property.GetMethod ?? property.SetMethod)
				|| PropertyOverridesNode.CanShow(property);
		}
		public IntermediateLanguageAssemblyAttributeWriter(ILanguage language, IFormatter formatter, IExceptionFormatter exceptionFormatter, bool writeExceptionsAsComments, bool shouldGenerateBlocks)
        {
            this.Language = language;
            this.formatter = formatter;
			this.exceptionFormatter = exceptionFormatter;
			this.WriteExceptionsAsComments = writeExceptionsAsComments;
			this.shouldGenerateBlocks = shouldGenerateBlocks;
		}
 protected void AddGeneratedFilterMethodsToDecompiledType(DecompiledType decompiledType, TypeSpecificContext context, ILanguage language)
 {
     foreach (GeneratedMethod generatedMethod in context.GeneratedFilterMethods)
     {
         CachedDecompiledMember member = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(generatedMethod.Method), generatedMethod.Body, generatedMethod.Context));
         AddDecompiledMemberToDecompiledType(member, decompiledType);
     }
 }
Ejemplo n.º 29
0
		protected virtual void DecompileFields(ILanguage language, ITextOutput output) {
			foreach (var vm in HexVMs) {
				language.WriteCommentLine(output, string.Empty);
				language.WriteCommentLine(output, string.Format("{0}:", vm.Name));
				foreach (var field in vm.HexFields)
					language.WriteCommentLine(output, string.Format("{0:X8} - {1:X8} {2} = {3}", field.StartOffset, field.EndOffset, field.FormattedValue, field.Name));
			}
		}
Ejemplo n.º 30
0
 public NodeDecompiler(Func<Func<object>, object> execInThread, ITextOutput output, ILanguage language, DecompilationContext decompilationContext, IDecompileNodeContext decompileNodeContext = null)
 {
     this.execInThread = execInThread;
     this.output = output;
     this.language = language;
     this.decompilationContext = decompilationContext;
     this.decompileNodeContext = decompileNodeContext;
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Colorizes source code using the specified language, the default formatter, and the default style sheet.
 /// </summary>
 /// <param name="sourceCode">The source code to colorize.</param>
 /// <param name="language">The language to use to colorize the source code.</param>
 /// <param name="textWriter">The text writer to which the colorized source code will be written.</param>
 public void Colorize(string sourceCode, ILanguage language, TextWriter textWriter)
 {
     Colorize(sourceCode, language, Formatters.Default, StyleSheets.Default, textWriter);
 }
Ejemplo n.º 32
0
 public void AddNestedDecompiledTypesToCache(TypeDefinition type, ILanguage language, bool renameInvalidMembers, Dictionary <string, DecompiledType> decompiledTypes)
 {
 }
Ejemplo n.º 33
0
 public CssBraceExtractor(ILanguage lang)
 {
     this.lang = lang;
 }
Ejemplo n.º 34
0
 public void AddTextIDToList(ILanguage text)
 {
     textIDs.Add(text);
 }
 public void SetCurrentLanguage(ILanguage language)
 {
     _currentLanguage = language;
     _log.Info(string.Format(_currentLanguage.GetWord("LanguageSet"), "Names", language.Identifier));
 }
Ejemplo n.º 36
0
 protected sealed override void WriteToolTip(ISyntaxHighlightOutput output, ILanguage language)
 {
     base.WriteToolTip(output, language);
 }
Ejemplo n.º 37
0
 public void AddTypeContextToCache(TypeDefinition type, ILanguage language, bool renameInvalidMembers, TypeSpecificContext typeContex)
 {
 }
Ejemplo n.º 38
0
 public void AddDecompiledMemberToCache(IMemberDefinition member, ILanguage language, bool renameInvalidMembers, CachedDecompiledMember decompiledMember)
 {
 }
Ejemplo n.º 39
0
 public FreelanceProgrammer(ILanguage lang) : base(lang)
 {
 }
Ejemplo n.º 40
0
        private void LoadBlueprints(ILanguage languages)
        {
            var blueprintsJson = IOUtils.GetBlueprintsJson();
            var blueprints     =
                JsonConvert.DeserializeObject <List <Blueprint> >(blueprintsJson, blueprintConverter)
                .Where(b => b.Ingredients.Any());


            State.Blueprints = new List <Blueprint>(blueprints);
            if (Settings.Default.Favorites == null)
            {
                Settings.Default.Favorites = new StringCollection();
            }

            if (Settings.Default.Ignored == null)
            {
                Settings.Default.Ignored = new StringCollection();
            }

            if (Settings.Default.ShoppingList == null)
            {
                Settings.Default.ShoppingList = new StringCollection();
            }

            foreach (var blueprint in State.Blueprints)
            {
                var text = $"{CommanderName}:{blueprint}";

                if (Settings.Default.Favorites.Contains(text))
                {
                    blueprint.Favorite = true;
                    favoritedBlueprints.Add(blueprint);

                    if (Settings.Default.Favorites.Contains($"{blueprint}"))
                    {
                        Settings.Default.Favorites.Remove($"{blueprint}");
                        Settings.Default.Save();
                    }
                }
                else if (Settings.Default.Favorites.Contains($"{blueprint}"))
                {
                    blueprint.Favorite = true;
                    favoritedBlueprints.Add(blueprint);
                    Settings.Default.Favorites.Remove($"{blueprint}");
                    Settings.Default.Favorites.Add(text);
                    Settings.Default.Save();
                }

                if (Settings.Default.Ignored.Contains(text))
                {
                    blueprint.Ignored = true;

                    if (Settings.Default.Ignored.Contains($"{blueprint}"))
                    {
                        Settings.Default.Ignored.Remove($"{blueprint}");
                        Settings.Default.Save();
                    }
                }
                else if (Settings.Default.Ignored.Contains($"{blueprint}"))
                {
                    blueprint.Ignored = true;
                    Settings.Default.Ignored.Remove($"{blueprint}");
                    Settings.Default.Ignored.Add(text);
                    Settings.Default.Save();
                }

                blueprint.ShoppingListCount = Settings.Default.ShoppingList.Cast <string>().Count(l => l == text);

                blueprint.PropertyChanged += (o, e) =>
                {
                    if (e.PropertyName == "Favorite")
                    {
                        if (blueprint.Favorite)
                        {
                            Settings.Default.Favorites.Add($"{CommanderName}:{blueprint}");
                            favoritedBlueprints.Add(blueprint);
                        }
                        else
                        {
                            Settings.Default.Favorites.Remove($"{CommanderName}:{blueprint}");
                            favoritedBlueprints.Remove(blueprint);
                        }

                        Settings.Default.Save();
                    }
                    else if (e.PropertyName == "Ignored")
                    {
                        if (blueprint.Ignored)
                        {
                            Settings.Default.Ignored.Add($"{CommanderName}:{blueprint}");
                        }
                        else
                        {
                            Settings.Default.Ignored.Remove($"{CommanderName}:{blueprint}");
                        }

                        Settings.Default.Save();
                    }
                    else if (e.PropertyName == "ShoppingListCount")
                    {
                        while (Settings.Default.ShoppingList.Contains(text))
                        {
                            Settings.Default.ShoppingList.Remove(text);
                        }

                        for (var i = 0; i < blueprint.ShoppingListCount; i++)
                        {
                            Settings.Default.ShoppingList.Add(text);
                        }

                        Settings.Default.Save();
                    }
                };
            }

            Filters = new BlueprintFilters(languages, State.Blueprints);

            shoppingList = new ShoppingListViewModel(State.Blueprints, languages);
        }
Ejemplo n.º 41
0
 /// <summary>
 /// Loads the specified language.
 /// </summary>
 /// <param name="language">The language to load.</param>
 /// <remarks>
 /// If a language with the same identifier has already been loaded, the existing loaded language will be replaced by the new specified language.
 /// </remarks>
 public static void Load(ILanguage language)
 {
     LanguageRepository.Load(language);
 }
Ejemplo n.º 42
0
 public bool IsTypeContextInCache(TypeDefinition type, ILanguage language, bool renameInvalidMembers)
 {
     return(false);
 }
Ejemplo n.º 43
0
 /// <summary>
 /// 清空语言包数据
 /// </summary>
 public static void Clear()
 {
     language = null;
     s_dict.Clear();
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Adds the range of specified entities translated in the specified language.
 /// </summary>
 public static void AddRange <T>(this ListItemCollection items, IEnumerable <T> objects, ILanguage language) where T : IEntity
 {
     foreach (T o in objects)
     {
         items.Add(new ListItem(o.ToString(language), o.GetId().ToString()));
     }
 }
Ejemplo n.º 45
0
 public Dictionary <string, DecompiledType> GetNestedDecompiledTypesFromCache(TypeDefinition type, ILanguage language, bool renameInvalidMembers)
 {
     throw new NotSupportedException("EmptyDecompilationCacheService doesn't support this method.");
 }
Ejemplo n.º 46
0
        Dictionary <string, Tuple <IDecompilerOption, Action <string> > > CreateLanguageOptionsDictionary(ILanguage language)
        {
            var dict = new Dictionary <string, Tuple <IDecompilerOption, Action <string> > >();

            if (language == null)
            {
                return(dict);
            }

            foreach (var tmp in language.Settings.Options)
            {
                var opt = tmp;
                if (opt.Type == typeof(bool))
                {
                    dict[GetOptionName(opt)] = Tuple.Create(opt, new Action <string>(a => opt.Value = true));
                    dict[GetOptionName(opt, BOOLEAN_NO_PREFIX)]   = Tuple.Create(opt, new Action <string>(a => opt.Value = false));
                    dict[GetOptionName(opt, BOOLEAN_DONT_PREFIX)] = Tuple.Create(opt, new Action <string>(a => opt.Value = false));
                }
                else if (opt.Type == typeof(int))
                {
                    dict[GetOptionName(opt)] = Tuple.Create(opt, new Action <string>(a => opt.Value = ParseInt32(a)));
                }
                else if (opt.Type == typeof(string))
                {
                    dict[GetOptionName(opt)] = Tuple.Create(opt, new Action <string>(a => opt.Value = ParseString(a)));
                }
                else
                {
                    Debug.Fail(string.Format("Unsupported type: {0}", opt.Type));
                }
            }

            return(dict);
        }
Ejemplo n.º 47
0
 public void AddModuleContextToCache(ModuleDefinition module, ILanguage language, bool renameInvalidMembers, ModuleSpecificContext assemblyContext)
 {
 }
Ejemplo n.º 48
0
 protected sealed override void Write(ISyntaxHighlightOutput output, ILanguage language)
 {
     output.WriteFilename(resource.Name);
 }
Ejemplo n.º 49
0
 public bool AreNestedDecompiledTypesInCache(TypeDefinition type, ILanguage language, bool renameInvalidMembers)
 {
     return(false);
 }
Ejemplo n.º 50
0
        void ParseCommandLine(string[] args)
        {
            if (args.Length == 0)
            {
                throw new ErrorException(dnSpy_Console_Resources.MissingOptions);
            }

            bool      canParseCommands = true;
            ILanguage lang             = null;
            Dictionary <string, Tuple <IDecompilerOption, Action <string> > > langDict = null;

            for (int i = 0; i < args.Length; i++)
            {
                if (lang == null)
                {
                    lang     = GetLanguage();
                    langDict = CreateLanguageOptionsDictionary(lang);
                }
                var arg  = args[i];
                var next = i + 1 < args.Length ? args[i + 1] : null;
                if (arg.Length == 0)
                {
                    continue;
                }

                // **********************************************************************
                // If you add more '--' options here, also update 'string[] ourOptions'
                // **********************************************************************

                if (canParseCommands && arg[0] == '-')
                {
                    string error;
                    switch (arg)
                    {
                    case "--":
                        canParseCommands = false;
                        break;

                    case "-r":
                    case "--recursive":
                        isRecursive = true;
                        break;

                    case "-o":
                    case "--output-dir":
                        if (next == null)
                        {
                            throw new ErrorException(dnSpy_Console_Resources.MissingOutputDir);
                        }
                        outputDir = next;
                        i++;
                        break;

                    case "-l":
                    case "--lang":
                        if (next == null)
                        {
                            throw new ErrorException(dnSpy_Console_Resources.MissingLanguageName);
                        }
                        language = next;
                        i++;
                        if (GetLanguage() == null)
                        {
                            throw new ErrorException(string.Format(dnSpy_Console_Resources.LanguageDoesNotExist, language));
                        }
                        lang     = null;
                        langDict = null;
                        break;

                    case "--asm-path":
                        if (next == null)
                        {
                            throw new ErrorException(dnSpy_Console_Resources.MissingAsmSearchPath);
                        }
                        asmPaths.AddRange(next.Split(new char[] { PATHS_SEP }, StringSplitOptions.RemoveEmptyEntries));
                        i++;
                        break;

                    case "--user-gac":
                        if (next == null)
                        {
                            throw new ErrorException(dnSpy_Console_Resources.MissingUserGacPath);
                        }
                        userGacPaths.AddRange(next.Split(new char[] { PATHS_SEP }, StringSplitOptions.RemoveEmptyEntries));
                        i++;
                        break;

                    case "--no-gac":
                        useGac = false;
                        break;

                    case "--no-stdlib":
                        addCorlibRef = false;
                        break;

                    case "--no-sln":
                        createSlnFile = false;
                        break;

                    case "--sln-name":
                        if (next == null)
                        {
                            throw new ErrorException(dnSpy_Console_Resources.MissingSolutionName);
                        }
                        slnName = next;
                        i++;
                        if (Path.IsPathRooted(slnName))
                        {
                            throw new ErrorException(string.Format(dnSpy_Console_Resources.InvalidSolutionName, slnName));
                        }
                        break;

                    case "--threads":
                        if (next == null)
                        {
                            throw new ErrorException(dnSpy_Console_Resources.MissingNumberOfThreads);
                        }
                        i++;
                        numThreads = NumberVMUtils.ParseInt32(next, int.MinValue, int.MaxValue, out error);
                        if (!string.IsNullOrEmpty(error))
                        {
                            throw new ErrorException(error);
                        }
                        break;

                    case "--vs":
                        if (next == null)
                        {
                            throw new ErrorException(dnSpy_Console_Resources.MissingVSVersion);
                        }
                        i++;
                        int vsVer;
                        vsVer = NumberVMUtils.ParseInt32(next, int.MinValue, int.MaxValue, out error);
                        if (!string.IsNullOrEmpty(error))
                        {
                            throw new ErrorException(error);
                        }
                        switch (vsVer)
                        {
                        case 2005: projectVersion = ProjectVersion.VS2005; break;

                        case 2008: projectVersion = ProjectVersion.VS2008; break;

                        case 2010: projectVersion = ProjectVersion.VS2010; break;

                        case 2012: projectVersion = ProjectVersion.VS2012; break;

                        case 2013: projectVersion = ProjectVersion.VS2013; break;

                        case 2015: projectVersion = ProjectVersion.VS2015; break;

                        default: throw new ErrorException(string.Format(dnSpy_Console_Resources.InvalidVSVersion, vsVer));
                        }
                        break;

                    case "--no-resources":
                        unpackResources = false;
                        break;

                    case "--no-resx":
                        createResX = false;
                        break;

                    case "--no-baml":
                        decompileBaml = false;
                        break;

                    case "-t":
                    case "--type":
                        if (next == null)
                        {
                            throw new ErrorException(dnSpy_Console_Resources.MissingTypeName);
                        }
                        i++;
                        typeName = next;
                        break;

                    case "--md":
                        if (next == null)
                        {
                            throw new ErrorException(dnSpy_Console_Resources.MissingMDToken);
                        }
                        i++;
                        mdToken = NumberVMUtils.ParseInt32(next, int.MinValue, int.MaxValue, out error);
                        if (!string.IsNullOrEmpty(error))
                        {
                            throw new ErrorException(error);
                        }
                        break;

                    case "--gac-file":
                        if (next == null)
                        {
                            throw new ErrorException(dnSpy_Console_Resources.MissingGacFile);
                        }
                        i++;
                        gacFiles.Add(next);
                        break;

                    case "--project-guid":
                        if (next == null || !Guid.TryParse(next, out projectGuid))
                        {
                            throw new ErrorException(dnSpy_Console_Resources.InvalidGuid);
                        }
                        i++;
                        break;

                    default:
                        Tuple <IDecompilerOption, Action <string> > tuple;
                        if (langDict.TryGetValue(arg, out tuple))
                        {
                            bool hasArg = tuple.Item1.Type != typeof(bool);
                            if (hasArg && next == null)
                            {
                                throw new ErrorException(dnSpy_Console_Resources.MissingOptionArgument);
                            }
                            if (hasArg)
                            {
                                i++;
                            }
                            tuple.Item2(next);
                            break;
                        }

                        throw new ErrorException(string.Format(dnSpy_Console_Resources.InvalidOption, arg));
                    }
                }
                else
                {
                    files.Add(arg);
                }
            }
        }
Ejemplo n.º 51
0
 public CachedDecompiledMember GetDecompiledMemberFromCache(IMemberDefinition member, ILanguage language, bool renameInvalidMembers)
 {
     throw new NotSupportedException("EmptyDecompilationCacheService doesn't support this method.");
 }
 public override ModuleSpecificContext GetModuleContext(ModuleDefinition module, ILanguage language)
 {
     return(new ModuleSpecificContext());
 }
Ejemplo n.º 53
0
 public TypeSpecificContext GetTypeContextFromCache(TypeDefinition type, ILanguage language, bool renameInvalidMembers)
 {
     throw new NotSupportedException("EmptyDecompilationCacheService doesn't support this method.");
 }
Ejemplo n.º 54
0
 public Translation(ContentItem page, ILanguage language)
 {
     this.page     = page;
     this.language = language;
 }
Ejemplo n.º 55
0
 public bool IsDecompiledMemberInCache(IMemberDefinition member, ILanguage language, bool renameInvalidMembers)
 {
     return(false);
 }
Ejemplo n.º 56
0
 /// <summary>
 /// Colorizes source code using the specified language, the default formatter, and the default style sheet.
 /// </summary>
 /// <param name="sourceCode">The source code to colorize.</param>
 /// <param name="language">The language to use to colorize the source code.</param>
 /// <returns>The colorized source code.</returns>
 public string Colorize(string sourceCode, ILanguage language)
 {
     return(Colorize(sourceCode, language, Formatters.Default, StyleSheets.Default));
 }
Ejemplo n.º 57
0
 public static bool IsLinqKeyword(this ILanguage lang, String text)
 {
     return(lang.Settings.Linq.Contains(lang.NormalizationFunction(text), comparer));
 }
 public override AssemblySpecificContext GetAssemblyContext(AssemblyDefinition assembly, ILanguage language)
 {
     return(new AssemblySpecificContext());
 }
Ejemplo n.º 59
0
        private BaseProjectBuilder GetProjectBuilder(AssemblyDefinition assembly, GeneratorProjectInfo projectInfo, ProjectGenerationSettings settings, ILanguage language, string projFilePath, DecompilationPreferences preferences, IFrameworkResolver frameworkResolver, ITargetPlatformResolver targetPlatformResolver)
        {
            TargetPlatform     targetPlatform = targetPlatformResolver.GetTargetPlatform(assembly.MainModule.FilePath, assembly.MainModule);
            BaseProjectBuilder projectBuilder = null;

            if (targetPlatform == TargetPlatform.NetCore)
            {
                projectBuilder = new NetCoreProjectBuilder(projectInfo.Target, projFilePath, language, preferences, null, NoCacheAssemblyInfoService.Instance, projectInfo.VisualStudioVersion, settings);
            }
            else if (targetPlatform == TargetPlatform.WinRT)
            {
                projectBuilder = new WinRTProjectBuilder(projectInfo.Target, projFilePath, language, preferences, null, NoCacheAssemblyInfoService.Instance, projectInfo.VisualStudioVersion, settings);
            }
            else
            {
                projectBuilder = new MSBuildProjectBuilder(projectInfo.Target, projFilePath, language, frameworkResolver, preferences, null, NoCacheAssemblyInfoService.Instance, projectInfo.VisualStudioVersion, settings);
            }

            return(projectBuilder);
        }
Ejemplo n.º 60
0
 public bool IsModuleContextInCache(ModuleDefinition module, ILanguage language, bool renameInvalidMembers)
 {
     return(false);
 }