We are pretty much aware of pinvoke acedGetSym\acedPutSym in .NET to manipulate lisp symbols , we can avoid pinvoking with help of SetLispSymbol and GetLispSymbol.
In the following example ,my attention is towards "how to store \retireve multiple fragements of information in lisp symbol " ,to achieve this we can use TypedValue object data type along with LispDataType enumerations as values.
public static void PutSymbol()
{
Document d = Application.DocumentManager.MdiActiveDocument;
Database db = d.Database;
// Create a list
TypedValue[] tValue = new TypedValue[7];
tValue.SetValue(new TypedValue((int)LispDataType.ListBegin), 0);
tValue.SetValue(new TypedValue((int)LispDataType.Text,
"Main List Item 1"), 1);
tValue.SetValue(new TypedValue((int)LispDataType.ListBegin), 2);
tValue.SetValue(new TypedValue((int)LispDataType.Text,
"Nested List Item 1"), 3);
tValue.SetValue(new TypedValue((int)LispDataType.Text,
"Nested List Item 2"), 4);
tValue.SetValue(new TypedValue((int)LispDataType.ListEnd), 5);
tValue.SetValue(new TypedValue((int)LispDataType.ListEnd), 6);
d.SetLispSymbol("lst", tValue);
}
public static void GetSymbol()
{
Document d = Application.DocumentManager.MdiActiveDocument;
Editor ed = d.Editor;
PromptResult res = ed.GetString("\nName of lisp-Symbol name: ");
if (res.Status == PromptStatus.OK)
{
TypedValue[] tValue = (TypedValue[])d.GetLispSymbol(res.StringResult);
if (tValue == null) return;
foreach (TypedValue tV in tValue)
{
ed.WriteMessage("\n");
ed.WriteMessage(tV.TypeCode + "," + tV.Value);
}
}
}