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
19
Source : AssemblyUtils.cs
with MIT License
from AlexanderPro
with MIT License
from AlexanderPro
public static void ExtractFileFromreplacedembly(string resourceName, string path)
{
var currentreplacedembly = replacedembly.GetExecutingreplacedembly();
var outputFileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
var resouceStream = currentreplacedembly.GetManifestResourceStream(resourceName);
resouceStream.CopyTo(outputFileStream);
resouceStream.Close();
outputFileStream.Close();
}
19
Source : Ring0.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
private static bool ExtractDriver(string fileName) {
string resourceName = "OpenHardwareMonitor.Hardware." +
(OperatingSystem.Is64BitOperatingSystem() ? "WinRing0x64.sys" :
"WinRing0.sys");
string[] names = Getreplacedembly().GetManifestResourceNames();
byte[] buffer = null;
for (int i = 0; i < names.Length; i++) {
if (names[i].Replace('\\', '.') == resourceName) {
using (Stream stream = Getreplacedembly().
GetManifestResourceStream(names[i]))
{
buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
}
}
}
if (buffer == null)
return false;
try {
using (FileStream target = new FileStream(fileName, FileMode.Create)) {
target.Write(buffer, 0, buffer.Length);
target.Flush();
}
} catch (IOException) {
// for example there is not enough space on the disk
return false;
}
// make sure the file is actually writen to the file system
for (int i = 0; i < 20; i++) {
try {
if (File.Exists(fileName) &&
new FileInfo(fileName).Length == buffer.Length)
{
return true;
}
Thread.Sleep(100);
} catch (IOException) {
Thread.Sleep(10);
}
}
// file still has not the right size, something is wrong
return false;
}
19
Source : HttpServer.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
private void ServeResourceImage(HttpListenerResponse response, string name) {
name = "OpenHardwareMonitor.Resources." + name;
string[] names =
replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();
for (int i = 0; i < names.Length; i++) {
if (names[i].Replace('\\', '.') == name) {
using (Stream stream = replacedembly.GetExecutingreplacedembly().
GetManifestResourceStream(names[i])) {
Image image = Image.FromStream(stream);
response.ContentType = "image/png";
try {
Stream output = response.OutputStream;
using (MemoryStream ms = new MemoryStream()) {
image.Save(ms, ImageFormat.Png);
ms.WriteTo(output);
}
output.Close();
} catch (HttpListenerException) {
}
image.Dispose();
response.Close();
return;
}
}
}
response.StatusCode = 404;
response.Close();
}
19
Source : EmbeddedResources.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
public static Image GetImage(string name) {
name = "OpenHardwareMonitor.Resources." + name;
string[] names =
replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();
for (int i = 0; i < names.Length; i++) {
if (names[i].Replace('\\', '.') == name) {
using (Stream stream = replacedembly.GetExecutingreplacedembly().
GetManifestResourceStream(names[i])) {
// "You must keep the stream open for the lifetime of the Image."
Image image = Image.FromStream(stream);
// so we just create a copy of the image
Bitmap bitmap = new Bitmap(image);
// and dispose it right here
image.Dispose();
return bitmap;
}
}
}
return new Bitmap(1, 1);
}
19
Source : EmbeddedResources.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
public static Icon GetIcon(string name) {
name = "OpenHardwareMonitor.Resources." + name;
string[] names =
replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();
for (int i = 0; i < names.Length; i++) {
if (names[i].Replace('\\', '.') == name) {
using (Stream stream = replacedembly.GetExecutingreplacedembly().
GetManifestResourceStream(names[i])) {
return new Icon(stream);
}
}
}
return null;
}
19
Source : HttpServer.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
private void ServeResourceFile(HttpListenerResponse response, string name,
string ext)
{
// resource names do not support the hyphen
name = "OpenHardwareMonitor.Resources." +
name.Replace("custom-theme", "custom_theme");
string[] names =
replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();
for (int i = 0; i < names.Length; i++) {
if (names[i].Replace('\\', '.') == name) {
using (Stream stream = replacedembly.GetExecutingreplacedembly().
GetManifestResourceStream(names[i])) {
response.ContentType = GetcontentType("." + ext);
response.ContentLength64 = stream.Length;
byte[] buffer = new byte[512 * 1024];
int len;
try {
Stream output = response.OutputStream;
while ((len = stream.Read(buffer, 0, buffer.Length)) > 0) {
output.Write(buffer, 0, len);
}
output.Flush();
output.Close();
response.Close();
} catch (HttpListenerException) {
} catch (InvalidOperationException) {
}
return;
}
}
}
response.StatusCode = 404;
response.Close();
}
19
Source : Icon.cs
with MIT License
from AlexPshul
with MIT License
from AlexPshul
private void CanvasViewOnPaintSurface(object sender, SKPaintSurfaceEventArgs args)
{
SKCanvas canvas = args.Surface.Canvas;
canvas.Clear();
if (string.IsNullOrEmpty(ResourceId))
return;
using (Stream stream = GetType().replacedembly.GetManifestResourceStream(ResourceId))
{
SKSvg svg = new SKSvg();
svg.Load(stream);
SKImageInfo info = args.Info;
canvas.Translate(info.Width / 2f, info.Height / 2f);
SKRect bounds = svg.ViewBox;
float xRatio = info.Width / bounds.Width;
float yRatio = info.Height / bounds.Height;
float ratio = Math.Min(xRatio, yRatio);
canvas.Scale(ratio);
canvas.Translate(-bounds.MidX, -bounds.MidY);
canvas.DrawPicture(svg.Picture);
}
}
19
Source : SwaggerUI.cs
with MIT License
from aliencube
with MIT License
from aliencube
public async Task<ISwaggerUI> BuildAsync()
{
var replacedembly = replacedembly.GetExecutingreplacedembly();
using (var stream = replacedembly.GetManifestResourceStream(swaggerUiCss))
using (var reader = new StreamReader(stream))
{
this._swaggerUiCss = await reader.ReadToEndAsync().ConfigureAwait(false);
}
using (var stream = replacedembly.GetManifestResourceStream(swaggerUiBundleJs))
using (var reader = new StreamReader(stream))
{
this._swaggerUiBundleJs = await reader.ReadToEndAsync().ConfigureAwait(false);
}
using (var stream = replacedembly.GetManifestResourceStream(swaggerUiStandalonePresetJs))
using (var reader = new StreamReader(stream))
{
this._swaggerUiStandalonePresetJs = await reader.ReadToEndAsync().ConfigureAwait(false);
}
using (var stream = replacedembly.GetManifestResourceStream(indexHtml))
using (var reader = new StreamReader(stream))
{
this._indexHtml = await reader.ReadToEndAsync().ConfigureAwait(false);
}
return this;
}
19
Source : Core.cs
with MIT License
from AliFlux
with MIT License
from AliFlux
public static string GetEmbeddedResource(Type replacedemblyType, string resourceName)
{
var replacedembly = replacedemblyType.GetTypeInfo().replacedembly;
using (Stream stream = replacedembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
19
Source : ImGuiController.cs
with MIT License
from allenwp
with MIT License
from allenwp
private byte[] GetEmbeddedResourceBytes(string resourceName)
{
replacedembly replacedembly = typeof(ImGuiController).replacedembly;
using (Stream s = replacedembly.GetManifestResourceStream(resourceName))
{
byte[] ret = new byte[s.Length];
s.Read(ret, 0, (int)s.Length);
return ret;
}
}
19
Source : JsonMetadataParserTests.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn
with BSD 3-Clause "New" or "Revised" License
from Altinn
private ModelMetadata LoadTestData(string resourceName)
{
replacedembly replacedembly = typeof(JsonMetadataParserTests).GetTypeInfo().replacedembly;
using Stream resource = replacedembly.GetManifestResourceStream(resourceName);
if (resource == null)
{
throw new InvalidOperationException("Unable to find test data embedded in the test replacedembly.");
}
using StreamReader streamReader = new StreamReader(resource);
JsonValue jsonValue = JsonValue.Parse(streamReader);
return new JsonSerializer().Deserialize<ModelMetadata>(jsonValue);
}
19
Source : JsonSchemaToInstanceModelGeneratorTests.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn
with BSD 3-Clause "New" or "Revised" License
from Altinn
private JsonSchema LoadTestData(string resourceName)
{
replacedembly replacedembly = typeof(JsonSchemaToInstanceModelGeneratorTests).GetTypeInfo().replacedembly;
using Stream resource = replacedembly.GetManifestResourceStream(resourceName);
if (resource == null)
{
throw new InvalidOperationException("Unable to find test data embedded in the test replacedembly.");
}
using StreamReader streamReader = new StreamReader(resource);
JsonValue jsonValue = JsonValue.Parse(streamReader);
return new JsonSerializer().Deserialize<JsonSchema>(jsonValue);
}
19
Source : TwoWayXsdToJsonSchemaConversionTests.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn
with BSD 3-Clause "New" or "Revised" License
from Altinn
private Stream LoadTestData(string resourceName)
{
replacedembly replacedembly = typeof(XsdToJsonSchemaTests).GetTypeInfo().replacedembly;
Stream resource = replacedembly.GetManifestResourceStream(resourceName);
if (resource == null)
{
throw new InvalidOperationException("Unable to find test data embedded in the test replacedembly.");
}
return resource;
}
19
Source : EmbeddedResource.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn
with BSD 3-Clause "New" or "Revised" License
from Altinn
public static Stream LoadDataFromEmbeddedResource(string resourceName)
{
var replacedembly = replacedembly.GetExecutingreplacedembly();
Stream resource = replacedembly.GetManifestResourceStream(resourceName);
if (resource == null)
{
throw new InvalidOperationException("Unable to find test data embedded in the test replacedembly.");
}
return resource;
}
19
Source : TestDataHelper.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn
with BSD 3-Clause "New" or "Revised" License
from Altinn
public static Stream LoadDataFromEmbeddedResource(string resourceName)
{
var replacedembly = replacedembly.GetExecutingreplacedembly();
Stream resourceStream = replacedembly.GetManifestResourceStream(resourceName);
if (resourceStream == null)
{
throw new InvalidOperationException("Unable to find test data embedded in the test replacedembly.");
}
resourceStream.Seek(0, SeekOrigin.Begin);
return resourceStream;
}
19
Source : FileIconMapper.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
void EnsureSpecialImages()
{
if ((_lvUp != 0))
return;
Image img = Bitmap.FromStream(typeof(FileIconMapper).replacedembly.GetManifestResourceStream(
typeof(FileIconMapper).Namespace + ".UpDnListView.png"));
int count = img.Width / 16;
_imageList.Images.AddStrip(img);
_lvUp = _imageList.Images.Count - count + 1;
}
19
Source : StatusImageMapper.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
public ImageList CreateStatusImageList(bool width8)
{
int width = width8 ? 8 : 7;
using (Stream images = typeof(StatusImageMapper).replacedembly.GetManifestResourceStream(typeof(StatusImageMapper).Namespace + string.Format(CultureInfo.InvariantCulture, ".StatusGlyphs{0}.bmp", width)))
{
if (images == null)
return null;
Bitmap bitmap = (Bitmap)Image.FromStream(images, true);
ImageList imageList = new ImageList();
imageList.ImageSize = new Size(width, bitmap.Height);
bitmap.MakeTransparent(bitmap.GetPixel(0, 0));
imageList.Images.AddStrip(bitmap);
return imageList;
}
}
19
Source : Utils.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
public static string GetEmbeddedStringResource(replacedembly replacedembly, string resourceName)
{
string result = null;
// Use the .NET procedure for loading a file embedded in the replacedembly
Stream stream = replacedembly.GetManifestResourceStream(resourceName);
if (stream != null)
{
// Convert bytes to string
byte[] fileContentsAsBytes = new byte[stream.Length];
stream.Read(fileContentsAsBytes, 0, (int)stream.Length);
result = Encoding.Default.GetString(fileContentsAsBytes);
}
else
{
// Embedded resource not found - list available resources
Debug.WriteLine("Unable to find the embedded resource file '" + resourceName + "'.");
Debug.WriteLine(" Available resources:");
foreach (string aResourceName in replacedembly.GetManifestResourceNames())
{
Debug.WriteLine(" " + aResourceName);
}
}
return result;
}
19
Source : Utils.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
public static void WriteEmbeddedResourceToBinaryFile(replacedembly replacedembly, string embeddedResourceName, string fileName)
{
// Get file contents
Stream stream = replacedembly.GetManifestResourceStream(embeddedResourceName);
if (stream == null)
throw new InvalidOperationException("Failed to get embedded resource '" + embeddedResourceName + "' from replacedembly '" + replacedembly.FullName);
// Write to file
BinaryWriter sw = null;
FileStream fs = null;
try
{
byte[] fileContentsAsBytes = new byte[stream.Length];
stream.Read(fileContentsAsBytes, 0, (int)stream.Length);
FileMode mode = FileMode.CreateNew;
if (File.Exists(fileName))
{
mode = FileMode.Truncate;
}
fs = new FileStream(fileName, mode);
sw = new BinaryWriter(fs);
sw.Write(fileContentsAsBytes);
}
finally
{
if (fs != null)
{
fs.Close();
}
if (sw != null)
{
sw.Close();
}
}
}
19
Source : Zip.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
public static void ExtractZipResource(string destinationPath, replacedembly replacedembly, string resourceName)
{
Directory.CreateDirectory(destinationPath);
//extract to the temp folder
Stream zipStream = replacedembly.GetManifestResourceStream(resourceName);
ZipArchive za = new ZipArchive(zipStream);
za.ExtractToDirectory(destinationPath);
}
19
Source : EmbeddedResourceUtils.cs
with Apache License 2.0
from Anapher
with Apache License 2.0
from Anapher
public static string LoadResourceFile(replacedembly replacedembly, string path)
{
using var stream = replacedembly.GetManifestResourceStream(path);
if (stream == null) throw new InvalidOperationException("Could not load manifest resource stream.");
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
}
19
Source : HotCompiler.cs
with MIT License
from AndreiMisiukevich
with MIT License
from AndreiMisiukevich
public bool TryLoadreplacedembly(string res)
{
try
{
var stream = typeof(HotCompiler).replacedembly.GetManifestResourceStream($"Xamarin.Forms.HotReload.Reloader.res.{res}.dll");
_references.Add(MetadataReference.CreateFromStream(stream));
return true;
}
catch
{
return false;
}
}
19
Source : HotReloader.cs
with MIT License
from AndreiMisiukevich
with MIT License
from AndreiMisiukevich
private async void InitializeElement(object obj, bool hasCodeGenAttr, bool isInjected = false)
{
if (obj == null)
{
return;
}
if (obj is Cell cell && _ignoredElementInit != obj)
{
cell.PropertyChanged += OnCellPropertyChanged;
}
var elementType = obj.GetType();
var clreplacedName = RetrieveClreplacedName(elementType);
if (!_resourceMapping.TryGetValue(clreplacedName, out ReloadItem item))
{
item = new ReloadItem { HasXaml = hasCodeGenAttr };
_resourceMapping[clreplacedName] = item;
if (item.HasXaml)
{
var type = obj.GetType();
var getXamlForType = XamlLoaderType.GetMethod("GetXamlForType", BindingFlags.Static | BindingFlags.NonPublic);
string xaml = null;
try
{
var length = getXamlForType?.GetParameters()?.Length;
if (length.HasValue)
{
switch (length.Value)
{
case 1:
xaml = getXamlForType.Invoke(null, new object[] { type })?.ToString();
break;
case 2:
xaml = getXamlForType.Invoke(null, new object[] { type, true })?.ToString();
break;
case 3:
getXamlForType.Invoke(null, new object[] { type, obj, true })?.ToString();
break;
}
}
}
catch
{
//suppress
}
if (xaml != null)
{
item.Xaml.LoadXml(xaml);
}
else
{
var stream = type.replacedembly.GetManifestResourceStream(type.FullName + ".xaml");
try
{
if (stream == null)
{
var appResName = type.replacedembly.GetManifestResourceNames()
.FirstOrDefault(x => (x.Contains("obj.Debug.") || x.Contains("obj.Release")) && x.Contains(type.Name));
if (!string.IsNullOrWhiteSpace(appResName))
{
stream = type.replacedembly.GetManifestResourceStream(appResName);
}
}
if (stream != null && stream != Stream.Null)
{
using (var reader = new StreamReader(stream))
{
xaml = reader.ReadToEnd();
item.Xaml.LoadXml(xaml);
}
}
}
finally
{
stream?.Dispose();
}
}
}
}
if (!(obj is ResourceDictionary))
{
item.Objects.Add(obj);
}
if (_ignoredElementInit == obj)
{
return;
}
if (!item.HasUpdates && !isInjected)
{
OnLoaded(obj, false);
}
else
{
var code = item.Code;
if (isInjected)
{
code = code?.Replace("HotReloader.Current.InjectComponentInitialization(this)", string.Empty);
}
var csharpType = !string.IsNullOrWhiteSpace(item.Code) ? HotCompiler.Current.Compile(item.Code, obj.GetType().FullName) : null;
if (csharpType != null)
{
await Task.Delay(50);
}
ReloadElement(obj, item, csharpType);
}
}
19
Source : HotReloader.cs
with MIT License
from AndreiMisiukevich
with MIT License
from AndreiMisiukevich
private ReloadItem GereplacedemForReloadingSourceRes(Uri source, object belongObj)
{
if (source?.IsWellFormedOriginalString() ?? false)
{
var resourceId = GetResId(source, belongObj);
using (var resStream = belongObj.GetType().replacedembly.GetManifestResourceStream(resourceId))
{
if (resStream != null && resStream != Stream.Null)
{
using (var resReader = new StreamReader(resStream))
{
var resClreplacedName = RetrieveClreplacedName(resReader.ReadToEnd());
if (_resourceMapping.TryGetValue(resClreplacedName, out ReloadItem resItem))
{
return resItem;
}
}
}
}
}
return null;
}
19
Source : CSharpClassesTab.cs
with MIT License
from AndresTraks
with MIT License
from AndresTraks
private void LoadIcon(string imageName)
{
Stream iconStream = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream($"DotNetWrapperGen.Images.{imageName}.png");
Image icon = Image.FromStream(iconStream);
imageList.Images.Add(imageName, icon);
}
19
Source : PasswordLists.cs
with MIT License
from andrewlock
with MIT License
from andrewlock
private HashSet<string> LoadPreplacedwordList(string listName)
{
HashSet<string> hashset;
var replacedembly = typeof(PreplacedwordLists).GetTypeInfo().replacedembly;
using (var stream = replacedembly.GetManifestResourceStream(Prefix + listName))
{
using (var streamReader = new StreamReader(stream))
{
hashset = new HashSet<string>(
GetLines(streamReader),
StringComparer.OrdinalIgnoreCase);
}
}
_logger.LogDebug("Loaded {NumberCommonPreplacedwords} common preplacedwords from resource {ResourceName}", hashset.Count, listName);
return hashset;
}
19
Source : EventStoreMigrator.cs
with Apache License 2.0
from aneshas
with Apache License 2.0
from aneshas
private string Script()
{
var replacedembly = GetType().replacedembly;
var resourceName = $"{GetType().Namespace}.EventStore.sql";
using var stream = replacedembly.GetManifestResourceStream(resourceName);
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
}
19
Source : MotelsMapPage.xaml.cs
with MIT License
from AngelGarcia13
with MIT License
from AngelGarcia13
void AddMapStyle()
{
var replacedembly = typeof(MotelsMapPage).GetTypeInfo().replacedembly;
var stream = replacedembly.GetManifestResourceStream($"CabanasRD.GoogleMapStyles.json");
string styleFile;
using (var reader = new System.IO.StreamReader(stream))
{
styleFile = reader.ReadToEnd();
}
MotelsMap.MapStyle = MapStyle.FromJson(styleFile);
}
19
Source : EmailTemplateSender.cs
with MIT License
from angelsix
with MIT License
from angelsix
public async Task<SendEmailResponse> SendGeneralEmailAsync(SendEmailDetails details, string replacedle, string content1, string content2, string buttonText, string buttonUrl)
{
var templateText = default(string);
// Read the general template from file
// TODO: Replace with IoC Flat data provider
using (var reader = new StreamReader(replacedembly.GetEntryreplacedembly().GetManifestResourceStream("Fasetto.Word.Web.Server.Email.Templates.GeneralTemplate.htm"), Encoding.UTF8))
{
// Read file contents
templateText = await reader.ReadToEndAsync();
}
// Replace special values with those inside the template
templateText = templateText.Replace("--replacedle--", replacedle)
.Replace("--Content1--", content1)
.Replace("--Content2--", content2)
.Replace("--ButtonText--", buttonText)
.Replace("--ButtonUrl--", buttonUrl);
// Set the details content to this template content
details.Content = templateText;
// Send email
return await DI.EmailSender.SendEmailAsync(details);
}
19
Source : Startup.cs
with Apache License 2.0
from anjoy8
with Apache License 2.0
from anjoy8
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MyContext myContext, ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter, IHostApplicationLifetime lifetime)
{
// Ip限流,尽量放管道外层
app.UseIpLimitMildd();
// 记录请求与返回数据
app.UseReuestResponseLog();
// 用户访问记录(必须放到外层,不然如果遇到异常,会报错,因为不能返回流)
app.UseRecordAccessLogsMildd();
// signalr
app.UseSignalRSendMildd();
// 记录ip请求
app.UseIPLogMildd();
// 查看注入的所有服务
app.UseAllServicesMildd(_services);
if (env.IsDevelopment())
{
// 在开发环境中,使用异常页面,这样可以暴露错误堆栈信息,所以不要放在生产环境。
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// 在非开发环境中,使用HTTP严格安全传输(or HSTS) 对于保护web安全是非常重要的。
// 强制实施 HTTPS 在 ASP.NET Core,配合 app.UseHttpsRedirection
//app.UseHsts();
}
// 封装Swagger展示
app.UseSwaggerMildd(() => GetType().GetTypeInfo().replacedembly.GetManifestResourceStream("Blog.Core.Api.index.html"));
// ↓↓↓↓↓↓ 注意下边这些中间件的顺序,很重要 ↓↓↓↓↓↓
// CORS跨域
app.UseCors(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }));
// 跳转https
//app.UseHttpsRedirection();
// 使用静态文件
app.UseStaticFiles();
// 使用cookie
app.UseCookiePolicy();
// 返回错误码
app.UseStatusCodePages();
// Routing
app.UseRouting();
// 这种自定义授权中间件,可以尝试,但不推荐
// app.UseJwtTokenAuth();
// 测试用户,用来通过鉴权
if (Configuration.GetValue<bool>("AppSettings:UseLoadTest"))
{
app.UseMiddleware<ByPreplacedAuthMidd>();
}
// 先开启认证
app.UseAuthentication();
// 然后是授权中间件
app.UseAuthorization();
//开启性能分析
app.UseMiniProfilerMildd();
// 开启异常中间件,要放到最后
//app.UseExceptionHandlerMidd();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapHub<ChatHub>("/api2/chatHub");
});
// 生成种子数据
app.UseSeedDataMildd(myContext, Env.WebRootPath);
// 开启QuartzNetJob调度服务
app.UseQuartzJobMildd(tasksQzServices, schedulerCenter);
// 服务注册
app.UseConsulMildd(Configuration, lifetime);
// 事件总线,订阅服务
app.ConfigureEventBus();
}
19
Source : Certificate.cs
with MIT License
from anjoy8
with MIT License
from anjoy8
public static X509Certificate2 Get()
{
var replacedembly = typeof(Certificate).GetTypeInfo().replacedembly;
var names = replacedembly.GetManifestResourceNames();
/***********************************************************************************************
* Please note that here we are using a local certificate only for testing purposes. In a
* real environment the certificate should be created and stored in a secure way, which is out
* of the scope of this project.
**********************************************************************************************/
using (var stream = replacedembly.GetManifestResourceStream("Idenreplacedy.API.Certificate.idsrv3test.pfx"))
{
return new X509Certificate2(ReadStream(stream), "idsrv3test");
}
}
19
Source : GeneralHelper.cs
with MIT License
from AnkiTools
with MIT License
from AnkiTools
internal static string ReadResource(string path)
{
return new StreamReader(replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(path)).ReadToEnd();
}
19
Source : MqdfParams.cs
with Apache License 2.0
from AnkiUniversal
with Apache License 2.0
from AnkiUniversal
private static Stream GetResource(string resourceName)
{
replacedembly replacedembly = typeof(MqdfParams).GetTypeInfo().replacedembly;
string[] names = replacedembly.GetManifestResourceNames();
foreach (var name in names)
{
if (name.Contains(resourceName))
return replacedembly.GetManifestResourceStream(name);
}
return null;
}
19
Source : ActionManager.cs
with GNU General Public License v3.0
from anotak
with GNU General Public License v3.0
from anotak
internal void LoadActions(replacedembly asm)
{
Stream actionsdata;
StreamReader actionsreader;
Configuration cfg;
string name, shortname;
bool debugonly;
string[] resnames;
replacedemblyName asmname = asm.GetName();
// Find a resource named Actions.cfg
resnames = asm.GetManifestResourceNames();
foreach(string rn in resnames)
{
// Found one?
if(rn.EndsWith(ACTIONS_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
{
// Get a stream from the resource
actionsdata = asm.GetManifestResourceStream(rn);
actionsreader = new StreamReader(actionsdata, Encoding.ASCII);
// Load configuration from stream
cfg = new Configuration();
cfg.InputConfiguration(actionsreader.ReadToEnd());
if(cfg.ErrorResult)
{
string errordesc = "Error in Actions configuration on line " + cfg.ErrorLine + ": " + cfg.ErrorDescription;
General.CancelAutoMapLoad();
General.ErrorLogger.Add(ErrorType.Error, "Unable to read Actions configuration from replacedembly " + Path.GetFileName(asm.Location));
Logger.WriteLogLine(errordesc);
General.ShowErrorMessage("Unable to read Actions configuration from replacedembly " + Path.GetFileName(asm.Location) + "!\n" + errordesc, MessageBoxButtons.OK);
}
else
{
// Read the categories structure
IDictionary cats = cfg.ReadSetting("categories", new Hashtable());
foreach(DictionaryEntry c in cats)
{
// Make the category if not already added
if(!categories.ContainsKey(c.Key.ToString()))
categories.Add(c.Key.ToString(), c.Value.ToString());
}
// Go for all objects in the configuration
foreach(DictionaryEntry a in cfg.Root)
{
// Get action properties
shortname = a.Key.ToString();
name = asmname.Name.ToLowerInvariant() + "_" + shortname;
debugonly = cfg.ReadSetting(a.Key + ".debugonly", false);
// Not the categories structure?
if(shortname.ToLowerInvariant() != "categories")
{
// Check if action should be included
if(General.DebugBuild || !debugonly)
{
// Create an action
CreateAction(cfg, name, shortname);
}
}
}
}
// Done with the resource
actionsreader.Dispose();
actionsdata.Dispose();
}
}
}
19
Source : ResourceImage.cs
with GNU General Public License v3.0
from anotak
with GNU General Public License v3.0
from anotak
protected override void LocalLoadImage()
{
Stream bitmapdata;
lock(this)
{
// No failure checking here. I anything fails here, it is not the user's fault,
// because the resources this loads are in the replacedembly.
// Get resource from memory
bitmapdata = replacedembly.GetManifestResourceStream(resourcename);
if(bitmap != null) bitmap.Dispose();
bitmap = (Bitmap)Image.FromStream(bitmapdata);
bitmapdata.Dispose();
// Preplaced on to base
base.LocalLoadImage();
}
}
19
Source : Plugin.cs
with GNU General Public License v3.0
from anotak
with GNU General Public License v3.0
from anotak
public Stream GetResourceStream(string resourcename)
{
string[] resnames;
// Find a resource
resnames = asm.GetManifestResourceNames();
foreach(string rn in resnames)
{
// Found it?
if(rn.EndsWith(resourcename, StringComparison.InvariantCultureIgnoreCase))
{
// Get a stream from the resource
return asm.GetManifestResourceStream(rn);
}
}
// Nothing found
return null;
}
19
Source : KHPCPatchManager.cs
with Apache License 2.0
from AntonioDePau
with Apache License 2.0
from AntonioDePau
static replacedembly CurrentDomain_replacedemblyResolve(object sender, ResolveEventArgs args){
var replacedemblyName = new replacedemblyName(args.Name).Name + ".dll";
var resourceName = EmbeddedLibraries.FirstOrDefault(x => x.EndsWith(replacedemblyName));
if(resourceName == null){
return null;
}
using (var stream = Executingreplacedembly.GetManifestResourceStream(resourceName)){
var bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
return replacedembly.Load(bytes);
}
}
19
Source : KHPCPatchManager.cs
with Apache License 2.0
from AntonioDePau
with Apache License 2.0
from AntonioDePau
static void UpdateResources(){
string resourceName = Executingreplacedembly.GetManifestResourceNames().Single(str => str.EndsWith("resources.zip"));
using (Stream stream = Executingreplacedembly.GetManifestResourceStream(resourceName)){
ZipFile zip = ZipFile.Read(stream);
Directory.CreateDirectory("resources");
zip.ExtractSelectedEntries("*.txt", "resources", "", ExtractExistingFileAction.OverwriteSilently);
}
}
19
Source : Il2cppContext.cs
with GNU General Public License v3.0
from anydream
with GNU General Public License v3.0
from anydream
public static void SaveToFolder(string folder, List<CompileUnit> units, HashSet<string> addUnitNames, string addParams = null)
{
Directory.CreateDirectory(folder);
HashSet<string> unitNames = new HashSet<string>(addUnitNames);
foreach (var unit in units)
{
if (!string.IsNullOrEmpty(unit.DeclCode))
{
string path = Path.Combine(folder, unit.Name + ".h");
File.WriteAllBytes(path, Encoding.UTF8.GetBytes(unit.DeclCode));
}
if (!string.IsNullOrEmpty(unit.ImplCode))
{
unitNames.Add(unit.Name);
string path = Path.Combine(folder, unit.Name + ".cpp");
File.WriteAllBytes(path, Encoding.UTF8.GetBytes(unit.ImplCode));
}
}
// 生成编译脚本
StringBuilder sb = new StringBuilder();
sb.AppendLine("@echo off");
sb.AppendFormat("BuildTheCode -addcflags \"-DGC_THREADS\" {0} il2cpp.cpp", addParams);
foreach (string unitName in unitNames)
sb.AppendFormat(" {0}.cpp", unitName);
sb.AppendLine();
File.WriteAllText(Path.Combine(folder, "build.cmd"), sb.ToString());
// 释放运行时代码
string strRuntimePack = "il2cpp.runtime.zip";
var zip = new FastZip();
zip.ExtractZip(replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(strRuntimePack),
folder,
FastZip.Overwrite.Always,
null, null, null, false, true);
}
19
Source : SystemTrayIcons.cs
with GNU General Public License v3.0
from AnyStatus
with GNU General Public License v3.0
from AnyStatus
private static Icon Load(string name)
{
try
{
return new Icon(replacedembly.GetExecutingreplacedembly().GetManifestResourceStream(Prefix + name), SystemInformation.SmallIconSize);
}
catch
{
return SystemIcons.Information;
}
}
19
Source : TestRunner.cs
with MIT License
from apdevelop
with MIT License
from apdevelop
private static byte[] ReadResource(string id)
{
var replacedembly = System.Reflection.replacedembly.GetExecutingreplacedembly();
var resourceName = replacedembly.GetName().Name + "." + id;
byte[] data = null;
using (var stream = replacedembly.GetManifestResourceStream(resourceName))
{
data = new byte[stream.Length];
stream.Read(data, 0, (int)stream.Length);
}
return data;
}
19
Source : TestBase.cs
with MIT License
from apexsharp
with MIT License
from apexsharp
private Stream GetZipResource(string fileName)
{
var replacedembly = typeof(TestBase).GetTypeInfo().replacedembly;
return replacedembly.GetManifestResourceStream($"{replacedembly.GetName().Name}.ZipFiles.{fileName}.zip");
}
19
Source : ZipFile.SaveSelfExtractor.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
private void _SaveSfxStub(string exeToGenerate, SelfExtractorSaveOptions options)
{
string nameOfIconFile = null;
string stubExe = null;
string unpackedResourceDir = null;
string tmpDir = null;
try
{
if (File.Exists(exeToGenerate))
{
if (Verbose) StatusMessageTextWriter.WriteLine("The existing file ({0}) will be overwritten.", exeToGenerate);
}
if (!exeToGenerate.EndsWith(".exe"))
{
if (Verbose) StatusMessageTextWriter.WriteLine("Warning: The generated self-extracting file will not have an .exe extension.");
}
// workitem 10553
tmpDir = TempFileFolder ?? Path.GetDirectoryName(exeToGenerate);
stubExe = GenerateTempPathname(tmpDir, "exe");
// get the Ionic.Zip replacedembly
replacedembly a1 = typeof(ZipFile).replacedembly;
using (var csharp = new Microsoft.CSharp.CSharpCodeProvider
(new Dictionary<string,string>() { { "CompilerVersion", "v2.0" } })) {
// The following is a perfect opportunity for a linq query, but
// I cannot use it. DotNetZip needs to run on .NET 2.0,
// and using LINQ would break that. Here's what it would look
// like:
//
// var settings = (from x in SettingsList
// where x.Flavor == flavor
// select x).First();
ExtractorSettings settings = null;
foreach (var x in SettingsList)
{
if (x.Flavor == options.Flavor)
{
settings = x;
break;
}
}
// sanity check; should never happen
if (settings == null)
throw new BadStateException(String.Format("While saving a Self-Extracting Zip, Cannot find that flavor ({0})?", options.Flavor));
// This is the list of referenced replacedemblies. Ionic.Zip is
// needed here. Also if it is the winforms (gui) extractor, we
// need other referenced replacedemblies, like
// System.Windows.Forms.dll, etc.
var cp = new System.CodeDom.Compiler.CompilerParameters();
cp.Referencedreplacedemblies.Add(a1.Location);
if (settings.Referencedreplacedemblies != null)
foreach (string ra in settings.Referencedreplacedemblies)
cp.Referencedreplacedemblies.Add(ra);
cp.GenerateInMemory = false;
cp.GenerateExecutable = true;
cp.IncludeDebugInformation = false;
cp.CompilerOptions = "";
replacedembly a2 = replacedembly.GetExecutingreplacedembly();
// Use this to concatenate all the source code resources into a
// single module.
var sb = new System.Text.StringBuilder();
// In case there are compiler errors later, we allocate a source
// file name now. If errors are detected, we'll spool the source
// code as well as the errors (in comments) into that filename,
// and throw an exception with the filename. Makes it easier to
// diagnose. This should be rare; most errors happen only
// during devlpmt of DotNetZip itself, but there are rare
// occasions when they occur in other cases.
string sourceFile = GenerateTempPathname(tmpDir, "cs");
// // debugging: enumerate the resources in this replacedembly
// Console.WriteLine("Resources in this replacedembly:");
// foreach (string rsrc in a2.GetManifestResourceNames())
// {
// Console.WriteLine(rsrc);
// }
// Console.WriteLine();
// all the source code is embedded in the DLL as a zip file.
using (ZipFile zip = ZipFile.Read(a2.GetManifestResourceStream("Ionic.Zip.Resources.ZippedResources.zip")))
{
// // debugging: enumerate the files in the embedded zip
// Console.WriteLine("Entries in the embbedded zip:");
// foreach (ZipEntry entry in zip)
// {
// Console.WriteLine(entry.FileName);
// }
// Console.WriteLine();
unpackedResourceDir = GenerateTempPathname(tmpDir, "tmp");
if (String.IsNullOrEmpty(options.IconFile))
{
// Use the ico file that is embedded into the Ionic.Zip
// DLL itself. To do this we must unpack the icon to
// the filesystem, in order to specify it on the cmdline
// of csc.exe. This method will remove the unpacked
// file later.
System.IO.Directory.CreateDirectory(unpackedResourceDir);
ZipEntry e = zip["zippedFile.ico"];
// Must not extract a readonly file - it will be impossible to
// delete later.
if ((e.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
e.Attributes ^= FileAttributes.ReadOnly;
e.Extract(unpackedResourceDir);
nameOfIconFile = Path.Combine(unpackedResourceDir, "zippedFile.ico");
cp.CompilerOptions += String.Format("/win32icon:\"{0}\"", nameOfIconFile);
}
else
cp.CompilerOptions += String.Format("/win32icon:\"{0}\"", options.IconFile);
cp.Outputreplacedembly = stubExe;
if (options.Flavor == SelfExtractorFlavor.WinFormsApplication)
cp.CompilerOptions += " /target:winexe";
if (!String.IsNullOrEmpty(options.AdditionalCompilerSwitches))
cp.CompilerOptions += " " + options.AdditionalCompilerSwitches;
if (String.IsNullOrEmpty(cp.CompilerOptions))
cp.CompilerOptions = null;
if ((settings.CopyThroughResources != null) && (settings.CopyThroughResources.Count != 0))
{
if (!Directory.Exists(unpackedResourceDir)) System.IO.Directory.CreateDirectory(unpackedResourceDir);
foreach (string re in settings.CopyThroughResources)
{
string filename = Path.Combine(unpackedResourceDir, re);
ExtractResourceToFile(a2, re, filename);
// add the file into the target replacedembly as an embedded resource
cp.EmbeddedResources.Add(filename);
}
}
// add the Ionic.Utils.Zip DLL as an embedded resource
cp.EmbeddedResources.Add(a1.Location);
// file header
sb.Append("// " + Path.GetFileName(sourceFile) + "\n")
.Append("// --------------------------------------------\n//\n")
.Append("// This SFX source file was generated by DotNetZip ")
.Append(ZipFile.LibraryVersion.ToString())
.Append("\n// at ")
.Append(System.DateTime.Now.ToString("yyyy MMMM dd HH:mm:ss"))
.Append("\n//\n// --------------------------------------------\n\n\n");
// replacedembly attributes
if (!String.IsNullOrEmpty(options.Description))
sb.Append("[replacedembly: System.Reflection.replacedemblyreplacedle(\""
+ options.Description.Replace("\"", "")
+ "\")]\n");
else
sb.Append("[replacedembly: System.Reflection.replacedemblyreplacedle(\"DotNetZip SFX Archive\")]\n");
if (!String.IsNullOrEmpty(options.ProductVersion))
sb.Append("[replacedembly: System.Reflection.replacedemblyInformationalVersion(\""
+ options.ProductVersion.Replace("\"", "")
+ "\")]\n");
// workitem
string copyright =
(String.IsNullOrEmpty(options.Copyright))
? "Extractor: Copyright � Dino Chiesa 2008-2011"
: options.Copyright.Replace("\"", "");
if (!String.IsNullOrEmpty(options.ProductName))
sb.Append("[replacedembly: System.Reflection.replacedemblyProduct(\"")
.Append(options.ProductName.Replace("\"", ""))
.Append("\")]\n");
else
sb.Append("[replacedembly: System.Reflection.replacedemblyProduct(\"DotNetZip\")]\n");
sb.Append("[replacedembly: System.Reflection.replacedemblyCopyright(\"" + copyright + "\")]\n")
.Append(String.Format("[replacedembly: System.Reflection.replacedemblyVersion(\"{0}\")]\n", ZipFile.LibraryVersion.ToString()));
if (options.FileVersion != null)
sb.Append(String.Format("[replacedembly: System.Reflection.replacedemblyFileVersion(\"{0}\")]\n",
options.FileVersion.ToString()));
sb.Append("\n\n\n");
// Set the default extract location if it is available
string extractLoc = options.DefaultExtractDirectory;
if (extractLoc != null)
{
// remove double-quotes and replace slash with double-slash.
// This, because the value is going to be embedded into a
// cs file as a quoted string, and it needs to be escaped.
extractLoc = extractLoc.Replace("\"", "").Replace("\\", "\\\\");
}
string postExCmdLine = options.PostExtractCommandLine;
if (postExCmdLine != null)
{
postExCmdLine = postExCmdLine.Replace("\\", "\\\\");
postExCmdLine = postExCmdLine.Replace("\"", "\\\"");
}
foreach (string rc in settings.ResourcesToCompile)
{
using (Stream s = zip[rc].OpenReader())
{
if (s == null)
throw new ZipException(String.Format("missing resource '{0}'", rc));
using (StreamReader sr = new StreamReader(s))
{
while (sr.Peek() >= 0)
{
string line = sr.ReadLine();
if (extractLoc != null)
line = line.Replace("@@EXTRACTLOCATION", extractLoc);
line = line.Replace("@@REMOVE_AFTER_EXECUTE", options.RemoveUnpackedFilesAfterExecute.ToString());
line = line.Replace("@@QUIET", options.Quiet.ToString());
if (!String.IsNullOrEmpty(options.SfxExeWindowreplacedle))
line = line.Replace("@@SFX_EXE_WINDOW_replacedLE", options.SfxExeWindowreplacedle);
line = line.Replace("@@EXTRACT_EXISTING_FILE", ((int)options.ExtractExistingFile).ToString());
if (postExCmdLine != null)
line = line.Replace("@@POST_UNPACK_CMD_LINE", postExCmdLine);
sb.Append(line).Append("\n");
}
}
sb.Append("\n\n");
}
}
}
string LiteralSource = sb.ToString();
#if DEBUGSFX
// for debugging only
string sourceModule = GenerateTempPathname(tmpDir, "cs");
using (StreamWriter sw = File.CreateText(sourceModule))
{
sw.Write(LiteralSource);
}
Console.WriteLine("source: {0}", sourceModule);
#endif
var cr = csharp.CompilereplacedemblyFromSource(cp, LiteralSource);
if (cr == null)
throw new SfxGenerationException("Cannot compile the extraction logic!");
if (Verbose)
foreach (string output in cr.Output)
StatusMessageTextWriter.WriteLine(output);
if (cr.Errors.Count != 0)
{
using (TextWriter tw = new StreamWriter(sourceFile))
{
// first, the source we compiled
tw.Write(LiteralSource);
// now, append the compile errors
tw.Write("\n\n\n// ------------------------------------------------------------------\n");
tw.Write("// Errors during compilation: \n//\n");
string p = Path.GetFileName(sourceFile);
foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors)
{
tw.Write(String.Format("// {0}({1},{2}): {3} {4}: {5}\n//\n",
p, // 0
error.Line, // 1
error.Column, // 2
error.IsWarning ? "Warning" : "error", // 3
error.ErrorNumber, // 4
error.ErrorText)); // 5
}
}
throw new SfxGenerationException(String.Format("Errors compiling the extraction logic! {0}", sourceFile));
}
OnSaveEvent(ZipProgressEventType.Saving_AfterCompileSelfExtractor);
// Now, copy the resulting EXE image to the _writestream.
// Because this stub exe is being saved first, the effect will be to
// concatenate the exe and the zip data together.
using (System.IO.Stream input = System.IO.File.OpenRead(stubExe))
{
byte[] buffer = new byte[4000];
int n = 1;
while (n != 0)
{
n = input.Read(buffer, 0, buffer.Length);
if (n != 0)
WriteStream.Write(buffer, 0, n);
}
}
}
OnSaveEvent(ZipProgressEventType.Saving_AfterSaveTempArchive);
}
finally
{
try
{
if (Directory.Exists(unpackedResourceDir))
{
try { Directory.Delete(unpackedResourceDir, true); }
catch (System.IO.IOException exc1)
{
StatusMessageTextWriter.WriteLine("Warning: Exception: {0}", exc1);
}
}
if (File.Exists(stubExe))
{
try { File.Delete(stubExe); }
catch (System.IO.IOException exc1)
{
StatusMessageTextWriter.WriteLine("Warning: Exception: {0}", exc1);
}
}
}
catch (System.IO.IOException) { }
}
return;
}
19
Source : ZipFile.SaveSelfExtractor.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
private static void ExtractResourceToFile(replacedembly a, string resourceName, string filename)
{
int n = 0;
byte[] bytes = new byte[1024];
using (Stream instream = a.GetManifestResourceStream(resourceName))
{
if (instream == null)
throw new ZipException(String.Format("missing resource '{0}'", resourceName));
using (FileStream outstream = File.OpenWrite(filename))
{
do
{
n = instream.Read(bytes, 0, bytes.Length);
outstream.Write(bytes, 0, n);
} while (n > 0);
}
}
}
19
Source : TestBase.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
[TestInitialize]
public void InitBase()
{
_clipartPath = Path.Combine(Path.GetTempPath(), @"EPPlus clipart");
if (!Directory.Exists(_clipartPath))
{
Directory.CreateDirectory(_clipartPath);
}
if(Environment.GetEnvironmentVariable("EPPlusTestInputPath")!=null)
{
_testInputPath = Environment.GetEnvironmentVariable("EPPlusTestInputPath");
}
var asm = replacedembly.GetExecutingreplacedembly();
var validExtensions = new[]
{
".gif", ".wmf"
};
foreach (var name in asm.GetManifestResourceNames())
{
foreach (var ext in validExtensions)
{
if (name.EndsWith(ext, StringComparison.OrdinalIgnoreCase))
{
string fileName = name.Replace("EPPlusTest.Resources.", "");
using (var stream = asm.GetManifestResourceStream(name))
using (var file = File.Create(Path.Combine(_clipartPath, fileName)))
{
stream.CopyTo(file);
}
break;
}
}
}
//_worksheetPath = Path.Combine(Path.GetTempPath(), @"EPPlus worksheets");
//if (!Directory.Exists(_worksheetPath))
//{
// Directory.CreateDirectory(_worksheetPath);
//}
var di=new DirectoryInfo(_worksheetPath);
_worksheetPath = di.FullName + "\\";
_pck = new ExcelPackage();
}
19
Source : WorksheetsTests.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
[TestMethod, Ignore]
public void DeleteFirstTwoColumnsFromRangeColumnsShouldBeDeleted()
{
// Arrange
ExcelPackage pck = new ExcelPackage();
using (
Stream file =
replacedembly.GetExecutingreplacedembly().GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
{
pck.Load(file);
}
var wsData = pck.Workbook.Worksheets[1];
// Act
wsData.DeleteColumn(1, 2);
pck.SaveAs(new FileInfo(OutputDirectory + "AfterDeleteColumn.xlsx"));
// replacedert
replacedert.AreEqual("First Name", wsData.Cells["A1"].Text);
replacedert.AreEqual("Family Name", wsData.Cells["B1"].Text);
}
19
Source : WorksheetsTests.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
[TestMethod,Ignore]
public void DeleteFirstColumnInRangeColumnShouldBeDeleted()
{
// Arrange
ExcelPackage pck = new ExcelPackage();
using (
Stream file =
replacedembly.GetExecutingreplacedembly().GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
{
pck.Load(file);
}
var wsData = pck.Workbook.Worksheets[1];
// Act
wsData.DeleteColumn(1);
pck.SaveAs(new FileInfo(OutputDirectory + "AfterDeleteColumn.xlsx"));
// replacedert
replacedert.AreEqual("replacedle", wsData.Cells["A1"].Text);
replacedert.AreEqual("First Name", wsData.Cells["B1"].Text);
replacedert.AreEqual("Family Name", wsData.Cells["C1"].Text);
}
19
Source : WorksheetsTests.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
[TestMethod, Ignore]
public void DeleteLastColumnInRangeColumnShouldBeDeleted()
{
// Arrange
ExcelPackage pck = new ExcelPackage();
using (
Stream file =
replacedembly.GetExecutingreplacedembly().GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
{
pck.Load(file);
}
var wsData = pck.Workbook.Worksheets[1];
// Act
wsData.DeleteColumn(4);
pck.SaveAs(new FileInfo(OutputDirectory + "AfterDeleteColumn.xlsx"));
// replacedert
replacedert.AreEqual("Id", wsData.Cells["A1"].Text);
replacedert.AreEqual("replacedle", wsData.Cells["B1"].Text);
replacedert.AreEqual("First Name", wsData.Cells["C1"].Text);
}
19
Source : WorksheetsTests.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
[TestMethod, Ignore]
public void DeleteColumnAfterNormalRangeSheetShouldRemainUnchanged()
{
// Arrange
ExcelPackage pck = new ExcelPackage();
using (
Stream file =
replacedembly.GetExecutingreplacedembly().GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
{
pck.Load(file);
}
var wsData = pck.Workbook.Worksheets[1];
// Act
wsData.DeleteColumn(5);
pck.SaveAs(new FileInfo(OutputDirectory + "AfterDeleteColumn.xlsx"));
// replacedert
replacedert.AreEqual("Id", wsData.Cells["A1"].Text);
replacedert.AreEqual("replacedle", wsData.Cells["B1"].Text);
replacedert.AreEqual("First Name", wsData.Cells["C1"].Text);
replacedert.AreEqual("Family Name", wsData.Cells["D1"].Text);
}
19
Source : WorksheetsTests.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
[TestMethod, Ignore]
[ExpectedException(typeof(ArgumentException))]
public void DeleteColumnBeforeRangeMimitThrowsArgumentException()
{
// Arrange
ExcelPackage pck = new ExcelPackage();
using (
Stream file =
replacedembly.GetExecutingreplacedembly().GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
{
pck.Load(file);
}
var wsData = pck.Workbook.Worksheets[1];
// Act
wsData.DeleteColumn(0);
// replacedert
replacedert.Fail();
}
See More Examples