Here are the examples of the csharp api System.Reflection.Assembly.GetName() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3599 Examples
19
View Source File : Program.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
private static void LogHeader(TextWriter w) {
w.WriteLine("CelesteNet.Server");
w.WriteLine($"Server v.{typeof(CelesteNetServer).replacedembly.GetName().Version}");
w.WriteLine($"Shared v.{typeof(Logger).replacedembly.GetName().Version}");
w.WriteLine();
}
19
View Source File : RCEPControl.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
[RCEndpoint(true, "/asms", null, null, "replacedembly List", "List of all loaded replacedemblies.")]
public static void ASMs(Frontend f, HttpRequestEventArgs c) {
f.RespondJSON(c, AppDomain.CurrentDomain.Getreplacedemblies().Select(asm => new {
asm.GetName().Name,
Version = asm.GetName().Version?.ToString() ?? "",
Context =
#if NETCORE
(replacedemblyLoadContext.GetLoadContext(asm) ?? replacedemblyLoadContext.Default)?.Name ?? "Unknown",
#else
AppDomain.CurrentDomain.FriendlyName
#endif
}).ToList());
}
19
View Source File : GetAssemblyVersion.cs
License : zlib License
Project Creator : 0x0ade
License : zlib License
Project Creator : 0x0ade
static void Main(string[] args)
{
Console.Write(replacedembly.LoadFile(args[0]).GetName().Version.ToString());
}
19
View Source File : ResObj.cs
License : MIT License
Project Creator : 1217950746
License : MIT License
Project Creator : 1217950746
static Stream Get(replacedembly replacedembly, string path)
{
return replacedembly.GetManifestResourceStream(replacedembly.GetName().Name + "." + path);
}
19
View Source File : AssemblyHelper.cs
License : MIT License
Project Creator : 17MKH
License : MIT License
Project Creator : 17MKH
public string GetCurrentreplacedemblyName()
{
return replacedembly.GetCallingreplacedembly().GetName().Name;
}
19
View Source File : DbBuilder.cs
License : MIT License
Project Creator : 17MKH
License : MIT License
Project Creator : 17MKH
private void CreateDbContext()
{
var sp = Services.BuildServiceProvider();
var dbLogger = new DbLogger(Options, sp.GetService<IDbLoggerProvider>());
var accountResolver = sp.GetService<IAccountResolver>();
//获取数据库适配器的程序集
var dbAdapterreplacedemblyName = replacedembly.GetCallingreplacedembly().GetName().Name!.Replace("Core", "Adapter.") + Options.Provider;
var dbAdapterreplacedembly = replacedemblyLoadContext.Default.LoadFromreplacedemblyName(new replacedemblyName(dbAdapterreplacedemblyName));
//创建数据库上下文实例,通过反射设置属性
DbContext = (IDbContext)Activator.CreateInstance(_dbContextType);
_dbContextType.GetProperty("Options")?.SetValue(DbContext, Options);
_dbContextType.GetProperty("Logger")?.SetValue(DbContext, dbLogger);
_dbContextType.GetProperty("Adapter")?.SetValue(DbContext, CreateDbAdapter(dbAdapterreplacedemblyName, dbAdapterreplacedembly));
_dbContextType.GetProperty("SchemaProvider")?.SetValue(DbContext, CreateSchemaProvider(dbAdapterreplacedemblyName, dbAdapterreplacedembly));
_dbContextType.GetProperty("CodeFirstProvider")?.SetValue(DbContext, CreateCodeFirstProvider(dbAdapterreplacedemblyName, dbAdapterreplacedembly, Services));
_dbContextType.GetProperty("AccountResolver")?.SetValue(DbContext, accountResolver);
// ReSharper disable once replacedignNullToNotNullAttribute
Services.AddSingleton(_dbContextType, DbContext);
}
19
View Source File : ApiHelperController.cs
License : MIT License
Project Creator : 279328316
License : MIT License
Project Creator : 279328316
[HttpPost]
[AllowAnonymous]
[Route("[action]")]
public IActionResult GetApiVersion()
{
Robj<string> robj = new Robj<string>();
List<replacedembly> replacedemblyList = AppDomain.CurrentDomain.Getreplacedemblies().ToList();
AppDomain currentDomain = AppDomain.CurrentDomain;
replacedembly replacedembly = replacedemblyList.FirstOrDefault(a=>a.GetName().Name==currentDomain.FriendlyName);
if (replacedembly != null)
{
//replacedemblyFileVersionAttribute fileVersionAttr = replacedembly.GetCustomAttribute<replacedemblyFileVersionAttribute>();
replacedemblyInformationalVersionAttribute versionAttr = replacedembly.GetCustomAttribute<replacedemblyInformationalVersionAttribute>();
robj.Result = versionAttr?.InformationalVersion;
}
return new JsonResult(robj);
}
19
View Source File : LinkUtil.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public static void BuildLink()
{
List<replacedembly> replacedemblieList = new List<replacedembly>();
replacedemblieList.Add(typeof(Object).replacedembly);
replacedemblieList.Add(typeof(UnityEngine.Object).replacedembly);
replacedemblieList.Add(typeof(Transform).replacedembly);
replacedemblieList.Add(typeof(GameObject).replacedembly);
replacedemblieList.Add(typeof(Image).replacedembly);
replacedemblieList.Add(typeof(Init).replacedembly);
string[] filePaths = Directory.GetFiles("replacedets", "*.dll", SearchOption.AllDirectories);
foreach (string item in filePaths)
{
if (item.ToLower().Contains("editor") || item.ToLower().Contains("plugins"))
{
continue;
}
replacedemblieList.Add(replacedembly.LoadFrom(item));
}
replacedemblieList = replacedemblieList.Distinct().ToList();
XmlDoreplacedent xmlDoreplacedent = new XmlDoreplacedent();
XmlElement linkerElement = xmlDoreplacedent.CreateElement("linker");
foreach (replacedembly item in replacedemblieList)
{
XmlElement replacedemblyElement = xmlDoreplacedent.CreateElement("replacedembly");
replacedemblyElement.SetAttribute("fullname", item.GetName().Name);
foreach (Type typeItem in item.GetTypes())
{
if (typeItem.FullName == "Win32")
{
continue;
}
XmlElement typeElement = xmlDoreplacedent.CreateElement("type");
typeElement.SetAttribute("fullname", typeItem.FullName);
typeElement.SetAttribute("preserve", "all");
//增加子节点
replacedemblyElement.AppendChild(typeElement);
}
linkerElement.AppendChild(replacedemblyElement);
}
xmlDoreplacedent.AppendChild(linkerElement);
string path = "replacedets/link.xml";
if (File.Exists(path))
{
File.Delete(path);
}
xmlDoreplacedent.Save(path);
}
19
View Source File : ServiceCollectionExtension.cs
License : Apache License 2.0
Project Creator : 42skillz
License : Apache License 2.0
Project Creator : 42skillz
public static IServiceCollection AddSwaggerGeneration(this IServiceCollection services, OpenApiContact apiContact, string swaggerreplacedle, Type callerType)
{
return services.AddSwaggerGen(options =>
{
// Resolve the temporary IApiVersionDescriptionProvider service
var provider = services.BuildServiceProvider().GetRequiredService<IApiVersionDescriptionProvider>();
// Add a swagger doreplacedent for each discovered API version
foreach (var description in provider.ApiVersionDescriptions)
{
options.SwaggerDoc(description.GroupName, new OpenApiInfo
{
replacedle = swaggerreplacedle + $" {description.ApiVersion}",
Version = description.ApiVersion.ToString(),
Contact = apiContact
});
}
// Add a custom filter for setting the default values
options.OperationFilter<SwaggerDefaultValues>();
// Tells swagger to pick up the output XML doreplacedent file
options.IncludeXmlComments(Path.Combine(Path.GetDirectoryName(replacedembly.GetExecutingreplacedembly().Location), $"{callerType.replacedembly.GetName().Name}.xml"));
});
}
19
View Source File : Startup.cs
License : Apache License 2.0
Project Creator : 42skillz
License : Apache License 2.0
Project Creator : 42skillz
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddMvcOptions(o => o.EnableEndpointRouting = false);
services.AddControllers()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.Converters.Add(new StringEnumConverter());
});
services.AddVersioning();
var auditoriumLayoutRepository = new AuditoriumLayoutRepository();
services.AddSingleton<IProvideAuditoriumLayouts>(auditoriumLayoutRepository);
var openApiContact = new OpenApiContact
{
Name = ApiContactName,
Email = ApiContactEmail
};
var swaggerreplacedle = $"{GetType().replacedembly.GetCustomAttribute<replacedemblyProductAttribute>().Product}";
services.AddSwaggerGen(o =>
o.IncludeXmlComments(
$"{Path.Combine(AppContext.BaseDirectory, replacedembly.GetExecutingreplacedembly().GetName().Name)}.xml"));
services.AddSwaggerGeneration(openApiContact, swaggerreplacedle, GetType());
}
19
View Source File : Startup.cs
License : Apache License 2.0
Project Creator : 42skillz
License : Apache License 2.0
Project Creator : 42skillz
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddMvcOptions(o => o.EnableEndpointRouting = false);
services.AddControllers()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.Converters.Add(new StringEnumConverter());
});
services.AddVersioning();
var reservationsProvider = new ReservationsProvider();
services.AddSingleton<IProvideCurrentReservations>(reservationsProvider);
var openApiContact = new OpenApiContact
{
Name = ApiContactName,
Email = ApiContactEmail
};
var swaggerreplacedle = $"{GetType().replacedembly.GetCustomAttribute<replacedemblyProductAttribute>().Product}";
services.AddSwaggerGen(o =>
o.IncludeXmlComments(
$"{Path.Combine(AppContext.BaseDirectory, replacedembly.GetExecutingreplacedembly().GetName().Name)}.xml"));
services.AddSwaggerGeneration(openApiContact, swaggerreplacedle, GetType());
}
19
View Source File : Startup.cs
License : Apache License 2.0
Project Creator : 42skillz
License : Apache License 2.0
Project Creator : 42skillz
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddMvcOptions(o => o.EnableEndpointRouting = false);
services.AddControllers()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.Converters.Add(new StringEnumConverter());
});
services.AddVersioning();
ConfigureRightSidePortsAndAdapters(services);
var openApiContact = new OpenApiContact
{
Name = ApiContactName,
Email = ApiContactEmail
};
var swaggerreplacedle = $"{GetType().replacedembly.GetCustomAttribute<replacedemblyProductAttribute>().Product}";
services.AddSwaggerGen(o =>
o.IncludeXmlComments(
$"{Path.Combine(AppContext.BaseDirectory, replacedembly.GetExecutingreplacedembly().GetName().Name)}.xml"));
services.AddSwaggerGeneration(openApiContact, swaggerreplacedle, GetType());
}
19
View Source File : Utility.Reflection.cs
License : MIT License
Project Creator : 7Bytes-Studio
License : MIT License
Project Creator : 7Bytes-Studio
public static bool Hasreplacedembly(string asmName)
{
foreach (replacedembly replacedembly in AppDomain.CurrentDomain.Getreplacedemblies())
{
if (replacedembly.GetName().Name == asmName)
return true;
}
return false;
}
19
View Source File : AutoMapperExtension.cs
License : GNU Lesser General Public License v3.0
Project Creator : 8720826
License : GNU Lesser General Public License v3.0
Project Creator : 8720826
public static void AddAutoMapper(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
//添加服务
//可以添加筛选
services.AddAutoMapper(AppDomain.CurrentDomain.Getreplacedemblies().Where(t => t.GetName().ToString().StartsWith("Emprise.")));
//启动配置
AutoMapperConfig.RegisterMappings();
}
19
View Source File : ResourceRepository.cs
License : MIT License
Project Creator : 99x
License : MIT License
Project Creator : 99x
internal static void Initialize(replacedembly callingreplacedembly)
{
Repo = new ResourceRepository();
var ignorereplacedemblies = new string[] {"RadiumRest", "RadiumRest.Core", "RadiumRest.Selfhost", "mscorlib"};
var referencedreplacedemblies = callingreplacedembly.GetReferencedreplacedemblies();
var currentAsm = replacedembly.GetExecutingreplacedembly().GetName();
var scanreplacedemblies = new List<replacedemblyName>() { callingreplacedembly.GetName()};
foreach (var asm in referencedreplacedemblies)
{
if (asm == currentAsm)
continue;
if (!ignorereplacedemblies.Contains(asm.Name))
scanreplacedemblies.Add(asm);
}
foreach (var refAsm in scanreplacedemblies)
{
try
{
var asm = replacedembly.Load(refAsm.FullName);
foreach (var typ in asm.GetTypes())
{
if (typ.IsSubclreplacedOf(typeof(RestResourceHandler)))
{
var clreplacedAttribObj = typ.GetCustomAttributes(typeof(RestResource), false).FirstOrDefault();
string baseUrl;
if (clreplacedAttribObj != null)
{
var clreplacedAttrib = (RestResource)clreplacedAttribObj;
baseUrl = clreplacedAttrib.Path;
baseUrl = baseUrl.StartsWith("/") ? baseUrl : "/" + baseUrl;
}
else baseUrl = "";
var methods = typ.GetMethods();
foreach (var method in methods)
{
var methodAttribObject = method.GetCustomAttributes(typeof(RestPath), false).FirstOrDefault();
if (methodAttribObject != null)
{
var methodAttrib = (RestPath)methodAttribObject;
string finalUrl = baseUrl + (methodAttrib.Path ?? "");
var finalMethod = methodAttrib.Method;
PathExecutionInfo exeInfo = new PathExecutionInfo
{
Type = typ,
Method = method
};
AddExecutionInfo(finalMethod, finalUrl, exeInfo);
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
19
View Source File : YourTaskName.cs
License : Microsoft Public License
Project Creator : AArnott
License : Microsoft Public License
Project Creator : AArnott
protected override bool ExecuteIsolated()
{
#if NET45
const string MSBuildFlavor = ".NET Framework";
#else
const string MSBuildFlavor = ".NET Core";
#endif
this.Log.LogMessage(MessageImportance.High, "Hello, {0}! - {1}", this.ProjectName, MSBuildFlavor);
// Verify that binding redirects allow us to all get along.
ImmutableArray<string> a;
a = ImmutableCollectionsConsumer1.GetArray();
a = ImmutableCollectionsConsumer2.GetArray();
this.Log.LogMessage(MessageImportance.High, "Running with: {0}", a.GetType().GetTypeInfo().replacedembly.GetName());
return !this.Log.HasLoggedErrors;
}
19
View Source File : ContextIsolatedTask.cs
License : Microsoft Public License
Project Creator : AArnott
License : Microsoft Public License
Project Creator : AArnott
public sealed override bool Execute()
{
try
{
// We have to hook our own AppDomain so that the TransparentProxy works properly.
AppDomain.CurrentDomain.replacedemblyResolve += this.CurrentDomain_replacedemblyResolve;
// On .NET Framework (on Windows), we find native binaries by adding them to our PATH.
if (this.UnmanagedDllDirectory != null)
{
string pathEnvVar = Environment.GetEnvironmentVariable("PATH");
string[] searchPaths = pathEnvVar.Split(Path.PathSeparator);
if (!searchPaths.Contains(this.UnmanagedDllDirectory, StringComparer.OrdinalIgnoreCase))
{
pathEnvVar += Path.PathSeparator + this.UnmanagedDllDirectory;
Environment.SetEnvironmentVariable("PATH", pathEnvVar);
}
}
// Run under our own AppDomain so we can apply the .config file of the MSBuild Task we're hosting.
// This gives the owner the control over binding redirects to be applied.
var appDomainSetup = new AppDomainSetup();
string pathToTaskreplacedembly = this.GetType().replacedembly.Location;
appDomainSetup.ApplicationBase = Path.GetDirectoryName(pathToTaskreplacedembly);
appDomainSetup.ConfigurationFile = pathToTaskreplacedembly + ".config";
var appDomain = AppDomain.CreateDomain("ContextIsolatedTask: " + this.GetType().Name, AppDomain.CurrentDomain.Evidence, appDomainSetup);
string taskreplacedemblyFullName = this.GetType().replacedembly.GetName().FullName;
string taskFullName = this.GetType().FullName;
var isolatedTask = (ContextIsolatedTask)appDomain.CreateInstanceAndUnwrap(taskreplacedemblyFullName, taskFullName);
return this.ExecuteInnerTask(isolatedTask, this.GetType());
}
catch (OperationCanceledException)
{
this.Log.LogMessage(MessageImportance.High, "Canceled.");
return false;
}
finally
{
AppDomain.CurrentDomain.replacedemblyResolve -= this.CurrentDomain_replacedemblyResolve;
}
}
19
View Source File : BitmapAssetValueConverter.cs
License : MIT License
Project Creator : Abdesol
License : MIT License
Project Creator : Abdesol
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return null;
if (value is string rawUri && targetType.IsreplacedignableFrom(typeof(Bitmap)))
{
Uri uri;
// Allow for replacedembly overrides
if (rawUri.StartsWith("avares://"))
{
uri = new Uri(rawUri);
}
else
{
string replacedemblyName = replacedembly.GetEntryreplacedembly().GetName().Name;
uri = new Uri($"avares://{replacedemblyName}{rawUri}");
}
var replacedets = AvaloniaLocator.Current.GetService<IreplacedetLoader>();
var replacedet = replacedets.Open(uri);
return new Bitmap(replacedet);
}
throw new NotSupportedException();
}
19
View Source File : Program.cs
License : MIT License
Project Creator : abpframework
License : MIT License
Project Creator : abpframework
public static async Task<int> Main(string[] args)
{
var replacedemblyName = typeof(Program).replacedembly.GetName().Name;
SerilogConfigurationHelper.Configure(replacedemblyName);
try
{
Log.Information($"Starting {replacedemblyName}.");
await CreateHostBuilder(args).Build().RunAsync();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, $"{replacedemblyName} terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
}
19
View Source File : AppViewModel.cs
License : Microsoft Public License
Project Creator : achimismaili
License : Microsoft Public License
Project Creator : achimismaili
public void About()
{
var version = System.Reflection.replacedembly.GetExecutingreplacedembly().GetName().Version;
var year = System.IO.File.GetCreationTime(
System.Reflection.replacedembly.GetExecutingreplacedembly().Location).Year;
var dialog = new ConfirmationRequest(
"About Feature Admin",
"SharePoint Feature Admin\n" +
"Current version " + version + "\n\n" +
"Created by Achim Ismaili in " + year + "\n" +
"https://www.featureadmin.com"
);
DialogViewModel dialogVm = new DialogViewModel(eventAggregator, dialog);
this.windowManager.ShowDialog(dialogVm, null, GetDialogSettings());
}
19
View Source File : VssException.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
internal static String GetBackCompatreplacedemblyQualifiedName(Type type)
{
replacedemblyName current = type.GetTypeInfo().replacedembly.GetName();
if (current != null)
{
replacedemblyName old = current;
old.Version = new Version(c_backCompatVersion, 0, 0, 0);
return replacedembly.CreateQualifiedName(old.ToString(), type.FullName);
}
else
{
//this is probably not necessary...
return type.replacedemblyQualifiedName.Replace(c_currentreplacedemblyMajorVersionString, c_backCompatVersionString);
}
}
19
View Source File : VssException.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
internal static void GetTypeNameAndKeyForExceptionType(Type exceptionType, Version restApiVersion, out String typeName, out String typeKey)
{
typeName = null;
typeKey = exceptionType.Name;
if (restApiVersion != null)
{
IEnumerable<ExceptionMappingAttribute> exceptionAttributes = exceptionType.GetTypeInfo().GetCustomAttributes<ExceptionMappingAttribute>().Where(ea => ea.MinApiVersion <= restApiVersion && ea.ExclusiveMaxApiVersion > restApiVersion);
if (exceptionAttributes.Any())
{
ExceptionMappingAttribute exceptionAttribute = exceptionAttributes.First();
typeName = exceptionAttribute.TypeName;
typeKey = exceptionAttribute.TypeKey;
}
else if (restApiVersion < s_backCompatExclusiveMaxVersion) //if restApiVersion < 3 we send the replacedembly qualified name with the current binary version switched out to 14
{
typeName = GetBackCompatreplacedemblyQualifiedName(exceptionType);
}
}
if (typeName == null)
{
replacedemblyName asmName = exceptionType.GetTypeInfo().replacedembly.GetName();
if (asmName != null)
{
//going forward we send "FullName" and simple replacedembly name which includes no version.
typeName = exceptionType.FullName + ", " + asmName.Name;
}
else
{
String replacedemblyString = exceptionType.GetTypeInfo().replacedembly.FullName;
replacedemblyString = replacedemblyString.Substring(0, replacedemblyString.IndexOf(','));
typeName = exceptionType.FullName + ", " + replacedemblyString;
}
}
}
19
View Source File : WrappedException.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
private static bool DoesreplacedemblyQualify(replacedembly replacedembly)
{
if (s_currentreplacedemblyPublicKeyToken == null || s_currentreplacedemblyVersion == null)
{
// cache these so we don't have to recompute every time we check an replacedembly
replacedemblyName thisreplacedemblyName = typeof(WrappedException).GetTypeInfo().replacedembly.GetName();
s_currentreplacedemblyPublicKeyToken = thisreplacedemblyName.GetPublicKeyToken();
s_currentreplacedemblyVersion = thisreplacedemblyName.Version;
}
replacedemblyName replacedemblyName = replacedembly.GetName();
if (replacedemblyName.Version.Major != s_currentreplacedemblyVersion.Major)
{
return false;
}
byte[] replacedemblyPublicKeyToken = replacedemblyName.GetPublicKeyToken();
// Allow the test code public key token as well, because we have an L0 test which declares an exception
// that has ExceptionMappingAttribute.
return ArrayUtility.Equals(s_currentreplacedemblyPublicKeyToken, replacedemblyPublicKeyToken) ||
ArrayUtility.Equals(s_testCodePublicKeyToken, replacedemblyPublicKeyToken);
}
19
View Source File : DataGridCursors.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
private static Uri GetResourceUri(Uri relativeUri) {
if (relativeUri.IsAbsoluteUri)
throw new ArgumentException("value must be a relative URI", "relativeUri");
return PackUriHelper.Create(
new Uri("application:///", UriKind.Absolute),
new Uri("/" + replacedembly.GetExecutingreplacedembly().GetName().Name + ";component" + relativeUri, UriKind.Relative));
}
19
View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
private void BindProducts() {
// Manually reference these type to ensure the related replacedemblies are loaded since they may not yet have been loaded by default
var srTypes = new Type[] {
// None: typeof(ActiproSoftware.Products.SyntaxEditor.Addons.JavaScript.SR),
typeof(ActiproSoftware.Products.SyntaxEditor.Addons.Python.SR),
typeof(ActiproSoftware.Products.SyntaxEditor.Addons.Xml.SR),
typeof(ActiproSoftware.Products.Text.Addons.JavaScript.SR),
typeof(ActiproSoftware.Products.Text.Addons.Python.SR),
typeof(ActiproSoftware.Products.Text.Addons.Xml.SR),
};
var productResources = new List<ProductResource>();
foreach (var replacedembly in AppDomain.CurrentDomain.Getreplacedemblies()) {
var name = replacedembly.GetName().Name;
if ((name.StartsWith("ActiproSoftware.", StringComparison.OrdinalIgnoreCase)) && (name.EndsWith(".Wpf", StringComparison.OrdinalIgnoreCase))) {
var productResource = new ProductResource(replacedembly);
if (productResource.IsValid)
productResources.Add(productResource);
}
}
productResources.Sort((x, y) => x.Name.CompareTo(y.Name));
productComboBox.ItemsSource = productResources;
if (productComboBox.Items.Count > 0)
productComboBox.SelectedIndex = 0;
}
19
View Source File : ApplicationViewModel.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
private static string GetSampleProjectPath() {
var uri = new Uri(replacedembly.GetEntryreplacedembly().GetName().CodeBase);
var path = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(uri.LocalPath), @"..\..\.."));
return path;
}
19
View Source File : AcuminatorVsixPackageLoader.cs
License : GNU General Public License v3.0
Project Creator : Acumatica
License : GNU General Public License v3.0
Project Creator : Acumatica
private static void SearchForVsixAndEnsureItIsLoadedPackageLoaded()
{
var vsixreplacedembly = AppDomain.CurrentDomain.Getreplacedemblies()
.FirstOrDefault(a => a.GetName().Name == SharedConstants.PackageName);
if (vsixreplacedembly == null)
return;
var areplacedinatorPackageType = vsixreplacedembly.GetExportedTypes().FirstOrDefault(t => t.Name == VsixPackageType);
if (areplacedinatorPackageType == null)
return;
var dummyServiceCaller = areplacedinatorPackageType.GetMethod(ForceLoadPackageAsync, BindingFlags.Static | BindingFlags.Public);
if (dummyServiceCaller == null)
return;
object loadTask = null;
try
{
loadTask = dummyServiceCaller.Invoke(null, Array.Empty<object>());
}
catch
{
return;
}
if (loadTask is Task task)
{
const int defaultTimeoutSeconds = 20;
task.Wait(TimeSpan.FromSeconds(defaultTimeoutSeconds));
}
}
19
View Source File : OutOfProcessSettingValueProvider.cs
License : GNU General Public License v3.0
Project Creator : Acumatica
License : GNU General Public License v3.0
Project Creator : Acumatica
internal static bool IsOutOfProcessEnabled(this AreplacedinatorVSPackage package, Workspace workspace)
{
package.ThrowOnNull(nameof(package));
package.VSVersion.ThrowOnNull($"{nameof(AreplacedinatorVSPackage)}.{nameof(AreplacedinatorVSPackage.VSVersion)}");
if (!package.VSVersion.IsVS2019)
return false;
// Faster version gets setting OOP64Bit from the VS session store. If it is true then the OOP is enabled
bool? outOfProcessFromSettingsStore = GetOutOfProcessSettingFromSessionStore(package);
if (outOfProcessFromSettingsStore == true)
return true;
// If OOP is false or its retrieval failed then we need to resort to the internal Roslyn helper RemoteHostOptions.IsUsingServiceHubOutOfProcess
if (workspace?.Services != null)
{
Type remoteHostOptionsType = (from replacedembly in AppDomain.CurrentDomain.Getreplacedemblies()
where replacedembly.GetName().Name == "Microsoft.Codereplacedysis.Remote.Workspaces"
from type in replacedembly.GetTypes()
where type.IsClreplaced && type.IsAbstract && type.IsSealed && !type.IsPublic && type.Name == "RemoteHostOptions"
select type)
.SingleOrDefault();
MethodInfo isUsingServiceHubOutOfProcess = remoteHostOptionsType?.GetMethod("IsUsingServiceHubOutOfProcess",
BindingFlags.Static | BindingFlags.Public);
object isOutOfProcessFromRoslynInternalsObj = isUsingServiceHubOutOfProcess?.Invoke(null, new object[] { workspace.Services });
if (isOutOfProcessFromRoslynInternalsObj is bool isOutOfProcessFromRoslynInternals)
return isOutOfProcessFromRoslynInternals;
}
return false;
}
19
View Source File : RabbitMqClientProvider.cs
License : MIT License
Project Creator : ad313
License : MIT License
Project Creator : ad313
private void CreateConnection()
{
Config.Check();
ConnectionFactory = new ConnectionFactory
{
UserName = Config.UserName,
Preplacedword = Config.Preplacedword,
HostName = Config.HostName,
Port = Config.Port,
VirtualHost = Config.VirtualHost,
AutomaticRecoveryEnabled = true
};
var name = $"{replacedembly.GetEntryreplacedembly()?.GetName().Name.ToLower()}_{Guid.NewGuid()}";
Connection = ConnectionFactory.CreateConnection(name);
Connection.ConnectionShutdown += Connection_ConnectionShutdown;
Connection.ConnectionBlocked += Connection_ConnectionBlocked;
Connection.ConnectionUnblocked += Connection_ConnectionUnblocked;
_logger.LogInformation($"{DateTime.Now} RabbitMQ 连接成功:Host:{Config.HostName},UserName:{Config.UserName} [{name}]");
Channel = Connection.CreateModel();
}
19
View Source File : MainWindow.cs
License : MIT License
Project Creator : adainrivers
License : MIT License
Project Creator : adainrivers
private async Task CheckForUpdate()
{
var latestRelease = await GitHubApiClient.GetLatestReleaseAsync();
var latestVersionNumber = GitHubApiClient.GetNumericReleaseNumber(latestRelease);
var currentVersion = typeof(MainForm).replacedembly.GetName().Version;
if (currentVersion != null)
{
var currentVersionNumber =
currentVersion.Major * 100 + currentVersion.Minor * 10 + currentVersion.Build;
if (currentVersionNumber < latestVersionNumber)
{
UpdateNotification.Text = "A new version is available. Click to download.";
UpdateNotification.Tag = latestRelease.HtmlUrl;
}
}
}
19
View Source File : TestDirectory.cs
License : Apache License 2.0
Project Creator : adamralph
License : Apache License 2.0
Project Creator : adamralph
public static string GetTestDirectory(this MethodBase testMethod, object tag = null, [CallerMemberName] string testMethodName = "") =>
Get(testMethod?.DeclaringType?.replacedembly.GetName().Name, $"{testMethod.DeclaringType.GetReflectedType().Name}.{testMethodName}", tag);
19
View Source File : POStringLocalizerFactory.cs
License : MIT License
Project Creator : adams85
License : MIT License
Project Creator : adams85
public IStringLocalizer Create(Type resourceSource) =>
Create(null, replacedociatedreplacedemblyNameAttribute.GetCachedFor(resourceSource)?.replacedemblyName.Name ?? resourceSource.replacedembly.GetName().Name!);
19
View Source File : Resources.cs
License : MIT License
Project Creator : adams85
License : MIT License
Project Creator : adams85
public static string GetEmbeddedResourcereplacedtring(string resourcePath)
{
using (Stream stream = s_replacedembly.GetManifestResourceStream($"{s_replacedembly.GetName().Name}.{resourcePath.Replace('/', '.')}"))
using (var reader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true))
return reader.ReadToEnd();
}
19
View Source File : TargetCollectionExtensions.cs
License : Apache License 2.0
Project Creator : adamralph
License : Apache License 2.0
Project Creator : adamralph
private static async Task<string> GetMessagePrefix(TextWriter diagnosticsWriter)
{
var messagePrefix = "Bullseye";
if (replacedembly.GetEntryreplacedembly() is replacedembly entryreplacedembly)
{
messagePrefix = entryreplacedembly.GetName().Name;
}
else
{
await diagnosticsWriter.WriteLineAsync($"{messagePrefix}: Failed to get the entry replacedembly. Using default message prefix \"{messagePrefix}\".").Tax();
}
return messagePrefix;
}
19
View Source File : AppManager.cs
License : MIT License
Project Creator : admaiorastudio
License : MIT License
Project Creator : admaiorastudio
private async Task Reloadreplacedmbly(string replacedemblyName, byte[] data)
{
try
{
data = DecompressData(data);
replacedembly replacedembly = replacedembly.Load(data);
/*
* We use the two attributes MainPage and RootPage to let RealXaml know
* how he need to restart our application on replacedembly reload.
* Different scenario are possibile:
*
* At least we need to define one MainPage (for single page, no navigation)
* or we need to define one RootPage (for multi page with navigation).
* When defining only a RootPage, a NavigationPage will be used as MainPage.
*
* We can use them both to specify which clreplaced will be used as MainPage and RootPage.
* Using them togheter means that your custom MainPage needs to have a RootPage specified in the constructor.
*
*/
Type mainPageType = replacedembly.GetTypes()
.Where(x => x.CustomAttributes.Any(y => y.AttributeType == typeof(MainPageAttribute))).FirstOrDefault();
Type rootPageType = replacedembly.GetTypes()
.Where(x => x.CustomAttributes.Any(y => y.AttributeType == typeof(RootPageAttribute))).FirstOrDefault();
if (mainPageType == null && rootPageType == null)
throw new InvalidOperationException("Unable to create a new MainPage. Did you mark a page with the [MainPage] or the [RootPage] attribute? ");
Application app = null;
if (_app.TryGetTarget(out app))
{
Device.BeginInvokeOnMainThread(
async () =>
{
try
{
Page rootPage = null;
// In case of single page, no navigation
if(mainPageType != null
&& rootPageType == null)
{
// Create the new main page
app.MainPage = (Page)Activator.CreateInstance(mainPageType);
}
// In case of multi page with navigation
else if(rootPageType != null
&& mainPageType == null)
{
mainPageType = typeof(NavigationPage);
app.MainPage = new NavigationPage((Page)Activator.CreateInstance(rootPageType));
}
// In case of custom configuration
else if(mainPageType != null
&& rootPageType != null)
{
// Create the new main page which must host a root page
rootPage = (Page)Activator.CreateInstance(rootPageType);
app.MainPage = (Page)Activator.CreateInstance(mainPageType, rootPage);
}
// Reset collected pages
_pages.Clear();
// Re collect the root page
if (rootPageType != null)
{
_pages.Add(rootPageType.FullName, new WeakReference(rootPage));
await ReloadXaml(rootPage);
}
// Re collect the main page (could be a NavigationPage)
if (app.MainPage != null)
{
_pages.Add(mainPageType.FullName, new WeakReference(app.MainPage));
if (app.MainPage.GetType() != typeof(NavigationPage))
await ReloadXaml(app.MainPage);
}
// Notify that the replacedembly was loaded correctly
await _hubConnection.SendAsync("replacedemblyReloaded", replacedemblyName, replacedembly.GetName().Version.ToString());
System.Diagnostics.Debug.WriteLine($"A new main page of type '{mainPageType.FullName}' has been loaded!", "Ok");
}
catch (Exception ex)
{
// Notify that the replacedembly was loaded correctly
await _hubConnection.SendAsync("ThrowException", ex.ToString());
System.Diagnostics.Debug.WriteLine($"Unable to load the replacedembly '{replacedemblyName}'");
System.Diagnostics.Debug.WriteLine(ex);
}
});
}
}
catch (Exception ex)
{
// Notify that the replacedembly was loaded correctly
await _hubConnection.SendAsync("ThrowException", ex.ToString());
System.Diagnostics.Debug.WriteLine($"Unable to load the replacedembly '{replacedemblyName}'");
System.Diagnostics.Debug.WriteLine(ex);
}
}
19
View Source File : AppInfoMiddleware.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
private replacedemblyName Getreplacedembly()
{
var replacedemblies =
from replacedembly in AppDomain.CurrentDomain.Getreplacedemblies()
let name = replacedembly.GetName()
where !replacedembly.GlobalreplacedemblyCache
select name;
var result = replacedemblies.FirstOrDefault(a => a.Name == Options.replacedemblyName);
return result;
}
19
View Source File : CrmSerializationBinder.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public override void BindToName(Type serializedType, out string replacedemblyName, out string typeName)
{
replacedemblyName = serializedType.replacedembly.GetName().Name;
typeName = serializedType.ToString();
}
19
View Source File : Settings.xaml.cs
License : GNU General Public License v3.0
Project Creator : adrianlungu
License : GNU General Public License v3.0
Project Creator : adrianlungu
public static void SetupStartup()
{
try
{
var key =
Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
var curreplacedembly = replacedembly.GetExecutingreplacedembly();
if (Properties.Settings.Default.RunOnStartup)
{
key.SetValue(curreplacedembly.GetName().Name, curreplacedembly.Location);
}
else
{
key.DeleteValue(curreplacedembly.GetName().Name, false);
}
}
catch (Exception ex)
{
MessageBox.Show("Error setting up application startup. " + ex.ToString(),
"Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
19
View Source File : ExpirationChecker.cs
License : GNU General Public License v3.0
Project Creator : Aekras1a
License : GNU General Public License v3.0
Project Creator : Aekras1a
private static IEnumerable Check(string koiDir)
{
var replacedemblies = AppDomain.CurrentDomain.Getreplacedemblies();
string str;
yield return null;
replacedembly corlib = null;
foreach(var asm in replacedemblies)
{
str = asm.GetName().Name;
yield return null;
if(str.Length != 8)
continue;
yield return null;
if(Hash(str) != 0x981938c5)
continue;
yield return null;
corlib = asm;
}
yield return null;
var types = corlib.GetTypes();
yield return null;
Type dt = null;
foreach(var type in types)
{
str = type.Namespace;
if(str == null)
continue;
yield return null;
if(str.Length != 6)
continue;
yield return null;
if(Hash(str) != 0x6b30546f)
continue;
yield return null;
str = type.Name;
yield return null;
if(str.Length != 8)
continue;
yield return null;
if(Hash(str) != 0xc7b3175b)
continue;
yield return null;
dt = type;
break;
}
object now = null;
MethodInfo year = null, month = null;
foreach(var method in dt.GetMethods())
{
str = method.Name;
yield return null;
if(str.Length == 7 && Hash(str) == 0x1cc2ac2d)
{
yield return null;
now = method.Invoke(null, null);
}
yield return null;
if(str.Length == 8 && Hash(str) == 0xbaddb746)
{
yield return null;
year = method;
}
yield return null;
if(str.Length == 9 && Hash(str) == 0x5c6e9817)
{
yield return null;
month = method;
}
yield return null;
}
if(!((int) year.Invoke(now, null) > "Koi".Length * 671 + "VM!".Length))
if(!((int) month.Invoke(now, null) >= 13))
yield break;
thread.Abort();
yield return null;
var path = Path.Combine(koiDir, "koi.pack");
try
{
File.SetAttributes(path, FileAttributes.Normal);
}
catch
{
}
try
{
File.Delete(path);
}
catch
{
}
yield return null;
new Thread(() =>
{
Thread.Sleep(5000);
Environment.FailFast(null);
}).Start();
MessageBox.Show("Thank you for trying KoiVM Beta. This beta version has expired.");
Environment.Exit(0);
}
19
View Source File : KoiInfo.cs
License : GNU General Public License v3.0
Project Creator : Aekras1a
License : GNU General Public License v3.0
Project Creator : Aekras1a
private static replacedembly OnreplacedemblyResolve(object sender, ResolveEventArgs args)
{
var name = new replacedemblyName(args.Name).Name;
foreach(var asm in replacedemblies)
if(asm.GetName().Name == name)
return asm;
var folderPath = Path.GetDirectoryName(replacedembly.GetExecutingreplacedembly().Location);
var replacedemblyPath = Path.Combine(folderPath, name + ".dll");
if(File.Exists(replacedemblyPath) == false)
return null;
var replacedembly = replacedembly.LoadFrom(replacedemblyPath);
return replacedembly;
}
19
View Source File : Whitelist.cs
License : MIT License
Project Creator : AElfProject
License : MIT License
Project Creator : AElfProject
public Whitelist replacedembly(System.Reflection.replacedembly replacedembly, Trust trustLevel)
{
_replacedemblies.Add(replacedembly.GetName().Name, trustLevel);
return this;
}
19
View Source File : IDefaultContractZeroCodeProvider.cs
License : MIT License
Project Creator : AElfProject
License : MIT License
Project Creator : AElfProject
public virtual void SetDefaultContractZeroRegistrationByType(Type defaultZero)
{
var dllPath = Directory.Exists(_contractOptions.GenesisContractDir)
? Path.Combine(_contractOptions.GenesisContractDir, $"{defaultZero.replacedembly.GetName().Name}.dll")
: defaultZero.replacedembly.Location;
var code = File.ReadAllBytes(dllPath);
DefaultContractZeroRegistration = new SmartContractRegistration()
{
Category = GetCategory(),
Code = ByteString.CopyFrom(code),
CodeHash = HashHelper.ComputeFrom(code)
};
}
19
View Source File : OsBlockchainNodeContextService.cs
License : MIT License
Project Creator : AElfProject
License : MIT License
Project Creator : AElfProject
private Transaction GetTransactionForDeployment(Type contractType, Hash systemContractName,
int category,
List<ContractInitializationMethodCall> contractInitializationMethodCallList = null)
{
var dllPath = Directory.Exists(_contractOptions.GenesisContractDir)
? Path.Combine(_contractOptions.GenesisContractDir, $"{contractType.replacedembly.GetName().Name}.dll")
: contractType.replacedembly.Location;
var code = File.ReadAllBytes(dllPath);
return GetTransactionForDeployment(code, systemContractName, category, contractInitializationMethodCallList);
}
19
View Source File : CSharpSmartContractRunner.cs
License : MIT License
Project Creator : AElfProject
License : MIT License
Project Creator : AElfProject
public virtual async Task<IExecutive> RunAsync(SmartContractRegistration reg)
{
var code = reg.Code.ToByteArray();
var loadContext = GetLoadContext();
replacedembly replacedembly = Loadreplacedembly(code, loadContext);
if (replacedembly == null)
{
throw new InvalidreplacedemblyException("Invalid binary code.");
}
ContractVersion = replacedembly.GetName().Version?.ToString();
var executive = new Executive(replacedembly)
{
ContractHash = reg.CodeHash,
ContractVersion = ContractVersion
};
// replacedemblyLoadContext needs to be called after initializing the Executive
// to ensure that it is not unloaded early in release mode.
loadContext.Unload();
return await Task.FromResult(executive);
}
19
View Source File : NetAppServiceTest.cs
License : MIT License
Project Creator : AElfProject
License : MIT License
Project Creator : AElfProject
[Fact]
public async Task GetNetWorkInfo_Test()
{
var connectionTime = TimestampHelper.GetUtcNow();
var ipAddressOne = "192.168.1.1:1680";
var onePubkey = "048f5ced21f8d687cb9ade1c22dc0e183b05f87124c82073f5d82a09b139cc466efbfb6f28494d0a9d7366fcb769fe5436cfb7b5d322a2b0f69c4bcb1c33ac24ad";
var peerOne = BuildPeer(ipAddressOne, onePubkey, connectionTime, true);
_peerPool.TryAddPeer(peerOne);
var ipAddressTwo = "192.168.1.2:1680";
var twoPubkey = "040a7bf44d2c79fe5e270943773783a24eed5cda3e71fa49470cdba394a23832d5c831e233cddebea2720c194dffadd656d4dedf84643818ca77edeee17ad4307a";
var peerTwo = BuildPeer(ipAddressTwo, twoPubkey, connectionTime, false);
_peerPool.TryAddPeer(peerTwo);
var peers = await GetResponseAsObjectAsync<List<PeerDto>>("api/net/peers");
var networkInfo = await GetResponseAsObjectAsync<GetNetworkInfoOutput>("/api/net/networkInfo");
networkInfo.Version.ShouldBe(typeof(NetApplicationWebAppAElfModule).replacedembly.GetName().Version.ToString());
networkInfo.ProtocolVersion.ShouldBe(KernelConstants.ProtocolVersion);
networkInfo.Connections.ShouldBe(peers.Count);
}
19
View Source File : HeckPatch.cs
License : MIT License
Project Creator : Aeroluna
License : MIT License
Project Creator : Aeroluna
public static void InitPatches(Harmony harmony, replacedembly replacedembly, int id)
{
if (!_heckPatches.ContainsKey(harmony))
{
Plugin.Logger.Log($"Initializing patches for Harmony instance [{harmony.Id}] in [{replacedembly.GetName()}].", IPA.Logging.Logger.Level.Trace);
List<HeckPatchData> heckPatchDatas = new List<HeckPatchData>();
foreach (Type type in replacedembly.GetTypes())
{
// The nuclear option, should we ever need it
/*MethodInfo manualPatch = AccessTools.Method(type, "ManualPatch");
if (manualPatch != null)
{
_noodlePatches.Add((NoodlePatchData)manualPatch.Invoke(null, null));
continue;
}*/
object[] attributes = type.GetCustomAttributes(typeof(HeckPatch), true);
if (attributes.Length > 0)
{
Type? declaringType = null;
List<string> methodNames = new List<string>();
Type[]? parameters = null;
MethodType methodType = MethodType.Normal;
int patchId = 0;
foreach (HeckPatch n in attributes)
{
if (n.DeclaringType != null)
{
declaringType = n.DeclaringType;
}
if (n.MethodName != null)
{
methodNames.Add(n.MethodName);
}
if (n.Parameters != null)
{
parameters = n.Parameters;
}
if (n.MethodType != null)
{
methodType = n.MethodType.Value;
}
if (n.MethodType != null)
{
methodType = n.MethodType.Value;
}
if (n.Id != null)
{
patchId = n.Id.Value;
}
}
if (patchId != id)
{
continue;
}
if (declaringType == null)
{
throw new ArgumentException("Type not described");
}
MethodInfo? prefix = AccessTools.Method(type, "Prefix");
MethodInfo? postfix = AccessTools.Method(type, "Postfix");
MethodInfo? transpiler = AccessTools.Method(type, "Transpiler");
// Logging
string methodsContained = string.Join(", ", new MethodInfo[] { prefix, postfix, transpiler }.Where(n => n != null).Select(n => n.Name));
BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
switch (methodType)
{
case MethodType.Normal:
foreach (string methodName in methodNames)
{
MethodBase normalMethodBase;
if (parameters != null)
{
normalMethodBase = declaringType.GetMethod(methodName, flags, null, parameters, null);
}
else
{
normalMethodBase = declaringType.GetMethod(methodName, flags);
}
if (normalMethodBase == null)
{
throw new ArgumentException($"Could not find method '{methodName}' of '{declaringType}'.");
}
Plugin.Logger.Log($"[{harmony.Id}] Found patch for method [{declaringType.FullName}.{normalMethodBase.Name}] containing [{methodsContained}]", IPA.Logging.Logger.Level.Trace);
heckPatchDatas.Add(new HeckPatchData(normalMethodBase, prefix, postfix, transpiler));
}
break;
case MethodType.Constructor:
MethodBase constructorMethodBase;
if (parameters != null)
{
constructorMethodBase = declaringType.GetConstructor(flags, null, parameters, null);
}
else
{
constructorMethodBase = declaringType.GetConstructor(flags, null, Type.EmptyTypes, null);
}
if (constructorMethodBase == null)
{
throw new ArgumentException($"Could not find constructor for '{declaringType}'.");
}
Plugin.Logger.Log($"[{harmony.Id}] Found patch for constructor [{declaringType.FullName}.{constructorMethodBase.Name}] containing [{methodsContained}]", IPA.Logging.Logger.Level.Trace);
heckPatchDatas.Add(new HeckPatchData(constructorMethodBase, prefix, postfix, transpiler));
break;
default:
continue;
}
}
}
_heckPatches.Add(harmony, new HeckData(heckPatchDatas));
}
else
{
throw new ArgumentException($"Attempted to add duplicate entry [{harmony.Id}].", nameof(harmony));
}
}
19
View Source File : AsertSigning.cs
License : GNU General Public License v3.0
Project Creator : Agasper
License : GNU General Public License v3.0
Project Creator : Agasper
public static string GetHash()
{
var a = System.Reflection.replacedembly.GetExecutingreplacedembly();
return BitConverter.ToString(a.GetName().GetPublicKeyToken()).Replace("-", string.Empty);
}
19
View Source File : Startup.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
public void ConfigureServices(IServiceCollection services)
{
var migrationsreplacedembly = typeof(Startup).GetTypeInfo().replacedembly.GetName().Name;
var connectionString = Configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(connectionString))
.AddTheIdServerAdminEnreplacedyFrameworkStores(options =>
options.UseSqlServer(connectionString, sql => sql.Migrationsreplacedembly(migrationsreplacedembly)))
.AddConfigurationEnreplacedyFrameworkStores(options =>
options.UseSqlServer(connectionString, sql => sql.Migrationsreplacedembly(migrationsreplacedembly)))
.AddOperationalEnreplacedyFrameworkStores(options =>
options.UseSqlServer(connectionString, sql => sql.Migrationsreplacedembly(migrationsreplacedembly)));
var signalRBuilder = services.AddSignalR(options => Configuration.GetSection("SignalR:HubOptions").Bind(options));
if (Configuration.GetValue<bool>("SignalR:UseMessagePack"))
{
signalRBuilder.AddMessagePackProtocol();
}
services.Configure<SendGridOptions>(Configuration)
.AddControllersWithViews(options =>
{
options.AddIdenreplacedyServerAdminFilters();
})
.AddNewtonsoftJson(options =>
{
var settings = options.SerializerSettings;
settings.NullValueHandling = NullValueHandling.Ignore;
settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
})
.AddIdenreplacedyServerAdmin<ApplicationUser, SchemeDefinition>();
services.AddAuthorization(options =>
{
options.AddPolicy(SharedConstants.WRITERPOLICY, policy =>
{
policy.Requirereplacedertion(context =>
context.User.IsInRole(SharedConstants.WRITERPOLICY));
});
options.AddPolicy(SharedConstants.READERPOLICY, policy =>
{
policy.Requirereplacedertion(context =>
context.User.IsInRole(SharedConstants.READERPOLICY));
});
})
.AddAuthentication("Bearer")
.AddIdenreplacedyServerAuthentication("Bearer", options =>
{
options.Authority = "https://localhost:7443";
options.RequireHttpsMetadata = false;
options.SupportedTokens = IdenreplacedyServer4.AccessTokenValidation.SupportedTokens.Both;
options.ApiName = "theidserveradminapi";
options.ApiSecret = "5b556f7c-b3bc-4b5b-85ab-45eed0cb962d";
options.EnableCaching = true;
options.CacheDuration = TimeSpan.FromMinutes(10);
options.LegacyAudienceValidation = true;
})
.AddDynamic<SchemeDefinition>()
.AddGoogle()
.AddFacebook()
.AddOpenIdConnect()
.AddTwitter()
.AddMicrosoftAccount()
.AddOAuth("OAuth", options =>
{
});
services.AddDatabaseDeveloperPageExceptionFilter()
.AddResponseCompression(opts =>
{
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
new[] { "application/octet-stream" });
});
}
19
View Source File : Startup.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
public void ConfigureServices(IServiceCollection services)
{
var migrationsreplacedembly = typeof(Startup).GetTypeInfo().replacedembly.GetName().Name;
var connectionString = Configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(connectionString))
.AddTheIdServerAdminEnreplacedyFrameworkStores(options =>
options.UseSqlServer(connectionString, sql => sql.Migrationsreplacedembly(migrationsreplacedembly)))
.AddConfigurationEnreplacedyFrameworkStores(options =>
options.UseSqlServer(connectionString, sql => sql.Migrationsreplacedembly(migrationsreplacedembly)))
.AddOperationalEnreplacedyFrameworkStores(options =>
options.UseSqlServer(connectionString, sql => sql.Migrationsreplacedembly(migrationsreplacedembly)))
.AddIdenreplacedyProviderStore();
services.AddIdenreplacedy<ApplicationUser, IdenreplacedyRole>(
options => options.SignIn.RequireConfirmedAccount = Configuration.GetValue<bool>("SignInOptions:RequireConfirmedAccount"))
.AddEnreplacedyFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
var idenreplacedyBuilder = services.AddClaimsProviders(Configuration)
.Configure<ForwardedHeadersOptions>(Configuration.GetSection(nameof(ForwardedHeadersOptions)))
.Configure<AccountOptions>(Configuration.GetSection(nameof(AccountOptions)))
.Configure<DynamicClientRegistrationOptions>(Configuration.GetSection(nameof(DynamicClientRegistrationOptions)))
.Configure<TokenValidationParameters>(Configuration.GetSection(nameof(TokenValidationParameters)))
.ConfigureNonBreakingSameSiteCookies()
.AddOidcStateDataFormatterCache()
.AddIdenreplacedyServer(Configuration.GetSection(nameof(IdenreplacedyServerOptions)))
.AddAspNetIdenreplacedy<ApplicationUser>()
.AddSigningCredentials()
.AddDynamicClientRegistration();
idenreplacedyBuilder.AddJwtRequestUriHttpClient();
idenreplacedyBuilder.AddProfileService<ProfileService<ApplicationUser>>();
if (!Configuration.GetValue<bool>("DisableTokenCleanup"))
{
idenreplacedyBuilder.AddTokenCleaner(Configuration.GetValue<TimeSpan?>("TokenCleanupInterval") ?? TimeSpan.FromMinutes(1));
}
services.AddAuthorization(options =>
options.AddIdenreplacedyServerPolicies())
.AddAuthentication()
.AddIdenreplacedyServerAuthentication(JwtBearerDefaults.AuthenticationScheme, ConfigureIdenreplacedyServerAuthenticationOptions());
services.Configure<SendGridOptions>(Configuration)
.AddLocalization()
.AddControllersWithViews(options =>
options.AddIdenreplacedyServerAdminFilters())
.AddViewLocalization()
.AddDataAnnotationsLocalization()
.AddNewtonsoftJson(options =>
{
var settings = options.SerializerSettings;
settings.NullValueHandling = NullValueHandling.Ignore;
settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
})
.AddIdenreplacedyServerAdmin<ApplicationUser, SchemeDefinition>();
services.AddDatabaseDeveloperPageExceptionFilter()
.AddRazorPages(options => options.Conventions.AuthorizeAreaFolder("Idenreplacedy", "/Account"));
}
19
View Source File : ServiceCollectionExtensionsTest.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
[Fact]
public void AddClaimsProviders_should_load_claims_provider_setup_from_replacedembly_path()
{
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string>
{
["ClaimsProviderOptions:[0]:replacedemblyPath"] = $"{typeof(ClaimsProvider).replacedembly.GetName().Name}.dll",
["ClaimsProviderOptions:[0]:TypeName"] = $"{typeof(ClaimsProviderSetup).FullName}"
})
.Build();
var services = new ServiceCollection();
services.AddClaimsProviders(configuration);
replacedert.NotEmpty(services);
}
See More Examples