static string FromAApiVersionedFieldsArray(Type type, Array ary) { System.Text.StringBuilder sb = new StringBuilder(); string fmt = "[{0:X}" + (type.IsAbstract ? " {1}" : "") + "]: {2}\n"; for (int i = 0; i < ary.Length; i++) { AApiVersionedFields value = (AApiVersionedFields)ary.GetValue(i); if (value.ContentFields.Contains("Value")) { sb.Append(string.Format(fmt, i, value.GetType(), value["Value"])); } else { sb.Append(string.Format(fmt, i, value.GetType(), value)); } } return(sb.ToString().Trim('\n')); }
private static bool checkVersion(Type type, string field, int requestedApiVersion) { if (requestedApiVersion == 0) { return(true); } var min = AApiVersionedFields.MinimumVersion(type, field); if (min != 0 && requestedApiVersion < min) { return(false); } var max = AApiVersionedFields.MaximumVersion(type, field); if (max != 0 && requestedApiVersion > max) { return(false); } return(true); }
/// <summary> /// Gets a lookup table from fieldname to type. /// </summary> /// <param name="APIversion">Version of API to use</param> /// <param name="t">API data type to query</param> /// <returns></returns> public static Dictionary <string, Type> GetContentFieldTypes(int APIversion, Type t) { var types = new Dictionary <string, Type>(); var recommendedApiVersion = AApiVersionedFields.getRecommendedApiVersion(t); //Could be zero if no "recommendedApiVersion" const field var ap = t.GetProperties(); foreach (var m in ap) { if (AApiVersionedFields.banlist.Contains(m.Name)) { continue; } if (!AApiVersionedFields.checkVersion(t, m.Name, APIversion == 0 ? recommendedApiVersion : APIversion)) { continue; } types.Add(m.Name, m.PropertyType); } return(types); }
/// <summary> /// Get the TGIBlock list for a Content Field. /// </summary> /// <param name="f">The property name under inspection.</param> /// <returns>The TGIBlock list for a Content Field, if present; otherwise <c>null</c>.</returns> public DependentList <TGIBlock> GetTGIBlocks(string f) { return(AApiVersionedFields.GetTGIBlocks(this, f)); }
private static int MaximumVersion(Type type, string field) { return(AApiVersionedFields.Version(typeof(MaximumVersionAttribute), type, field)); }