// Token: 0x06001277 RID: 4727 RVA: 0x00069290 File Offset: 0x00067490 public SDK_DescriptionAttribute(Type typeToCopyExistingDescriptionFrom, int index = 0) { if (typeToCopyExistingDescriptionFrom == null) { VRTK_Logger.Fatal(new ArgumentNullException("typeToCopyExistingDescriptionFrom")); return; } Type typeFromHandle = typeof(SDK_DescriptionAttribute); SDK_DescriptionAttribute[] descriptions = SDK_DescriptionAttribute.GetDescriptions(typeToCopyExistingDescriptionFrom); if (descriptions.Length == 0) { VRTK_Logger.Fatal(new ArgumentOutOfRangeException("typeToCopyExistingDescriptionFrom", typeToCopyExistingDescriptionFrom, string.Format("'{0}' doesn't specify any SDK descriptions via '{1}' to copy.", typeToCopyExistingDescriptionFrom.Name, typeFromHandle.Name))); return; } if (descriptions.Length <= index) { VRTK_Logger.Fatal(new ArgumentOutOfRangeException("index", index, string.Format("'{0}' has no '{1}' at that index.", typeToCopyExistingDescriptionFrom.Name, typeFromHandle.Name))); return; } SDK_DescriptionAttribute sdk_DescriptionAttribute = descriptions[index]; this.prettyName = sdk_DescriptionAttribute.prettyName; this.symbol = sdk_DescriptionAttribute.symbol; this.vrDeviceName = sdk_DescriptionAttribute.vrDeviceName; this.index = index; }
// Token: 0x06001B22 RID: 6946 RVA: 0x0008E028 File Offset: 0x0008C228 private void SetUp(Type baseType, Type fallbackType, string actualTypeName, int descriptionIndex) { if (baseType == null || fallbackType == null) { return; } if (!baseType.IsSubclassOf(typeof(SDK_Base))) { VRTK_Logger.Fatal(new ArgumentOutOfRangeException("baseType", baseType, string.Format("'{0}' is not a subclass of the SDK base type '{1}'.", baseType.Name, typeof(SDK_Base).Name))); return; } if (!fallbackType.IsSubclassOf(baseType)) { VRTK_Logger.Fatal(new ArgumentOutOfRangeException("fallbackType", fallbackType, string.Format("'{0}' is not a subclass of the SDK base type '{1}'.", fallbackType.Name, baseType.Name))); return; } this.baseTypeName = baseType.FullName; this.fallbackTypeName = fallbackType.FullName; this.typeName = actualTypeName; if (string.IsNullOrEmpty(actualTypeName)) { this.type = fallbackType; this.originalTypeNameWhenFallbackIsUsed = null; this.descriptionIndex = -1; this.description = new SDK_DescriptionAttribute(typeof(SDK_FallbackSystem), 0); return; } Type type = Type.GetType(actualTypeName); if (type == null) { this.type = fallbackType; this.originalTypeNameWhenFallbackIsUsed = actualTypeName; this.descriptionIndex = -1; this.description = new SDK_DescriptionAttribute(typeof(SDK_FallbackSystem), 0); VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_NOT_FOUND, new object[] { actualTypeName, fallbackType.Name })); return; } if (!type.IsSubclassOf(baseType)) { VRTK_Logger.Fatal(new ArgumentOutOfRangeException("actualTypeName", actualTypeName, string.Format("'{0}' is not a subclass of the SDK base type '{1}'.", actualTypeName, baseType.Name))); return; } SDK_DescriptionAttribute[] descriptions = SDK_DescriptionAttribute.GetDescriptions(type); if (descriptions.Length <= descriptionIndex) { VRTK_Logger.Fatal(new ArgumentOutOfRangeException("descriptionIndex", descriptionIndex, string.Format("'{0}' has no '{1}' at that index.", actualTypeName, typeof(SDK_DescriptionAttribute).Name))); return; } this.type = type; this.originalTypeNameWhenFallbackIsUsed = null; this.descriptionIndex = descriptionIndex; this.description = descriptions[descriptionIndex]; }
// Token: 0x06001B1F RID: 6943 RVA: 0x0008DF58 File Offset: 0x0008C158 public static VRTK_SDKInfo[] Create <BaseType, FallbackType>(Type actualType) where BaseType : SDK_Base where FallbackType : BaseType { string fullName = actualType.FullName; SDK_DescriptionAttribute[] descriptions = SDK_DescriptionAttribute.GetDescriptions(actualType); if (descriptions.Length == 0) { VRTK_Logger.Fatal(string.Format("'{0}' doesn't specify any SDK descriptions via '{1}'.", fullName, typeof(SDK_DescriptionAttribute).Name)); return(new VRTK_SDKInfo[0]); } List <VRTK_SDKInfo> list = new List <VRTK_SDKInfo>(descriptions.Length); foreach (SDK_DescriptionAttribute sdk_DescriptionAttribute in descriptions) { VRTK_SDKInfo vrtk_SDKInfo = new VRTK_SDKInfo(); vrtk_SDKInfo.SetUp(typeof(BaseType), typeof(FallbackType), fullName, sdk_DescriptionAttribute.index); list.Add(vrtk_SDKInfo); } return(list.ToArray()); }
/// <summary> /// Creates new SDK infos for a type. /// </summary> /// <typeparam name="BaseType">The SDK base type. Must be a subclass of SDK_Base.</typeparam> /// <typeparam name="FallbackType">The SDK type to fall back on if problems occur. Must be a subclass of `BaseType.</typeparam> /// <param name="actualType">The SDK type to use. Must be a subclass of `BaseType.</param> /// <returns>Multiple newly created instances.</returns> public static VRTK_SDKInfo[] Create <BaseType, FallbackType>(Type actualType) where BaseType : SDK_Base where FallbackType : BaseType { string actualTypeName = actualType.FullName; SDK_DescriptionAttribute[] descriptions = SDK_DescriptionAttribute.GetDescriptions(actualType); if (descriptions.Length == 0) { VRTK_Logger.Fatal(string.Format("'{0}' doesn't specify any SDK descriptions via '{1}'.", actualTypeName, typeof(SDK_DescriptionAttribute).Name)); return(new VRTK_SDKInfo[0]); } HashSet <VRTK_SDKInfo> sdkInfos = new HashSet <VRTK_SDKInfo>(); foreach (SDK_DescriptionAttribute description in descriptions) { VRTK_SDKInfo sdkInfo = new VRTK_SDKInfo(); sdkInfo.SetUp(typeof(BaseType), typeof(FallbackType), actualTypeName, description.index); sdkInfos.Add(sdkInfo); } return(sdkInfos.ToArray()); }