System.Reflection.Assembly.GetManifestResourceNames()

Here are the examples of the csharp api System.Reflection.Assembly.GetManifestResourceNames() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

532 Examples 7

19 Source : ResourceHelper.cs
with Apache License 2.0
from Chem4Word

public static Stream GetBinaryResource(replacedembly replacedembly, string resourceName)
        {
            Stream data = null;

            string fullName = string.Empty;
            int count = 0;

            string[] resources = replacedembly.GetManifestResourceNames();
            foreach (var s in resources)
            {
                if (s.EndsWith($".{resourceName}"))
                {
                    count++;
                    fullName = s;
                }
                //Debug.WriteLine(s);
            }

            if (!string.IsNullOrEmpty(fullName))
            {
                data = replacedembly.GetManifestResourceStream(fullName);
            }

            if (count != 1)
            {
                Debug.WriteLine("Unique match not found");
#if DEBUG
                Debugger.Break();
#endif
            }

            return data;
        }

19 Source : ResourceHelper.cs
with Apache License 2.0
from Chem4Word

private static Stream GetBinaryResource(string resourceName)
        {
            replacedembly replacedembly = replacedembly.GetExecutingreplacedembly();

            Stream data = null;

            string fullName = string.Empty;
            int count = 0;

            string[] resources = replacedembly.GetManifestResourceNames();
            foreach (var s in resources)
            {
                if (s.EndsWith($".{resourceName}"))
                {
                    count++;
                    fullName = s;
                }
                //Debug.WriteLine(s);
            }

            if (!string.IsNullOrEmpty(fullName))
            {
                data = replacedembly.GetManifestResourceStream(fullName);
            }

            if (count != 1)
            {
                return null;
            }

            return data;
        }

19 Source : EmbeddedResources.cs
with MIT License
from Chroma-2D

public static string[] GetResourceNames()
            => Thisreplacedembly.GetManifestResourceNames();

19 Source : NativeHostBase.cs
with MIT License
from chromelyapps

protected virtual IntPtr GetIconHandle()
        {
            var hIcon = IconHandler.LoadIconFromFile(_options.RelativePathToIconFile);
            try
            {
                if (hIcon == null)
                {
                    var replacedembly = replacedembly.GetEntryreplacedembly();
                    var iconAsResource = replacedembly?.GetManifestResourceNames()
                        .FirstOrDefault(res => res.EndsWith(_options.RelativePathToIconFile));
                    if (iconAsResource != null)
                    {
                        using (var resStream = replacedembly.GetManifestResourceStream(iconAsResource))
                        {
                            using(var fileStream = new FileStream(_options.RelativePathToIconFile, FileMode.Create))
                            {
                                resStream?.CopyTo(fileStream);
                            }
                        }
                    }
                    hIcon = IconHandler.LoadIconFromFile(_options.RelativePathToIconFile);
                }
            }
            catch
            {
                // ignore
            }
            return hIcon ?? LoadIconW(IntPtr.Zero, (IntPtr)IDI_APPLICATION);
        }

19 Source : ComparerTests.cs
with MIT License
from cincuranet

private static IEnumerable<(string name, string version)> TestCaseScripts()
            {
                return typeof(ComparerTests).replacedembly.GetManifestResourceNames()
                    .Select(resourceName => Regex.Match(resourceName, $@"\.{Regex.Escape(Base)}\.(?<name>.+?\..+?_(?<version>\d+))(\.[Source|Target]+)?\.sql$", RegexOptions.CultureInvariant))
                    .Where(match => match.Success)
                    .Select(match => (name: match.Groups["name"].Value, version: match.Groups["version"].Value))
                    .Distinct()
                    .OrderBy(x => x.name)
                    .Select(x => (x.name, x.version == DefaultVersion ? null : x.version));
            }

19 Source : Translation.cs
with MIT License
from CitiesSkylinesMods

public static string GetTranslatedFileName(string filename, string language) {
            language = GetValidLanguageCode(language);

            string translatedFilename = filename;
            if (language != DEFAULT_LANGUAGE_CODE) {
                int delimiterIndex = filename.Trim().LastIndexOf('.'); // file extension

                translatedFilename = string.Empty;

                if (delimiterIndex >= 0) {
                    translatedFilename = filename.Substring(0, delimiterIndex);
                }

                translatedFilename += $"_{language.Trim().ToLower()}";

                if (delimiterIndex >= 0) {
                    translatedFilename += filename.Substring(delimiterIndex);
                }
            }

            if (replacedembly.GetExecutingreplacedembly()
                        .GetManifestResourceNames()
                        .Contains(RESOURCES_PREFIX + translatedFilename)) {
                Log._Debug($"Translated file {translatedFilename} found");
                return translatedFilename;
            }

            if (!DEFAULT_LANGUAGE_CODE.Equals(language)) {
                Log.Warning($"Translated file {translatedFilename} not found!");
            }

            return filename;
        }

19 Source : DLLExtractor.cs
with MIT License
from Clef-0

public static byte[] ExtractResource(replacedembly replacedembly, string resourceName)
        {
            if (replacedembly == null)
            {
                return null;
            }

            using (Stream resFilestream = replacedembly.GetManifestResourceStream(resourceName))
            {
                if (resFilestream == null)
                {
                    MessageBox.Show(string.Join(",",replacedembly.GetManifestResourceNames()));
                    return null;
                }

                byte[] bytes = new byte[resFilestream.Length];
                resFilestream.Read(bytes, 0, bytes.Length);

                return bytes;
            }
        }

19 Source : ResourceFileExtractor.cs
with MIT License
from ClosedXML

public IEnumerable<string> GetFileNames()
        {
            string _path = replacedemblyName + m_resourceFilePath;
            foreach (string _resourceName in replacedembly.GetManifestResourceNames())
            {
                if (_resourceName.StartsWith(_path))
                {
                    yield return _resourceName.Replace(_path, string.Empty);
                }
            }
        }

19 Source : Extensions.cs
with MIT License
from cloudnative-netcore

public static void MigrateDataFromScript(this MigrationBuilder migrationBuilder)
        {
            var replacedembly = replacedembly.GetEntryreplacedembly();
            if (replacedembly == null) return;
            var files = replacedembly.GetManifestResourceNames();
            var filePrefix = $"{replacedembly.GetName().Name}.Core.Infrastructure.Persistence.Scripts.";

            foreach (var file in files
                .Where(f => f.StartsWith(filePrefix) && f.EndsWith(".sql"))
                .Select(f => new {PhysicalFile = f, LogicalFile = f.Replace(filePrefix, string.Empty)})
                .OrderBy(f => f.LogicalFile))
            {
                using var stream = replacedembly.GetManifestResourceStream(file.PhysicalFile);
                using var reader = new StreamReader(stream!);
                var command = reader.ReadToEnd();

                if (string.IsNullOrWhiteSpace(command))
                    continue;

                migrationBuilder.Sql(command);
            }
        }

19 Source : EmbeddedFileSet.cs
with GNU Lesser General Public License v3.0
from cnAbp

public void AddFiles(Dictionary<string, IFileInfo> files)
        {
            var lastModificationTime = GetLastModificationTime();

            foreach (var resourcePath in replacedembly.GetManifestResourceNames())
            {
                if (!BaseNamespace.IsNullOrEmpty() && !resourcePath.StartsWith(BaseNamespace))
                {
                    continue;
                }

                var fullPath = ConvertToRelativePath(resourcePath).EnsureStartsWith('/');

                if (fullPath.Contains("/"))
                {
                    AddDirectoriesRecursively(files, fullPath.Substring(0, fullPath.LastIndexOf('/')), lastModificationTime);
                }

                files[fullPath] = new EmbeddedResourceFileInfo(
                    replacedembly,
                    resourcePath,
                    fullPath,
                    CalculateFileName(fullPath),
                    lastModificationTime
                );
            }
        }

19 Source : Mimikatz.cs
with BSD 3-Clause "New" or "Revised" License
from cobbr

public static string Command(string Command = "privilege::debug sekurlsa::logonPreplacedwords")
        {
            // Console.WriteLine(String.Join(",", System.Reflection.replacedembly.GetExecutingreplacedembly().GetManifestResourceNames()));
            if (MimikatzPE == null)
            {
                string[] manifestResources = System.Reflection.replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();
                if (IntPtr.Size == 4 && MimikatzPE == null)
                {
                    if (PEBytes32 == null)
                    {
                        PEBytes32 = Utilities.GetEmbeddedResourceBytes("powerkatz_x86.dll");
                        if (PEBytes32 == null) { return ""; }
                    }
                    MimikatzPE = PE.Load(PEBytes32);
                }
                else if (IntPtr.Size == 8 && MimikatzPE == null)
                {
                    if (PEBytes64 == null)
                    {
                        PEBytes64 = Utilities.GetEmbeddedResourceBytes("powerkatz_x64.dll");
                        if (PEBytes64 == null) { return ""; }
                    }
                    MimikatzPE = PE.Load(PEBytes64);
                }
            }
            if (MimikatzPE == null) { return ""; }
            IntPtr functionPointer = MimikatzPE.GetFunctionExport("powershell_reflective_mimikatz");
            if (functionPointer == IntPtr.Zero) { return ""; }

            MimikatzType mimikatz = (MimikatzType) Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(MimikatzType));
            IntPtr input = Marshal.StringToHGlobalUni(Command);
            try
            {
                IntPtr output = mimikatz(input);
                return Marshal.PtrToStringUni(output);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("MimikatzException: " + e.Message + e.StackTrace);
                return "";
            }
        }

19 Source : Mimikatz.cs
with BSD 3-Clause "New" or "Revised" License
from cobbr

public static string Command(string Command = "privilege::debug sekurlsa::logonPreplacedwords")
        {
            string[] manifestResources = System.Reflection.replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();

            try
            {
                if (IntPtr.Size == 4 && !MappedMimikatz)
                {
                    if (PEBytes32 == null)
                    {
                        PEBytes32 = Utilities.GetEmbeddedResourceBytes("powerkatz_x86.dll");
                        if (PEBytes32 == null) { return ""; }
                    }

                    MimikatzPE = Overload.OverloadModule(PEBytes32, false);
                    MappedMimikatz = true;
                }
                else if (IntPtr.Size == 8)
                {
                    if (PEBytes64 == null && !MappedMimikatz)
                    {
                        PEBytes64 = Utilities.GetEmbeddedResourceBytes("powerkatz_x64.dll");
                        if (PEBytes64 == null) { return ""; }
                    }

                    MimikatzPE = Overload.OverloadModule(PEBytes64, false);
                    MappedMimikatz = true;
                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }

            try
            {
                string output = "";
                Thread t = new Thread(() =>
                {
                    try
                    {
                        object[] parameters =
                        {
                            Command
                        };

                        output = (string)Execution.DynamicInvoke.Generic.CallMappedDLLModuleExport(MimikatzPE.PEINFO, MimikatzPE.ModuleBase, "powershell_reflective_mimikatz", typeof(MimikatzType), parameters);
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine("MimikatzException: " + e.Message + e.StackTrace);
                    }
                });
                t.Start();
                t.Join();
                return output;
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("MimikatzException: " + e.Message + e.StackTrace);
                return "";
            }
        }

19 Source : Updater.cs
with MIT License
from codewitch-honey-crisis

public static void DeleteUpdaterFiles()
		{
			// delete the updater files. We scan the resources so we know what they are
			var names = replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();
			for (var i = 0; i < names.Length; i++)
			{
				var name = names[i];
				if (name.Contains(".ZZupdater0."))
				{
					try
					{
						File.Delete(name.Substring(name.IndexOf('.') + 1));
					}
					catch { }
				}
			}
		}

19 Source : Updater.cs
with MIT License
from codewitch-honey-crisis

public static void Update(Version version,string[] args=null)
		{
			var ns = typeof(Updater).Namespace;
			var names = replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();
			string exename=null;
			for (var i = 0;i<names.Length;i++)
			{
				var name = names[i];
				if(name.Contains(".ZZupdater0."))
				{
					var respath = name;
					if(string.IsNullOrEmpty(exename) && name.EndsWith(".exe"))
						exename = name.Substring(name.IndexOf('.') + 1);
					name = name.Substring(name.IndexOf('.') + 1);
					using (var stm = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(respath))
					using (var stm2 = File.OpenWrite(name))
					{
						stm2.SetLength(0L);
						stm.CopyTo(stm2);
					}

					
				}
			}
			if(null!=exename)
			{
				var psi = new ProcessStartInfo();
				var sb = new StringBuilder();
				sb.Append(_Esc(replacedembly.GetEntryreplacedembly().GetModules()[0].Name));
				sb.Append(' ');
				sb.Append(_Esc(_VersionUrls[version].ToString()));
				if (null != args)
				{
					for (var i = 0; i < args.Length; ++i)
					{
						sb.Append(' ');
						sb.Append(_Esc(args[i]));
					}
				}
				psi.Arguments = sb.ToString();
				psi.FileName = exename;
				var proc = Process.Start(psi);
			}

		}

19 Source : Program.cs
with MIT License
from Const-me

static void dbgPrintResourceNames()
		{
			foreach( string n in replacedembly.GetExecutingreplacedembly().GetManifestResourceNames() )
				Console.WriteLine( n );
		}

19 Source : MonFilesMonsterLoader.cs
with MIT License
from CoreOpenMMO

Dictionary<ushort, MonsterType> IMonsterLoader.LoadMonsters(string loadFromFile)
        {
            if (string.IsNullOrWhiteSpace(loadFromFile))
            {
                throw new ArgumentNullException(nameof(loadFromFile));
            }

            var monsFilePattern = "COMMO.Server.Data." + ServerConfiguration.MonsterFilesDirectory;

            var replacedembly = replacedembly.GetExecutingreplacedembly();

            var monsterDictionary = new Dictionary<ushort, MonsterType>();
            var monsterFilePaths = replacedembly.GetManifestResourceNames().Where(s => s.Contains(monsFilePattern));

            foreach (var monsterFilePath in monsterFilePaths)
            {
                using (var stream = replacedembly.GetManifestResourceStream(monsterFilePath))
                {
                    if (stream == null)
                    {
                        throw new Exception($"Failed to load {monsterFilePath}.");
                    }

                    using (var reader = new StreamReader(stream))
                    {
                        var dataList = new List<Tuple<string, string>>();

                        var propName = string.Empty;
                        var propData = string.Empty;

                        foreach (var readLine in reader.ReadToEnd().Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                        {
                            var inLine = readLine?.Split(new[] { ObjectsFileItemLoader.CommentSymbol }, 2).FirstOrDefault();

                            // ignore comments and empty lines.
                            if (string.IsNullOrWhiteSpace(inLine))
                            {
                                continue;
                            }

                            var data = inLine.Split(new[] { ObjectsFileItemLoader.PropertyValueSeparator }, 2);

                            if (data.Length > 2)
                            {
                                throw new Exception($"Malformed line [{inLine}] in objects file: [{monsterFilePath}]");
                            }

                            if (data.Length == 1)
                            {
                                // line is a continuation of the last prop.
                                propData += data[0].ToLower().Trim();
                            }
                            else
                            {
                                if (propName.Length > 0 && propData.Length > 0)
                                {
                                    dataList.Add(new Tuple<string, string>(propName, propData));
                                }

                                propName = data[0].ToLower().Trim();
                                propData = data[1].Trim();
                            }
                        }

                        if (propName.Length > 0 && propData.Length > 0)
                        {
                            dataList.Add(new Tuple<string, string>(propName, propData));
                        }

                        var current = new MonsterType();

                        foreach (var tuple in dataList)
                        {
                            switch (tuple.Item1)
                            {
                                case "racenumber":
                                    current.SetId(Convert.ToUInt16(tuple.Item2));
                                    break;
                                case "name":
                                    current.SetName(tuple.Item2.Trim('\"'));
                                    break;
                                case "article":
                                    current.SetArticle(tuple.Item2.Trim('\"'));
                                    break;
                                case "outfit":
                                    current.SetOutfit(tuple.Item2.Trim('(', ')'));
                                    break;
                                case "corpse":
                                    current.SetCorpse(Convert.ToUInt16(tuple.Item2));
                                    break;
                                case "blood":
                                    current.SetBlood(tuple.Item2);
                                    break;
                                case "experience":
                                    current.SetExperience(Convert.ToUInt32(tuple.Item2));
                                    break;
                                case "summoncost":
                                    current.SetSummonCost(Convert.ToUInt16(tuple.Item2));
                                    break;
                                case "fleethreshold":
                                    current.SetFleeTreshold(Convert.ToUInt16(tuple.Item2));
                                    break;
                                case "attack":
                                    current.SetAttack(Convert.ToUInt16(tuple.Item2));
                                    break;
                                case "defend":
                                    current.SetDefend(Convert.ToUInt16(tuple.Item2));
                                    break;
                                case "armor":
                                    current.SetArmor(Convert.ToUInt16(tuple.Item2));
                                    break;
                                case "poison":
                                    current.SetConditionInfect(Convert.ToUInt16(tuple.Item2), ConditionType.Posion);
                                    break;
                                case "losetarget":
                                    current.SetLoseTarget(Convert.ToByte(tuple.Item2));
                                    break;
                                case "strategy":
                                    current.SetStrategy(tuple.Item2.Trim('(', ')'));
                                    break;
                                case "flags":
                                    current.SetFlags(tuple.Item2.Trim('{', '}'));
                                    break;
                                case "skills":
                                    current.SetSkills(tuple.Item2.Trim('{', '}'));
                                    break;
                                case "spells":
                                    current.SetSpells(tuple.Item2.Trim('{', '}'));
                                    break;
                                case "inventory":
                                    current.SetInventory(tuple.Item2.Trim('{', '}'));
                                    break;
                                case "talk":
                                    current.SetPhrases(tuple.Item2.Trim('{', '}'));
                                    break;
                            }
                        }

                        current.LockChanges();
                        monsterDictionary.Add(current.RaceId, current);
                    }
                }
            }

            return monsterDictionary;
        }

19 Source : CosmosAssembler.cs
with BSD 3-Clause "New" or "Revised" License
from CosmosOS

public void Initialize(bool enableVBE, string VBEResolution)
        {
            uint xSig = 0x1BADB002;

            DataMembers.Add(new DataIfNotDefined("ELF_COMPILATION"));
            DataMembers.Add(new DataMember("MultibootSignature", new uint[] { xSig }));

            uint xFlags = 0;

            if (enableVBE)
            {
                xFlags = 0x10007;
            }
            else
            {
                xFlags = 0x10003;
            }
            
            DataMembers.Add(new DataMember("MultibootHeaderAddr", ElementReference.New("MultibootSignature")));
            DataMembers.Add(new DataMember("MultibootLoadAddr", ElementReference.New("MultibootSignature")));
            DataMembers.Add(new DataMember("MultibootLoadEndAddr", ElementReference.New("_end_code")));
            DataMembers.Add(new DataMember("MultibootBSSEndAddr", ElementReference.New("_end_code")));
            DataMembers.Add(new DataMember("MultibootEntryAddr", ElementReference.New("Kernel_Start")));
            if (enableVBE)
            {
                DataMembers.Add(new DataMember("", 0));
                DataMembers.Add(new DataMember("", 800, 600, 32));
            } 
            DataMembers.Add(new DataEndIfDefined());

            DataMembers.Add(new DataIfDefined("ELF_COMPILATION"));
            if (enableVBE)
            {
                xFlags = 0x10007;
            }
            else
            {
                xFlags = 0x10003;
            }
            DataMembers.Add(new DataMember("MultibootSignature", new uint[] { xSig }));
            DataMembers.Add(new DataMember("MultibootFlags", xFlags));
            DataMembers.Add(new DataMember("MultibootChecksum", (int)(0 - (xFlags + xSig))));
            if (enableVBE)
            {
                try
                {
                    string[] res = VBEResolution.Split('x');

                    DataMembers.Add(new DataMember("", 0, 0, 0, 0, 0));
                    DataMembers.Add(new DataMember("", 0));
                    DataMembers.Add(new DataMember("", int.Parse(res[0]), int.Parse(res[1]), int.Parse(res[2])));
                }
                catch
                {
                    Console.WriteLine("VBE Resolution must be this format: 1920x1080x32");
                }
            }
            DataMembers.Add(new DataEndIfDefined());

            // graphics info fields
            if (enableVBE)
            {
                DataMembers.Add(new DataMember("MultibootGraphicsRuntime_VbeModeInfoAddr", 1 << 2));
                DataMembers.Add(new DataMember("MultibootGraphicsRuntime_VbeControlInfoAddr", 1 << 0));
                DataMembers.Add(new DataMember("MultibootGraphicsRuntime_VbeMode", 0));
            }
            else
            {
                DataMembers.Add(new DataMember("MultibootGraphicsRuntime_VbeModeInfoAddr", System.Int32.MaxValue));
                DataMembers.Add(new DataMember("MultibootGraphicsRuntime_VbeControlInfoAddr", System.Int32.MaxValue));
                DataMembers.Add(new DataMember("MultibootGraphicsRuntime_VbeMode", System.Int32.MaxValue));
            } 

            // memory
            DataMembers.Add(new DataMember("MultiBootInfo_Memory_High", 0));
            DataMembers.Add(new DataMember("MultiBootInfo_Memory_Low", 0));
            DataMembers.Add(new DataMember("Before_Kernel_Stack", new byte[0x50000]));
            DataMembers.Add(new DataMember("Kernel_Stack", Array.Empty<byte>()));
            DataMembers.Add(new DataMember("MultiBootInfo_Structure", new uint[1]));

            // constants
            DataMembers.Add(new DataMember(@"__uint2double_const", new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x41 }));
            DataMembers.Add(new DataMember(@"__ulong2double_const", 0x5F800000));
            DataMembers.Add(new DataMember(@"__doublesignbit", 0x8000000000000000));
            DataMembers.Add(new DataMember(@"__floatsignbit", 0x80000000));

            if (mComPort > 0)
            {
                new Define("DEBUGSTUB");
            }

            // This is our first entry point. Multiboot uses this as Cosmos entry point.
            new Label("Kernel_Start", isGlobal: true);
            XS.Set(ESP, "Kernel_Stack");

            // Displays "Cosmos" in top left. Used to make sure Cosmos is booted in case of hang.
            // ie bootloader debugging. This must be the FIRST code, even before setup so we know
            // we are being called properly by the bootloader and that if there are problems its
            // somwhere in our code, not the bootloader.
            WriteDebugVideo("Cosmos pre boot");

            // For when using Bochs, causes a break ASAP on entry after initial Cosmos display.
            //new LiteralreplacedemblerCode("xchg bx, bx");

            // CLI ASAP
            WriteDebugVideo("Clearing interrupts.");
            XS.ClearInterruptFlag();


            WriteDebugVideo("Begin multiboot info.");
            new LiteralreplacedemblerCode("%ifndef EXCLUDE_MULTIBOOT_MAGIC");
            new Comment(this, "MultiBoot compliant loader provides info in registers: ");
            new Comment(this, "EBX=multiboot_info ");
            new Comment(this, "EAX=0x2BADB002 - check if it's really Multiboot-compliant loader ");
            new Comment(this, "                ;- copy mb info - some stuff for you  ");
            new Comment(this, "BEGIN - Multiboot Info");
            new Mov
            {
                DestinationRef = ElementReference.New("MultiBootInfo_Structure"),
                DestinationIsIndirect = true,
                SourceReg = RegistersEnum.EBX
            };
            XS.Add(EBX, 4);
            XS.Set(EAX, EBX, sourceIsIndirect: true);
            new Mov
            {
                DestinationRef = ElementReference.New("MultiBootInfo_Memory_Low"),
                DestinationIsIndirect = true,
                SourceReg = RegistersEnum.EAX
            };
            XS.Add(EBX, 4);
            XS.Set(EAX, EBX, sourceIsIndirect: true);
            new Mov
            {
                DestinationRef = ElementReference.New("MultiBootInfo_Memory_High"),
                DestinationIsIndirect = true,
                SourceReg = RegistersEnum.EAX
            };
            new Comment(this, "END - Multiboot Info");
            new LiteralreplacedemblerCode("%endif");
            WriteDebugVideo("Creating GDT.");
            CreateGDT();

            WriteDebugVideo("Configuring PIC");
            ConfigurePIC();

            WriteDebugVideo("Creating IDT.");
            CreateIDT();

            if (enableVBE)
            {
                new Mov { DestinationReg = XSRegisters.EBX, SourceRef = ElementReference.New("MultiBootInfo_Structure"), SourceIsIndirect = true };
                new Mov { DestinationReg = XSRegisters.EAX, SourceReg = XSRegisters.EBX, SourceIsIndirect = true, SourceDisplacement = 72 };
                new Mov { DestinationRef = ElementReference.New("MultibootGraphicsRuntime_VbeControlInfoAddr"), DestinationIsIndirect = true, SourceReg = XSRegisters.EAX };
                new Mov { DestinationReg = XSRegisters.EAX, SourceReg = XSRegisters.EBX, SourceIsIndirect = true, SourceDisplacement = 76 };
                new Mov { DestinationRef = ElementReference.New("MultibootGraphicsRuntime_VbeModeInfoAddr"), DestinationIsIndirect = true, SourceReg = XSRegisters.EAX };
                new Mov { DestinationReg = XSRegisters.EAX, SourceReg = XSRegisters.EBX, SourceIsIndirect = true, SourceDisplacement = 80 };
                new Mov { DestinationRef = ElementReference.New("MultibootGraphicsRuntime_VbeMode"), DestinationIsIndirect = true, SourceReg = XSRegisters.EAX };
            }

            //WriteDebugVideo("Initializing SSE.");
            //new Comment(this, "BEGIN - SSE Init");
            //// CR4[bit 9]=1, CR4[bit 10]=1, CR0[bit 2]=0, CR0[bit 1]=1
            //XS.Mov(XSRegisters.EAX, XSRegisters.Registers.CR4);
            //XS.Or(XSRegisters.EAX, 0x100);
            //XS.Mov(XSRegisters.CR4, XSRegisters.Registers.EAX);
            //XS.Mov(XSRegisters.EAX, XSRegisters.Registers.CR4);
            //XS.Or(XSRegisters.EAX, 0x200);
            //XS.Mov(XSRegisters.CR4, XSRegisters.Registers.EAX);
            //XS.Mov(XSRegisters.EAX, XSRegisters.Registers.CR0);

            //XS.And(XSRegisters.EAX, 0xfffffffd);
            //XS.Mov(XSRegisters.CR0, XSRegisters.Registers.EAX);
            //XS.Mov(XSRegisters.EAX, XSRegisters.Registers.CR0);

            //XS.And(XSRegisters.EAX, 1);
            //XS.Mov(XSRegisters.CR0, XSRegisters.Registers.EAX);
            //new Comment(this, "END - SSE Init");

            if (mComPort > 0)
            {
                WriteDebugVideo("Initializing DebugStub.");
                XS.Call(AsmMarker.Labels[AsmMarker.Type.DebugStub_Init]);
            }

            // Jump to Kernel entry point
            WriteDebugVideo("Jumping to kernel.");
            XS.Call(EntryPointName);

            new Comment(this, "Kernel done - loop till next IRQ");
            XS.Label(".loop");
            XS.ClearInterruptFlag();
            XS.Halt();
            XS.Jump(".loop");

            if (mComPort > 0)
            {
                var xGen = new AsmGenerator();

                void Generatereplacedembler(replacedembler replacedembler)
                {
                    CurrentInstance.Instructions.AddRange(replacedembler.Instructions);
                    CurrentInstance.DataMembers.AddRange(replacedembler.DataMembers);
                }

                if (ReadDebugStubFromDisk)
                {
                    foreach (var xFile in Directory.GetFiles(CosmosPaths.DebugStubSrc, "*.xs"))
                    {
                        Generatereplacedembler(xGen.Generate(xFile));
                    }
                }
                else
                {
                    foreach (var xManifestName in typeof(ReferenceHelper).replacedembly.GetManifestResourceNames())
                    {
                        if (!xManifestName.EndsWith(".xs", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        using (var xStream = typeof(ReferenceHelper).replacedembly.GetManifestResourceStream(xManifestName))
                        {
                            using (var xReader = new StreamReader(xStream))
                            {
                                Generatereplacedembler(xGen.Generate(xReader));
                            }
                        }
                    }
                }
                OnAfterEmitDebugStub();
            }
            else
            {
                XS.Label(AsmMarker.Labels[AsmMarker.Type.DebugStub_Step]);
                XS.Return();
            }

            // Start emitting replacedembly labels
            CurrentInstance.EmitAsmLabels = true;
        }

19 Source : Program.cs
with BSD 3-Clause "New" or "Revised" License
from CosmosOS

private static void RunGen1()
        {
            if (_CPU != "X86") throw new Exception("Gen1 only supports X86");
            try
            {
                // Generate output
                foreach (var xFile in _XsFiles)
                {
                    var xReader = File.OpenText(xFile);
                    if (_Append)
                    {
                        _Gen.GenerateToFile(xFile, xReader, File.AppendText(_OutputPath));
                    }
                    else if (_XsFiles.Count == 1 && _OutputPath != null)
                    {
                        _Gen.GenerateToFile(xFile, File.OpenText(xFile), File.CreateText(_OutputPath));
                    }
                    else
                    {
                        Console.WriteLine(xFile);
                        _Gen.GenerateToFiles(xFile);
                    }
                }

                // Generate output from embedded resources
                foreach (var xreplacedembly in _replacedemblies)
                {
                    TextWriter xWriter = null;
                    if (!_Append)
                    {
                        var xDestination = Path.ChangeExtension(xreplacedembly.Location, "asm");
                        xWriter = new StreamWriter(File.Create(xDestination));
                    }

                    var xResources = xreplacedembly.GetManifestResourceNames().Where(r => r.EndsWith(".xs", StringComparison.OrdinalIgnoreCase));
                    foreach (var xResource in xResources)
                    {
                        var xStream = xreplacedembly.GetManifestResourceStream(xResource);
                        _Gen.GenerateToFile(xResource, new StreamReader(xStream), xWriter);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }

19 Source : App.xaml.cs
with GNU General Public License v3.0
from CrackyStudio

private static replacedembly OnResolvereplacedembly(object sender, ResolveEventArgs args)
        {
            try
            {
                replacedembly parentreplacedembly = replacedembly.GetExecutingreplacedembly();
                string finalname = args.Name.Substring(0, args.Name.IndexOf(',')) + ".dll";
                string[] ResourcesList = parentreplacedembly.GetManifestResourceNames();
                string OurResourceName = null;

                for (int i = 0; i <= ResourcesList.Length - 1; i++)
                {
                    string name = ResourcesList[i];

                    if (name.EndsWith(finalname))
                    {
                        OurResourceName = name;
                        break;
                    }
                }

                if (!string.IsNullOrWhiteSpace(OurResourceName))
                {
                    using (Stream stream = parentreplacedembly.GetManifestResourceStream(OurResourceName))
                    {
                        byte[] block = new byte[stream.Length];
                        stream.Read(block, 0, block.Length);
                        return replacedembly.Load(block);
                    }
                }
                else
                {
                    return null;
                }
            }
            catch (Exception)
            {
                return null;
            }
        }

19 Source : FormBuilder.cs
with MIT License
from CXuesong

public virtual IForm<T> Build(replacedembly resourcereplacedembly = null, string resourceName = null)
        {
            if (resourcereplacedembly == null)
            {
                resourcereplacedembly = typeof(T).replacedembly;
            }
            if (resourceName == null)
            {
                resourceName = typeof(T).FullName;
            }
            if (this._form._prompter == null)
            {
                this._form._prompter = async (context, prompt, state, field) =>
                {
                    var preamble = context.MakeMessage();
                    var promptMessage = context.MakeMessage();
                    if (prompt.GenerateMessages(preamble, promptMessage))
                    {
                        await context.PostAsync(preamble);
                    }
                    await context.PostAsync(promptMessage);
                    return prompt;
                };
            }
            var lang = resourcereplacedembly.GetCustomAttribute<NeutralResourcesLanguageAttribute>();
            if (lang != null && !string.IsNullOrWhiteSpace(lang.CultureName))
            {
                IEnumerable<string> missing, extra;
                string name = null;
                foreach (var resource in resourcereplacedembly.GetManifestResourceNames())
                {
                    if (resource.Contains(resourceName))
                    {
                        var pieces = resource.Split('.');
                        name = string.Join(".", pieces.Take(pieces.Count() - 1));
                        break;
                    }
                }
                if (name != null)
                {
                    var rm = new ResourceManager(name, resourcereplacedembly);
                    var rs = rm.GetResourceSet(Thread.CurrentThread.CurrentUICulture, true, true);
                    _form.Localize(rs.GetEnumerator(), out missing, out extra);
                    if (missing.Any())
                    {
                        throw new MissingManifestResourceException($"Missing resources {missing}");
                    }
                }
            }
            Validate();
            return this._form;
        }

19 Source : DatabaseUtils.cs
with MIT License
from cyilcode

private static byte[] GetResourceData(string resourceName)
        {
            string embeddedResource = replacedembly
                .GetExecutingreplacedembly()
                .GetManifestResourceNames()
                .FirstOrDefault(resource => resource.Contains(resourceName));

            if (!string.IsNullOrWhiteSpace(embeddedResource))
            {
                using (Stream stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(embeddedResource))
                {
                    var data = new byte[stream.Length];
                    stream.Read(data, 0, data.Length);
                    return data;
                }
            }

            return null;
        }

19 Source : JSModuleReferenceHelper.cs
with MIT License
from Daddoon

private static string GetWebpackConfigFileContent()
        {
            //This project replacedembly object
            var replacedembly = typeof(JSModuleReferenceHelper).replacedembly;

            var resources = replacedembly.GetManifestResourceNames();

            //Fetching the js template file
            var resourceName = resources.Single(str => str.EndsWith(WebpackConfigFileName));

            using (Stream stream = replacedembly.GetManifestResourceStream(resourceName))
            using (StreamReader reader = new StreamReader(stream))
            {
                return reader.ReadToEnd();
            }
        }

19 Source : BlazorPolyfillMiddlewareExtensions.cs
with MIT License
from Daddoon

private static FileContentReference GetPatchedBlazorServerFile()
        {
            if (_patchedBlazorServerFile == null)
            {
                BlazorPolyfillOptions option = GetOptions();

                if (option.UsePackagedBlazorServerLibrary)
                {
                    //Get packaged blazor.server.js
                    var replacedembly = GetBlazorPolyfillreplacedembly();

                    var resources = replacedembly.GetManifestResourceNames();
                    var resourceName = resources.Single(str => str.EndsWith("blazor.server.packaged.js"));

                    using (Stream stream = replacedembly.GetManifestResourceStream(resourceName))
                    {
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            string js = reader.ReadToEnd();

                            string Etag = EtagGenerator.GenerateEtagFromString(js);

                            //Computing Build time for the Last-Modified Http Header
                            //We should rely on the creation date of the Microsoft API
                            //not the Blazor.Polyfill.Server one as the Microsoft.AspNetCore.Components.Server
                            //replacedembly may be updated in time. We will rely on the current creation/modification date on disk
                            DateTime buildTime = GetreplacedemblyCreationDate(replacedembly);

                            _patchedBlazorServerFile = new FileContentReference()
                            {
                                Value = js,
                                ETag = Etag,
                                LastModified = buildTime,
                                ContentLength = System.Text.UTF8Encoding.UTF8.GetByteCount(js).ToString(CultureInfo.InvariantCulture)
                            };
                        }
                    }
                }
                else
                {
                    var replacedembly = GetAspNetCoreComponentsServerreplacedembly();

                    var resources = replacedembly.GetManifestResourceNames();
                    var resourceName = resources.Single(str => str.EndsWith("blazor.server.js"));

                    using (Stream stream = replacedembly.GetManifestResourceStream(resourceName))
                    {
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            string js = reader.ReadToEnd();


                            #region Patch Regex

                            //Patch Descriptor Regex as it make Babel crash during transform
                            js = js.Replace("/\\W*Blazor:[^{]*(?<descriptor>.*)$/;", @"/[\0-\/:-@\[-\^`\{-\uFFFF]*Blazor:(?:(?!\{)[\s\S])*(.*)$/;");

                            js = js.Replace("/^\\s*Blazor-Component-State:(?<state>[a-zA-Z0-9\\+\\/=]+)$/", @"/^[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*Blazor\x2DComponent\x2DState:([\+\/-9=A-Za-z]+)$/");

                            js = js.Replace("/^\\s*Blazor:[^{]*(?<descriptor>.*)$/", @"/^[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*Blazor:(?:(?!\{)[\s\S])*(.*)$/");

                            #endregion Patch Regex

                            //Transpile code to ES5 for IE11 before manual patching
                            js = Transform(js, "blazor.server.js", "{\"plugins\":[\"proposal-clreplaced-properties\",\"proposal-object-rest-spread\"],\"presets\":[[\"env\",{\"targets\":{\"browsers\":[\"ie 11\",\"Chrome 78\"]}}], \"es2015\",\"es2016\",\"es2017\",\"stage-3\"], \"sourceType\": \"script\"}");

                            #region Regex named groups fix

                            //At this point, Babel has unminified the code, and fixed IE11 issues, like 'import' method calls.

                            //We still need to fix 'descriptor' regex evaluation code, as it was expecting a named capture group.
                            js = Regex.Replace(js, "([_a-zA-Z0-9]+)(.groups[ ]*&&[ ]*[_a-zA-Z0-9]+.groups.descriptor)", "$1[1]");

                            //We still need to fix 'state' regex evaluation code, as it was expecting a named capture group.
                            js = Regex.Replace(js, "([_a-zA-Z0-9]+)(.groups[ ]*&&[ ]*[_a-zA-Z0-9]+.groups.state)", "$1[1]");

                            #endregion Regex named groups fix

                            //Minify with AjaxMin (we don't want an additional external tool with NPM or else for managing this
                            //kind of thing here...
                            js = Uglify.Js(js).Code;

                            //Computing ETag. Should be computed last !
                            string Etag = EtagGenerator.GenerateEtagFromString(js);

                            //Computing Build time for the Last-Modified Http Header
                            //We should rely on the creation date of the Microsoft API
                            //not the Blazor.Polyfill.Server one as the Microsoft.AspNetCore.Components.Server
                            //replacedembly may be updated in time. We will rely on the current creation/modification date on disk
                            DateTime buildTime = GetreplacedemblyCreationDate(replacedembly);

                            _patchedBlazorServerFile = new FileContentReference()
                            {
                                Value = js,
                                ETag = Etag,
                                LastModified = buildTime,
                                ContentLength = System.Text.UTF8Encoding.UTF8.GetByteCount(js).ToString(CultureInfo.InvariantCulture)
                            };
                        }
                    }
                }
            }

            return _patchedBlazorServerFile;
        }

19 Source : BlazorPolyfillMiddlewareExtensions.cs
with MIT License
from Daddoon

private static FileContentReference GetBlazorPolyfillFile(bool isIE11, bool isMinified)
        {
            if (!isIE11)
            {
                if (_fakeie11Polyfill == null)
                {
                    var replacedembly = GetBlazorPolyfillreplacedembly();

                    var resources = replacedembly.GetManifestResourceNames();
                    var resourceName = resources.Single(str => str.EndsWith("fake.polyfill.js"));

                    using (Stream stream = replacedembly.GetManifestResourceStream(resourceName))
                    {
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            string js = reader.ReadToEnd();

                            //Computing ETag. Should be computed last !
                            string Etag = EtagGenerator.GenerateEtagFromString(js);

                            //Computing Build time for the Last-Modified Http Header
                            DateTime buildTime = GetBlazorPolyfillServerBuildDate();

                            _fakeie11Polyfill = new FileContentReference()
                            {
                                Value = js,
                                ETag = Etag,
                                LastModified = buildTime,
                                ContentLength = System.Text.UTF8Encoding.UTF8.GetByteCount(js).ToString(CultureInfo.InvariantCulture)
                            };
                        }
                    }
                }

                return _fakeie11Polyfill;
            }
            else
            {
                if (isMinified)
                {
                    if (_ie11PolyfillMin == null)
                    {
                        var replacedembly = GetBlazorPolyfillreplacedembly();

                        var resources = replacedembly.GetManifestResourceNames();
                        var resourceName = resources.Single(str => str.EndsWith("blazor.polyfill.min.js"));

                        using (Stream stream = replacedembly.GetManifestResourceStream(resourceName))
                        {
                            using (StreamReader reader = new StreamReader(stream))
                            {
                                string js = reader.ReadToEnd();

                                //Should inject es5 module override before launch
                                js = GetOptions().GetJavascriptToInject() + js;

                                //Computing ETag. Should be computed last !
                                string Etag = EtagGenerator.GenerateEtagFromString(js);

                                //Computing Build time for the Last-Modified Http Header
                                DateTime buildTime = GetBlazorPolyfillServerBuildDate();

                                _ie11PolyfillMin = new FileContentReference()
                                {
                                    Value = js,
                                    ETag = Etag,
                                    LastModified = buildTime,
                                    ContentLength = System.Text.UTF8Encoding.UTF8.GetByteCount(js).ToString(CultureInfo.InvariantCulture)
                                };
                            }
                        }
                    }

                    return _ie11PolyfillMin;
                }
                else
                {
                    if (_ie11Polyfill == null)
                    {
                        var replacedembly = GetBlazorPolyfillreplacedembly();

                        var resources = replacedembly.GetManifestResourceNames();
                        var resourceName = resources.Single(str => str.EndsWith("blazor.polyfill.js"));

                        using (Stream stream = replacedembly.GetManifestResourceStream(resourceName))
                        {
                            using (StreamReader reader = new StreamReader(stream))
                            {
                                string js = reader.ReadToEnd();

                                //Should inject es5 module override before launch
                                js = GetOptions().GetJavascriptToInject() + js;

                                //Computing ETag. Should be computed last !
                                string Etag = EtagGenerator.GenerateEtagFromString(js);

                                //Computing Build time for the Last-Modified Http Header
                                DateTime buildTime = GetBlazorPolyfillServerBuildDate();

                                _ie11Polyfill = new FileContentReference()
                                {
                                    Value = js,
                                    ETag = Etag,
                                    LastModified = buildTime,
                                    ContentLength = System.Text.UTF8Encoding.UTF8.GetByteCount(js).ToString(CultureInfo.InvariantCulture)
                                };
                            }
                        }
                    }

                    return _ie11Polyfill;
                }
            }
        }

19 Source : JSModuleReferenceHelper.cs
with MIT License
from Daddoon

private static string BuildES5EntryFile(List<JSFileRefs> jsFilesRef)
        {
            string js = string.Empty;

            //This project replacedembly object
            var replacedembly = typeof(JSModuleReferenceHelper).replacedembly;

            var resources = replacedembly.GetManifestResourceNames();

            //Fetching the js template file
            var resourceName = resources.Single(str => str.EndsWith(ES5EntryFileName));

            using (Stream stream = replacedembly.GetManifestResourceStream(resourceName))
            using (StreamReader reader = new StreamReader(stream))
            {
                js = reader.ReadToEnd();

                StringBuilder sbImport = new StringBuilder();
                StringBuilder sbExport = new StringBuilder();

                foreach (JSFileRefs importRef in jsFilesRef)
                {
                    sbImport.AppendLine($"import * as {importRef.JSImportAbsolutePathComputedVariableName} from '{HttpUtility.JavaScriptStringEncode(importRef.WebpackFullPath)}';");
                    sbExport.AppendLine($"    window._es5Export['{HttpUtility.JavaScriptStringEncode(importRef.JSImportAbsolutePathComputedVariableName)}'] = {importRef.JSImportAbsolutePathComputedVariableName};");
                }

                js = js.Replace("/*_IMPORT_ZONE_*/", sbImport.ToString());
                js = js.Replace("/*_EXPORT_ZONE_*/", sbExport.ToString());
            }

            return js;
        }

19 Source : MainPageViewModel.cs
with MIT License
from DanielCauser

private void LoadMonkeys()
        {
            if (IsBusy) return;

            IsBusy = true;

            if(_monkeys is null)
            {
                using (var reader = new StreamReader(replacedembly.Getreplacedembly(typeof(App))
                                                               .GetManifestResourceStream(replacedembly.Getreplacedembly(typeof(App)).GetManifestResourceNames().First()) ?? throw new InvalidOperationException()))
                {
                    _monkeys = JsonConvert.DeserializeObject<IEnumerable<Monkey>>(reader.ReadToEnd());
                }
            }

            int index = _random.Next(0, _monkeys.Count());

            SelectedMonkey = _monkeys.ElementAt(index);

            IsBusy = false;
        }

19 Source : CommonLib.cs
with MIT License
from dansiegel

public static IEnumerable<string> GetManifestResourceNames() =>
            typeof(CommonLib).replacedembly.GetManifestResourceNames();

19 Source : SCSSToCSSFixture.cs
with MIT License
from dansiegel

private IEnumerable<string> EmbeddedResources() =>
            GetType().replacedembly.GetManifestResourceNames();

19 Source : EmbeddedImageExtension.cs
with MIT License
from dansiegel

public ImageSource ProvideValue(IServiceProvider serviceProvider)
        {
            var replacedembly = GetType().replacedembly;
            var name = replacedembly.GetManifestResourceNames().FirstOrDefault(x => x.EndsWith(ResourceName, StringComparison.InvariantCultureIgnoreCase));

            if (string.IsNullOrEmpty(name)) return null;

            return ImageSource.FromStream(() => replacedembly.GetManifestResourceStream(name));
        }

19 Source : DataRepository.cs
with MIT License
from danvic712

private void LoadCommandXml(string fullPath)
        {
            SqlCommand command = null;
            replacedembly dll = replacedembly.LoadFile(fullPath);
            string[] xmlFiles = dll.GetManifestResourceNames();
            for (int i = 0; i < xmlFiles.Length; i++)
            {
                Stream stream = dll.GetManifestResourceStream(xmlFiles[i]);
                XElement rootNode = XElement.Load(stream);
                var targetNodes = from n in rootNode.Descendants("Command")
                                  select n;
                foreach (var item in targetNodes)
                {
                    command = new SqlCommand
                    {
                        Name = item.Attribute("Name").Value.ToString(),
                        Sql = item.Value.ToString().Replace("<![CDATA[", "").Replace("]]>", "")
                    };
                    command.Sql = command.Sql.Replace("\r\n", "").Replace("\n", "").Trim();
                    LoadSQL(command.Name, command.Sql);
                }
            }
        }

19 Source : XamlUtil.cs
with MIT License
from davidortinau

public static string GetXamlForType(Type type)
        {

            var replacedembly = type.GetTypeInfo().replacedembly;

            string resourceId;
            string xaml = string.Empty;
            if (XamlResources.TryGetValue(type, out resourceId))
            {
                var result = ReadResourceAsXaml(type, replacedembly, resourceId);
                if (result != null)
                    return result;
            }

            var likelyResourceName = type.Name + ".xaml";
            var resourceNames = replacedembly.GetManifestResourceNames();
            string resourceName = null;

            // first preplaced, pray to find it because the user named it correctly

            foreach (var resource in resourceNames)
            {
                if (ResourceMatchesFilename(replacedembly, resource, likelyResourceName))
                {
                    resourceName = resource;
                    xaml = ReadResourceAsXaml(type, replacedembly, resource);
                    if (xaml != null)
                        goto end;
                }
            }

            // okay maybe they at least named it .xaml

            foreach (var resource in resourceNames)
            {
                if (!resource.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
                    continue;

                resourceName = resource;
                xaml = ReadResourceAsXaml(type, replacedembly, resource);
                if (xaml != null)
                    goto end;
            }

            foreach (var resource in resourceNames)
            {
                if (resource.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
                    continue;

                resourceName = resource;
                xaml = ReadResourceAsXaml(type, replacedembly, resource, true);
                if (xaml != null)
                    goto end;
            }

        end:
            if (string.IsNullOrEmpty(xaml))
                return null;

            XamlResources[type] = resourceName;
            return xaml;
            //var alternateXaml = ResourceLoader.ResourceProvider?.Invoke(resourceName);
            //return alternateXaml ?? xaml;
        }

19 Source : SamplesLoader.cs
with MIT License
from davidwengier

private static IEnumerable<string> GetSamples()
        {
            yield return " - None - ";
            foreach (string name in typeof(SamplesLoader).replacedembly.GetManifestResourceNames())
            {
                if (name.StartsWith("SourceGeneratorPlayground.Samples") && name.EndsWith(".Generator.cs"))
                {
                    yield return name.Split(".")[2];
                }
            }
        }

19 Source : ConsoleImage.cs
with GNU General Public License v3.0
from deathkiller

public static bool RenderFromManifestResource(string name, out int imageTop)
        {
            if (ConsoleUtils.IsOutputRedirected) {
                imageTop = -1;
                return false;
            }

            replacedembly a = replacedembly.GetExecutingreplacedembly();
            string[] resources = a.GetManifestResourceNames();
            for (int j = 0; j < resources.Length; j++) {
                if (resources[j].EndsWith("." + name, StringComparison.Ordinal)) {
                    using (Stream s = a.GetManifestResourceStream(resources[j])) {
                        return Render(s, out imageTop);
                    }
                }
            }

            imageTop = -1;
            return false;
        }

19 Source : Resource.cs
with GNU General Public License v3.0
from Decimation

private static ResourceManager GetManager(replacedembly replacedembly)
		{
			string name = null;

			foreach (string v in replacedembly.GetManifestResourceNames()) {
				string value = replacedembly.GetName().Name;

				if (v.Contains(value!) || v.Contains("EmbeddedResources")) {
					name = v;
					break;
				}
			}

			if (name == null) {
				return null;
			}

			name = name[..name.LastIndexOf('.')];

			var resourceManager = new ResourceManager(name, replacedembly);

			return resourceManager;
		}

19 Source : LogoLoader.cs
with MIT License
from DerekZiemba

public static BitMap GetLogo() {
      var replacedembly = replacedembly.GetExecutingreplacedembly();
      var resourceName = "DVDVideo200.png";
      var allResources = replacedembly.GetManifestResourceNames();
      string fullName = allResources.Single(str => str.EndsWith(resourceName));
#if WINFORMS
      using (Stream stream = replacedembly.GetManifestResourceStream(fullName)) { 
        return new BitMap(stream);
      }
#elif WPF
      using (Stream stream = replacedembly.GetManifestResourceStream(fullName)) {
        var source = new BitmapImage();
        source.BeginInit();
        source.StreamSource = stream;
        source.CacheOption = BitmapCacheOption.OnLoad;
        source.EndInit();
        return new BitMap(source);
      }
#endif
    }

19 Source : Resources.cs
with MIT License
from derplayer

public static void InitResources()
        {
            var test = replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();

            using (Stream stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream("ShenmueHDTools.Resources.gfx"))
            {
                byte[] bytes = new byte[stream.Length]; stream.Position = 0; stream.Read(bytes, 0, (int)stream.Length);
                var Res = Unzip(bytes);

                foreach (var Item in Res)
                {
                        TypeConverter tc = TypeDescriptor.GetConverter(typeof(Image));
                        Image newImage = (Image)tc.ConvertFrom(Item.Content);
                        gfx.Add(newImage);
                }
            }

            using (Stream stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream("ShenmueHDTools.Resources.load"))
            {
                byte[] bytes = new byte[stream.Length]; stream.Position = 0; stream.Read(bytes, 0, (int)stream.Length);
                var Res = Unzip(bytes);

                foreach (var Item in Res)
                {
                    TypeConverter tc = TypeDescriptor.GetConverter(typeof(Image));
                    Image newImage = (Image)tc.ConvertFrom(Item.Content);
                    load.Add(newImage);
                }
            }

            using (Stream stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream("ShenmueHDTools.Resources.database"))
            {
                byte[] bytes = new byte[stream.Length]; stream.Position = 0; stream.Read(bytes, 0, (int)stream.Length);
                var Res = Unzip(bytes);

                foreach (var Item in Res)
                {
                    data.Add(Path.GetFileNameWithoutExtension(Item.Filename), System.Text.Encoding.UTF8.GetString(Item.Content));
                }
            }

            using (Stream stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream("ShenmueHDTools.Resources.mid"))
            {
                byte[] bytes = new byte[stream.Length]; stream.Position = 0; stream.Read(bytes, 0, (int)stream.Length);
                var Res = Unzip(bytes);

                int i = 0;
                foreach (var Item in Res)
                {
                    string filePath = Path.Combine(Path.GetTempPath(), i + ".bin");
                    using (BinaryWriter writer = new BinaryWriter(new FileStream(filePath, FileMode.Create)))
                    {
                        writer.Write(Item.Content, 0, Item.Content.Length);
                        i++;
                    }
                }
            }
        }

19 Source : EmbeddedResource.cs
with MIT License
from devlooped

public static string GetContent(string relativePath)
    {
        var filePath = Path.Combine(baseDir, Path.GetFileName(relativePath));
        if (File.Exists(filePath))
            return File.ReadAllText(filePath);

        var baseName = replacedembly.GetExecutingreplacedembly().GetName().Name;
        var resourceName = relativePath
            .TrimStart('.')
            .Replace(Path.DirectorySeparatorChar, '.')
            .Replace(Path.AltDirectorySeparatorChar, '.');

        var manifestResourceName = replacedembly.GetExecutingreplacedembly()
            .GetManifestResourceNames().FirstOrDefault(x => x.EndsWith(resourceName));

        if (string.IsNullOrEmpty(manifestResourceName))
            throw new InvalidOperationException($"Did not find required resource ending in '{resourceName}' in replacedembly '{baseName}'.");

        using var stream = replacedembly.GetExecutingreplacedembly()
            .GetManifestResourceStream(manifestResourceName);

        if (stream == null)
            throw new InvalidOperationException($"Did not find required resource '{manifestResourceName}' in replacedembly '{baseName}'.");

        using var reader = new StreamReader(stream);
        return reader.ReadToEnd();
    }

19 Source : SourceSet.cs
with MIT License
from DevTeam

private static IEnumerable<(string file, string code)> GetResources(Regex filter)
        {
            var replacedembly = typeof(SourceSet).replacedembly;
            foreach (var resourceName in replacedembly.GetManifestResourceNames())
            {
                if (!filter.IsMatch(resourceName))
                {
                    continue;
                }

                using var reader = new StreamReader(replacedembly.GetManifestResourceStream(resourceName) ?? throw new InvalidOperationException($"Cannot read {resourceName}."));
                var code = reader.ReadToEnd();
                yield return (resourceName, code);
            }
        }

19 Source : AssemblyLicenseProviderAttribute.cs
with MIT License
from DevZest

[System.Diagnostics.Codereplacedysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
        private string GetLicenseFromreplacedembly(replacedembly replacedembly)
        {
            System.Diagnostics.Debug.replacedert(replacedembly != null);

            replacedemblyLicenseLoaderAttribute loaderAttribute = Attribute.GetCustomAttribute(replacedembly, typeof(replacedemblyLicenseLoaderAttribute)) as replacedemblyLicenseLoaderAttribute;
            if (loaderAttribute != null)
            {
                IreplacedemblyLicenseLoader loader = (IreplacedemblyLicenseLoader)Activator.CreateInstance(loaderAttribute.LoaderType);
                return loader.Load(replacedembly);
            }

            string[] resources = replacedembly.GetManifestResourceNames();
            if (resources == null || resources.Length == 0)
                return null;

            string suffix = replacedemblyLicenseFileName;
            string resourceName = null;
            foreach (string name in resources)
            {
                if (name.EndsWith(suffix, StringComparison.OrdinalIgnoreCase))
                {
                    resourceName = name;
                    break;
                }
            }

            if (resourceName == null)
                return null;

            using (Stream stream = replacedembly.GetManifestResourceStream(resourceName))
            {
                if (stream == null)
                    return null;

                using (StreamReader streamReader = new StreamReader(stream))
                {
                    return streamReader.ReadToEnd();
                }
            }
        }

19 Source : AssetBundleHelper.cs
with MIT License
from DickDangerJustice

public static replacedetBundle GetreplacedetBundleFromResources(string fileName)
        {
            var execreplacedembly = replacedembly.GetExecutingreplacedembly();

            var resourceName = execreplacedembly.GetManifestResourceNames()
                .Single(str => str.EndsWith(fileName));

            replacedetBundle replacedetBundle;
            using (var stream = execreplacedembly.GetManifestResourceStream(resourceName))
            {
                replacedetBundle = replacedetBundle.LoadFromStream(stream);
            }

            return replacedetBundle;
        }

19 Source : Mod.cs
with MIT License
from DickDangerJustice

public static replacedetBundle GetreplacedetBundleFromResources(string fileName)
        {
            var execreplacedembly = replacedembly.GetExecutingreplacedembly();

            var resourceName = execreplacedembly.GetManifestResourceNames()
                .Single(str => str.EndsWith(fileName));

            using var stream = execreplacedembly.GetManifestResourceStream(resourceName);

            return replacedetBundle.LoadFromStream(stream);
        }

19 Source : Setup.cs
with MIT License
from DickDangerJustice

public static replacedetBundle GetreplacedetBundleFromResources(string fileName)
        {
            var execreplacedembly = replacedembly.GetExecutingreplacedembly();

            var resourceName = execreplacedembly.GetManifestResourceNames()
                .Single(str => str.EndsWith(fileName));

            using (var stream = execreplacedembly.GetManifestResourceStream(resourceName))
            {
                return replacedetBundle.LoadFromStream(stream);
            }
        }

19 Source : FontResolver.cs
with MIT License
from Didstopia

public byte[] GetFont(string faceName)
        {
            using (var ms = new MemoryStream())
            {
                var replacedembly = typeof(FontResolver).GetTypeInfo().replacedembly;
                var resources = replacedembly.GetManifestResourceNames();
                var resourceName = resources.First(x => x == faceName);
                using (var rs = replacedembly.GetManifestResourceStream(resourceName))
                {
                    rs.CopyTo(ms);
                    ms.Position = 0;
                    return ms.ToArray();
                }
            }
        }

19 Source : ScriptExecutor.cs
with MIT License
from dimven

private void AddEmbeddedLib(ScriptEngine engine)
        {
            // use embedded python lib
            var asm = this.GetType().replacedembly;
            var resQuery = from name in asm.GetManifestResourceNames()
                           where name.ToLowerInvariant().EndsWith("python_27_lib.zip")
                           select name;
            var resName = resQuery.Single();
            var importer = new IronPython.Modules.ResourceMetaPathImporter(asm, resName);
            dynamic sys = IronPython.Hosting.Python.GetSysModule(engine);
            sys.meta_path.append(importer);            
        }

19 Source : Helper.cs
with MIT License
from DogusTeknoloji

private static string GetDefaultTemplate() {
            var replaced = typeof(Generator).replacedembly;
            var resourceName = replaced.GetManifestResourceNames().First(r => r.Contains("template.handlebars"));
            using (var reader = new StreamReader(replaced.GetManifestResourceStream(resourceName), Encoding.UTF8)) {
                return reader.ReadToEnd();
            }
        }

19 Source : ManifestResourceStreamConfigurationObjectsProvider.cs
with MIT License
from dolittle

public bool CanProvide(Type type)
        {
            var filename = GetFilenameFor(type);
            var resourceNames = _entryreplacedembly.GetManifestResourceNames().Where(_ => _.EndsWith(filename, StringComparison.InvariantCultureIgnoreCase)).ToArray();
            if (resourceNames.Length > 1) throw new MultipleFilesAvailableOfSameType(type, resourceNames);
            return resourceNames.Length == 1;
        }

19 Source : ManifestResourceStreamConfigurationObjectsProvider.cs
with MIT License
from dolittle

public object Provide(Type type)
        {
            var filename = GetFilenameFor(type);
            var resourceName = _entryreplacedembly.GetManifestResourceNames().SingleOrDefault(_ => _.EndsWith(filename, StringComparison.InvariantCultureIgnoreCase));
            if (resourceName != null)
            {
                using var reader = new StreamReader(_entryreplacedembly.GetManifestResourceStream(resourceName));
                var content = reader.ReadToEnd();
                return _parsers.Parse(type, resourceName, content);
            }

            throw new UnableToProvideConfigurationObject<ManifestResourceStreamConfigurationObjectsProvider>(type);
        }

19 Source : GameplayButton.cs
with GNU Lesser General Public License v3.0
from DorCoMaNdO

protected static byte[] GetBytesFromEmbeddedResource(replacedembly asm, string embeddedResourcePath)
        {
            string embeddedResourceFullPath = asm.GetManifestResourceNames().FirstOrDefault(resourceName => resourceName.EndsWith(embeddedResourcePath, StringComparison.Ordinal));

            if (string.IsNullOrEmpty(embeddedResourceFullPath)) throw new ArgumentNullException(nameof(embeddedResourcePath), $"The embedded resource \"{embeddedResourcePath}\" was not found in replacedembly \"{asm.GetName().Name}\".");

            return asm.GetManifestResourceStream(embeddedResourceFullPath).ReadFully();
        }

19 Source : SvgDocument.cs
with MIT License
from dotnet-campus

private static string GetEnreplacedyUri(string uri)
        {
            lock (_enreplacediesUrisLock)
            {
                if (_enreplacediesUris == null)
                {
                    _enreplacediesUris = new Dictionary<string, string>();
                    string[] names = _rootType.replacedembly.GetManifestResourceNames();
                    foreach (string name in names)
                    {
                        if (name.StartsWith(_rootType.Namespace))
                        {
                            string namePart = name.Substring(_rootType.Namespace.Length + 1); // the +1 is for the "."
                            _enreplacediesUris[namePart] = name;
                            _enreplacediesUris[namePart.Replace("_", "")] = name;
                        }
                    }
                }
                string enreplacedyUri;
                _enreplacediesUris.TryGetValue(uri, out enreplacedyUri);
                return enreplacedyUri;
            }
        }

19 Source : AssemblyExtensions.cs
with MIT License
from dotnet-toolbelt

public static string GetManifestResourcereplacedtring(this replacedembly replacedembly, string resourceName)
        {
            var result = "";
            var resourceFileName = replacedembly.GetManifestResourceNames().FirstOrDefault(x => x.EndsWith(resourceName, StringComparison.InvariantCultureIgnoreCase));

            if (string.IsNullOrEmpty(resourceFileName)) return result;

            using (Stream stream = replacedembly.GetManifestResourceStream(resourceFileName))
            using (StreamReader reader = new StreamReader(stream))
            {
                result = reader.ReadToEnd();
            }
            return result;
        }

See More Examples