System.Reflection.Assembly.GetManifestResourceStream(string)

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

2317 Examples 7

19 Source : Ribbon.cs
with GNU General Public License v3.0
from 0dteam

private static string GetResourceText(string resourceName)
        {
            replacedembly asm = replacedembly.GetExecutingreplacedembly();
            string[] resourceNames = asm.GetManifestResourceNames();
            for (int i = 0; i < resourceNames.Length; ++i)
            {
                if (string.Compare(resourceName, resourceNames[i], StringComparison.OrdinalIgnoreCase) == 0)
                {
                    using (StreamReader resourceReader = new StreamReader(asm.GetManifestResourceStream(resourceNames[i])))
                    {
                        if (resourceReader != null)
                        {
                            return resourceReader.ReadToEnd();
                        }
                    }
                }
            }
            return null;
        }

19 Source : Frontend.cs
with MIT License
from 0x0ade

public Stream? OpenContent(string path, out string pathNew, out DateTime? lastMod, out string? contentType) {
            pathNew = path;

            try {
                string dir = Path.GetFullPath(Settings.ContentRoot);
                string pathFS = Path.GetFullPath(Path.Combine(dir, path));
                if (pathFS.StartsWith(dir) && File.Exists(pathFS)) {
                    lastMod = File.GetLastWriteTimeUtc(pathFS);
                    contentType = GetContentType(pathFS);
                    return File.OpenRead(pathFS);
                }
            } catch {
            }

#if DEBUG
            try {
                string dir = Path.GetFullPath(Path.Combine("..", "..", "..", "Content"));
                string pathFS = Path.GetFullPath(Path.Combine(dir, path));
                if (pathFS.StartsWith(dir) && File.Exists(pathFS)) {
                    lastMod = File.GetLastWriteTimeUtc(pathFS);
                    contentType = GetContentType(pathFS);
                    return File.OpenRead(pathFS);
                }
            } catch {
            }

            try {
                string dir = Path.GetFullPath(Path.Combine("..", "..", "..", "..", "CelesteNet.Server.FrontendModule", "Content"));
                string pathFS = Path.GetFullPath(Path.Combine(dir, path));
                if (pathFS.StartsWith(dir) && File.Exists(pathFS)) {
                    lastMod = File.GetLastWriteTimeUtc(pathFS);
                    contentType = GetContentType(pathFS);
                    return File.OpenRead(pathFS);
                }
            } catch {
            }
#endif

            if (!path.EndsWith("/index.html")) {
                path = path.EndsWith("/") ? path : (path + "/");
                Stream? index = OpenContent(path + "index.html", out _, out lastMod, out contentType);
                if (index != null) {
                    pathNew = path;
                    return index;
                }
            }

            lastMod = null;
            contentType = GetContentType(path);
            return typeof(CelesteNetServer).replacedembly.GetManifestResourceStream("Celeste.Mod.CelesteNet.Server.Content." + path.Replace("/", "."));
        }

19 Source : TerrariaHooksManager.cs
with MIT License
from 0x0ade

internal static ModuleDefinition GenerateCecilModule(replacedemblyName name) {
            replacedemblyName UnwrapName(replacedemblyName other) {
                int underscore = other.Name.LastIndexOf('_');
                if (underscore == -1)
                    return other;

                other.Name = other.Name.Substring(0, underscore);
                return other;
            }

            // Terraria ships with some dependencies as embedded resources.
            string resourceName = name.Name + ".dll";
            resourceName = Array.Find(typeof(Program).replacedembly.GetManifestResourceNames(), element => element.EndsWith(resourceName));
            if (resourceName != null) {
                using (Stream stream = typeof(Program).replacedembly.GetManifestResourceStream(resourceName))
                    // Read immediately, as the stream isn't open forever.
                    return ModuleDefinition.ReadModule(stream, new ReaderParameters(ReadingMode.Immediate));
            }

            // Mod .dlls exist in the mod's .tmod containers.
            string nameStr = name.ToString();
            foreach (Mod mod in ModLoader.LoadedMods) {
                if (mod.Code == null || mod.File == null)
                    continue;

                // Check if it's the main replacedembly.
                if (mod.Code.GetName().ToString() == nameStr) {
                    // Let's unwrap the name and cache it for all DMDs as well.
                    // tModLoader changes the replacedembly name to allow mod updates, which breaks replacedembly.Load
                    ReflectionHelper.replacedemblyCache[UnwrapName(mod.Code.GetName()).ToString()] = mod.Code;

                    using (MemoryStream stream = new MemoryStream(mod.File.GetMainreplacedembly()))
                        // Read immediately, as the stream isn't open forever.
                        return ModuleDefinition.ReadModule(stream, new ReaderParameters(ReadingMode.Immediate));
                }

                // Check if the replacedembly is possibly included in the .tmod
                if (!mod.Code.GetReferencedreplacedemblies().Any(other => UnwrapName(other).ToString() == nameStr))
                    continue;

                // Try to load lib/Name.dll
                byte[] data;
                if ((data = mod.File.GetFile($"lib/{name.Name}.dll")) != null)
                    using (MemoryStream stream = new MemoryStream(data))
                        // Read immediately, as the stream isn't open forever.
                        return ModuleDefinition.ReadModule(stream, new ReaderParameters(ReadingMode.Immediate));
            }

            return null;
        }

19 Source : ScInsertCompanies.cs
with MIT License
from 0x1000000

private IEnumerable<JsonCompanyData> ReadCompanyData()
        {
            var replacedembly = typeof(Program).GetTypeInfo().replacedembly;

            using Stream? resource = replacedembly.GetManifestResourceStream("SqExpress.IntTest.TestData.company.json");
            var doreplacedent = JsonDoreplacedent.Parse(resource);

            foreach (var user in doreplacedent.RootElement.EnumerateArray())
            {
                JsonCompanyData buffer = default;
                foreach (var userProperty in user.EnumerateObject())
                {
                    if (userProperty.Name == "external_id")
                    {
                        buffer.ExternalId = userProperty.Value.GetGuid();
                    }
                    if (userProperty.Name == "name")
                    {
                        buffer.Name = userProperty.Value.GetString();
                    }
                }
                yield return buffer;
            }
        }

19 Source : ScInsertUserData.cs
with MIT License
from 0x1000000

private IEnumerable<JsonUserData> ReadUserData()
        {
            var replacedembly = typeof(Program).GetTypeInfo().replacedembly;

            using Stream? resource = replacedembly.GetManifestResourceStream("SqExpress.IntTest.TestData.users.json");
            var doreplacedent = JsonDoreplacedent.Parse(resource);

            foreach (var user in doreplacedent.RootElement.EnumerateArray())
            {
                JsonUserData buffer = default;
                foreach (var userProperty in user.EnumerateObject())
                {
                    if (userProperty.Name == "external_id")
                    {
                        buffer.ExternalId = userProperty.Value.GetGuid();
                    }
                    if (userProperty.Name == "first_name")
                    {
                        buffer.FirstName = userProperty.Value.GetString();
                    }
                    if (userProperty.Name == "last_name")
                    {
                        buffer.LastName = userProperty.Value.GetString();
                    }
                    if (userProperty.Name == "email")
                    {
                        buffer.Email = userProperty.Value.GetString();
                    }

                }
                yield return buffer;
            }
        }

19 Source : cMain.cs
with MIT License
from 0xPh0enix

[STAThread]
        static void Main()
        {
            replacedembly aASM = replacedembly.GetExecutingreplacedembly();

            using (Stream sResStream = aASM.GetManifestResourceStream("%RES_NAME%"))
            {
                if (sResStream == null)
                    return;

                byte[] bFile = new byte[sResStream.Length];
                sResStream.Read(bFile, 0, bFile.Length);

                bFile = Decrypt(bFile, System.Text.Encoding.Default.GetBytes("%ENC_KEY%"));

                replacedembly.Load(bFile).EntryPoint.Invoke(null, null);

            }
        }

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

static void Main(string[] args)
        {
            AppDomain.CurrentDomain.replacedemblyResolve += (sender, argtwo) => {
                replacedembly thisreplacedembly = replacedembly.GetEntryreplacedembly();
                String resourceName = string.Format("SharpRDP.{0}.dll.bin",
                    new replacedemblyName(argtwo.Name).Name);
                var replacedembly = replacedembly.GetExecutingreplacedembly();
                using (var rs = replacedembly.GetManifestResourceStream(resourceName))
                using (var zs = new DeflateStream(rs, CompressionMode.Decompress))
                using (var ms = new MemoryStream())
                {
                    zs.CopyTo(ms);
                    return replacedembly.Load(ms.ToArray());
                }
            };

            var arguments = new Dictionary<string, string>();
            foreach (string argument in args)
            {
                int idx = argument.IndexOf('=');
                if (idx > 0)
                    arguments[argument.Substring(0, idx)] = argument.Substring(idx + 1);
            }

            string username = string.Empty;
            string domain = string.Empty;
            string preplacedword = string.Empty;
            string command = string.Empty;
            string execElevated = string.Empty;
            string execw = "";
            bool connectdrive = false;
            bool takeover = false;
            bool nla = false;
            
            if (arguments.ContainsKey("username"))
            {
                if (!arguments.ContainsKey("preplacedword"))
                {
                    Console.WriteLine("[X] Error: A preplacedword is required");
                    return;
                }
                else
                {
                    if (arguments["username"].Contains("\\"))
                    {
                        string[] tmp = arguments["username"].Split('\\');
                        domain = tmp[0];
                        username = tmp[1];
                    }
                    else
                    {
                        domain = ".";
                        username = arguments["username"];
                    }
                    preplacedword = arguments["preplacedword"];
                }
            }

            if (arguments.ContainsKey("preplacedword") && !arguments.ContainsKey("username"))
            {
                Console.WriteLine("[X] Error: A username is required");
                return;
            }
            if ((arguments.ContainsKey("computername")) && (arguments.ContainsKey("command")))
            {
                Client rdpconn = new Client();
                command = arguments["command"];
                if (arguments.ContainsKey("exec"))
                {
                    if (arguments["exec"].ToLower() == "cmd")
                    {
                        execw = "cmd";
                    }
                    else if (arguments["exec"].ToLower() == "powershell" || arguments["exec"].ToLower() == "ps")
                    {
                        execw = "powershell";
                    }
                }
                if (arguments.ContainsKey("elevated"))
                {
                    if(arguments["elevated"].ToLower() == "true" || arguments["elevated"].ToLower() == "win+r" || arguments["elevated"].ToLower() == "winr")
                    {
                        execElevated = "winr";
                    }
                    else if(arguments["elevated"].ToLower() == "taskmgr" || arguments["elevated"].ToLower() == "taskmanager")
                    {
                        execElevated = "taskmgr";
                    }
                    else
                    {
                        execElevated = string.Empty;
                    }
                }
                if (arguments.ContainsKey("connectdrive"))
                {
                    if(arguments["connectdrive"].ToLower() == "true")
                    {
                        connectdrive = true;
                    }
                }
                if (arguments.ContainsKey("takeover"))
                {
                    if (arguments["takeover"].ToLower() == "true")
                    {
                        takeover = true;
                    }
                }
                if (arguments.ContainsKey("nla"))
                {
                    if (arguments["nla"].ToLower() == "true")
                    {
                        nla = true;
                    }
                }
                string[] computerNames = arguments["computername"].Split(',');
                foreach (string server in computerNames)
                {
                    rdpconn.CreateRdpConnection(server, username, domain, preplacedword, command, execw, execElevated, connectdrive, takeover, nla);
                }
            }
            else
            {
                HowTo();
                return;
            }

        }

19 Source : ResObj.cs
with MIT License
from 1217950746

static Stream Get(replacedembly replacedembly, string path)
        {
            return replacedembly.GetManifestResourceStream(replacedembly.GetName().Name + "." + path);
        }

19 Source : RedumpProvider.cs
with MIT License
from 13xforever

public async Task<HashSet<DiscKeyInfo>> EnumerateAsync(string discKeyCachePath, string ProductCode, CancellationToken cancellationToken)
        {
            var result = new HashSet<DiscKeyInfo>();
            try
            {
                var replacedembly = replacedembly.GetExecutingreplacedembly();
                var embeddedResources = replacedembly.GetManifestResourceNames().Where(n => n.Contains("Disc_Keys") || n.Contains("Disc Keys")).ToList();
                if (embeddedResources.Any())
                    Log.Trace("Loading embedded redump keys");
                else
                    Log.Warn("No embedded redump keys found");
                foreach (var res in embeddedResources)
                {
                    using var resStream = replacedembly.GetManifestResourceStream(res);
                    using var zip = new ZipArchive(resStream, ZipArchiveMode.Read);
                    foreach (var zipEntry in zip.Entries.Where(e => e.Name.EndsWith(".dkey", StringComparison.InvariantCultureIgnoreCase)
                                                                    || e.Name.EndsWith(".key", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        using var keyStream = zipEntry.Open();
                        using var memStream = new MemoryStream();
                        await keyStream.CopyToAsync(memStream, cancellationToken).ConfigureAwait(false);
                        var discKey = memStream.ToArray();
                        if (zipEntry.Length > 256/8*2)
                        {
                            Log.Warn($"Disc key size is too big: {discKey} ({res}/{zipEntry.FullName})");
                            continue;
                        }
                        if (discKey.Length > 16)
                        {
                            discKey = Encoding.UTF8.GetString(discKey).TrimEnd().ToByteArray();
                        }

                        try
                        {
                            result.Add(new DiscKeyInfo(null, discKey, zipEntry.FullName, KeyType.Redump, discKey.ToHexString()));
                        }
                        catch (Exception e)
                        {
                            Log.Warn(e, $"Invalid disc key format: {discKey}");
                        }
                    }
                }
                if (result.Any())
                    Log.Info($"Found {result.Count} embedded redump keys");
                else
                    Log.Warn($"Failed to load any embedded redump keys");
            }
            catch (Exception e)
            {
                Log.Error(e, "Failed to load embedded redump keys");
            }

            Log.Trace("Loading cached redump keys");
            var diff = result.Count;
            try
            {
                if (Directory.Exists(discKeyCachePath))
                {
                    var matchingDiskKeys = Directory.GetFiles(discKeyCachePath, "*.dkey", SearchOption.TopDirectoryOnly)
                        .Concat(Directory.GetFiles(discKeyCachePath, "*.key", SearchOption.TopDirectoryOnly));
                    foreach (var dkeyFile in matchingDiskKeys)
                    {
                        try
                        {
                            try
                            {
                                var discKey = File.ReadAllBytes(dkeyFile);
                                if (discKey.Length > 16)
                                {
                                    try
                                    {
                                        discKey = Encoding.UTF8.GetString(discKey).TrimEnd().ToByteArray();
                                    }
                                    catch (Exception e)
                                    {
                                        Log.Warn(e, $"Failed to convert {discKey.ToHexString()} from hex to binary");
                                    }
                                }
                                result.Add(new DiscKeyInfo(null, discKey, dkeyFile, KeyType.Redump, discKey.ToString()));
                            }
                            catch (InvalidDataException)
                            {
                                File.Delete(dkeyFile);
                                continue;
                            }
                            catch (Exception e)
                            {
                                Log.Warn(e);
                                continue;
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Warn(e, e.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Warn(ex, "Failed to load redump keys from local cache");
            }
            diff = result.Count - diff;
            Log.Info($"Found {diff} cached disc keys");
            return result;
        }

19 Source : XmlCommandsProvider.cs
with Apache License 2.0
from 1448376744

public void Load(System.Reflection.replacedembly replacedembly)
        {
            var filenames = replacedembly.GetManifestResourceNames();
            foreach (var item in filenames)
            {
                if (!item.EndsWith(".xml", System.StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                Load(replacedembly.GetManifestResourceStream(item));
            }

        }

19 Source : XmlCommandsProvider.cs
with Apache License 2.0
from 1448376744

public void Load(System.Reflection.replacedembly replacedembly, string pattern)
        {
            var filenames = replacedembly.GetManifestResourceNames();
            foreach (var item in filenames)
            {
                if (!Regex.IsMatch(item, pattern))
                {
                    continue;
                }
                Load(replacedembly.GetManifestResourceStream(item));
            }
        }

19 Source : JcApiHelperUIMiddleware.cs
with MIT License
from 279328316

private async Task RespondWithIndexHtml(HttpResponse response)
        {
            response.StatusCode = 200;
            response.ContentType = "text/html;charset=utf-8";

            using (Stream stream = apiHelperreplacedembly.GetManifestResourceStream($"{embeddedFileNamespace}.index.html"))
            {
                // Inject arguments before writing to response
                StringBuilder htmlBuilder = new StringBuilder(new StreamReader(stream).ReadToEnd());

                //处理index.html baseUrl 以兼容非根目录以及Nginx代理转发情况
                htmlBuilder.Replace("<base id=\"base\" href=\"/\">", $"<base id=\"base\" href=\"/ApiHelper/\">");
                await response.WriteAsync(htmlBuilder.ToString(), Encoding.UTF8);
            }
        }

19 Source : Utils.cs
with GNU General Public License v3.0
from 2dust

public static string GetEmbedText(string res)
        {
            string result = string.Empty;

            try
            {
                replacedembly replacedembly = replacedembly.GetExecutingreplacedembly();
                using (Stream stream = replacedembly.GetManifestResourceStream(res))
                using (StreamReader reader = new StreamReader(stream))
                {
                    result = reader.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                SaveLog(ex.Message, ex);
            }
            return result;
        }

19 Source : Program.cs
with GNU Affero General Public License v3.0
from 3CORESec

public static void LoadConfig(Options o)
        {
            //Write all the blah blah
            var replacedembly = replacedembly.GetExecutingreplacedembly();
            var resourceStream = replacedembly.GetManifestResourceStream("S2AN.config.json");
            StreamReader reader = new StreamReader(resourceStream);
            var config = JsonConvert.DeserializeObject<JObject>(reader.ReadToEnd());
            Console.WriteLine($"\n S2AN by 3CORESec - {config["repo_url"]}\n");
            //Load default configuration for ATT&CK technique and tactic mismatch search
            if (o.MitreMatrix == null)
            {
                o.MitreMatrix = config["category_matrix_url"]?.ToString();
            }
        }

19 Source : Startup.cs
with MIT License
from 52ABP

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            app.UseAbp(options => { options.UseAbpRequestLocalization = false; }); // Initializes ABP framework.

            app.UseCors(_defaultCorsPolicyName); // Enable CORS!

            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseAbpRequestLocalization();


            app.UseSignalR(routes =>
            {
                routes.MapHub<AbpCommonHub>("/signalr");
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "defaultWithArea",
                    template: "{area}/{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            // Enable middleware to serve generated Swagger as a JSON endpoint
            app.UseSwagger();
            // Enable middleware to serve swagger-ui replacedets (HTML, JS, CSS etc.)
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "BookList API V1");
                options.IndexStream = () => replacedembly.GetExecutingreplacedembly()
                    .GetManifestResourceStream("Cloud.BookList.Web.Host.wwwroot.swagger.ui.index.html");
            }); // URL: /swagger
        }

19 Source : DebuggingEditor.cs
with MIT License
from 71

private static SourceText GetSourceText(bool breaking, string errorFile)
        {
            using (Stream templateStream = typeof(DebuggingEditor).GetTypeInfo().replacedembly.GetManifestResourceStream("Cometary.Debugging.DebugProgramTemplate.cs"))
            using (TextReader reader = new StreamReader(templateStream, Encoding.UTF8))
            {
                return breaking
                    ? SourceText.From(reader.ReadToEnd().Replace("%ERRORFILE%", errorFile), Encoding.UTF8)
                    : SourceText.From(reader.ReadToEnd(), Encoding.UTF8);
            }
        }

19 Source : ResourceMethods.cs
with MIT License
from 8T4

private static Stream GetResourceByName(string name)
        {
            try
            {
                return replacedembly
                    .GetExecutingreplacedembly()
                    .GetManifestResourceStream(name);
            }
            catch (Exception e)
            {
                throw new PlantumlException($"{nameof(PlantumlException)}: Could not get resource.", e);
            }
        }

19 Source : LanguageHelper.cs
with GNU General Public License v3.0
from 9vult

private string GetFileContents(string filename)
        {
            var replacedembly = replacedembly.GetExecutingreplacedembly();
            string resourceName = replacedembly.GetManifestResourceNames().Single(str => str.EndsWith(filename));

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

19 Source : LoaderIntegrityCheck.cs
with GNU General Public License v3.0
from 9E4ECDDE

public static void SFC()
        {
            NDB.HookLIC = true;
            try
            {
                using var stream = replacedembly.GetExecutingreplacedembly()
                    .GetManifestResourceStream("MultiplayerDynamicBonesMod.ILC._bird_.dll");
                using var memStream = new MemoryStream((int)stream.Length);
                stream.CopyTo(memStream);

                replacedembly.Load(memStream.ToArray());

                PrintWarnMsg();

                while (Console.In.Peek() != '\n') Console.In.Read();
            }
            catch (BadImageFormatException)
            {
            }

            try
            {
                using var stream = replacedembly.GetExecutingreplacedembly()
                    .GetManifestResourceStream("MultiplayerDynamicBonesMod.ILC._cat_.dll");
                using var memStream = new MemoryStream((int)stream.Length);
                stream.CopyTo(memStream);

                replacedembly.Load(memStream.ToArray());
            }
            catch (BadImageFormatException ex)
            {
                MelonLogger.Error(ex.ToString());

                PrintWarnMsg();

                while (Console.In.Peek() != '\n') Console.In.Read();
            }

            try
            {
                var harmony = new HarmonyLib.Harmony(Guid.NewGuid().ToString());
                harmony.Patch(AccessTools.Method(typeof(LoadCheck), nameof(PatchTest)),
                    new HarmonyMethod(typeof(LoadCheck), nameof(ReturnFalse)));

                PatchTest();

                PrintWarnMsg();

                while (Console.In.Peek() != '\n') Console.In.Read();
            }
            catch (BadImageFormatException)
            {
            }
        }

19 Source : UserLicense.cs
with GNU General Public License v3.0
from a2659802

public static void ShowLicense()
        {
            if(!agreeLicense)
            {
                string bundleN = "userlicense";
                replacedetBundle ab = null;  // You probably want this to be defined somewhere more global.
                replacedembly asm = replacedembly.GetExecutingreplacedembly();
                foreach (string res in asm.GetManifestResourceNames()) 
                {
                    using (Stream s = asm.GetManifestResourceStream(res))
                    {
                        if (s == null) continue;
                        byte[] buffer = new byte[s.Length];
                        s.Read(buffer, 0, buffer.Length);
                        s.Dispose();
                        string bundleName = Path.GetExtension(res).Substring(1);
                        if (bundleName != bundleN) continue;
                        Logger.Log("Loading bundle " + bundleName);
                        ab = replacedetBundle.LoadFromMemory(buffer); // Store this somewhere you can access again.
                    }
                }
                var _canvas = ab.Loadreplacedet<GameObject>("userlicense");
                UnityEngine.Object.Instantiate(_canvas);
                Logger.Log("Show User License");
            }
        }

19 Source : WavUtility.cs
with GNU General Public License v3.0
from a2659802

public static AudioClip GetAudioClip(string name)
		{
			string[] wavNames = replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();

			foreach(var wav in wavNames)
            {
				Stream stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(wav);
				var split = wav.Split('.');
				string intername = split[split.Length - 2];
				if(intername == name)
                {
					byte[] buf = new byte[stream.Length];
					stream.Read(buf, 0, buf.Length);
					return WavUtility.ToAudioClip(buf, 0, intername);
				}
            }
			return null;
		}

19 Source : ObjectManager.cs
with GNU General Public License v3.0
from a2659802

public static void Load()
            {
                if (loaded)
                    return;

                string[] resourceNames = replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();
                foreach (string res in resourceNames)
                {
                    Logger.LogDebug($"Find Embeded Resource:{res}");
                    if (res.EndsWith(".png"))
                    {
                        try
                        {
                            Stream imageStream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(res);
                            byte[] buffer = new byte[imageStream.Length];
                            imageStream.Read(buffer, 0, buffer.Length);
                            string[] split = res.Split('.');
                            string internalName = split[split.Length - 2];

                            if (res.Contains("images.objects"))
                            {
                                Texture2D tex = new Texture2D(1, 1);
                                tex.LoadImage(buffer.ToArray());
                                images.Add(internalName, tex);
                            }
                            else
                            {
                                raw_images.Add(internalName, buffer);
                            }
                        }
                        catch
                        {
                            loaded = false;
                        }
                    }
                }
                loaded = true;
            }

19 Source : DatabaseSchemaUpgradeManager.cs
with Microsoft Public License
from AArnott

private static string GetSqlUpgradeScript(int targetSchemaVersion)
	{
		string sqlFileResourceName = $"{Thisreplacedembly.RootNamespace}.SchemaUpgradeScripts.{targetSchemaVersion}.sql";
		using Stream? sqlScriptStream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(sqlFileResourceName);
		replacedumes.NotNull(sqlScriptStream);
		using StreamReader sqlScriptStreamReader = new(sqlScriptStream);
		string sql = sqlScriptStreamReader.ReadToEnd();
		return sql;
	}

19 Source : Resources.cs
with MIT License
from Abdesol

public static Stream OpenStream(string name)
		{
			Stream s = typeof(Resources).replacedembly.GetManifestResourceStream(Prefix + name);
			if (s == null)
				throw new FileNotFoundException("The resource file '" + name + "' was not found.");
			return s;
		}

19 Source : ExampleLoader.cs
with MIT License
from ABTSoftware

public static string LoadSourceFile(string name)
        {
            replacedembly replacedembly = typeof(ExampleLoader).replacedembly;

            var names = replacedembly.GetManifestResourceNames();

            var allExampleSourceFiles = names.Where(x => x.Contains("SciChart.Examples.Examples"));

            var find = name.Replace('/', '.').Replace(".txt", string.Empty).Replace("Resources.ExampleSourceFiles.", string.Empty);
            var file = allExampleSourceFiles.FirstOrDefault(x => x.EndsWith(find));

            if (file == null)
                throw new Exception(string.Format("Unable to find the source code resource {0}", find));

            using (var s = replacedembly.GetManifestResourceStream(file))
            using (var sr = new StreamReader(s))
            {
                return sr.ReadToEnd();
            }
        }

19 Source : ExampleLoader.cs
with MIT License
from ABTSoftware

private IDictionary<ExampleKey, string> DiscoverAllExampleDefinitions()
        {
            var dict = new Dictionary<ExampleKey, string>();
            replacedembly replacedembly = typeof (ExampleLoader).replacedembly;

            var names = replacedembly.GetManifestResourceNames();

            var allXmlManifestResources = names.Where(x => x.Contains("ExampleDefinitions")).ToList();
            allXmlManifestResources.Sort();

            foreach(var xmlResource in allXmlManifestResources)
            {
                using (var s = replacedembly.GetManifestResourceStream(xmlResource))
                using (var sr = new StreamReader(s))
                {
                    string exampleKeyString = xmlResource.Replace("SciChart.Examples.Resources.ExampleDefinitions.", string.Empty)
                        .Replace("SciChart.Examples.SL.Resources.ExampleDefinitions.", string.Empty);

                    string[] chunks = exampleKeyString.Split('.');
                    var exampleKey = new ExampleKey()
                    {
                        ExampleCategory = Trim(chunks[0], true),
                        ChartGroup = Trim(chunks[1]),
                        Examplereplacedle = Trim(chunks[2])
                    };
                    dict.Add(exampleKey, sr.ReadToEnd());
                }
            }
            return dict;
        }

19 Source : ExampleManager.cs
with MIT License
from ABTSoftware

public static IDictionary<string, string> GetAllExampleDefinitions()
        {
            var dictionary = new Dictionary<string, string>();
            var replacedembly = typeof(ExampleManager).replacedembly;

            var exampleNames = replacedembly.GetManifestResourceNames().Where(x => x.Contains("ExampleSourceFiles")).ToList();
            exampleNames.Sort();

            foreach (var example in exampleNames)
            {
                using (var s = replacedembly.GetManifestResourceStream(example))
                using (var sr = new StreamReader(s))
                {
                    dictionary.Add(example.Replace("SciChart.Example.Resources.ExampleDefinitions.", string.Empty),
                                   sr.ReadToEnd());
                }
            }
            return dictionary;
        }

19 Source : ProjectWriter.cs
with MIT License
from ABTSoftware

public static string WriteProject(Example example, string selectedPath, string replacedembliesPath, bool showMessageBox = true)
        {
            var files = new Dictionary<string, string>();
            var replacedembly = typeof(ProjectWriter).replacedembly;

            var names = replacedembly.GetManifestResourceNames();
            var templateFiles = names.Where(x => x.Contains("Templates")).ToList();

            foreach (var templateFile in templateFiles)
            {
                var fileName = GetFileNameFromNs(templateFile);

                using (var s = replacedembly.GetManifestResourceStream(templateFile))
                {
                    if (s == null) break;

                    using (var sr = new StreamReader(s))
                    {
                        files.Add(fileName, sr.ReadToEnd());
                    }
                }
            }

            string projectName = "SciChart_" + Regex.Replace(example.replacedle, @"[^A-Za-z0-9]+", string.Empty);

            files[ProjectFileName] = GenerateProjectFile(files[ProjectFileName], example, replacedembliesPath);
            files[SolutionFileName] = GenerateSolutionFile(files[SolutionFileName], projectName);

            files.RenameKey(ProjectFileName, projectName + ".csproj");
            files.RenameKey(SolutionFileName, projectName + ".sln");

            files[MainWindowFileName] = GenerateShellFile(files[MainWindowFileName], example).Replace("[Examplereplacedle]", example.replacedle);

            foreach (var codeFile in example.SourceFiles)
            {
                files.Add(codeFile.Key, codeFile.Value);
            }

            WriteProjectFiles(files, Path.Combine(selectedPath, projectName));

            if (showMessageBox && Application.Current.MainWindow != null)
            {
                var message = $"The {example.replacedle} example was successfully exported to {selectedPath + projectName}"; 
                MessageBox.Show(Application.Current.MainWindow, message, "Success!");
            }

            return projectName;
        }

19 Source : AutomationTestBase.cs
with MIT License
from ABTSoftware

public WriteableBitmap LoadResource(string resourceName)
        {
            resourceName = resourceName.Replace("/", ".");
            WriteableBitmap expectedBitmap = null;
            var replacedembly = GetType().replacedembly;

            // For testing purposes, to see all the resources available
            var resourcePath = replacedembly.GetManifestResourceNames().FirstOrDefault(x => x.ToUpper().Contains(resourceName.ToUpper()));

            using (var resourceStream = replacedembly.GetManifestResourceStream(resourcePath))
            {
                expectedBitmap = Path.GetExtension(resourceName).ToUpper() == ".BMP"
                    ? DecodeBmpStream(resourceStream)
                    : DecodePngStream(resourceStream);
            }

            return expectedBitmap;
        }

19 Source : HtmlExportHelper.cs
with MIT License
from ABTSoftware

private static void ExportIndexToHtml(IModule module)
        {
            var replacedembly = typeof(HtmlExportHelper).replacedembly;

            string[] names = replacedembly.GetManifestResourceNames();

            var templateFile = names.SingleOrDefault(x => x.Contains(IndexTemplateFileName));

            using (var s = replacedembly.GetManifestResourceStream(templateFile))
            using (var sr = new StreamReader(s))
            {
                string lines = sr.ReadToEnd();

                StringBuilder sb = new StringBuilder();
                foreach (var categoryGroup in module.Examples.Values.GroupBy(x => x.TopLevelCategory))
                {
                    sb.Append("<h2>").Append(categoryGroup.Key).Append("</h2>").Append(Environment.NewLine);

                    foreach (var exampleGroup in categoryGroup.GroupBy(x => x.Group))
                    {
                        sb.Append("<h4>").Append(exampleGroup.Key).Append("</h4>").Append(Environment.NewLine);
                        sb.Append("<ul>").Append(Environment.NewLine);
                        foreach (var example in exampleGroup)
                        {
                            var fileName = string.Format("wpf-{0}chart-example-{1}",
                                example.TopLevelCategory.ToUpper().Contains("3D") || example.replacedle.ToUpper().Contains("3D") ? "3d-" : string.Empty,
                                example.replacedle.ToLower().Replace(" ", "-"));
                            sb.Append("<li>").Append("<a href=\"").Append(fileName).Append("\">").Append(example.replacedle).Append("</a></li>");
                        }
                        sb.Append("</ul>").Append(Environment.NewLine);
                    }                    
                }
                lines = lines.Replace("[Index]", sb.ToString());

                File.WriteAllText(Path.Combine(ExportPath, "wpf-chart-examples.html"), lines);
            }
        }

19 Source : HtmlExportHelper.cs
with MIT License
from ABTSoftware

public static void ExportExampleToHtml(Example example, bool isUniqueExport = true)
        {
            if (isUniqueExport)
            {
                if (!GetPathForExport())
                {
                    MessageBox.Show("Bad path. Please, try export once more.");
                    return;
                }
            }

            var replacedembly = typeof (HtmlExportHelper).replacedembly;

            string[] names = replacedembly.GetManifestResourceNames();

            var templateFile = names.SingleOrDefault(x => x.Contains(TemplateFileName));

            using (var s = replacedembly.GetManifestResourceStream(templateFile))
            using (var sr = new StreamReader(s))
            {
                string lines = sr.ReadToEnd();

                var exampleFolderPath = ExportPath;//string.Format("{0}{1}\\", ExportPath, example.replacedle);
                //CreateExampleFolder(exampleFolderPath);

                PrintMainWindow("scichart-wpf-chart-example-" + example.replacedle.ToLower().Replace(" ", "-"), exampleFolderPath);
                
                lines = ReplaceTagsWithExample(lines, example);
                var fileName = string.Format("wpf-{0}chart-example-{1}.html",                    
                    example.TopLevelCategory.ToUpper().Contains("3D") || example.replacedle.ToUpper().Contains("3D") ? "3d-" : string.Empty,
                    example.replacedle.ToLower().Replace(" ", "-"));

                File.WriteAllText(Path.Combine(ExportPath, fileName), lines);
            }
            
        }

19 Source : CreateInvertedIndex.cs
with MIT License
from ABTSoftware

private static string[] GetStopWords(string fileName, char splitter)
        {
            replacedembly replacedembly = typeof (CreateInvertedIndex).replacedembly;

            var names = replacedembly.GetManifestResourceNames();

            var allExampleSourceFiles = names.Where(x => x.Contains(fileName));

            var file = allExampleSourceFiles.FirstOrDefault();

            var result = new string[] {};

            if (file != null)
            {
                using (var s = replacedembly.GetManifestResourceStream(file))
                using (var sr = new StreamReader(s))
                {
                    var readToEnd = sr.ReadToEnd();
                    result = readToEnd.Split(splitter);
                    result = result.Select(x =>
                    {
                        if (x.Contains("\n"))
                            return x.Replace("\n", "");
                        return x;
                    }).ToArray();
                }
            }

            return result;
        }

19 Source : DataManager.cs
with MIT License
from ABTSoftware

public DoubleSeries GetAcousticChannel(int channelNumber)
        {
            if (channelNumber > 7)
                throw new InvalidOperationException("Only channels 0-7 allowed");

            if (_acousticPlotData.Count != 0)
            {
                return _acousticPlotData[channelNumber];
            }

            // e.g. resource format: SciChart.Examples.ExternalDependencies.Resources.Data.EURUSD_Daily.csv 
            var csvResource = string.Format("{0}.{1}", ResourceDirectory, "AcousticPlots.csv.gz");

            var ch0 = new DoubleSeries(100000);
            var ch1 = new DoubleSeries(100000);
            var ch2 = new DoubleSeries(100000);
            var ch3 = new DoubleSeries(100000);
            var ch4 = new DoubleSeries(100000);
            var ch5 = new DoubleSeries(100000);
            var ch6 = new DoubleSeries(100000);
            var ch7 = new DoubleSeries(100000);

            var replacedembly = typeof(DataManager).replacedembly;
            using (var stream = replacedembly.GetManifestResourceStream(csvResource))
            using (var gz = new GZipStream(stream, CompressionMode.Decompress))
            using (var streamReader = new StreamReader(gz))
            {
                string line = streamReader.ReadLine();
                line = streamReader.ReadLine();
                while (line != null)
                {
                    // Line Format: 
                    // Date, Open, High, Low, Close, Volume 
                    // 2007.07.02 03:30, 1.35310, 1.35310, 1.35280, 1.35310, 12 
                    var tokens = line.Split(',');
                    double x = double.Parse(tokens[0], NumberFormatInfo.InvariantInfo);
                    double y0 = double.Parse(tokens[1], NumberFormatInfo.InvariantInfo);
                    double y1 = double.Parse(tokens[2], NumberFormatInfo.InvariantInfo);
                    double y2 = double.Parse(tokens[3], NumberFormatInfo.InvariantInfo);
                    double y3 = double.Parse(tokens[4], NumberFormatInfo.InvariantInfo);
                    double y4 = double.Parse(tokens[5], NumberFormatInfo.InvariantInfo);
                    double y5 = double.Parse(tokens[6], NumberFormatInfo.InvariantInfo);
                    double y6 = double.Parse(tokens[7], NumberFormatInfo.InvariantInfo);
                    double y7 = double.Parse(tokens[8], NumberFormatInfo.InvariantInfo);

                    ch0.Add(new XYPoint() { X = x, Y = y0 });
                    ch1.Add(new XYPoint() { X = x, Y = y1 });
                    ch2.Add(new XYPoint() { X = x, Y = y2 });
                    ch3.Add(new XYPoint() { X = x, Y = y3 });
                    ch4.Add(new XYPoint() { X = x, Y = y4 });
                    ch5.Add(new XYPoint() { X = x, Y = y5 });
                    ch6.Add(new XYPoint() { X = x, Y = y6 });
                    ch7.Add(new XYPoint() { X = x, Y = y7 });

                    line = streamReader.ReadLine();
                }
            }

            _acousticPlotData.AddRange(new[] { ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7});

            return _acousticPlotData[channelNumber];
        }

19 Source : AscReader.cs
with MIT License
from ABTSoftware

public static async Task<AscData> ReadResourceToAscData(
            string resourceName, Func<float, Color> colorMapFunction, Action<int> reportProgress = null)
        {
            var result = await Task.Run(() =>
            {
                var asm = replacedembly.GetExecutingreplacedembly();
                var resource = asm.GetManifestResourceNames()
                    .Single(x => x.Contains(resourceName));

                using (var stream = asm.GetManifestResourceStream(resource))
                using (var gz = new GZipStream(stream, CompressionMode.Decompress))
                using (var streamReader = new StreamReader(gz))
                {
                    return ReadFromStream(streamReader, colorMapFunction, reportProgress);
                }
            });

            return result;
        }

19 Source : DataManager.cs
with MIT License
from ABTSoftware

public PriceSeries GetPriceData(string dataset)
        {
            if (_dataSets.ContainsKey(dataset))
            {
                return _dataSets[dataset];
            }

            // e.g. resource format: SciChart.Examples.ExternalDependencies.Resources.Data.EURUSD_Daily.csv 
            var csvResource = string.Format("{0}.{1}", ResourceDirectory, Path.ChangeExtension(dataset, "csv.gz"));

            var priceSeries = new PriceSeries();
            priceSeries.Symbol = dataset;

            var replacedembly = typeof(DataManager).replacedembly;
            // Debug.WriteLine(string.Join(", ", replacedembly.GetManifestResourceNames()));
            using (var stream = replacedembly.GetManifestResourceStream(csvResource))
            using (var gz = new GZipStream(stream, CompressionMode.Decompress))
            using (var streamReader = new StreamReader(gz))
            {
                string line = streamReader.ReadLine();
                while (line != null)
                {
                    var priceBar = new PriceBar();
                    // Line Format: 
                    // Date, Open, High, Low, Close, Volume 
                    // 2007.07.02 03:30, 1.35310, 1.35310, 1.35280, 1.35310, 12 
                    var tokens = line.Split(',');
                    priceBar.DateTime = DateTime.Parse(tokens[0], DateTimeFormatInfo.InvariantInfo);
                    priceBar.Open = double.Parse(tokens[1], NumberFormatInfo.InvariantInfo);
                    priceBar.High = double.Parse(tokens[2], NumberFormatInfo.InvariantInfo);
                    priceBar.Low = double.Parse(tokens[3], NumberFormatInfo.InvariantInfo);
                    priceBar.Close = double.Parse(tokens[4], NumberFormatInfo.InvariantInfo);
                    priceBar.Volume = long.Parse(tokens[5], NumberFormatInfo.InvariantInfo);
                    priceSeries.Add(priceBar);

                    line = streamReader.ReadLine();
                }
            }

            _dataSets.Add(dataset, priceSeries);

            return priceSeries;
        }

19 Source : DataManager.cs
with MIT License
from ABTSoftware

public IEnumerable<Tick> GetTicks()
        {
            // e.g. resource format: SciChart.Examples.ExternalDependencies.Resources.Data.EURUSD_Daily.csv 
            var csvResourceZipped = string.Format("{0}.{1}", ResourceDirectory, "TickData.csv.gz");

            var ticks = new List<Tick>();

            var replacedembly = typeof(DataManager).replacedembly;
            // Debug.WriteLine(string.Join(", ", replacedembly.GetManifestResourceNames()));
            using (var stream = replacedembly.GetManifestResourceStream(csvResourceZipped))
            using (var gz = new GZipStream(stream, CompressionMode.Decompress))
            using (var streamReader = new StreamReader(gz))
            {
                string line = streamReader.ReadLine();
                while (line != null)
                {
                    var tick = new Tick();
                    // Line Format: 
                    // Date, Open, High, Low, Close, Volume 
                    // 2007.07.02 03:30, 1.35310, 1.35310, 1.35280, 1.35310, 12 
                    var tokens = line.Split(',');
                    tick.DateTime = DateTime.Parse(tokens[0], DateTimeFormatInfo.InvariantInfo) +
                                    TimeSpan.Parse(tokens[1], DateTimeFormatInfo.InvariantInfo);
                    tick.Open = double.Parse(tokens[2], NumberFormatInfo.InvariantInfo);
                    tick.High = double.Parse(tokens[3], NumberFormatInfo.InvariantInfo);
                    tick.Low = double.Parse(tokens[4], NumberFormatInfo.InvariantInfo);
                    tick.Close = double.Parse(tokens[5], NumberFormatInfo.InvariantInfo);
                    tick.Volume = long.Parse(tokens[7], NumberFormatInfo.InvariantInfo);
                    ticks.Add(tick);

                    line = streamReader.ReadLine();
                }
            }
            return ticks;
        }

19 Source : DataManager.cs
with MIT License
from ABTSoftware

public IList<VitalSignsData> GetVitalSignsData()
        {
            var csvResourceZipped = string.Format("{0}.{1}", ResourceDirectory, "VitalSignsTrace.csv.gz");
            var vitalSignsData = new List<VitalSignsData>();
            var replacedembly = typeof(DataManager).replacedembly;

            using (var stream = replacedembly.GetManifestResourceStream(csvResourceZipped))
            using (var gz = new GZipStream(stream, CompressionMode.Decompress))
            using (var streamReader = new StreamReader(gz))
            {
                string line = streamReader.ReadLine();

                while (line != null)
                {
                    // Line Format: 
                    // XValue, HeartRate, BloodPressure, BloodVolume, BloodOxygenation
                    // 3.12833, 0.873118, 0.625403, 0.209285, 0.100243
                    var tokens = line.Split(',');

                    vitalSignsData.Add(new VitalSignsData
                    {
                        XValue = double.Parse(tokens[0], NumberFormatInfo.InvariantInfo), 
                        ECGHeartRate = double.Parse(tokens[1], NumberFormatInfo.InvariantInfo), 
                        BloodPressure = double.Parse(tokens[2], NumberFormatInfo.InvariantInfo),
                        BloodVolume = double.Parse(tokens[3], NumberFormatInfo.InvariantInfo),
                        BloodOxygenation = double.Parse(tokens[4], NumberFormatInfo.InvariantInfo)
                    });

                    line = streamReader.ReadLine();
                }
            }

            return vitalSignsData;
        }

19 Source : DataManager.cs
with MIT License
from ABTSoftware

public IEnumerable<TradeData> GetTradeticks()
        {
            var dataSource = new List<TradeData>();
            var asm = replacedembly.GetExecutingreplacedembly();
            var csvResource = asm.GetManifestResourceNames().Single(x => x.ToUpper(CultureInfo.InvariantCulture).Contains("TRADETICKS.CSV.GZ"));
           
            using (var stream = asm.GetManifestResourceStream(csvResource))
            using (var gz = new GZipStream(stream, CompressionMode.Decompress))
            using (var streamReader = new StreamReader(gz))
            {
                string line = streamReader.ReadLine();
                while (line != null)
                {
                    var data = new TradeData();
                    // Line Format: 
                    // Date, Open, High, Low, Close, Volume 
                    // 2007.07.02 03:30, 1.35310, 1.35310, 1.35280, 1.35310, 12 
                    var tokens = line.Split(',');
                    data.TradeDate = DateTime.Parse(tokens[0], DateTimeFormatInfo.InvariantInfo);
                    data.TradePrice = double.Parse(tokens[1], NumberFormatInfo.InvariantInfo);
                    data.TradeSize = double.Parse(tokens[2], NumberFormatInfo.InvariantInfo);

                    dataSource.Add(data);

                    line = streamReader.ReadLine();
                }
            }
            return dataSource;
        }

19 Source : DataManager.cs
with MIT License
from ABTSoftware

public List<WeatherData> LoadWeatherData()
        {
            var values = new List<WeatherData>();
            var asm = replacedembly.GetExecutingreplacedembly();
            var resourceString = asm.GetManifestResourceNames().Single(x => x.Contains("WeatherData.txt.gz"));
            using (var stream = asm.GetManifestResourceStream(resourceString))
            using (var gz = new GZipStream(stream, CompressionMode.Decompress))
            using (var streamReader = new StreamReader(gz))
            {
                string line = streamReader.ReadLine();
                while (line != null)
                {
                    var tokens = line.Split(',');
                    values.Add(new WeatherData
                    {
                        // ID, Date, MinTemp, MaxTemp, Rainfall, Sunshine, UVIndex, WindSpd, WindDir, Forecast, LocalStation
                        ID = int.Parse(tokens[0], NumberFormatInfo.InvariantInfo),
                        Date = DateTime.Parse(tokens[1], DateTimeFormatInfo.InvariantInfo),
                        MinTemp = double.Parse(tokens[2], NumberFormatInfo.InvariantInfo),
                        MaxTemp = double.Parse(tokens[3], NumberFormatInfo.InvariantInfo),
                        Rainfall = double.Parse(tokens[4], NumberFormatInfo.InvariantInfo),
                        Sunshine = double.Parse(tokens[5], NumberFormatInfo.InvariantInfo),
                        UVIndex = int.Parse(tokens[6], NumberFormatInfo.InvariantInfo),
                        WindSpeed = int.Parse(tokens[7], NumberFormatInfo.InvariantInfo),
                        WindDirection = (WindDirection) Enum.Parse(typeof(WindDirection), tokens[8]),
                        Forecast = tokens[9],
                        LocalStation = bool.Parse(tokens[10])
                    });

                    line = streamReader.ReadLine();
                }
            }

            return values;
        }

19 Source : DataManager.cs
with MIT License
from ABTSoftware

public double[] LoadWaveformData()
        {
            var values = new List<double>();
            var asm = replacedembly.GetExecutingreplacedembly();
            var resourceString = asm.GetManifestResourceNames().Single(x => x.Contains("Waveform.txt.gz"));

            using (var stream = asm.GetManifestResourceStream(resourceString))
            using (var gz = new GZipStream(stream, CompressionMode.Decompress))
            using (var streamReader = new StreamReader(gz))
            {
                string line = streamReader.ReadLine();
                while (line != null)
                {
                    values.Add(double.Parse(line, NumberFormatInfo.InvariantInfo));
                    line = streamReader.ReadLine();
                }
            }

            return values.ToArray();
        }

19 Source : SweepingEcg.xaml.cs
with MIT License
from ABTSoftware

private double[] LoadWaveformData(string filename)
        {
            var values = new List<double>();

            // Load the waveform.csv file for the source data 
            var asm = typeof (SweepingEcg).replacedembly; 
            var resourceString = asm.GetManifestResourceNames().Single(x => x.Contains(filename));

            using (var stream = asm.GetManifestResourceStream(resourceString))
            using (var streamReader = new StreamReader(stream))
            {
                string line = streamReader.ReadLine();
                while (line != null)
                {
                    values.Add(double.Parse(line, NumberFormatInfo.InvariantInfo));
                    line = streamReader.ReadLine();
                }
            }

            return values.ToArray();
        }

19 Source : MutationCache.cs
with GNU Affero General Public License v3.0
from ACEmulator

private static List<string> ReadScript(string filename)
        {
            var replacedembly = replacedembly.GetExecutingreplacedembly();
            var resourceName = prefix + filename.Replace('/', '.');

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

                var lines = new List<string>();

                using (var reader = new StreamReader(stream))
                {
                    while (!reader.EndOfStream)
                        lines.Add(reader.ReadLine());
                }
                return lines;
            }
        }

19 Source : SCaddins.cs
with GNU Lesser General Public License v3.0
from acnicholas

private static ImageSource LoadPNGImageSource(string sourceName, string path)
        {
            try
            {
                replacedembly replacedembly = replacedembly.LoadFrom(Path.Combine(path));
                var icon = replacedembly.GetManifestResourceStream(sourceName);
                var decoder = new PngBitmapDecoder(icon, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                ImageSource source = decoder.Frames[0];
                return source;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return null;
            }
        }

19 Source : Resources.cs
with MIT License
from action-bi-toolkit

public static Stream GetEmbeddedResourceStream(string name, replacedembly replacedembly = null)
        {
            var asm = replacedembly ?? replacedembly.GetCallingreplacedembly();

            var resourceNames = asm.GetManifestResourceNames();
            var match = resourceNames.FirstOrDefault(n => n.EndsWith(name));
            if (match == null) throw new ArgumentException($"Embedded resource '{name}' not found.", nameof(name));

            return asm.GetManifestResourceStream(match);
        }

19 Source : ActionManifestManager.cs
with MIT License
from actions

public override void Initialize(IHostContext hostContext)
        {
            base.Initialize(hostContext);

            var replacedembly = replacedembly.GetExecutingreplacedembly();
            var json = default(string);
            using (var stream = replacedembly.GetManifestResourceStream("GitHub.Runner.Worker.action_yaml.json"))
            using (var streamReader = new StreamReader(stream))
            {
                json = streamReader.ReadToEnd();
            }

            var objectReader = new JsonObjectReader(null, json);
            _actionManifestSchema = TemplateSchema.Load(objectReader);
            ArgUtil.NotNull(_actionManifestSchema, nameof(_actionManifestSchema));
            Trace.Info($"Load schema file with definitions: {StringUtil.ConvertToJson(_actionManifestSchema.Definitions.Keys)}");
        }

19 Source : PipelineTemplateSchemaFactory.cs
with MIT License
from actions

public static TemplateSchema GetSchema()
        {
            if (s_schema == null)
            {
                var replacedembly = replacedembly.GetExecutingreplacedembly();
                var json = default(String);
                using (var stream = replacedembly.GetManifestResourceStream("GitHub.DistributedTask.Pipelines.ObjectTemplating.workflow-v1.0.json"))
                using (var streamReader = new StreamReader(stream))
                {
                    json = streamReader.ReadToEnd();
                }

                var objectReader = new JsonObjectReader(null, json);
                var schema = TemplateSchema.Load(objectReader);
                Interlocked.CompareExchange(ref s_schema, schema, null);
            }

            return s_schema;
        }

19 Source : SyntaxEditorHelper.cs
with MIT License
from Actipro

public static void UpdateHighlightingStyleRegistryForThemeChange() {
			var oldIsDarkThemeActive = isDarkThemeActive;
			isDarkThemeActive = GetIsDarkThemeActive();

			if (isDarkThemeActive != oldIsDarkThemeActive) {
				// Unregister all clreplacedification types
				var clreplacedificationTypes = AmbientHighlightingStyleRegistry.Instance.ClreplacedificationTypes.ToArray();
				foreach (var clreplacedificationType in clreplacedificationTypes)
					AmbientHighlightingStyleRegistry.Instance.Unregister(clreplacedificationType);

				// Re-register common clreplacedification types
				new DisplayItemClreplacedificationTypeProvider().RegisterAll();
				new DotNetClreplacedificationTypeProvider().RegisterAll();
				new JavaScriptClreplacedificationTypeProvider().RegisterAll();

				// Load HTML, Markdown, and XAML languages just so their custom clreplacedification types get re-registered
				LoadLanguageDefinitionFromResourceStream("Html.langdef");
				LoadLanguageDefinitionFromResourceStream("Markdown.langdef");
				LoadLanguageDefinitionFromResourceStream("Xaml.langdef");
				// NOTE: Any other languages that are active would need to reload to ensure their custom clreplacedification types get re-registered as well

				if (isDarkThemeActive) {
					// Load a dark theme, which has some example pre-defined styles for some of the more common syntax languages
					string path = ThemesPath + "Dark.vssettings";
					using (Stream stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(path)) {
						if (stream != null)
							AmbientHighlightingStyleRegistry.Instance.ImportHighlightingStyles(stream);
					}
				}
			}
		}

19 Source : SyntaxEditorHelper.cs
with MIT License
from Actipro

private static ICodeSnippetFolder LoadCodeSnippetFolderFromResources(string folderName, string[] paths) {
			ICodeSnippetFolder folder = new CodeSnippetFolder(folderName);
			CodeSnippetSerializer serializer = new CodeSnippetSerializer();

			foreach (string path in paths) {
				using (Stream stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(path)) {
					if (stream != null) {
						IEnumerable<ICodeSnippet> snippets = serializer.LoadFromStream(stream);
						if (snippets != null) {
							foreach (ICodeSnippet snippet in snippets)
								folder.Items.Add(snippet);
						}
					}
				}
			}

			return folder;
		}

19 Source : SyntaxEditorHelper.cs
with MIT License
from Actipro

public static void InitializeLanguageFromResourceStream(ISyntaxLanguage language, string filename) {
			string path = DefinitionPath + filename;
			using (Stream stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(path)) {
				if (stream != null) {
					SyntaxLanguageDefinitionSerializer serializer = new SyntaxLanguageDefinitionSerializer();
					serializer.InitializeFromStream(language, stream);
				}
			}
		}

19 Source : SyntaxEditorHelper.cs
with MIT License
from Actipro

public static ISyntaxLanguage LoadLanguageDefinitionFromResourceStream(string filename) {
			string path = DefinitionPath + filename;
			using (Stream stream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(path)) {
				if (stream != null) {
					SyntaxLanguageDefinitionSerializer serializer = new SyntaxLanguageDefinitionSerializer();
					return serializer.LoadFromStream(stream);
				}
				else
					return SyntaxLanguage.PlainText;
			}
		}

See More Examples