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 : SqliteUserData.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public override void CopyTo(UserData other) {
using UserDataBatchContext batchOther = other.OpenBatch();
using UserDataBatchContext batch = OpenBatch();
lock (GlobalLock) {
MiniCommand mini = new(this);
mini.Next(new() {
SqliteOpenMode.ReadOnly,
$@"
SELECT uid, key, keyfull, registered
FROM meta;
"
});
(SqliteConnection con, SqliteCommand cmd, SqliteDataReader reader) = mini.Read();
List<string> uids = new();
while (reader.Read())
other.Insert(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetBoolean(3));
foreach (string table in GetAllTables()) {
bool data = table.StartsWith("data.");
bool file = table.StartsWith("file.");
if (!data && !file)
continue;
mini.Next(new() {
SqliteOpenMode.ReadOnly,
$@"
SELECT uid, value
FROM [{table}];
",
});
(con, cmd, reader) = mini.Read();
if (data) {
using MiniCommand miniName = new(this) {
mini.Connection,
SqliteOpenMode.ReadOnly,
@"
SELECT real, format, type
FROM data
WHERE name = $name;
",
{ "$name", table }
};
(_, _, SqliteDataReader readerName) = miniName.Read();
miniName.Add((SqliteConnection?) null);
if (!readerName.Read())
continue;
string name = readerName.GetString(0);
string typeName = readerName.GetString(1);
Type? type = Type.GetType(typeName);
while (reader.Read()) {
string uid = reader.GetString(0);
switch ((DataFormat) reader.GetInt32(1)) {
case DataFormat.MessagePack:
default: {
if (type == null) {
// TODO: Cannot transform data from MessagePack to Yaml!
} else {
using Stream stream = reader.GetStream(2);
object? value = MessagePackSerializer.Deserialize(type, stream, MessagePackHelper.Options);
using MemoryStream ms = new();
using StreamWriter msWriter = new(ms);
YamlHelper.Serializer.Serialize(msWriter, value);
ms.Seek(0, SeekOrigin.Begin);
other.InsertData(uid, name, type, ms);
}
break;
}
case DataFormat.Yaml: {
using Stream stream = reader.GetStream(2);
other.InsertData(uid, name, type, stream);
break;
}
}
}
} else if (file) {
using MiniCommand miniName = new(this) {
mini.Connection,
SqliteOpenMode.ReadOnly,
@"
SELECT real
FROM file
WHERE name = $name;
",
{ "$name", table }
};
(_, _, SqliteDataReader readerName) = miniName.Read();
miniName.Add((SqliteConnection?) null);
if (!readerName.Read())
continue;
string name = readerName.GetString(0);
while (reader.Read()) {
string uid = reader.GetString(0);
using Stream stream = reader.GetStream(1);
other.InsertFile(uid, name, stream);
}
} else {
// ??
}
}
}
}
19
Source : TccMaster.cs
with MIT License
from 2881099
with MIT License
from 2881099
TccMaster<TDBKey> Then(Type tccUnitType, object state)
{
if (tccUnitType == null) throw new ArgumentNullException(nameof(tccUnitType));
var unitTypeBase = typeof(TccUnit<>);
if (state == null && tccUnitType.BaseType.GetGenericTypeDefinition() == typeof(TccUnit<>)) unitTypeBase = unitTypeBase.MakeGenericType(tccUnitType.BaseType.GetGenericArguments()[0]);
else unitTypeBase = unitTypeBase.MakeGenericType(state.GetType());
if (unitTypeBase.IsreplacedignableFrom(tccUnitType) == false) throw new ArgumentException($"{tccUnitType.DisplayCsharp(false)} 必须继承 {unitTypeBase.DisplayCsharp(false)}");
var unitCtors = tccUnitType.GetConstructors();
if (unitCtors.Length != 1 && unitCtors[0].GetParameters().Length > 0) throw new ArgumentException($"{tccUnitType.FullName} 不能使用构造函数");
var unitTypeConved = Type.GetType(tccUnitType.replacedemblyQualifiedName);
if (unitTypeConved == null) throw new ArgumentException($"{tccUnitType.FullName} 无效");
var unit = unitTypeConved.CreateInstanceGetDefaultValue() as ITccUnit;
(unit as ITccUnitSetter)?.SetState(state);
_thenUnits.Add(unit);
_thenUnitInfos.Add(new TccUnitInfo
{
Description = unitTypeConved.GetDescription(),
Index = _thenUnitInfos.Count + 1,
Stage = TccUnitStage.Try,
State = state == null ? null : Newtonsoft.Json.JsonConvert.SerializeObject(state),
StateTypeName = state?.GetType().replacedemblyQualifiedName,
Tid = _tid,
TypeName = tccUnitType.replacedemblyQualifiedName,
});
return this;
}
19
Source : SagaMaster.cs
with MIT License
from 2881099
with MIT License
from 2881099
SagaMaster<TDBKey> Then(Type sagaUnitType, object state)
{
if (sagaUnitType == null) throw new ArgumentNullException(nameof(sagaUnitType));
var unitTypeBase = typeof(SagaUnit<>);
if (state == null && sagaUnitType.BaseType.GetGenericTypeDefinition() == typeof(SagaUnit<>)) unitTypeBase = unitTypeBase.MakeGenericType(sagaUnitType.BaseType.GetGenericArguments()[0]);
else unitTypeBase = unitTypeBase.MakeGenericType(state.GetType());
if (unitTypeBase.IsreplacedignableFrom(sagaUnitType) == false) throw new ArgumentException($"{sagaUnitType.DisplayCsharp(false)} 必须继承 {unitTypeBase.DisplayCsharp(false)}");
var unitCtors = sagaUnitType.GetConstructors();
if (unitCtors.Length != 1 && unitCtors[0].GetParameters().Length > 0) throw new ArgumentException($"{sagaUnitType.FullName} 不能使用构造函数");
var unitTypeConved = Type.GetType(sagaUnitType.replacedemblyQualifiedName);
if (unitTypeConved == null) throw new ArgumentException($"{sagaUnitType.FullName} 无效");
var unit = unitTypeConved.CreateInstanceGetDefaultValue() as ISagaUnit;
(unit as ISagaUnitSetter)?.SetState(state);
_thenUnits.Add(unit);
_thenUnitInfos.Add(new SagaUnitInfo
{
Description = unitTypeConved.GetDescription(),
Index = _thenUnitInfos.Count + 1,
Stage = SagaUnitStage.Commit,
State = state == null ? null : Newtonsoft.Json.JsonConvert.SerializeObject(state),
StateTypeName = state?.GetType().replacedemblyQualifiedName,
Tid = _tid,
TypeName = sagaUnitType.replacedemblyQualifiedName,
});
return this;
}
19
Source : DynamicProxy.cs
with MIT License
from 2881099
with MIT License
from 2881099
static replacedembly CompileCode(string cscode)
{
var files = Directory.GetFiles(Directory.GetParent(Type.GetType("FreeSql.DynamicProxy, FreeSql.DynamicProxy").replacedembly.Location).FullName);
using (var compiler = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("cs"))
{
var objCompilerParameters = new System.CodeDom.Compiler.CompilerParameters();
objCompilerParameters.Referencedreplacedemblies.Add("System.dll");
objCompilerParameters.Referencedreplacedemblies.Add("System.Core.dll");
objCompilerParameters.Referencedreplacedemblies.Add("FreeSql.DynamicProxy.dll");
foreach (var dll in files)
{
if (!dll.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) &&
!dll.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) continue;
Console.WriteLine(dll);
var dllName = string.Empty;
var idx = dll.LastIndexOf('/');
if (idx != -1) dllName = dll.Substring(idx + 1);
else
{
idx = dll.LastIndexOf('\\');
if (idx != -1) dllName = dll.Substring(idx + 1);
}
if (string.IsNullOrEmpty(dllName)) continue;
try
{
var replaced = replacedembly.LoadFile(dll);
objCompilerParameters.Referencedreplacedemblies.Add(dllName);
}
catch
{
}
}
objCompilerParameters.GenerateExecutable = false;
objCompilerParameters.GenerateInMemory = true;
var cr = compiler.CompilereplacedemblyFromSource(objCompilerParameters, cscode);
if (cr.Errors.Count > 0)
throw new DynamicProxyException($"FreeSql.DynamicProxy 失败提示:{cr.Errors[0].ErrorText} {cscode}", null);
return cr.Compiledreplacedembly;
}
}
19
Source : ILRuntimeManager.cs
with MIT License
from 404Lcc
with MIT License
from 404Lcc
public unsafe void InitializeILRuntime()
{
#if UNITY_EDITOR
appdomain.DebugService.StartDebugService(56000);
#endif
#if DEBUG && (UNITY_EDITOR || UNITY_ANDROID || UNITY_IPHONE)
appdomain.UnityMainThreadID = Thread.CurrentThread.ManagedThreadId;
#endif
ILRuntimeHelper.RegisterCrossBindingAdaptor(appdomain);
ILRuntimeHelper.RegisterCLRMethodRedirction(appdomain);
ILRuntimeHelper.RegisterMethodDelegate(appdomain);
ILRuntimeHelper.RegisterValueTypeBinderHelper(appdomain);
JsonMapper.RegisterILRuntimeCLRRedirection(appdomain);
PType.RegisterILRuntimeCLRRedirection(appdomain);
Type.GetType("ILRuntime.Runtime.Generated.CLRBindings")?.GetMethod("Initialize")?.Invoke(null, new object[] { appdomain });
typeList = appdomain.LoadedTypes.Values.Select(x => x.ReflectionType).ToList();
}
19
Source : PType.cs
with MIT License
from 404Lcc
with MIT License
from 404Lcc
public static object CreateInstance(Type type)
{
if (Type.GetType(type.FullName) == null)
{
if (CreateInstanceFunc != null)
{
return CreateInstanceFunc.Invoke(type.FullName);
}
}
return Activator.CreateInstance(type
#if !(CF || SILVERLIGHT || WINRT || PORTABLE || NETSTANDARD1_3 || NETSTANDARD1_4)
, nonPublic: true
#endif
);
}
19
Source : CometaryExtensions.cs
with MIT License
from 71
with MIT License
from 71
public static Type GetCorrespondingType(this ITypeSymbol symbol)
{
if (symbol == null)
throw new ArgumentNullException(nameof(symbol));
switch (symbol.TypeKind)
{
case TypeKind.Array:
return ((IArrayTypeSymbol)symbol).ElementType.GetCorrespondingType().MakeArrayType();
case TypeKind.Enum:
case TypeKind.Clreplaced:
case TypeKind.Delegate:
case TypeKind.Interface:
case TypeKind.Struct:
break;
case TypeKind.Pointer:
return ((IPointerTypeSymbol)symbol).PointedAtType.GetCorrespondingType().MakePointerType();
case TypeKind.TypeParameter:
ITypeParameterSymbol typeParameter = (ITypeParameterSymbol)symbol;
return typeParameter.DeclaringType.GetCorrespondingType().GenericTypeArguments[typeParameter.Ordinal];
default:
throw new ArgumentOutOfRangeException();
}
INamedTypeSymbol named = (INamedTypeSymbol)symbol;
Type type = named.ContainingNamespace.IsGlobalNamespace
? Type.GetType($"{named.MetadataName}, {named.Containingreplacedembly.MetadataName}")
: Type.GetType($"{named.ContainingNamespace}.{named.MetadataName}, {named.Containingreplacedembly.MetadataName}");
if (type == null)
return null;
int typeArgsLength = type.GenericTypeArguments.Length;
if (typeArgsLength == 0)
return type;
Type[] typeArgs = new Type[typeArgsLength];
for (int i = 0; i < typeArgsLength; i++)
{
typeArgs[i] = named.TypeArguments[i].GetCorrespondingType();
}
return type.MakeGenericType(typeArgs);
}
19
Source : Utility.Convertor.cs
with MIT License
from 7Bytes-Studio
with MIT License
from 7Bytes-Studio
public static Type Convert(string typeStr)
{
if (typeStr == "int") typeStr = "Int32";
else if (typeStr == "float") typeStr = "Single";
else if (typeStr == "double") typeStr = "Double";
else if (typeStr == "decimal") typeStr = "Decimal";
else if (typeStr == "char") typeStr = "Char";
else if (typeStr == "string") typeStr = "String";
if (typeStr.Contains("int")) typeStr=typeStr.Replace("int", "Int32");
if (typeStr.Contains("float")) typeStr=typeStr.Replace("float", "Single");
if (typeStr.Contains("double")) typeStr=typeStr.Replace("double", "Double");
if (typeStr.Contains("decimal")) typeStr=typeStr.Replace("decimal", "Decimal");
if (typeStr.Contains("char")) typeStr=typeStr.Replace("char", "Char");
if (typeStr.Contains("string")) typeStr=typeStr.Replace("string", "String");
if (typeStr.StartsWith("List"))
{
return Type.GetType(string.Format("System.Collections.Generic.List`1[System.{0}]", typeStr.Slice('<','>')));
}
else if (typeStr.StartsWith("Dictionary"))
{
var str = typeStr.Slice('<', '>');
var s = str.Split(',');
return Type.GetType(string.Format("System.Collections.Generic.Dictionary`2[System.{0},System.{1}]", s[0], s[1]));
}
else
{
return Type.GetType(string.Format("System.{0}", typeStr));
}
}
19
Source : UMAAssetIndexerEditor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void ShowTypes()
{
GUILayout.BeginHorizontal(EditorStyles.toolbarButton);
GUILayout.Space(10);
bShowTypes = EditorGUILayout.Foldout(bShowTypes, "Additional Indexed Types");
GUILayout.EndHorizontal();
if (bShowTypes)
{
GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
// Draw and handle the Drag/Drop
GUILayout.Space(20);
Rect dropTypeArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));
GUI.Box(dropTypeArea, "Drag a single type here to start indexing that type.");
GUILayout.Space(20);
DropAreaType(dropTypeArea);
foreach (string s in UAI.IndexedTypeNames)
{
System.Type CurrentType = System.Type.GetType(s);
GUILayout.BeginHorizontal(EditorStyles.textField);
GUILayout.Label(CurrentType.ToString(), GUILayout.MinWidth(240));
if (GUILayout.Button("-", GUILayout.Width(20.0f)))
{
RemovedTypes.Add(CurrentType);
}
GUILayout.EndHorizontal();
}
GUIHelper.EndVerticalPadded(10);
}
}
19
Source : UMAAssetIndexer.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
void ISerializationCallbackReceiver.OnAfterDeserialize()
{
var st = StartTimer();
#region typestuff
List<System.Type> newTypes = new List<System.Type>()
{
(typeof(SlotDatareplacedet)),
(typeof(OverlayDatareplacedet)),
(typeof(RaceData)),
(typeof(UMATextRecipe)),
(typeof(UMAWardrobeRecipe)),
(typeof(UMAWardrobeCollection)),
(typeof(RuntimeAnimatorController)),
#if UNITY_EDITOR
(typeof(AnimatorController)),
#endif
(typeof(DynamireplacedADnareplacedet)),
(typeof(Textreplacedet))
};
TypeToLookup = new Dictionary<System.Type, System.Type>()
{
{ (typeof(SlotDatareplacedet)),(typeof(SlotDatareplacedet)) },
{ (typeof(OverlayDatareplacedet)),(typeof(OverlayDatareplacedet)) },
{ (typeof(RaceData)),(typeof(RaceData)) },
{ (typeof(UMATextRecipe)),(typeof(UMATextRecipe)) },
{ (typeof(UMAWardrobeRecipe)),(typeof(UMAWardrobeRecipe)) },
{ (typeof(UMAWardrobeCollection)),(typeof(UMAWardrobeCollection)) },
{ (typeof(RuntimeAnimatorController)),(typeof(RuntimeAnimatorController)) },
#if UNITY_EDITOR
{ (typeof(AnimatorController)),(typeof(RuntimeAnimatorController)) },
#endif
{ typeof(Textreplacedet), typeof(Textreplacedet) },
{ (typeof(DynamireplacedADnareplacedet)), (typeof(DynamireplacedADnareplacedet)) }
};
List<string> invalidTypeNames = new List<string>();
// Add the additional Types.
foreach (string s in IndexedTypeNames)
{
if (s == "")
continue;
System.Type sType = System.Type.GetType(s);
if (sType == null)
{
invalidTypeNames.Add(s);
Debug.LogWarning("Could not find type for " + s);
continue;
}
newTypes.Add(sType);
if (!TypeToLookup.ContainsKey(sType))
{
TypeToLookup.Add(sType, sType);
}
}
Types = newTypes.ToArray();
if (invalidTypeNames.Count > 0)
{
foreach (string ivs in invalidTypeNames)
{
IndexedTypeNames.Remove(ivs);
}
}
BuildStringTypes();
#endregion
UpdateSerializedDictionaryItems();
StopTimer(st, "Before Serialize");
}
19
Source : CommonUtils.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
static string Process(object obj, int level, string prefLine, Dictionary<object, int> forParentLink, HashSet<string> excludeTypes)
{
try
{
if (obj == null) return "";
Type type = obj.GetType();
if (excludeTypes.Contains(type.Name)) return "<skip>";
if (type == typeof(DateTime))
{
return ((DateTime)obj).ToString("g");
}
else if (type.IsValueType || type == typeof(string))
{
return obj.ToString();
}
else if (type.IsArray || obj is IEnumerable)
{
string elementType = null;
Array array = null;
if (type.IsArray)
{
var tt = Type.GetType(type.FullName.Replace("[]", string.Empty));
if (tt != null)
{
elementType = tt.ToString();
if (excludeTypes.Contains(tt.Name)) return "<skips>";
}
//else return "<EEEEEEE" + type.FullName;
array = obj as Array;
}
else
{
//как лучше узнать кол-во и тип?
int cnt = 0;
foreach (var o in obj as IEnumerable) cnt++;
array = Array.CreateInstance(typeof(object), cnt);
int i = 0;
foreach (var o in obj as IEnumerable)
{
if (elementType == null && o != null)
{
var tt = o.GetType();
if (excludeTypes.Contains(tt.Name)) return "<skips>";
elementType = tt.ToString();
}
array.SetValue(o, i++);
}
}
if (elementType == null) elementType = "Object";
if (excludeTypes.Contains(elementType)) return "<skips>";
var info = "<" + elementType + "[" + array.Length.ToString() + "]" + ">";
if (level == 0)
{
return info + "[...]";
}
if (array.Length > 0)
{
var ress = new string[array.Length];
var resl = 0;
for (int i = 0; i < array.Length; i++)
{
ress[i] = Process(array.GetValue(i), level - 1, prefLine + PrefLineTab, forParentLink, excludeTypes);
resl += ress[i].Length;
}
if (resl < LineLength)
{
var res = info + "[" + ress[0];
for (int i = 1; i < ress.Length; i++)
{
res += ", " + ress[i];
}
return res + "]";
}
else
{
var res = info + "["
+ Environment.NewLine + prefLine + ress[0];
for (int i = 1; i < ress.Length; i++)
{
res += ", "
+ Environment.NewLine + prefLine + ress[i];
}
return res + Environment.NewLine + prefLine + "]";
}
}
return info + "[]";
}
else if (obj is Type) return "<Type>" + obj.ToString();
else if (type.IsClreplaced)
{
var info = "<" + type.Name + ">";
if (forParentLink.ContainsKey(obj))
{
if (forParentLink[obj] >= level)
return info + "{duplicate}";
else
forParentLink[obj] = level;
}
else
forParentLink.Add(obj, level);
if (level == 0)
{
return info + "{...}";
}
FieldInfo[] fields = type.GetFields(BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.Instance);
if (fields.Length > 0)
{
var ress = new string[fields.Length];
var resl = 0;
for (int i = 0; i < fields.Length; i++)
{
object fieldValue = fields[i].GetValue(obj);
ress[i] = fieldValue == null
? fields[i].Name + ": null"
: fields[i].Name + ": " + Process(fieldValue, level - 1, prefLine + PrefLineTab, forParentLink, excludeTypes);
resl += ress[i].Length;
}
if (resl < LineLength)
{
var res = info + "{" + ress[0];
for (int i = 1; i < ress.Length; i++)
{
res += ", " + ress[i];
}
return res + "}";
}
else
{
var res = info + "{"
+ Environment.NewLine + prefLine + ress[0];
for (int i = 1; i < ress.Length; i++)
{
res += ", "
+ Environment.NewLine + prefLine + ress[i];
}
return res + Environment.NewLine + prefLine + "}";
}
}
return info + "{}";
}
else
throw new ArgumentException("Unknown type");
}
catch
{
return "<exception>";
}
}
19
Source : ServerCoreSerializationBinder.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public override Type BindToType(string replacedemblyName, string typeName)
{
if (replacedemblyName.Contains("OCServer"))
{
var bindToType = Type.GetType(typeName.Replace("OCServer", "ServerOnlineCity"));
return bindToType;
}
else
{
var bindToType = LoadTypeFromreplacedembly(replacedemblyName, typeName.Replace("OCServer", "ServerOnlineCity"));
return bindToType;
}
}
19
Source : ViewLocator.cs
with MIT License
from Abdesol
with MIT License
from Abdesol
public IControl Build(object data)
{
var name = data.GetType().FullName!.Replace("ViewModel", "View");
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
else
{
return new TextBlock { Text = "Not Found: " + name };
}
}
19
Source : SystemType.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
void ISerializationCallbackReceiver.OnAfterDeserialize()
{
// Clreplaced references may move between asmdef or be renamed throughout MRTK development
// Check to see if we need to update our reference value
reference = TryMigrateReference(reference);
type = !string.IsNullOrEmpty(reference) ? Type.GetType(reference) : null;
}
19
Source : TypeReferencePropertyDrawer.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private static Type ResolveType(string clreplacedRef)
{
Type type;
if (!TypeMap.TryGetValue(clreplacedRef, out type))
{
type = !string.IsNullOrEmpty(clreplacedRef) ? Type.GetType(clreplacedRef) : null;
TypeMap[clreplacedRef] = type;
}
return type;
}
19
Source : UnityPlayerBuildTools.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public static void SyncSolution()
{
var syncVs = Type.GetType("UnityEditor.SyncVS,UnityEditor");
var syncSolution = syncVs.GetMethod("SyncSolution", BindingFlags.Public | BindingFlags.Static);
syncSolution.Invoke(null, null);
}
19
Source : MixedRealityCanvasInspector.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private void OnEnable()
{
canvasEditorType = Type.GetType("UnityEditor.CanvasEditor, UnityEditor");
if (canvasEditorType != null)
{
internalEditor = CreateEditor(targets, canvasEditorType);
canvas = target as Canvas;
isRootCanvas = canvas.transform.parent == null || canvas.transform.parent.GetComponentInParent<Canvas>() == null;
}
}
19
Source : FileCache.cs
with Apache License 2.0
from acarteas
with Apache License 2.0
from acarteas
public override Type BindToType(string replacedemblyName, string typeName)
{
Type typeToDeserialize = null;
String currentreplacedembly = replacedembly.Getreplacedembly(typeof(LocalCacheBinder)).FullName;
replacedemblyName = currentreplacedembly;
// Get the type using the typeName and replacedemblyName
typeToDeserialize = Type.GetType(String.Format("{0}, {1}",
typeName, replacedemblyName));
return typeToDeserialize;
}
19
Source : FileCacheBinder.cs
with Apache License 2.0
from acarteas
with Apache License 2.0
from acarteas
public override Type BindToType(string replacedemblyName, string typeName)
{
Type typeToDeserialize = null;
String currentreplacedembly = replacedembly.GetExecutingreplacedembly().FullName;
// In this case we are always using the current replacedembly
replacedemblyName = currentreplacedembly;
// Get the type using the typeName and replacedemblyName
typeToDeserialize = Type.GetType(String.Format("{0}, {1}",
typeName, replacedemblyName));
return typeToDeserialize;
}
19
Source : FileCacheManager.cs
with Apache License 2.0
from acarteas
with Apache License 2.0
from acarteas
public override Type BindToType(string replacedemblyName, string typeName)
{
Type typeToDeserialize = null;
String currentreplacedembly = replacedembly.Getreplacedembly(typeof(LocalCacheBinder)).FullName;
replacedemblyName = currentreplacedembly;
// Get the type using the typeName and replacedemblyName
typeToDeserialize = Type.GetType(String.Format("{0}, {1}",
typeName, replacedemblyName));
return typeToDeserialize;
}
19
Source : VssConnection.cs
with MIT License
from actions
with MIT License
from actions
private Type GetExtensibleType(Type managedType)
{
if (managedType.GetTypeInfo().IsAbstract || managedType.GetTypeInfo().IsInterface)
{
Type extensibleType = null;
// We can add extensible type registration for the client later (app.config? windows registry?). For now it is based solely on the attribute
if (!m_extensibleServiceTypes.TryGetValue(managedType.Name, out extensibleType))
{
VssClientServiceImplementationAttribute[] attributes = (VssClientServiceImplementationAttribute[])managedType.GetTypeInfo().GetCustomAttributes<VssClientServiceImplementationAttribute>(true);
if (attributes.Length > 0)
{
if (attributes[0].Type != null)
{
extensibleType = attributes[0].Type;
m_extensibleServiceTypes[managedType.Name] = extensibleType;
}
else if (!String.IsNullOrEmpty(attributes[0].TypeName))
{
extensibleType = Type.GetType(attributes[0].TypeName);
if (extensibleType != null)
{
m_extensibleServiceTypes[managedType.Name] = extensibleType;
}
else
{
Debug.replacedert(false, "VssConnection: Could not load type from type name: " + attributes[0].TypeName);
}
}
}
}
if (extensibleType == null)
{
throw new ExtensibleServiceTypeNotRegisteredException(managedType);
}
if (!managedType.GetTypeInfo().IsreplacedignableFrom(extensibleType.GetTypeInfo()))
{
throw new ExtensibleServiceTypeNotValidException(managedType, extensibleType);
}
return extensibleType;
}
else
{
return managedType;
}
}
19
Source : TypeExtensions.cs
with MIT License
from Adoxio
with MIT License
from Adoxio
public static Type GetType(string typeName)
{
Type type = Type.GetType(typeName);
if (type != null)
{
return type;
}
if (typeName.Contains(","))
{
// replacedume a comma means that the replacedembly name is explicity specified
return null;
}
// the specified type is not in mscorlib so we will go through the loaded replacedemblies
replacedembly[] replacedemblies = AppDomain.CurrentDomain.Getreplacedemblies();
foreach (replacedembly replacedembly in replacedemblies)
{
type = Type.GetType(typeName + ", " + replacedembly.FullName);
if (type != null)
{
return type;
}
}
return null;
}
19
Source : LiveIdLoginStatus.cs
with MIT License
from Adoxio
with MIT License
from Adoxio
private bool LiveIdWebAuthenticationHandlerExists()
{
if (Context.Request.ServerVariables.Get("MANAGED_PIPELINE_MODE") == "Integrated") return true;
var handlersSection = (HttpHandlersSection)WebConfigurationManager.GetSection("system.web/httpHandlers");
foreach (HttpHandlerAction handler in handlersSection.Handlers)
{
if (Type.GetType(handler.Type) == typeof(LiveIdWebAuthenticationHandler)
|| Type.GetType(handler.Type) == typeof(LiveIdAccountTransferHandler))
{
return true;
}
}
return false;
}
19
Source : TypeHelpers.cs
with MIT License
from adrianoc
with MIT License
from adrianoc
public static FieldInfo ResolveField(string declaringType, string fieldName)
{
var type = Type.GetType(declaringType);
if (type == null)
{
throw new Exception("Could not resolve field: '" + fieldName + "'. Type '" + declaringType + "' not found.");
}
return type.GetField(fieldName);
}
19
Source : TypeHelper.cs
with MIT License
from Adyen
with MIT License
from Adyen
internal static Type CreateGenericTypeFromStringFullNamespace(Type genericType, string tFullNamespace)
{
Type[] typeArgs = { Type.GetType(tFullNamespace) };
Type repositoryType = genericType.MakeGenericType(typeArgs);
return repositoryType;
}
19
Source : PhoneGameLoop.cs
with GNU General Public License v3.0
from aedenthorn
with GNU General Public License v3.0
from aedenthorn
public static void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
{
foreach (IContentPack contentPack in Helper.ContentPacks.GetOwned())
{
Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}");
try
{
MobilePhonePackJSON json = contentPack.ReadJsonFile<MobilePhonePackJSON>("content.json") ?? null;
if(json != null)
{
if (json.apps != null && json.apps.Any())
{
foreach (AppJSON app in json.apps)
{
Texture2D tex = contentPack.Loadreplacedet<Texture2D>(app.iconPath);
if (tex == null)
{
continue;
}
ModEntry.apps.Add(app.id, new MobileApp(app.name, app.keyPress, app.closePhone, tex));
Monitor.Log($"Added app {app.name} from {contentPack.DirectoryPath}");
}
}
else if (json.iconPath != null)
{
Texture2D icon = contentPack.Loadreplacedet<Texture2D>(json.iconPath);
if (icon == null)
{
continue;
}
ModEntry.apps.Add(json.id, new MobileApp(json.name, json.keyPress, json.closePhone, icon));
Monitor.Log($"Added app {json.name} from {contentPack.DirectoryPath}");
}
if (json.invites != null && json.invites.Any())
{
foreach (EventInvite invite in json.invites)
{
MobilePhoneCall.eventInvites.Add(invite);
Monitor.Log($"Added event invite {invite.name} from {contentPack.DirectoryPath}");
}
}
}
}
catch (Exception ex)
{
Monitor.Log($"error reading content.json file in content pack {contentPack.Manifest.Name}.\r\n{ex}", LogLevel.Error);
}
if (Directory.Exists(Path.Combine(contentPack.DirectoryPath, "replacedets", "events")))
{
Monitor.Log($"Adding events");
string[] events = Directory.GetFiles(Path.Combine(contentPack.DirectoryPath, "replacedets", "events"), "*.json");
Monitor.Log($"CP has {events.Length} events");
foreach (string eventFile in events)
{
try
{
string eventPath = Path.Combine("replacedets", "events", Path.GetFileName(eventFile));
Monitor.Log($"Adding events {Path.GetFileName(eventFile)} from {contentPack.DirectoryPath}");
Reminiscence r = contentPack.ReadJsonFile<Reminiscence>(eventPath);
MobilePhoneCall.contentPackReminiscences.Add(Path.GetFileName(eventFile).Replace(".json", ""), r);
Monitor.Log($"Added event {Path.GetFileName(eventFile)} from {contentPack.DirectoryPath}");
}
catch { }
}
}
if (Directory.Exists(Path.Combine(contentPack.DirectoryPath, "replacedets", "skins")))
{
Monitor.Log($"Adding skins");
string[] skins = Directory.GetFiles(Path.Combine(contentPack.DirectoryPath, "replacedets", "skins"), "*_landscape.png");
Monitor.Log($"CP has {skins.Length} skins");
foreach (string skinFile in skins)
{
try
{
string skinPath = Path.Combine("replacedets", "skins", Path.GetFileName(skinFile));
Monitor.Log($"Adding skin {Path.GetFileName(skinFile).Replace("_landscape.png", "")} from {contentPack.DirectoryPath}");
Texture2D skin = contentPack.Loadreplacedet<Texture2D>(skinPath.Replace("_landscape.png", ".png"));
Texture2D skinl = contentPack.Loadreplacedet<Texture2D>(skinPath);
ThemeApp.skinList.Add(contentPack.Manifest.UniqueID + ":" + Path.GetFileName(skinFile).Replace("_landscape.png", ""));
ThemeApp.skinDict.Add(contentPack.Manifest.UniqueID + ":" + Path.GetFileName(skinFile).Replace("_landscape.png", ""), new Texture2D[] { skin, skinl});
Monitor.Log($"Added skin {Path.GetFileName(skinFile).Replace("_landscape.png", "")} from {contentPack.DirectoryPath}");
}
catch { }
}
}
if (Directory.Exists(Path.Combine(contentPack.DirectoryPath, "replacedets", "backgrounds")))
{
Monitor.Log($"Adding backgrounds");
string[] backgrounds = Directory.GetFiles(Path.Combine(contentPack.DirectoryPath, "replacedets", "backgrounds"), "*_landscape.png");
Monitor.Log($"CP has {backgrounds.Length} backgrounds");
foreach (string backFile in backgrounds)
{
try
{
string backPath = Path.Combine("replacedets", "backgrounds", Path.GetFileName(backFile));
Monitor.Log($"Adding background {Path.GetFileName(backFile).Replace("_landscape.png", "")} from {contentPack.DirectoryPath}");
Texture2D back = contentPack.Loadreplacedet<Texture2D>(backPath.Replace("_landscape.png", ".png"));
Texture2D backl = contentPack.Loadreplacedet<Texture2D>(backPath);
ThemeApp.backgroundDict.Add(contentPack.Manifest.UniqueID + ":" + Path.GetFileName(backFile).Replace("_landscape.png", ""), new Texture2D[] { back, backl });
ThemeApp.backgroundList.Add(contentPack.Manifest.UniqueID + ":" + Path.GetFileName(backFile).Replace("_landscape.png", ""));
Monitor.Log($"Added background {Path.GetFileName(backFile).Replace("_landscape.png", "")} from {contentPack.DirectoryPath}");
}
catch { }
}
}
if (Directory.Exists(Path.Combine(contentPack.DirectoryPath, "replacedets", "ringtones")))
{
Monitor.Log($"Adding ringtones");
string[] rings = Directory.GetFiles(Path.Combine(contentPack.DirectoryPath, "replacedets", "ringtones"), "*.wav");
Monitor.Log($"CP has {rings.Length} ringtones");
foreach (string path in rings)
{
try
{
object ring;
try
{
var type = Type.GetType("System.Media.SoundPlayer, System");
ring = Activator.CreateInstance(type, new object[] { path });
}
catch
{
ring = SoundEffect.FromStream(new FileStream(path, FileMode.Open));
}
if (ring != null)
{
ThemeApp.ringDict.Add(string.Concat(contentPack.Manifest.UniqueID,":", Path.GetFileName(path).Replace(".wav", "")), ring);
ThemeApp.ringList.Add(string.Concat(contentPack.Manifest.UniqueID,":", Path.GetFileName(path).Replace(".wav", "")));
Monitor.Log($"loaded ring {path}");
}
else
Monitor.Log($"Couldn't load ring {path}");
}
catch (Exception ex)
{
Monitor.Log($"Couldn't load ring {path}:\r\n{ex}", LogLevel.Error);
}
}
}
}
ModEntry.listHeight = Config.IconMarginY + (int)Math.Ceiling(ModEntry.apps.Count / (float)ModEntry.gridWidth) * (Config.IconHeight + Config.IconMarginY);
PhoneVisuals.CreatePhoneTextures();
PhoneUtils.RefreshPhoneLayout();
if (Helper.ModRegistry.IsLoaded("purrplingcat.npcadventure"))
{
INpcAdventureModApi api = Helper.ModRegistry.GetApi<INpcAdventureModApi>("purrplingcat.npcadventure");
if (api != null)
{
Monitor.Log("Loaded NpcAdventureModApi successfully");
ModEntry.npcAdventureModApi = api;
}
}
}
19
Source : ThemeApp.cs
with GNU General Public License v3.0
from aedenthorn
with GNU General Public License v3.0
from aedenthorn
private static void CreateThemeLists()
{
if (Directory.Exists(Path.Combine(Helper.DirectoryPath, "replacedets", "skins")))
{
string[] skins = Directory.GetFiles(Path.Combine(Helper.DirectoryPath, "replacedets", "skins"), "*_landscape.png");
foreach (string path in skins)
{
try
{
Texture2D skin = Helper.Content.Load<Texture2D>(Path.Combine("replacedets", "skins", Path.GetFileName(path).Replace("_landscape", "")));
Texture2D skinl = Helper.Content.Load<Texture2D>(Path.Combine("replacedets", "skins", Path.GetFileName(path)));
if (skin != null && skinl != null)
{
skinDict.Add(Path.Combine("replacedets", "skins", Path.GetFileName(path).Replace("_landscape", "")), new Texture2D[] { skin, skinl });
Monitor.Log($"loaded skin {path.Replace("_landscape", "")}");
}
else
Monitor.Log($"Couldn't load skin {path.Replace("_landscape", "")}: texture was null", LogLevel.Error);
}
catch (Exception ex)
{
Monitor.Log($"Couldn't load skin {path.Replace("_landscape", "")}: {ex}", LogLevel.Error);
}
}
}
if (Directory.Exists(Path.Combine(Helper.DirectoryPath, "replacedets", "backgrounds")))
{
string[] papers = Directory.GetFiles(Path.Combine(Helper.DirectoryPath, "replacedets", "backgrounds"), "*_landscape.png");
foreach (string path in papers)
{
try
{
Texture2D back = Helper.Content.Load<Texture2D>(Path.Combine("replacedets", "backgrounds", Path.GetFileName(path).Replace("_landscape", "")));
Texture2D backl = Helper.Content.Load<Texture2D>(Path.Combine("replacedets", "backgrounds", Path.GetFileName(path)));
if (back != null && backl != null)
{
backgroundDict.Add(Path.Combine("replacedets", "backgrounds", Path.GetFileName(path).Replace("_landscape", "")), new Texture2D[] { back, backl });
Monitor.Log($"loaded background {path.Replace("_landscape", "")}");
}
else
Monitor.Log($"Couldn't load background {path.Replace("_landscape", "")}: texture was null", LogLevel.Error);
}
catch (Exception ex)
{
Monitor.Log($"Couldn't load background {path.Replace("_landscape", "")}: {ex}", LogLevel.Error);
}
}
}
if (Directory.Exists(Path.Combine(Helper.DirectoryPath, "replacedets", "ringtones")))
{
string[] rings = Directory.GetFiles(Path.Combine(Helper.DirectoryPath, "replacedets", "ringtones"), "*.wav");
foreach (string path in rings)
{
try
{
object ring;
try
{
var type = Type.GetType("System.Media.SoundPlayer, System");
ring = Activator.CreateInstance(type, new object[] { path });
}
catch
{
ring = SoundEffect.FromStream(new FileStream(path, FileMode.Open));
}
if (ring != null)
{
ringDict.Add(Path.GetFileName(path).Replace(".wav", ""), ring);
Monitor.Log($"loaded ring {path}");
}
else
Monitor.Log($"Couldn't load ring {path}", LogLevel.Error);
}
catch (Exception ex)
{
Monitor.Log($"Couldn't load ring {path}:\r\n{ex}", LogLevel.Error);
}
}
rings = Config.BuiltInRingTones.Split(',');
foreach (string ring in rings)
{
ringDict.Add(ring, null);
}
}
ringList = ringDict.Keys.ToList();
skinList = skinDict.Keys.ToList();
backgroundList = backgroundDict.Keys.ToList();
}
19
Source : IoC.cs
with MIT License
from afaniuolo
with MIT License
from afaniuolo
public static IFieldConverter CreateInstance(string converterType)
{
try
{
if (string.IsNullOrEmpty(converterType))
return null;
var type = Type.GetType(converterType);
return (IFieldConverter)container.GetInstance(type);
}
catch (Exception ex)
{
// TODO: Add Logging
return null;
}
}
19
Source : AssemblyHelper.cs
with MIT License
from AFei19911012
with MIT License
from AFei19911012
public static object CreateInternalInstance(string clreplacedName)
{
try
{
var type = Type.GetType($"{NameSpaceStr}.{clreplacedName}");
return type == null ? null : Activator.CreateInstance(type);
}
catch
{
return null;
}
}
19
Source : AsertSigning.cs
with GNU General Public License v3.0
from Agasper
with GNU General Public License v3.0
from Agasper
public static Type GetClreplaced()
{
return Type.GetType("UnityEngine.UnityCertificate, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
}
19
Source : EnumHelper.cs
with Mozilla Public License 2.0
from agebullhu
with Mozilla Public License 2.0
from agebullhu
public static List<IEnumInfomation> GetEnumInfomation(string typeName)
{
return GetEnumInfomation(Type.GetType(typeName));
}
19
Source : ViewLocator.cs
with MIT License
from ahopper
with MIT License
from ahopper
public IControl Build(object data)
{
var typeName = data.GetType().FullName;
if (typeName?.Replace("ViewModel", "View") is string name )
{
if(Type.GetType(name) is Type type)
{
if(Activator.CreateInstance(type) is Control control)
{
return control;
}
}
}
return new TextBlock { Text = $"View Not Found For: { typeName ?? data.GetType().Name }" };
}
19
Source : Type.cs
with Mozilla Public License 2.0
from ahyahy
with Mozilla Public License 2.0
from ahyahy
[ContextMethod("ЭтоПодкласс", "IsSubclreplacedOf")]
public bool IsSubclreplacedOf(ClType p1)
{
string str1 = Base_obj.ToString();
string str2 = p1.Base_obj.ToString();
System.Type Type1 = System.Type.GetType(str1.Replace("osf.Cl", "osf."));
System.Type Type2 = System.Type.GetType(str2.Replace("osf.Cl", "osf."));
return Type1.IsSubclreplacedOf(Type2);
}
19
Source : Type.cs
with Mozilla Public License 2.0
from ahyahy
with Mozilla Public License 2.0
from ahyahy
[ContextMethod("ЭтоЭкземплярТипа", "IsInstanceOfType")]
public bool IsInstanceOfType(IValue p1)
{
string str1 = Base_obj.ToString();
System.Type Type1 = System.Type.GetType(str1.Replace("osf.Cl", "osf."));
return Type1.IsInstanceOfType(((dynamic)p1).Base_obj);
}
19
Source : XmlAssetProcessor.cs
with MIT License
from aillieo
with MIT License
from aillieo
private static NodeBase XmlElementToBTNode(XmlElement xmlEle, NodeParent nodeParent = null)
{
string type = xmlEle.GetAttribute("type");
Type t = Type.GetType(type);
if (t == null)
{
return null;
}
NodeBase node = Activator.CreateInstance(t) as NodeBase;
if (node == null)
{
return null;
}
node.name = xmlEle.Name;
if (nodeParent != null)
{
nodeParent.AddChild(node);
}
XmlNodeList childNodes = xmlEle.ChildNodes;
if (childNodes.Count > 0)
{
foreach (var xmlNode in childNodes)
{
XmlElement childEle = xmlNode as XmlElement;
switch (childEle.Name)
{
case "param":
foreach (var xmlParam in childEle.ChildNodes)
{
XmlElement xe = xmlParam as XmlElement;
if (xe != null)
{
string name = xe.Name;
string typeInfo = xe.GetAttribute("type");
string serializedValue = xe.GetAttribute("value");
object value = ParamInfoProcessor.Load(Type.GetType(typeInfo), serializedValue);
node.GetType().GetField(name,BindingFlags.Instance|BindingFlags.NonPublic|BindingFlags.Public).SetValue(node,value);
}
}
break;
case "children":
foreach (var xmlChild in childEle.ChildNodes)
{
XmlElementToBTNode(xmlChild as XmlElement, node as NodeParent);
}
break;
}
}
}
return node;
}
19
Source : ParamDrawer.cs
with MIT License
from aillieo
with MIT License
from aillieo
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EnsureParamType();
switch (paramType)
{
case ParamType.Unknown:
Debug.LogError("Unknown type");
break;
case ParamType.Normal:
EditorGUI.PropertyField(position, property.FindPropertyRelative("value"), new GUIContent(property.FindPropertyRelative("key").stringValue));
break;
case ParamType.Array:
if (reorderableList == null)
{
CreateReorderableList(property);
}
reorderableList.DoList(position);
break;
case ParamType.Enum:
Type fieldType = fieldInfo.FieldType;
Type elementType = fieldType.GetElementType();
string enumTypeName = property.FindPropertyRelative("enumType").stringValue;
Type enumType = Type.GetType(enumTypeName);
var paramValue = property.FindPropertyRelative("value");
FieldInfo field = elementType.GetField("value", BindingFlags.Public | BindingFlags.Instance);
if (!Enum.IsDefined(enumType, paramValue.intValue))
{
paramValue.intValue = (int)Enum.GetValues(field.FieldType).GetValue(0);
}
paramValue.intValue = EditorGUI.Popup(position,property.FindPropertyRelative("key").stringValue, paramValue.intValue, enumType.GetEnumNames());
break;
}
}
19
Source : NavigationService.cs
with MIT License
from aimore
with MIT License
from aimore
private Type GetPageTypeForViewModel(Type viewModelType)
{
var viewName = viewModelType.FullName.Replace("Model", string.Empty);
var viewModelreplacedemblyName = viewModelType.GetTypeInfo().replacedembly.FullName;
var viewreplacedemblyName = string.Format(CultureInfo.InvariantCulture, "{0}, {1}", viewName, viewModelreplacedemblyName);
var viewType = Type.GetType(viewreplacedemblyName);
return viewType;
}
19
Source : Serialization.cs
with GNU General Public License v3.0
from aiportal
with GNU General Public License v3.0
from aiportal
public override Type BindToType(string replacedemblyName, string typeName)
{
Type type;
try
{
string executingreplacedemblyName = System.Reflection.replacedembly.GetExecutingreplacedembly().FullName;
type = Type.GetType(String.Format("{0}, {1}", typeName, executingreplacedemblyName));
}
catch (Exception)
{
type = Type.GetType(String.Format("{0}, {1}", typeName, replacedemblyName));
}
return type;
}
19
Source : SerializeEngine.cs
with GNU General Public License v3.0
from aiportal
with GNU General Public License v3.0
from aiportal
public override Type BindToType(string replacedemblyName, string typeName)
{
Type type;
try
{
string executingreplacedemblyName = System.Reflection.replacedembly.GetExecutingreplacedembly().FullName;
type = Type.GetType(String.Format("{0}, {1}", typeName, executingreplacedemblyName));
}
catch (Exception)
{
type = Type.GetType(String.Format("{0}, {1}", typeName, replacedemblyName));
}
return type;
}
19
Source : ViewLocator.cs
with GNU General Public License v3.0
from ajmcateer
with GNU General Public License v3.0
from ajmcateer
public IControl Build(object data)
{
var name = data.GetType().FullName.Replace("ViewModel", "View");
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type);
}
else
{
return new TextBlock { Text = "Not Found: " + name };
}
}
19
Source : TypeUtil.cs
with Apache License 2.0
from ajuna-network
with Apache License 2.0
from ajuna-network
public static bool TryGetType(string typeStr, out Type type)
{
type = null;
var typeNamespaces = new List<string>()
{
"SubstrateNetApi.Model.Types.Base",
"SubstrateNetApi.Model.Types.Enum",
"SubstrateNetApi.Model.Types.Struct",
"SubstrateNetApi.Model.Types.Custom"
}.ToArray();
foreach (var typeNameSpace in typeNamespaces)
{
type = Type.GetType($"{typeNameSpace}.{typeStr}, SubstrateNetApi");
if (type != null)
{
return true;
}
}
return false;
}
19
Source : Program.cs
with Apache License 2.0
from ajuna-network
with Apache License 2.0
from ajuna-network
private static void TestReflection(string[] args)
{
//var typeStr = "ProxyType";
//var typeStr = "U16";
var typeStr = "AccountInfo";
var typeNamespaces = new List<string>()
{
new U8().GetType().Namespace,
new DispatchClreplaced().GetType().Namespace,
new DispatchInfo().GetType().Namespace
}.ToArray();
foreach (var typeNameSpace in typeNamespaces)
{
var getType = Type.GetType($"{typeNameSpace}.{typeStr}, SubstrateNetApi");
if (getType != null)
{
var iType = (IType) Activator.CreateInstance(getType);
break;
}
}
//MethodInfo method = Type.GetType($"SubstrateNetApi.MetaDataModel.Values.{typeStr}, SubstrateNetApi")
// .GetMethod("Decode", BindingFlags.Static | BindingFlags.Public);
}
19
Source : EntityKeyMemberConverter.cs
with MIT License
from akaskela
with MIT License
from akaskela
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
EnsureReflectionObject(objectType);
object enreplacedyKeyMember = _reflectionObject.Creator();
ReadAndreplacedertProperty(reader, KeyPropertyName);
reader.ReadAndreplacedert();
_reflectionObject.SetValue(enreplacedyKeyMember, KeyPropertyName, reader.Value.ToString());
ReadAndreplacedertProperty(reader, TypePropertyName);
reader.ReadAndreplacedert();
string type = reader.Value.ToString();
Type t = Type.GetType(type);
ReadAndreplacedertProperty(reader, ValuePropertyName);
reader.ReadAndreplacedert();
_reflectionObject.SetValue(enreplacedyKeyMember, ValuePropertyName, serializer.Deserialize(reader, t));
reader.ReadAndreplacedert();
return enreplacedyKeyMember;
}
19
Source : DynamicUtils.cs
with MIT License
from akaskela
with MIT License
from akaskela
private static object CreateSharpArgumentInfoArray(params int[] values)
{
Type csharpArgumentInfoType = Type.GetType(CSharpArgumentInfoTypeName);
Type csharpArgumentInfoFlags = Type.GetType(CSharpArgumentInfoFlagsTypeName);
Array a = Array.CreateInstance(csharpArgumentInfoType, values.Length);
for (int i = 0; i < values.Length; i++)
{
MethodInfo createArgumentInfoMethod = csharpArgumentInfoType.GetMethod("Create", new[] { csharpArgumentInfoFlags, typeof(string) });
object arg = createArgumentInfoMethod.Invoke(null, new object[] { 0, null });
a.SetValue(arg, i);
}
return a;
}
19
Source : DefaultSerializationBinder.cs
with MIT License
from akaskela
with MIT License
from akaskela
private static Type GetTypeFromTypeNameKey(TypeNameKey typeNameKey)
{
string replacedemblyName = typeNameKey.replacedemblyName;
string typeName = typeNameKey.TypeName;
if (replacedemblyName != null)
{
replacedembly replacedembly;
#if !(DOTNET || PORTABLE40 || PORTABLE)
// look, I don't like using obsolete methods as much as you do but this is the only way
// replacedembly.Load won't check the GAC for a partial name
#pragma warning disable 618,612
replacedembly = replacedembly.LoadWithPartialName(replacedemblyName);
#pragma warning restore 618,612
#elif DOTNET || PORTABLE
replacedembly = replacedembly.Load(new replacedemblyName(replacedemblyName));
#else
replacedembly = replacedembly.Load(replacedemblyName);
#endif
#if !(PORTABLE40 || PORTABLE || DOTNET)
if (replacedembly == null)
{
// will find replacedemblies loaded with replacedembly.LoadFile outside of the main directory
replacedembly[] loadedreplacedemblies = AppDomain.CurrentDomain.Getreplacedemblies();
foreach (replacedembly a in loadedreplacedemblies)
{
if (a.FullName == replacedemblyName)
{
replacedembly = a;
break;
}
}
}
#endif
if (replacedembly == null)
{
throw new JsonSerializationException("Could not load replacedembly '{0}'.".FormatWith(CultureInfo.InvariantCulture, replacedemblyName));
}
Type type = replacedembly.GetType(typeName);
if (type == null)
{
throw new JsonSerializationException("Could not find type '{0}' in replacedembly '{1}'.".FormatWith(CultureInfo.InvariantCulture, typeName, replacedembly.FullName));
}
return type;
}
else
{
return Type.GetType(typeName);
}
}
19
Source : MultiBindingBehavior.cs
with MIT License
from aksoftware98
with MIT License
from aksoftware98
private void Update()
{
if (replacedociatedObject == null || string.IsNullOrEmpty(PropertyName))
{
return;
}
var targetProperty = PropertyName;
Type targetType;
if (targetProperty.Contains("."))
{
var propertyNameParts = targetProperty.Split('.');
targetType = Type.GetType($"Windows.UI.Xaml.Controls.{propertyNameParts[0]}, Windows");
targetProperty = propertyNameParts[1];
}
else
{
targetType = replacedociatedObject.GetType();
}
PropertyInfo targetDependencyPropertyField = null;
while (targetDependencyPropertyField == null && targetType != null)
{
var targetTypeInfo = targetType.GetTypeInfo();
targetDependencyPropertyField = targetTypeInfo.GetDeclaredProperty(targetProperty + "Property");
targetType = targetTypeInfo.BaseType;
}
var targetDependencyProperty = (DependencyProperty)targetDependencyPropertyField.GetValue(null);
var binding = new Binding()
{
Path = new PropertyPath("Value"),
Source = Items,
Converter = Converter,
ConverterParameter = ConverterParameter,
Mode = Mode
};
BindingOperations.SetBinding(replacedociatedObject, targetDependencyProperty, binding);
}
19
Source : Subtract.cs
with MIT License
from alaabenfatma
with MIT License
from alaabenfatma
public object GetInstance(string fullyQualifiedNameOfClreplaced)
{
var t = Type.GetType(fullyQualifiedNameOfClreplaced);
return Activator.CreateInstance(t);
}
19
Source : Registry.cs
with MIT License
from Alan-FGR
with MIT License
from Alan-FGR
public void DebugLoop(DebugLoopDelegate func, params string[] compNames) //no variadic templates so we use a hack
{
ComponentBufferBase[] compBuffers = new ComponentBufferBase[compNames.Length];
for (var i = 0; i < compNames.Length; i++)
{
string compName = compNames[i];
var compType = Type.GetType(compName);
var buffer = componentsManager_.GetType().GetMethod("GetBufferSlow").MakeGenericMethod(compType).Invoke(componentsManager_, new object[0]);
compBuffers[i] = (ComponentBufferBase) buffer;
}
for (var i = compBuffers[0].ComponentCount - 1; i >= 0; i--)
{
var comp = compBuffers[0].GetDebugUntypedBuffers();
EntIdx entIdx = comp.i2k[i];
ref EnreplacedyData enreplacedyData = ref data_[entIdx];
var indsDict = new Dictionary<ComponentBufferBase, int>();
indsDict.Add(compBuffers[0], i);
for (int j = 1; j < compBuffers.Length; j++)
{
if (compBuffers[j].HasComponentSlow(ref enreplacedyData))
{
int indexInBuf = compBuffers[j].GetDebugIdxFromKey(entIdx);
indsDict.Add(compBuffers[j], indexInBuf);
}
else
break;
if (j == compBuffers.Length-1)
{
func.Invoke(entIdx, indsDict);
}
}
}
}
19
Source : GraphCLI.Parser.cs
with MIT License
from alelievr
with MIT License
from alelievr
static Type TryParseNodeType(string type)
{
Type nodeType;
//try to parse the node type:
nodeType = Type.GetType(type);
if (nodeType == null)
nodeType = Type.GetType("ProceduralWorlds.Node." + type);
if (nodeType == null)
nodeType = Type.GetType("ProceduralWorlds.Core." + type);
//thorw exception if the type can't be parse / does not inherit from BaseNode
if (nodeType == null || !nodeType.IsSubclreplacedOf(typeof(BaseNode)))
throw new InvalidOperationException("Type " + type + " not found as a node type (" + nodeType + ")");
return nodeType;
}
19
Source : ExposedParameter.cs
with MIT License
from alelievr
with MIT License
from alelievr
internal ExposedParameter Migrate()
{
if (exposedParameterTypeCache.Count == 0)
{
foreach (var type in AppDomain.CurrentDomain.GetAllTypes())
{
if (type.IsSubclreplacedOf(typeof(ExposedParameter)) && !type.IsAbstract)
{
var paramType = Activator.CreateInstance(type) as ExposedParameter;
exposedParameterTypeCache[paramType.GetValueType()] = type;
}
}
}
#pragma warning disable CS0618 // Use of obsolete fields
var oldType = Type.GetType(type);
#pragma warning restore CS0618
if (oldType == null || !exposedParameterTypeCache.TryGetValue(oldType, out var newParamType))
return null;
var newParam = Activator.CreateInstance(newParamType) as ExposedParameter;
newParam.guid = guid;
newParam.name = name;
newParam.input = input;
newParam.settings = newParam.CreateSettings();
newParam.settings.guid = guid;
return newParam;
}
See More Examples