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
View Source File : SqliteUserData.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 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,
[email protected]"
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,
[email protected]"
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
View Source File : TccMaster.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 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
View Source File : SagaMaster.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 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
View Source File : DynamicProxy.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 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
View Source File : ILRuntimeManager.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 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
View Source File : PType.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 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
View Source File : CometaryExtensions.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 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
View Source File : Utility.Convertor.cs
License : MIT License
Project Creator : 7Bytes-Studio
License : MIT License
Project Creator : 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
View Source File : UMAAssetIndexerEditor.cs
License : Apache License 2.0
Project Creator : A7ocin
License : Apache License 2.0
Project Creator : 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
View Source File : UMAAssetIndexer.cs
License : Apache License 2.0
Project Creator : A7ocin
License : Apache License 2.0
Project Creator : 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
View Source File : CommonUtils.cs
License : Apache License 2.0
Project Creator : AantCoder
License : Apache License 2.0
Project Creator : 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
View Source File : ServerCoreSerializationBinder.cs
License : Apache License 2.0
Project Creator : AantCoder
License : Apache License 2.0
Project Creator : 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
View Source File : ViewLocator.cs
License : MIT License
Project Creator : Abdesol
License : MIT License
Project Creator : 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
View Source File : SystemType.cs
License : Apache License 2.0
Project Creator : abist-co-ltd
License : Apache License 2.0
Project Creator : 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
View Source File : TypeReferencePropertyDrawer.cs
License : Apache License 2.0
Project Creator : abist-co-ltd
License : Apache License 2.0
Project Creator : 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
View Source File : UnityPlayerBuildTools.cs
License : Apache License 2.0
Project Creator : abist-co-ltd
License : Apache License 2.0
Project Creator : 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
View Source File : MixedRealityCanvasInspector.cs
License : Apache License 2.0
Project Creator : abist-co-ltd
License : Apache License 2.0
Project Creator : 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
View Source File : FileCache.cs
License : Apache License 2.0
Project Creator : acarteas
License : Apache License 2.0
Project Creator : 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
View Source File : FileCacheBinder.cs
License : Apache License 2.0
Project Creator : acarteas
License : Apache License 2.0
Project Creator : 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
View Source File : FileCacheManager.cs
License : Apache License 2.0
Project Creator : acarteas
License : Apache License 2.0
Project Creator : 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
View Source File : VssConnection.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : 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
View Source File : TypeExtensions.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : 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
View Source File : LiveIdLoginStatus.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : 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
View Source File : TypeHelpers.cs
License : MIT License
Project Creator : adrianoc
License : MIT License
Project Creator : 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
View Source File : TypeHelper.cs
License : MIT License
Project Creator : Adyen
License : MIT License
Project Creator : Adyen
internal static Type CreateGenericTypeFromStringFullNamespace(Type genericType, string tFullNamespace)
{
Type[] typeArgs = { Type.GetType(tFullNamespace) };
Type repositoryType = genericType.MakeGenericType(typeArgs);
return repositoryType;
}
19
View Source File : PhoneGameLoop.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn
License : GNU General Public License v3.0
Project Creator : 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
View Source File : ThemeApp.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn
License : GNU General Public License v3.0
Project Creator : 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
View Source File : IoC.cs
License : MIT License
Project Creator : afaniuolo
License : MIT License
Project Creator : 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
View Source File : AssemblyHelper.cs
License : MIT License
Project Creator : AFei19911012
License : MIT License
Project Creator : 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
View Source File : AsertSigning.cs
License : GNU General Public License v3.0
Project Creator : Agasper
License : GNU General Public License v3.0
Project Creator : Agasper
public static Type GetClreplaced()
{
return Type.GetType("UnityEngine.UnityCertificate, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
}
19
View Source File : EnumHelper.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
public static List<IEnumInfomation> GetEnumInfomation(string typeName)
{
return GetEnumInfomation(Type.GetType(typeName));
}
19
View Source File : ViewLocator.cs
License : MIT License
Project Creator : ahopper
License : MIT License
Project Creator : 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
View Source File : Type.cs
License : Mozilla Public License 2.0
Project Creator : ahyahy
License : Mozilla Public License 2.0
Project Creator : 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
View Source File : Type.cs
License : Mozilla Public License 2.0
Project Creator : ahyahy
License : Mozilla Public License 2.0
Project Creator : 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
View Source File : XmlAssetProcessor.cs
License : MIT License
Project Creator : aillieo
License : MIT License
Project Creator : 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
View Source File : ParamDrawer.cs
License : MIT License
Project Creator : aillieo
License : MIT License
Project Creator : 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
View Source File : NavigationService.cs
License : MIT License
Project Creator : aimore
License : MIT License
Project Creator : 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
View Source File : Serialization.cs
License : GNU General Public License v3.0
Project Creator : aiportal
License : GNU General Public License v3.0
Project Creator : 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
View Source File : SerializeEngine.cs
License : GNU General Public License v3.0
Project Creator : aiportal
License : GNU General Public License v3.0
Project Creator : 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
View Source File : ViewLocator.cs
License : GNU General Public License v3.0
Project Creator : ajmcateer
License : GNU General Public License v3.0
Project Creator : 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
View Source File : TypeUtil.cs
License : Apache License 2.0
Project Creator : ajuna-network
License : Apache License 2.0
Project Creator : 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
View Source File : Program.cs
License : Apache License 2.0
Project Creator : ajuna-network
License : Apache License 2.0
Project Creator : 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
View Source File : EntityKeyMemberConverter.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : 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
View Source File : DynamicUtils.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : 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
View Source File : DefaultSerializationBinder.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : 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
View Source File : MultiBindingBehavior.cs
License : MIT License
Project Creator : aksoftware98
License : MIT License
Project Creator : 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
View Source File : Subtract.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
public object GetInstance(string fullyQualifiedNameOfClreplaced)
{
var t = Type.GetType(fullyQualifiedNameOfClreplaced);
return Activator.CreateInstance(t);
}
19
View Source File : Registry.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : 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
View Source File : GraphCLI.Parser.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : 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
View Source File : ExposedParameter.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : 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