static void AppendFields(StringBuilder sb, HeronType t) { sb.AppendLine(" fields"); sb.AppendLine(" {"); foreach (ExposedField f in t.GetExposedFields()) { sb.AppendLine(" " + f.ToString() + ";"); } sb.AppendLine(" }"); }
/// <summary> /// Iterates over 'HeronVisible' labeled exposedFields and values /// of the target object and exposes them. /// </summary> private void StoreExposedFunctionsAndFields() { if (type == null) { return; } if (!typeof(HeronValue).IsAssignableFrom(type)) { return; } foreach (MethodInfo mi in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)) { object[] attrs = mi.GetCustomAttributes(typeof(HeronVisible), true); if (attrs.Length > 0) { StoreExposedFunction(mi); } } foreach (FieldInfo fi in type.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)) { object[] attrs = fi.GetCustomAttributes(typeof(HeronVisible), true); if (attrs.Length > 0) { StoreExposedField(fi); } } // Add the exposed fields and methods from the base class if (baseType != null) { foreach (ExposedField xf in baseType.GetExposedFields()) { if (!exposedFields.ContainsKey(xf.name)) { exposedFields.Add(xf.name, xf); } } foreach (ExposedMethodValue xmv in baseType.GetExposedMethods()) { if (!exposedMethods.ContainsKey(xmv.Name)) { exposedMethods.Add(xmv.Name, xmv); } } } }
static void AppendFields(StringBuilder sb, HeronType t) { sb.AppendLine(" fields"); sb.AppendLine(" {"); foreach (ExposedField f in t.GetExposedFields()) sb.AppendLine(" " + f.ToString() + ";"); sb.AppendLine(" }"); }