public static string mmSaveObjs(object[,] objNames, object[,] objTypes, string location) { string resultData = ""; if (objNames.GetLength(0) != objTypes.GetLength(0) || objNames.GetLength(1) != 1 || objTypes.GetLength(1) != 1) { return("objNames and objTypes must be Vectors of the same length!"); } for (int iObj = 0; iObj < objNames.GetLength(0); iObj++) { ExcelObject obj = ObjectHandler.GetObject(objNames[iObj, 0].ToString(), objTypes[iObj, 0].ToString()); if (obj == null) { return("Object " + objNames[iObj, 0] + " of type " + objTypes[iObj, 0] + "does not exist!"); } resultData += obj.ObjectSerialize() + "\r\n"; } try { File.WriteAllText(location, resultData); } catch (Exception e) { return(e.Message); } return(objNames.GetLength(0) + " object(s) was/were saved!"); }
public static string mmModifyObj(string objName, string objType, string key, object value) { ExcelObject obj = ObjectHandler.GetObject(objName, objType); if (obj == null) { return("Object not found."); } FieldInfo[] keyList = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (var keyL in keyList) { if (key.ToUpper() == keyL.Name.ToUpper()) { try { keyL.SetValue(obj, value); return(obj.FinishMod().GetNameCounter()); } catch (Exception e) { return(e.Message); } } } return("Object found, key not found."); }
public ExcelObject CreateObject(string name, string type, object[,] range) { ExcelObject newObj = (ExcelObject)Activator.CreateInstance(Type.GetType(typeof(ExcelObject).Namespace + "." + type, true, true)); newObj.CreateObject(Tools.StringTrim(name), range); ObjList.Add(newObj.TakeOverOldObject(this)); return(newObj); }
public static string mmGetObj(string objName, string objType) { ExcelObject obj = ObjectHandler.GetObject(objName, objType); if (obj == null) { return("Object not found."); } return(obj.GetNameCounter()); }
public ExcelObject TakeOverOldObject(ExcelObjectHandler objHandler) { ExcelObject existingObj = objHandler.GetObject(_name, GetType().Name); if (existingObj != null) { _counter = existingObj._counter + 1; objHandler.ObjList.Remove(existingObj); } return(this); }
public static object[,] mmDisplayObj(string objName, string objType) { ExcelObject obj = ObjectHandler.GetObject(objName, objType); if (obj == null) { return new object[, ] { { "Object not found." } } } ; return(obj.DisplayObject()); }
public static object mmCurveDF(string objName, double time) { ExcelObject curveObj = ObjectHandler.GetObject(objName, "CURVE"); if (curveObj == null) { return("Object not found."); } try { return(((Curve)curveObj).GetDF(time)); } catch (Exception e) { return(e.Message); } }
public static object[,] mmGetObjInfo(string objName, string objType, string key, object column, object row) { ExcelObject obj = ObjectHandler.GetObject(objName, objType); if (obj == null) { return new object[, ] { { "Object not found." } } } ; FieldInfo[] keyList = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (var keyL in keyList) { if (key.ToUpper() == keyL.Name.ToUpper()) { try { if (typeof(IIMatrix).IsAssignableFrom(keyL.FieldType)) { return(((IIMatrix)keyL.GetValue(obj)).ObjInfo(column, row)); } return(new object[, ] { { keyL.GetValue(obj).ToString() } }); } catch (Exception e) { return(new object[, ] { { e.Message } }); } } } return(new object[, ] { { "Object found, key not found." } }); }