//[DebuggerStepThrough] public static Type GetType(string s) { Type ret; MsgTypes mt = GetMessageType(s); if (mt == MsgTypes.Unknown) { ret = Type.GetType(s, true, true); } else { ret = IRosMessage.generate(mt).GetType(); } // Console.WriteLine(s + "=" + ret.Name); return(ret); }
public static bool IsSizeKnown(Type T, bool recurse) { if (T == typeof(string) || T == typeof(String) || (T.FullName != null && T.FullName.Contains("Messages.std_msgs.String")) /*|| T.IsArray ERIC*/) { return(false); } if (T.FullName.Contains("System.") || T.FullName.Contains("Messages.std_msgs.Time") || T.FullName.Contains("Messages.std_msgs.Duration")) { return(true); } if (!recurse || !T.FullName.Contains("Messages")) { return(true); } FieldInfo[] infos = T.GetFields(); bool b = true; foreach (FieldInfo info in infos) { string fullName = info.FieldType.FullName; if (fullName != null) { if (fullName.Contains("Messages.")) { MsgTypes MT = GetMessageType(info.FieldType); IRosMessage TI = IRosMessage.generate(MT); b &= IsSizeKnown(TI.GetType(), true); //TI.Fields[info.Name].Type != typeof(string) && TI.Fields[info.Name].Type != typeof(String) && (!TI.Fields[info.Name].IsArray || TI.Fields[info.Name].Length != -1); } else { b &= !info.FieldType.IsArray && info.FieldType != typeof(string); } } if (!b) { break; } } return(b); }