Here are the examples of the csharp api System.Type.GetType(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1502 Examples
19
Source : PlatformUtils.cs
with GNU Lesser General Public License v2.1
from BepInEx
with GNU Lesser General Public License v2.1
from BepInEx
public static void SetPlatform()
{
var current = Platform.Unknown;
// For old Mono, get from a private property to accurately get the platform.
// static extern PlatformID Platform
var p_Platform = typeof(Environment).GetProperty("Platform", BindingFlags.NonPublic | BindingFlags.Static);
string platID;
if (p_Platform != null)
platID = p_Platform.GetValue(null, new object[0]).ToString();
else
// For .NET and newer Mono, use the usual value.
platID = Environment.OSVersion.Platform.ToString();
platID = platID.ToLowerInvariant();
if (platID.Contains("win"))
current = Platform.Windows;
else if (platID.Contains("mac") || platID.Contains("osx"))
current = Platform.MacOS;
else if (platID.Contains("lin") || platID.Contains("unix")) current = Platform.Linux;
if (Is(current, Platform.Linux) && Directory.Exists("/data") && File.Exists("/system/build.prop"))
current = Platform.Android;
else if (Is(current, Platform.Unix) && Directory.Exists("/System/Library/AccessibilityBundles"))
current = Platform.iOS;
// Is64BitOperatingSystem has been added in .NET Framework 4.0
var m_get_Is64BitOperatingSystem =
typeof(Environment).GetProperty("Is64BitOperatingSystem")?.GetGetMethod();
if (m_get_Is64BitOperatingSystem != null)
current |= (bool) m_get_Is64BitOperatingSystem.Invoke(null, new object[0]) ? Platform.Bits64 : 0;
else
current |= IntPtr.Size >= 8 ? Platform.Bits64 : 0;
if ((Is(current, Platform.MacOS) || Is(current, Platform.Linux)) && Type.GetType("Mono.Runtime") != null)
{
string arch;
IntPtr result;
if (Is(current, Platform.MacOS))
{
var utsname_osx = new utsname_osx();
result = uname_osx(ref utsname_osx);
arch = utsname_osx.machine;
}
else
{
// Linux
var utsname_linux = new utsname_linux();
result = uname_linux(ref utsname_linux);
arch = utsname_linux.machine;
}
if (result == IntPtr.Zero && (arch.StartsWith("aarch") || arch.StartsWith("arm")))
current |= Platform.ARM;
}
else
{
// Detect ARM based on PE info or uname.
typeof(object).Module.GetPEKind(out var peKind, out var machine);
if (machine == (ImageFileMachine) 0x01C4 /* ARM, .NET Framework 4.5 */)
current |= Platform.ARM;
}
PlatformHelper.Current = current;
}
19
Source : InputHotkeyBlock.cs
with GNU General Public License v3.0
from BepInEx
with GNU General Public License v3.0
from BepInEx
internal void Main()
{
//Try to get the type of the TextMeshPro InputField, if present
TMPInputFieldType = Type.GetType("TMPro.TMP_InputField, Unity.TextMeshPro");
if (TMPInputFieldType == null)
TMPInputFieldType = Type.GetType("TMPro.TMP_InputField, TextMeshPro-1.0.55.56.0b12");
Harmony.CreateAndPatchAll(typeof(Hooks));
}
19
Source : Patch.cs
with MIT License
from BepInEx
with MIT License
from BepInEx
public override Type BindToType(string replacedemblyName, string typeName)
{
var types = new Type[] {
typeof(PatchInfo),
typeof(Patch[]),
typeof(Patch)
};
foreach (var type in types)
if (typeName == type.FullName)
return type;
var typeToDeserialize = Type.GetType(string.Format("{0}, {1}", typeName, replacedemblyName));
return typeToDeserialize;
}
19
Source : TestEnvironment.cs
with MIT License
from BepInEx
with MIT License
from BepInEx
[Test]
public void OutputRuntimeInfo()
{
var runtimeInformationType = AccessTools.TypeByName("System.Runtime.InteropServices.RuntimeInformation");
var executingreplacedembly = replacedembly.GetExecutingreplacedembly();
TestTools.Log("Environment.OSVersion: " + Environment.OSVersion);
TestTools.Log("RuntimeInformation.OSDescription: " + GetProperty(runtimeInformationType, "OSDescription"));
TestTools.Log("IntPtr.Size: " + IntPtr.Size);
TestTools.Log("Environment.Is64BitProcess: " + GetProperty(typeof(Environment), "Is64BitProcess"));
TestTools.Log("Environment.Is64BitOperatingSystem: " + GetProperty(typeof(Environment), "Is64BitOperatingSystem"));
TestTools.Log("RuntimeInformation.ProcessArchitecture: " + GetProperty(runtimeInformationType, "ProcessArchitecture"));
TestTools.Log("RuntimeInformation.OSArchitecture: " + GetProperty(runtimeInformationType, "OSArchitecture"));
TestTools.Log("RuntimeInformation.FrameworkDescription: " + GetProperty(runtimeInformationType, "FrameworkDescription"));
TestTools.Log("Mono.Runtime.DisplayName: " + CallGetter(Type.GetType("Mono.Runtime"), "GetDisplayName"));
TestTools.Log("RuntimeEnvironment.RuntimeDirectory: " + RuntimeEnvironment.GetRuntimeDirectory());
TestTools.Log("RuntimeEnvironment.SystemVersion: " + RuntimeEnvironment.GetSystemVersion());
TestTools.Log("Environment.Version: " + Environment.Version);
TestTools.Log("Core replacedembly: " + typeof(object).replacedembly);
TestTools.Log("Executing replacedembly's ImageRuntimeVersion: " + executingreplacedembly.ImageRuntimeVersion);
TestTools.Log("Executing replacedembly's TargetFrameworkAttribute: " + (executingreplacedembly.GetCustomAttributes(true)
.Where(attr => attr.GetType().Name is "TargetFrameworkAttribute")
.Select(attr => Traverse.Create(attr).Property("FrameworkName").GetValue<string>())
.FirstOrDefault() ?? "null"));
}
19
Source : UserProxy.cs
with MIT License
from BerkanYildiz
with MIT License
from BerkanYildiz
protected override void OnMessage(MessageEventArgs Args)
{
if (Args.IsPing)
{
return;
}
Message Message = new Message(Args.Data);
string ClreplacedName = (string) Message.Parameters[1];
string MethodName = (string) Message.Parameters[2];
foreach (object Parameter in Message.Parameters.Skip(1))
{
Console.WriteLine(" - " + Parameter + " #" + Message.Parameters.IndexOf(Parameter) + ".");
}
if (string.IsNullOrEmpty(ClreplacedName) == false && string.IsNullOrEmpty(MethodName) == false)
{
Type Clreplaced = Type.GetType("PlayerUnknown.Lobby.Services.Api." + ClreplacedName);
if (Clreplaced != null)
{
MethodInfo Method = Clreplaced.GetMethod(MethodName, BindingFlags.Static | BindingFlags.Public);
if (Method != null)
{
PubgSession Session = this.Server.Sessions.Get(this.ID);
if (Session != null)
{
Method.Invoke(null, new object[] { Message, Session });
}
else
{
Lobby.Log.Warning(this.GetType(), "PubgSession == null at OnMessage(Args).");
}
}
else
{
Lobby.Log.Warning(this.GetType(), "Method(" + MethodName + ") == null at OnMessage(Args).");
}
}
else
{
Lobby.Log.Warning(this.GetType(), "Clreplaced(" + ClreplacedName + ") == null at OnMessage(Args).");
}
}
else
{
Lobby.Log.Warning(this.GetType(), "Message.IsValid != true at OnMessage(Args).");
}
Console.WriteLine("--------------------------");
}
19
Source : AppShell.xaml.cs
with MIT License
from beto-rodriguez
with MIT License
from beto-rodriguez
private void AppShell_SizeChanged(object sender, EventArgs e)
{
if (_isLoaded) return;
_isLoaded = true;
var samples = ViewModelsSamples.Index.Samples;
var i = 0;
foreach (var item in samples)
{
var t = Type.GetType($"XamarinSample.{item.Replace('/', '.')}.View");
//var i = Activator.CreateInstance(t);
Routing.RegisterRoute(item, t);
var shell_section = new ShellSection { replacedle = item };
ShellContent content;
try
{
content = new ShellContent()
{
Content = i == 0 ? Activator.CreateInstance(t) : null
};
}
catch (Exception ex)
{
throw ex;
}
shell_section.Items.Add(content);
Items.Add(shell_section);
_routesSamples.Add("//" + content.Route, item);
i++;
//if (i > 4) break;
}
Navigating += AppShell_Navigating;
}
19
Source : AppShell.xaml.cs
with MIT License
from beto-rodriguez
with MIT License
from beto-rodriguez
private void AppShell_Navigating(object sender, ShellNavigatingEventArgs e)
{
var shell = (AppShell)sender;
var r = shell.Items.Select(x => x.Currenreplacedem.Currenreplacedem.Route).ToArray();
var next = Items.FirstOrDefault(x => "//" + x.Currenreplacedem.Currenreplacedem.Route == e.Target.Location.OriginalString);
var item = _routesSamples[e.Target.Location.OriginalString];
var t = Type.GetType($"XamarinSample.{item.Replace('/', '.')}.View");
object i;
try
{
i = Activator.CreateInstance(t);
}
catch (Exception ex)
{
var a = 1;
throw;
}
var c = next.Items[0].Items[0];
c.Content = i;
}
19
Source : MainPage.xaml.cs
with MIT License
from beto-rodriguez
with MIT License
from beto-rodriguez
private void Border_PointerPressed(object sender, PointerRoutedEventArgs e)
{
var ctx = (string)((FrameworkElement)sender).DataContext;
var t = Type.GetType($"UWPSample.{ctx.Replace('/', '.')}.View");
content.Content = Activator.CreateInstance(t);
}
19
Source : ManagerGX.cs
with MIT License
from BigBigZBBing
with MIT License
from BigBigZBBing
internal static FieldArray NewArray(this EmitBasic basic, Type type, Int32 length = default(Int32))
{
LocalBuilder item = basic.DeclareLocal(type);
basic.IntegerMap(length);
basic.Emit(OpCodes.Newarr, Type.GetType(type.FullName.Replace("[]", "")));
basic.Emit(OpCodes.Stloc_S, item);
return new FieldArray(item, basic, length);
}
19
Source : ManagerGX.cs
with MIT License
from BigBigZBBing
with MIT License
from BigBigZBBing
internal static FieldArray NewArray(this EmitBasic basic, Type type, LocalBuilder length)
{
LocalBuilder item = basic.DeclareLocal(type);
basic.Emit(OpCodes.Ldloc_S, length);
basic.Emit(OpCodes.Newarr, Type.GetType(type.FullName.Replace("[]", "")));
basic.Emit(OpCodes.Stloc_S, item);
return new FieldArray(item, basic, -1);
}
19
Source : System_TypeWrap.cs
with MIT License
from bjfumac
with MIT License
from bjfumac
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
static int GetType(IntPtr L)
{
try
{
int count = LuaDLL.lua_gettop(L);
if (count == 1 && TypeChecker.CheckTypes<System.Type>(L, 1))
{
System.Type obj = (System.Type)ToLua.ToObject(L, 1);
System.Type o = obj.GetType();
ToLua.Push(L, o);
return 1;
}
else if (count == 1 && TypeChecker.CheckTypes<string>(L, 1))
{
string arg0 = ToLua.ToString(L, 1);
System.Type o = System.Type.GetType(arg0);
ToLua.Push(L, o);
return 1;
}
else if (count == 2)
{
string arg0 = ToLua.CheckString(L, 1);
bool arg1 = LuaDLL.luaL_checkboolean(L, 2);
System.Type o = System.Type.GetType(arg0, arg1);
ToLua.Push(L, o);
return 1;
}
else if (count == 3)
{
string arg0 = ToLua.CheckString(L, 1);
bool arg1 = LuaDLL.luaL_checkboolean(L, 2);
bool arg2 = LuaDLL.luaL_checkboolean(L, 3);
System.Type o = System.Type.GetType(arg0, arg1, arg2);
ToLua.Push(L, o);
return 1;
}
else
{
return LuaDLL.luaL_throw(L, "invalid arguments to method: System.Type.GetType");
}
}
catch (Exception e)
{
return LuaDLL.toluaL_exception(L, e);
}
}
19
Source : DemoService.cs
with MIT License
from BlazorComponent
with MIT License
from BlazorComponent
public RenderFragment GetShowCase(string type)
{
_showCaseCache ??= new ConcurrentCache<string, RenderFragment>();
return _showCaseCache.GetOrAdd(type, t =>
{
var showCase = Type.GetType($"{replacedembly.GetExecutingreplacedembly().GetName().Name}.{type}") ?? typeof(Template);
void ShowCase(RenderTreeBuilder builder)
{
builder.OpenComponent(0, showCase);
builder.CloseComponent();
}
return ShowCase;
});
}
19
Source : SettingEntry.cs
with MIT License
from blish-hud
with MIT License
from blish-hud
public override SettingEntry ReadJson(JsonReader reader, Type objectType, SettingEntry existingValue, bool hasExistingValue, JsonSerializer serializer) {
var jObj = JObject.Load(reader);
string entryTypeString = jObj[SETTINGTYPE_KEY].Value<string>();
var entryType = Type.GetType(entryTypeString);
if (entryType == null) {
Logger.Warn("Failed to load setting of missing type '{settingDefinedType}'.", entryTypeString);
return null;
}
var entryGeneric = Activator.CreateInstance(typeof(SettingEntry<>).MakeGenericType(entryType));
serializer.Populate(jObj.CreateReader(), entryGeneric);
return entryGeneric as SettingEntry;
}
19
Source : TypeExtensions.cs
with MIT License
from BLUDRAG
with MIT License
from BLUDRAG
public static Type GetInstanceType(string strFullyQualifiedName)
{
string sanitizedName = strFullyQualifiedName.Replace("PPtr<$", "").Replace(">", "");
Type type = Type.GetType(sanitizedName);
if(type != null) return type;
foreach(replacedembly asm in AppDomain.CurrentDomain.Getreplacedemblies())
{
Module[] modules = asm.GetModules();
foreach(Module module in modules)
{
foreach(Type _type in module.GetTypes())
{
if(_type.Name == sanitizedName)
return _type;
}
}
}
return null;
}
19
Source : PersistentArgument.cs
with MIT License
from BLUDRAG
with MIT License
from BLUDRAG
public static Type GetArgumentType(PersistentArgumentType type, float secondaryType, string replacedemblyQualifiedName)
{
switch (type)
{
case PersistentArgumentType.Bool: return typeof(bool);
case PersistentArgumentType.String: return typeof(string);
case PersistentArgumentType.Int: return typeof(int);
case PersistentArgumentType.Float: return typeof(float);
case PersistentArgumentType.Vector2: return typeof(Vector2);
case PersistentArgumentType.Vector3: return typeof(Vector3);
case PersistentArgumentType.Vector4: return typeof(Vector4);
case PersistentArgumentType.Quaternion: return typeof(Quaternion);
case PersistentArgumentType.Color: return typeof(Color);
case PersistentArgumentType.Color32: return typeof(Color32);
case PersistentArgumentType.Rect: return typeof(Rect);
case PersistentArgumentType.Enum:
case PersistentArgumentType.Object:
default:
if (!string.IsNullOrEmpty(replacedemblyQualifiedName))
return System.Type.GetType(replacedemblyQualifiedName);
else
return null;
case PersistentArgumentType.Parameter:
case PersistentArgumentType.ReturnValue:
if (!string.IsNullOrEmpty(replacedemblyQualifiedName))
return System.Type.GetType(replacedemblyQualifiedName);
else
return GetArgumentType((PersistentArgumentType)secondaryType, -1, null);
case PersistentArgumentType.None:
return null;
}
}
19
Source : PersistentCall.cs
with MIT License
from BLUDRAG
with MIT License
from BLUDRAG
internal static void GetMethodDetails(string serializedMethodName, Object target, out Type declaringType, out string methodName)
{
if (string.IsNullOrEmpty(serializedMethodName))
{
declaringType = null;
methodName = null;
return;
}
if (target == null)
{
var lastDot = serializedMethodName.LastIndexOf('.');
if (lastDot < 0)
{
declaringType = null;
methodName = serializedMethodName;
}
else
{
declaringType = Type.GetType(serializedMethodName.Substring(0, lastDot));
lastDot++;
methodName = serializedMethodName.Substring(lastDot, serializedMethodName.Length - lastDot);
}
}
else
{
declaringType = target.GetType();
methodName = serializedMethodName;
}
}
19
Source : JSON.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
private void ProcessMap(object obj, SafeDictionary<string, myPropInfo> props, Dictionary<string, object> dic)
{
foreach (var kv in dic)
{
myPropInfo p = props[kv.Key];
object o = p.getter(obj);
Type t = Type.GetType((string)kv.Value);
if (t == typeof(Guid))
p.setter(obj, CreateGuid((string)o));
}
}
19
Source : MonoUtility.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "This should never fail")]
private static bool CheckRunningOnMono()
{
try
{
return Type.GetType("Mono.Runtime") != null;
}
catch
{
return false;
}
}
19
Source : JSON.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
private Type GetTypeFromCache(string typename)
{
Type val = null;
if (_typecache.TryGetValue(typename, out val))
return val;
Type t = Type.GetType(typename);
_typecache.Add(typename, t);
return t;
}
19
Source : MonoVersionCheck.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
private bool HasMonoBug18599()
{
_logger.Debug("mono version 3.4.0, checking for mono bug #18599.");
var numberFormatterType = Type.GetType("System.NumberFormatter");
if (numberFormatterType == null)
{
_logger.Debug("Couldn't find System.NumberFormatter. Aborting test.");
return false;
}
var fieldInfo = numberFormatterType.GetField("userFormatProvider", BindingFlags.Static | BindingFlags.NonPublic);
if (fieldInfo == null)
{
_logger.Debug("userFormatProvider field not found, version likely preceeds the official v3.4.0.");
return false;
}
if (fieldInfo.GetCustomAttributes(false).Any(v => v is ThreadStaticAttribute))
{
_logger.Debug("userFormatProvider field doesn't contain the ThreadStatic Attribute, version is affected by the critical bug #18599.");
return true;
}
return false;
}
19
Source : PackageView.cs
with MIT License
from bonsai-rx
with MIT License
from bonsai-rx
static bool IsRunningOnMono()
{
return Type.GetType("Mono.Runtime") != null;
}
19
Source : Unity3DRider.cs
with MIT License
from bonzaiferroni
with MIT License
from bonzaiferroni
private static void SyncSolution()
{
System.Type T = System.Type.GetType("UnityEditor.SyncVS,UnityEditor");
System.Reflection.MethodInfo SyncSolution = T.GetMethod("SyncSolution",
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
SyncSolution.Invoke(null, null);
}
19
Source : FRPackager.cs
with MIT License
from bonzajplc
with MIT License
from bonzajplc
[MenuItem("Tools/Recorder/Generate replacedetstore package", false, 100)]
static void GeneratereplacedetStorePackage()
{
var rootPath = FRPackagerPaths.GetRecorderRootPath();
var type = Type.GetType("UnityEditor.Recorder.MovieRecorderPackager");
if (type != null)
{
var method = type.GetMethod("GeneratePackage");
method.Invoke(null, null);
replacedetDatabase.Refresh();
}
UpdateVersion();
var files = new []
{
Path.Combine(rootPath, "Recorder_install.pdf" ),
Path.Combine(rootPath, "Framework.meta" ),
Path.Combine(rootPath, "Framework/Core" ),
Path.Combine(rootPath, "Framework/Inputs" ),
Path.Combine(rootPath, "Framework/Recorders" ),
Path.Combine(rootPath, "Framework/Packager/Editor" ),
Path.Combine(rootPath, "Extensions/UTJ" ),
Path.Combine(rootPath, "Extensions/FCIntegration" ),
Path.Combine(rootPath, "Extensions/MovieRecorder/Packaging" ),
};
var destFile = k_PackageName + " " + RecorderVersion.Stage + " v"+ RecorderVersion.Version + ".unitypackage";
replacedetDatabase.ExportPackage(files, destFile, ExportPackageOptions.Recurse);
Debug.Log("Generated package: " + destFile);
}
19
Source : DetectUnoptimizedAssembly.cs
with MIT License
from bruno-garcia
with MIT License
from bruno-garcia
public bool IsSystemType(string type) => type == "[System.Runtime]System.Type" || Type.GetType(type) == typeof(Type);
19
Source : ReflectionUtils.cs
with MIT License
from BrunoS3D
with MIT License
from BrunoS3D
public static Type GetTypeByName(string type_name) {
Type t1 = Type.GetType(type_name);
if (t1 != null) {
return t1;
}
Type t2;
if (cache_types.TryGetValue(type_name, out t2)) {
return t2;
}
foreach (Type type in YieldGetFullTypes()) {
if (type.Name == type_name || type.FullName == type_name || type.GetTypeName(true) == type_name || type.GetTypeName(false) == type_name) {
return type;
}
if (type.Name.Contains("+")) {
string[] split = type.Name.Split('+');
return GetTypeByName(split[0]).GetNestedType(split[1]);
}
if (type.FullName.Contains("+")) {
string[] split = type.FullName.Split('+');
return GetTypeByName(split[0]).GetNestedType(split[1]);
}
if (type.GetTypeName(true).Contains("+")) {
string[] split = type.GetTypeName(true).Split('+');
return GetTypeByName(split[0]).GetNestedType(split[1]);
}
if (type.GetTypeName(false).Contains("+")) {
string[] split = type.GetTypeName(false).Split('+');
return GetTypeByName(split[0]).GetNestedType(split[1]);
}
}
return null;
}
19
Source : DefaultSerializationBinder.cs
with MIT License
from BrunoS3D
with MIT License
from BrunoS3D
private Type ParseTypeName(string typeName, DebugContext debugContext)
{
Type type;
// Look for custom defined type name lookups defined with the BindTypeNameToTypeAttribute.
if (customTypeNameToTypeBindings.TryGetValue(typeName, out type))
{
return type;
}
// Let's try it the traditional .NET way
type = Type.GetType(typeName);
if (type != null) return type;
// Let's try a short-cut
type = replacedemblyUtilities.GetTypeByCachedFullName(typeName);
if (type != null) return type;
// Generic/array type name handling
type = ParseGenericAndOrArrayType(typeName, debugContext);
if (type != null) return type;
string typeStr, replacedemblyStr;
ParseName(typeName, out typeStr, out replacedemblyStr);
if (!string.IsNullOrEmpty(typeStr) && replacedemblyStr != null && replacedemblyNameLookUp.ContainsKey(replacedemblyStr))
{
var replacedembly = replacedemblyNameLookUp[replacedemblyStr];
type = replacedembly.GetType(typeStr);
if (type != null) return type;
}
type = replacedemblyUtilities.GetTypeByCachedFullName(typeStr);
if (type != null) return type;
return null;
}
19
Source : JetFactory.cs
with Apache License 2.0
from bubibubi
with Apache License 2.0
from bubibubi
public virtual DbProviderFactory GetDataAccessProviderFactory(DataAccessProviderType dataAccessProviderType)
{
if (dataAccessProviderType == DataAccessProviderType.OleDb)
{
try
{
var type = Type.GetType("System.Data.OleDb.OleDbFactory, System.Data.OleDb");
var replacedemblyName = type.replacedembly.GetName();
var version = replacedemblyName.Version;
if (version < MinimumRequiredOleDbVersion &&
replacedemblyName.Name != "System.Data") // For .NET Framework, System.Data.OleDb is just a stub that references the .NET Framework implementation.
{
throw new TypeLoadException($"The referenced version '{version}' of 'System.Data.OleDb' is lower than the minimum required version {MinimumRequiredOleDbVersion}.");
}
return (DbProviderFactory) type
.GetField("Instance", BindingFlags.Static | BindingFlags.Public)
.GetValue(null);
}
catch (Exception e)
{
throw new TypeLoadException($"To use OLE DB in conjunction with Jet, please reference the 'System.Data.OleDb' (version >= {MinimumRequiredOleDbVersion}) NuGet package.", e);
}
}
else
{
try
{
var type = Type.GetType("System.Data.Odbc.OdbcFactory, System.Data.Odbc");
var replacedemblyName = type.replacedembly.GetName();
var version = replacedemblyName.Version;
if (version < MinimumRequiredOdbcVersion &&
replacedemblyName.Name != "System.Data") // For .NET Framework, System.Data.Odbc is just a stub that references the .NET Framework implementation.
{
throw new TypeLoadException($"The referenced version '{version}' of 'System.Data.Odbc' is lower than the minimum required version {MinimumRequiredOdbcVersion}.");
}
return (DbProviderFactory) type
.GetField("Instance", BindingFlags.Static | BindingFlags.Public)
.GetValue(null);
}
catch (Exception e)
{
throw new TypeLoadException($"To use ODBC in conjunction with Jet, please reference the 'System.Data.Odbc' (version >= {MinimumRequiredOdbcVersion}) NuGet package.", e);
}
}
}
19
Source : Helpers.cs
with Apache License 2.0
from bubibubi
with Apache License 2.0
from bubibubi
private static DbDataReader InternatExecute(DbConnection connection, DbTransaction transaction, string queryAndParameters)
{
string query;
string parameterString;
if (queryAndParameters.Contains("\n-\n"))
{
var i = queryAndParameters.IndexOf("\n-\n", StringComparison.Ordinal);
query = queryAndParameters.Substring(0, i);
parameterString = queryAndParameters.Substring(i + 3);
}
else
{
query = queryAndParameters;
parameterString = null;
}
var sqlParts = query.Split('\n');
var executionMethod = sqlParts[0];
var sql = string.Empty;
for (var i = 1; i < sqlParts.Length; i++)
sql += sqlParts[i] + "\r\n";
var command = connection.CreateCommand();
if (transaction != null)
command.Transaction = transaction;
command.CommandText = sql;
if (parameterString != null)
{
var parameterStringList = parameterString.Split('\n');
foreach (var sParameter in parameterStringList)
{
if (string.IsNullOrWhiteSpace(sParameter))
continue;
var match = _parseParameterRegex.Match(sParameter);
if (!match.Success)
throw new Exception("Parameter not valid " + sParameter);
var parameterName = match.Groups["name"]
.Value;
var parameterType = match.Groups["type"]
.Value;
var sparameterValue = match.Groups["value"]
.Value;
object parameterValue;
if (sparameterValue == "null")
parameterValue = DBNull.Value;
else
parameterValue = Convert.ChangeType(sparameterValue, Type.GetType("System." + parameterType));
var parameter = command.CreateParameter();
parameter.ParameterName = parameterName;
parameter.Value = parameterValue;
command.Parameters.Add(parameter);
}
}
if (executionMethod.StartsWith("ExecuteNonQuery"))
{
command.ExecuteNonQuery();
return null;
}
else if (executionMethod.StartsWith("ExecuteDbDataReader"))
{
return command.ExecuteReader();
}
else
throw new Exception("Unknown execution method " + executionMethod);
}
19
Source : Program.cs
with Apache License 2.0
from bubibubi
with Apache License 2.0
from bubibubi
private static void Main()
{
Console.WriteLine($"Running as {(Environment.Is64BitProcess ? "x64" : "x86")} process.");
var tagDBPARAMBINDINFOName = "tagDBPARAMBINDINFO" + (Environment.Is64BitProcess
? string.Empty
: "_x86");
// Is 2 on x86 and 8 on x64.
Console.WriteLine($"{tagDBPARAMBINDINFOName} field alignment is {Type.GetType($"System.Data.OleDb.{tagDBPARAMBINDINFOName}, System.Data.OleDb").StructLayoutAttribute.Pack}.");
// Is 8 on both x86 and x64.
Console.WriteLine($"tagDBPARAMS field alignment is {Type.GetType("System.Data.OleDb.tagDBPARAMS, System.Data.OleDb").StructLayoutAttribute.Pack}.");
Console.WriteLine();
//Console.WriteLine("Press any key to start...");
//Console.ReadKey();
//var northwindTest = new NorthwindTestOleDbCommand();
//northwindTest.Run();
var iceCreamTest = new IceCreamTest();
iceCreamTest.Run();
}
19
Source : Program.cs
with BSD 2-Clause "Simplified" License
from bytecode77
with BSD 2-Clause "Simplified" License
from bytecode77
static dynamic GetConstructor(string type, Type[] types, object[] parameters)
{
return Type.GetType(type).GetConstructor(types).Invoke(parameters);
}
19
Source : Program.cs
with BSD 2-Clause "Simplified" License
from bytecode77
with BSD 2-Clause "Simplified" License
from bytecode77
static dynamic GetProperty(string type, string property)
{
return Type.GetType(type).GetProperty(property).GetMethod.Invoke(null, new object[0]);
}
19
Source : Program.cs
with BSD 2-Clause "Simplified" License
from bytecode77
with BSD 2-Clause "Simplified" License
from bytecode77
static dynamic InvokeMethod(string type, string method, Type[] types, object[] parameters)
{
return Type.GetType(type).GetMethod(method, System.Reflection.BindingFlags.Static).Invoke(null, parameters);
}
19
Source : Program.cs
with BSD 2-Clause "Simplified" License
from bytecode77
with BSD 2-Clause "Simplified" License
from bytecode77
static Type GetType(string name)
{
return Type.GetType(name);
}
19
Source : SilverlightSerializer.cs
with MIT License
from CalciumFramework
with MIT License
from CalciumFramework
public static object Deserialize(Stream inputStream, object instance = null)
{
var v = Verbose;
CreateStacks();
try
{
_ktStack.Push(_knownTypes);
_piStack.Push(_propertyIds);
_loStack.Push(_loadedObjects);
var rw = new BinaryReader(inputStream);
var version = rw.ReadString();
var count = rw.ReadInt32();
if (version == "SerV3")
Verbose = rw.ReadBoolean();
_propertyIds = new List<string>();
_knownTypes = new List<Type>();
_loadedObjects = new List<object>();
for (var i = 0; i < count; i++)
{
var typeName = rw.ReadString();
var tp = Type.GetType(typeName);
if (tp == null)
{
typeName = typeName.Replace(", System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", string.Empty);
tp = Type.GetType(typeName);
if (tp == null)
{
var map = new TypeMappingEventArgs
{
TypeName = typeName
};
InvokeMapMissingType(map);
tp = map.UseType;
}
}
if (!Verbose)
{
if (tp == null)
{
throw new ArgumentException(string.Format("SilverlightSerializer: Cannot reference type {0} in this context", typeName));
}
}
_knownTypes.Add(tp);
}
count = rw.ReadInt32();
for (var i = 0; i < count; i++)
{
_propertyIds.Add(rw.ReadString());
}
return DeserializeObject(rw, null, instance);
}
finally
{
_knownTypes = _ktStack.Pop();
_propertyIds = _piStack.Pop();
_loadedObjects = _loStack.Pop();
Verbose = v;
}
}
19
Source : MarkupTypeResolver.cs
with MIT License
from CalciumFramework
with MIT License
from CalciumFramework
public Type Resolve(string qualifiedTypeName)
{
Type type;
if (qualifiedTypeName.Contains(":"))
{
var aliasAndTypeNameArray = qualifiedTypeName.Split(':');
if (aliasAndTypeNameArray.Length != 2)
{
throw new BindingException("Namespace aliased type name is invalid. " + qualifiedTypeName);
}
if (!NamespaceRegistry.TryResolveType(aliasAndTypeNameArray[0], aliasAndTypeNameArray[1], out type))
{
throw new BindingException("Unable to resolve namespace alias in " + qualifiedTypeName);
}
return type;
}
type = Type.GetType(qualifiedTypeName);
return type;
}
19
Source : SerializableType.cs
with MIT License
from CareBoo
with MIT License
from CareBoo
public static bool TryGetType(string typeString, out Type type)
{
#if UNITY_EDITOR
if (Guid.TryParse(typeString, out var guid))
type = TypeCache.GetTypesWithAttribute(typeof(GuidAttribute))
.FirstOrDefault(t => t.GUID == guid);
else
type = Type.GetType(typeString);
#else
type = Type.GetType(typeString);
#endif // UNITY_EDITOR
return type != null || string.IsNullOrEmpty(typeString);
}
19
Source : GetTypeFromManagedReferenceFullTypename.cs
with MIT License
from CareBoo
with MIT License
from CareBoo
public static bool GetTypeFromManagedReferenceFullTypename(
string managedReferenceFullTypename,
out Type type)
{
type = null;
var parts = managedReferenceFullTypename.Split(' ');
if (parts.Length == 2)
{
var replacedemblyPart = parts[0];
var nsClreplacednamePart = parts[1];
type = Type.GetType($"{nsClreplacednamePart}, {replacedemblyPart}");
}
return type != null;
}
19
Source : Symbols.cs
with MIT License
from CatLib
with MIT License
from CatLib
static Type GetSymbolType (SymbolKind kind, string fullname)
{
var type = Type.GetType (fullname);
if (type != null)
return type;
var replacedembly_name = GetSymbolreplacedemblyName (kind);
type = Type.GetType (fullname + ", " + replacedembly_name.FullName);
if (type != null)
return type;
try {
var replacedembly = SR.replacedembly.Load (replacedembly_name);
if (replacedembly != null)
return replacedembly.GetType (fullname);
} catch (FileNotFoundException) {
} catch (FileLoadException) {
}
return null;
}
19
Source : ObjectPacker.cs
with GNU Affero General Public License v3.0
from cc004
with GNU Affero General Public License v3.0
from cc004
private object Unpack(MsgPackReader reader, Type t)
{
if (t.IsPrimitive)
{
if (!reader.Read())
{
throw new FormatException();
}
if (t.Equals(typeof(int)) && reader.IsSigned())
{
return reader.ValueSigned;
}
if (t.Equals(typeof(uint)) && reader.IsUnsigned())
{
return reader.ValueUnsigned;
}
if (t.Equals(typeof(float)) && reader.Type == TypePrefixes.Float)
{
return reader.ValueFloat;
}
if (t.Equals(typeof(double)) && reader.Type == TypePrefixes.Double)
{
return reader.ValueDouble;
}
if (t.Equals(typeof(long)))
{
if (reader.IsSigned64())
{
return reader.ValueSigned64;
}
if (reader.IsSigned())
{
return (long)reader.ValueSigned;
}
}
else
{
if (!t.Equals(typeof(ulong)))
{
if (t.Equals(typeof(bool)) && reader.IsBoolean())
{
return reader.Type == TypePrefixes.True;
}
if (t.Equals(typeof(byte)) && reader.IsUnsigned())
{
return (byte)reader.ValueUnsigned;
}
if (t.Equals(typeof(sbyte)) && reader.IsSigned())
{
return (sbyte)reader.ValueSigned;
}
if (t.Equals(typeof(short)) && reader.IsSigned())
{
return (short)reader.ValueSigned;
}
if (t.Equals(typeof(ushort)) && reader.IsUnsigned())
{
return (ushort)reader.ValueUnsigned;
}
if (t.Equals(typeof(char)) && reader.IsUnsigned())
{
return (char)reader.ValueUnsigned;
}
throw new NotSupportedException();
}
if (reader.IsUnsigned64())
{
return reader.ValueUnsigned64;
}
if (reader.IsUnsigned())
{
return (ulong)reader.ValueUnsigned;
}
}
}
if (UnpackerMapping.TryGetValue(t, out UnpackDelegate value))
{
return value(this, reader);
}
if (t.IsArray)
{
if (!reader.Read() || (!reader.IsArray() && reader.Type != TypePrefixes.Nil))
{
throw new FormatException();
}
if (reader.Type == TypePrefixes.Nil)
{
return null;
}
Type elementType = t.GetElementType();
Array array = Array.CreateInstance(elementType, (int)reader.Length);
for (int i = 0; i < array.Length; i++)
{
array.SetValue(Unpack(reader, elementType), i);
}
return array;
}
if (!reader.Read())
{
throw new FormatException();
}
if (reader.Type == TypePrefixes.Nil)
{
return null;
}
if (t.IsInterface)
{
if (reader.Type != TypePrefixes.FixArray && reader.Length != 2)
{
throw new FormatException();
}
if (!reader.Read() || !reader.IsRaw())
{
throw new FormatException();
}
CheckBufferSize((int)reader.Length);
reader.ReadValueRaw(_buf, 0, (int)reader.Length);
t = Type.GetType(Encoding.UTF8.GetString(_buf, 0, (int)reader.Length));
if (!reader.Read() || reader.Type == TypePrefixes.Nil)
{
throw new FormatException();
}
}
if (!reader.IsMap())
{
throw new FormatException();
}
object uninitializedObject = FormatterServices.GetUninitializedObject(t);
ReflectionCacheEntry reflectionCacheEntry = ReflectionCache.Lookup(t);
int length = (int)reader.Length;
for (int j = 0; j < length; j++)
{
if (!reader.Read() || !reader.IsRaw())
{
throw new FormatException();
}
CheckBufferSize((int)reader.Length);
reader.ReadValueRaw(_buf, 0, (int)reader.Length);
string @string = Encoding.UTF8.GetString(_buf, 0, (int)reader.Length);
if (!reflectionCacheEntry.FieldMap.TryGetValue(@string, out FieldInfo value2))
{
throw new FormatException();
}
value2.SetValue(uninitializedObject, Unpack(reader, value2.FieldType));
}
(uninitializedObject as IDeserializationCallback)?.OnDeserialization(this);
return uninitializedObject;
}
19
Source : QPatch.cs
with MIT License
from ccgould
with MIT License
from ccgould
private static void PatchEasyCraft(Harmony harmony)
{
var isEasyCraftInstalled = QModServices.Main.ModPresent("EasyCraft");
if (isEasyCraftInstalled)
{
QuickLogger.Debug("EasyCraft is installed");
var easyCraftClosesreplacedemContainersType = Type.GetType("EasyCraft.ClosesreplacedemContainers, EasyCraft");
var easyCraftMainType = Type.GetType("EasyCraft.Main, EasyCraft");
var easyCraftSettingsType = Type.GetType("EasyCraft.Settings, EasyCraft");
if (easyCraftMainType != null)
{
QuickLogger.Debug("Got EasyCraft Main Type");
EasyCraftSettingsInstance = easyCraftMainType
.GetField("settings", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
if (EasyCraftSettingsInstance != null)
{
QuickLogger.Debug("Got EasyCraft Settings Field Info");
if (easyCraftSettingsType != null)
{
QuickLogger.Debug("Got EasyCraft Settings type");
QuickLogger.Debug($"Got EasyCraft Settings type: {easyCraftSettingsType.Name}");
var autoCraft = easyCraftSettingsType.GetField("autoCraft").GetValue(EasyCraftSettingsInstance);
UseStorage = easyCraftSettingsType.GetField("useStorage");
var returnSurplus = easyCraftSettingsType.GetField("returnSurplus")
.GetValue(EasyCraftSettingsInstance);
}
}
}
if (easyCraftClosesreplacedemContainersType != null)
{
QuickLogger.Debug("Got EasyCraft Type");
var destroyItemMethodInfo = easyCraftClosesreplacedemContainersType.GetMethod("DestroyItem");
var getPickupCountMethodInfo = easyCraftClosesreplacedemContainersType.GetMethod("GetPickupCount");
if (destroyItemMethodInfo != null)
{
QuickLogger.Debug("Got EasyCraft DestroyItem Method");
var postfix = typeof(EasyCraft_Patch).GetMethod("DestroyItem");
harmony.Patch(destroyItemMethodInfo, null, new HarmonyMethod(postfix));
}
if (getPickupCountMethodInfo != null)
{
QuickLogger.Debug("Got EasyCraft GetPickupCount Method");
var postfix = typeof(EasyCraft_Patch).GetMethod("GetPickupCount");
harmony.Patch(getPickupCountMethodInfo, null, new HarmonyMethod(postfix));
}
}
else
{
QuickLogger.Error("Failed to get EasyCraft Type");
}
}
else
{
QuickLogger.Debug("EasyCraft not installed");
}
}
19
Source : QPatch.cs
with MIT License
from ccgould
with MIT License
from ccgould
private static void PatchToolTipFactory(Harmony harmony)
{
var toolTipFactoryType = Type.GetType("TooltipFactory, replacedembly-CSharp");
if (toolTipFactoryType != null)
{
QuickLogger.Debug("Got TooltipFactory Type");
var inventoryItemViewMethodInfo = toolTipFactoryType.GetMethod("InventoryItem");
if (inventoryItemViewMethodInfo != null)
{
QuickLogger.Info("Got Inventory Item View Method Info");
var postfix = typeof(TooltipFactory_Patch).GetMethod("GetToolTip");
harmony.Patch(inventoryItemViewMethodInfo, null, new HarmonyMethod(postfix));
}
}
//if (easyCraftClosesreplacedemContainersType != null)
//{
// QuickLogger.Debug("Got EasyCraft Type");
// var destroyItemMethodInfo = easyCraftClosesreplacedemContainersType.GetMethod("DestroyItem");
// var getPickupCountMethodInfo = easyCraftClosesreplacedemContainersType.GetMethod("GetPickupCount");
// if (destroyItemMethodInfo != null)
// {
// QuickLogger.Debug("Got EasyCraft DestroyItem Method");
// var postfix = typeof(EasyCraft_Patch).GetMethod("DestroyItem");
// harmony.Patch(destroyItemMethodInfo, null, new HarmonyMethod(postfix));
// }
// if (getPickupCountMethodInfo != null)
// {
// QuickLogger.Debug("Got EasyCraft GetPickupCount Method");
// var postfix = typeof(EasyCraft_Patch).GetMethod("GetPickupCount");
// harmony.Patch(getPickupCountMethodInfo, null, new HarmonyMethod(postfix));
// }
//}
//else
//{
// QuickLogger.Error("Failed to get EasyCraft Type");
//}
}
19
Source : CefNetApplication.cs
with MIT License
from CefNet
with MIT License
from CefNet
protected virtual bool TryInitializeDllImportResolver(IntPtr libcefHandle)
{
#if NET
NativeLibrary.SetDllImportResolver(typeof(CefApi).replacedembly, ResolveNativeLibrary);
return true;
#else
Type nativeLibraryType = Type.GetType("System.Runtime.InteropServices.NativeLibrary");
if (nativeLibraryType is null)
return false;
Type dllImportResolverDelegateType = Type.GetType("System.Runtime.InteropServices.DllImportResolver");
if (dllImportResolverDelegateType is null)
return false;
MethodInfo setDllImportResolver = nativeLibraryType.GetMethod("SetDllImportResolver", new[] { typeof(replacedembly), dllImportResolverDelegateType });
if (setDllImportResolver is null)
return false;
setDllImportResolver.Invoke(null, new object[] {
typeof(CefApi).replacedembly,
Delegate.CreateDelegate(dllImportResolverDelegateType, this, new Func<string, replacedembly, DllImportSearchPath?, IntPtr>(ResolveNativeLibrary).Method)
});
return true;
#endif
}
19
Source : AlphaHostBuilder.cs
with MIT License
from centaurus-project
with MIT License
from centaurus-project
public void ConfigureServices(IServiceCollection services)
{
services
.AddMvc(options => options.EnableEndpointRouting = false);
services.Add(
new ServiceDescriptor(
typeof(IActionResultExecutor<JsonResult>),
Type.GetType("Microsoft.AspNetCore.Mvc.Infrastructure.SystemTextJsonResultExecutor, Microsoft.AspNetCore.Mvc.Core"),
ServiceLifetime.Singleton)
);
services.AddOptions<HostOptions>().Configure(opts => opts.ShutdownTimeout = TimeSpan.FromDays(365));
}
19
Source : CustomTuple.cs
with MIT License
from ch00486259
with MIT License
from ch00486259
public static Type CreateType(Type[] typeArray)
{
if (typeArray == null || typeArray.Length == 0)
return typeof(CustomTuple);
if (typeArray.Length > 10)
throw new ArgumentException("error interface definition ,max method parameter count is 10");
Type typleType = Type.GetType("Socean.Rpc.DynamicProxy.CustomTuple`" + typeArray.Length);
return typleType.MakeGenericType(typeArray);
}
19
Source : CustomAssetImporterSplitterGUI.cs
with MIT License
from charcolle
with MIT License
from charcolle
[InitializeOnLoadMethod]
static void Init() {
splitterGUILayoutType = Type.GetType( "UnityEditor.SplitterGUILayout,UnityEditor" );
}
19
Source : ViewLocator.cs
with MIT License
from ChaosInitiative
with MIT License
from ChaosInitiative
public IControl Build(object data)
{
string name = data.GetType().FullName.Replace("ViewModel", "View");
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type);
}
return new TextBlock { Text = "Not Found: " + name };
}
19
Source : HapticSystemAttribute.cs
with MIT License
from charles-river-analytics
with MIT License
from charles-river-analytics
public virtual void ResetAfterSerialization()
{
if(!string.IsNullOrEmpty(ConnectedSDKTypeName))
{
connectedSDKType = Type.GetType(ConnectedSDKTypeName);
}
}
19
Source : VRTK_SDKInfo.cs
with MIT License
from charles-river-analytics
with MIT License
from charles-river-analytics
private void SetUp(Type baseType, Type fallbackType, string actualTypeName, int descriptionIndex)
{
if (baseType == null || fallbackType == null)
return;
if (!VRTK_SharedMethods.IsTypeSubclreplacedOf(baseType, typeof(SDK_Base)))
{
VRTK_Logger.Fatal(new ArgumentOutOfRangeException("baseType", baseType, string.Format("'{0}' is not a subclreplaced of the SDK base type '{1}'.", baseType.Name, typeof(SDK_Base).Name)));
return;
}
if (!VRTK_SharedMethods.IsTypeSubclreplacedOf(fallbackType, baseType))
{
VRTK_Logger.Fatal(new ArgumentOutOfRangeException("fallbackType", fallbackType, string.Format("'{0}' is not a subclreplaced of the SDK base type '{1}'.", fallbackType.Name, baseType.Name)));
return;
}
baseTypeName = baseType.FullName;
fallbackTypeName = fallbackType.FullName;
typeName = actualTypeName;
if (string.IsNullOrEmpty(actualTypeName))
{
type = fallbackType;
originalTypeNameWhenFallbackIsUsed = null;
this.descriptionIndex = -1;
description = new SDK_DescriptionAttribute(typeof(SDK_FallbackSystem));
return;
}
Type actualType = Type.GetType(actualTypeName);
if (actualType == null)
{
type = fallbackType;
originalTypeNameWhenFallbackIsUsed = actualTypeName;
this.descriptionIndex = -1;
description = new SDK_DescriptionAttribute(typeof(SDK_FallbackSystem));
VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_NOT_FOUND, actualTypeName, fallbackType.Name));
return;
}
if (!VRTK_SharedMethods.IsTypeSubclreplacedOf(actualType, baseType))
{
VRTK_Logger.Fatal(new ArgumentOutOfRangeException("actualTypeName", actualTypeName, string.Format("'{0}' is not a subclreplaced of the SDK base type '{1}'.", actualTypeName, baseType.Name)));
return;
}
SDK_DescriptionAttribute[] descriptions = SDK_DescriptionAttribute.GetDescriptions(actualType);
if (descriptions.Length <= descriptionIndex)
{
VRTK_Logger.Fatal(new ArgumentOutOfRangeException("descriptionIndex", descriptionIndex, string.Format("'{0}' has no '{1}' at that index.", actualTypeName, typeof(SDK_DescriptionAttribute).Name)));
return;
}
type = actualType;
originalTypeNameWhenFallbackIsUsed = null;
this.descriptionIndex = descriptionIndex;
description = descriptions[descriptionIndex];
}
19
Source : VRTK_SDKInfo.cs
with MIT License
from charles-river-analytics
with MIT License
from charles-river-analytics
public void OnAfterDeserialize()
{
SetUp(Type.GetType(baseTypeName), Type.GetType(fallbackTypeName), typeName, descriptionIndex);
}
19
Source : VRTK_SharedMethods.cs
with MIT License
from charles-river-analytics
with MIT License
from charles-river-analytics
public static Type GetTypeUnknownreplacedembly(string typeName)
{
Type type = Type.GetType(typeName);
if (type != null)
{
return type;
}
#if !UNITY_WSA
replacedembly[] foundreplacedemblies = AppDomain.CurrentDomain.Getreplacedemblies();
for (int i = 0; i < foundreplacedemblies.Length; i++)
{
type = foundreplacedemblies[i].GetType(typeName);
if (type != null)
{
return type;
}
}
#endif
return null;
}
See More Examples