public static ObjectDefinition LoadObjectDescription() { CurrentState eCurrentState = CurrentState.State_ObjectProperties; ObjectDefinition NewObjectDef = new ObjectDefinition(false); PluginDef NewPluginDef = new PluginDef(false); string sCurrentLine = ""; char[] trimString = " \t\"\'".ToCharArray(); while (Filesystem.ReadLine(ref sCurrentLine)) { if (sCurrentLine.Trim(" \t\"\'".ToCharArray()).Length == 0) { continue; } // Skip any line with a #. It's a comment. if (sCurrentLine.StartsWith("#")) { continue; } switch (eCurrentState) { case CurrentState.State_ObjectProperties: { if (sCurrentLine.Substring(0, Math.Min(sCurrentLine.Length, 10)).CompareTo("ObjectName") == 0) { NewObjectDef.ObjectName = sCurrentLine.Substring(10).Trim(trimString); } else if (sCurrentLine.Substring(0, Math.Min(sCurrentLine.Length, 9)).CompareTo("ObjectDef") == 0) { NewObjectDef.ObjectClassType = sCurrentLine.Substring(9).Trim(trimString); } else if (sCurrentLine.CompareTo("EndObjectDef") == 0) { // this is the end of this object definition. return(NewObjectDef); } else { string param = sCurrentLine.Substring(0, sCurrentLine.IndexOfAny(trimString)); string value = sCurrentLine.Substring(sCurrentLine.IndexOfAny(trimString)).Trim(trimString); int leftCount = Helpers.CountStringOccurrences(value, "{"); int rightCount = Helpers.CountStringOccurrences(value, "}"); if (leftCount > rightCount) { while (Filesystem.ReadLine(ref sCurrentLine)) { value = string.Concat(value, sCurrentLine); leftCount = Helpers.CountStringOccurrences(value, "{"); rightCount = Helpers.CountStringOccurrences(value, "}"); if (leftCount == rightCount) { break; } } } // If it is none of the above then it is a class property. NewObjectDef.ClassProperties.Add( param, value ); } } break; } } return(NewObjectDef); }