/// <summary> /// /// </summary> /// <param name="app"></param> private void SaveClients(UIApplication app) { // (Konrad) Extract the variables used by this method var senders = Arg1 as Dictionary <string, string>; var receivers = Arg2 as Dictionary <string, string>; var doc = app.ActiveUIDocument.Document; var pInfo = SchemaUtilities.GetProjectInfo(doc); var schemaExists = SchemaUtilities.SchemaExist(Properties.Resources.SchemaName); var schema = schemaExists ? SchemaUtilities.GetSchema(Properties.Resources.SchemaName) : SchemaUtilities.CreateSchema(); using (var trans = new Transaction(doc, "Store Clients")) { trans.Start(); if (schemaExists) { SchemaUtilities.UpdateSchemaEntity(schema, pInfo, "senders", senders); SchemaUtilities.UpdateSchemaEntity(schema, pInfo, "receivers", receivers); } else { SchemaUtilities.AddSchemaEntity(schema, pInfo, "senders", senders); SchemaUtilities.AddSchemaEntity(schema, pInfo, "receivers", receivers); } trans.Commit(); } }
/// <summary> /// /// </summary> /// <param name="app"></param> private static void GetClients(UIApplication app) { if (!SchemaUtilities.SchemaExist(Properties.Resources.SchemaName)) { return; } var doc = app.ActiveUIDocument.Document; var schema = SchemaUtilities.GetSchema(Properties.Resources.SchemaName); var pInfo = SchemaUtilities.GetProjectInfo(doc); var receivers = pInfo.GetEntity(schema).Get <IDictionary <string, string> >(schema.GetField("receivers")); var senders = pInfo.GetEntity(schema).Get <IDictionary <string, string> >(schema.GetField("senders")); OnClientsRetrieved?.Invoke(receivers, senders); }