Exemple #1
0
        public override bool Execute( )
        {
            if (Language == null || string.IsNullOrEmpty(Language.ItemSpec))
            {
                Log.LogError("Missing Language PropertyItem definition in project to specify which CodeDomProvider to use.  e.g. <Language>C#</Language>");
                return(false);
            }

            // System.Diagnostics.Debugger.Launch ( );

            var provider = CreateCodeDomProvider(Language.ItemSpec);

            if (provider == null)
            {
                return(false);
            }

            var hasLinguist             = ReferencedAssemblies.Any(reference => Path.GetFileName(reference.ItemSpec) == "Linguist.dll");
            var hasLinguistWPF          = ReferencedAssemblies.Any(reference => Path.GetFileName(reference.ItemSpec) == "Linguist.WPF.dll");
            var hasLinguistXamarinForms = ReferencedAssemblies.Any(reference => Path.GetFileName(reference.ItemSpec) == "Linguist.Xamarin.Forms.dll");

            var compile           = new List <ITaskItem> ( );
            var embeddedResources = new List <ITaskItem> ( );

            foreach (var localization in Localizations)
            {
                if (localization == null || string.IsNullOrEmpty(localization.ItemSpec))
                {
                    continue;
                }

                var resourceSet = Generator.ResourceExtractor.ExtractResources(localization.ItemSpec);
                var code        = GenerateCode(provider, RootNamespace.ItemSpec, localization.ItemSpec, resourceSet, hasLinguist, hasLinguistWPF, hasLinguistXamarinForms, out var baseName, out var manifestPath);
                var resources   = Path.Combine(IntermediateOutputPath.ItemSpec, manifestPath + "." + baseName + ".resources");

                GenerateEmbeddedResource(resources, resourceSet);

                var codeItem      = new TaskItem(code);
                var resourcesItem = new TaskItem(resources);

                resourcesItem.SetMetadata("ManifestResourceName", resources);

                compile.Add(codeItem);
                embeddedResources.Add(resourcesItem);
            }

            Compile           = compile.ToArray( );
            EmbeddedResources = embeddedResources.ToArray( );

            return(true);
        }
Exemple #2
0
        private void setReferencedAssemblies()
        {
            _compilerParams.ReferencedAssemblies.Add("System.dll");
            _compilerParams.ReferencedAssemblies.Add("System.Data.dll");
            _compilerParams.ReferencedAssemblies.Add("System.XML.dll");
            _compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");
            _compilerParams.ReferencedAssemblies.Add("System.Drawing.dll");
            _compilerParams.ReferencedAssemblies.Add("System.Core.dll");
            _compilerParams.ReferencedAssemblies.Add("System.ComponentModel.DataAnnotations.dll");

            if (ReferencedAssemblies == null || !ReferencedAssemblies.Any())
            {
                return;
            }
            foreach (var asm in ReferencedAssemblies)
            {
                _compilerParams.ReferencedAssemblies.Add(asm);
            }
        }
        private void FilterByAssemblies(DependencyGraph newGraph)
        {
            var matchingEdges = _currentGraph.Edges.Where(x => ReferencedAssemblies.Any(y => y.ShouldShow && x.Source.Assembly == y.AssemblyName) && ReferencedAssemblies.Any(y => y.ShouldShow && x.Target.Assembly == y.AssemblyName));

            foreach (var edge in matchingEdges)
            {
                if (!newGraph.Vertices.Contains(edge.Source))
                {
                    newGraph.AddVertex(edge.Source);
                }

                if (!newGraph.Vertices.Contains(edge.Target))
                {
                    newGraph.AddVertex(edge.Target);
                }

                newGraph.AddEdge(edge);
            }
        }