/// <summary> /// Convert the text file to a binary module. /// </summary> /// <param name="filename">File to convert.</param> public static void ConvertFromText <T>(string filename) where T : NdapiModule { var type = NdapiMetadata.GetObjectTypeFrom <T>(); var status = NativeMethods.d2fctxcf_ConvertFile(NdapiContext.GetContext(), filename, type, NdapiConstants.TEXTTOBIN); Ensure.Success(status); }
/// <summary> /// Creates a coordinate declaration /// </summary> public Coordinate() : base(ObjectType.Coordinate) { _handle = new ObjectSafeHandle(); var status = NativeMethods.d2fcrdcr_Create(NdapiContext.GetContext(), out _handle); Ensure.Success(status); }
/// <summary> /// Checks if an object is considered a smart object. /// </summary> /// <param name="obj">Object to check.</param> /// <returns>The state indicating if it's a smart object or not.</returns> public bool IsSmartclass(NdapiObject obj) { var status = NativeMethods.d2folbis_IsSmartclassed(NdapiContext.GetContext(), _handle, obj._handle); Ensure.BooleanResult(status); return(status == D2fErrorCode.D2FS_YES); }
internal static T Create <T>(ObjectSafeHandle handle) where T : NdapiObject { var objectType = typeof(T); if (objectType == typeof(NdapiObject)) { ObjectType type; var status = NativeMethods.d2fobqt_QueryType(NdapiContext.GetContext(), handle, out type); Ensure.Success(status); if (type == ObjectType.Undefined) { return(null); } objectType = NdapiMetadata.ObjectTypeMapping[type]; } var instance = Activator.CreateInstance(objectType, BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { handle }, null); return((T)instance); }
/// <summary> /// Gets the value in the specified index. /// </summary> /// <param name="index">The one-based index of the value.</param> /// <returns>The row value.</returns> public string GetValueAt(int index) { string value; var status = NativeMethods.d2frcsgr_GetRow(NdapiContext.GetContext(), _handle, index, out value); Ensure.Success(status); return(value); }
/// <summary> /// Gets the role in the specified index. /// </summary> /// <param name="index">The one-based index of the role.</param> /// <returns>The role name.</returns> public string GetRoleAt(int index) { string role; var status = NativeMethods.d2fmmdgr_GetRole(NdapiContext.GetContext(), _handle, index, out role); Ensure.Success(status); return(role); }
/// <summary> /// Detaches the attached library and destroy the object. /// </summary> public void Detach() { var status = NativeMethods.d2falbdt_Detach(NdapiContext.GetContext(), _handle); Ensure.Success(status); _handle = null; }
/// <summary> /// Add an object to the object library tab. When adding an object, a copy is made and it is this copy that is added to the library. /// </summary> /// <typeparam name="T">Object type.</typeparam> /// <param name="obj">Object to add to library tab.</param> /// <param name="replace">Should replace the existing object.</param> /// <returns>A copy of the original object.</returns> public T AddObject <T>(T obj, bool replace) where T : NdapiObject { ObjectSafeHandle handle; var status = NativeMethods.d2folbao_AddObj(NdapiContext.GetContext(), ObjectLibrary._handle, _handle, obj._handle, out handle, replace); Ensure.Success(status); return(Create <T>(handle)); }
/// <summary> /// Gets the version of the last Form Builder that loaded the module. /// </summary> /// <param name="file">Form module location (.fmb file)</param> /// <param name="loadFromDb">Module should be loaded from database.</param> /// <returns>The Form Builder version</returns> public static int GetFileVersion(string file, bool loadFromDb) { int version; var status = NativeMethods.d2ffmdfv_FileVersion(NdapiContext.GetContext(), file, loadFromDb, out version); Ensure.Success(status); return(version); }
/// <summary> /// Gets the value of a boolean property. /// </summary> /// <param name="property">Property id.</param> /// <returns>The property value.</returns> public bool GetBooleanProperty(int property) { bool value; var status = NativeMethods.d2fobgb_GetBoolProp(NdapiContext.GetContext(), _handle, property, out value); Ensure.Success(status); return(value); }
/// <summary> /// Gets the associated menu in the specified index. /// </summary> /// <param name="index">The one-based index of the associated menu.</param> /// <returns>The associated menu name.</returns> public string GetAssociatedMenuAt(int index) { string menu; var status = NativeMethods.d2fmpmgam_GetAssocMenu(NdapiContext.GetContext(), _handle, index, out menu); Ensure.Success(status); return(menu); }
/// <summary> /// Gets the value of a string property. /// </summary> /// <param name="property">Property id.</param> /// <returns>The property value.</returns> public string GetStringProperty(int property) { string value; var status = NativeMethods.d2fobgt_GetTextProp(NdapiContext.GetContext(), _handle, property, out value); Ensure.Success(status); return(value); }
/// <summary> /// Gets the description for an object in the library. /// </summary> /// <param name="obj">Object in library.</param> /// <returns>Description of object.</returns> public string GetObjectDescription(NdapiObject obj) { string description; var status = NativeMethods.d2folbgd_GetDesc(NdapiContext.GetContext(), _handle, obj._handle, out description); Ensure.Success(status); return(description); }
/// <summary> /// Gets the name of the tab that a given object is on. /// </summary> /// <param name="obj">Object in library.</param> /// <returns>Name of tab the object is on.</returns> public string GetObjectTabName(NdapiObject obj) { string tabName; var status = NativeMethods.d2folbot_ObjTabname(NdapiContext.GetContext(), _handle, obj._handle, out tabName); Ensure.Success(status); return(tabName); }
/// <summary> /// Checks whether the property was inherited. /// </summary> /// <param name="property">Property id.</param> /// <returns>A boolean indicating whether property was inherited.</returns> public bool HasInheritedProperty(int property) { var status = NativeMethods.d2fobii_IspropInherited(NdapiContext.GetContext(), _handle, property); Ensure.BooleanResult(status); return(status == D2fErrorCode.D2FS_YES); }
/// <summary> /// Gets the version of the last Form Builder that loaded the library. /// </summary> /// <param name="file">Object library location (.olb file)</param> /// <returns>The Form Builder version</returns> public static int GetFileVersion(string file) { int version; var status = NativeMethods.d2folbfv_FileVersion(NdapiContext.GetContext(), file, out version); Ensure.Success(status); return(version); }
internal NdapiObject(string name, ObjectType type, NdapiObject parent = null) { var parentHandle = parent?._handle ?? new ObjectSafeHandle(); var status = NativeMethods.d2fobcr_Create(NdapiContext.GetContext(), parentHandle, out _handle, name, (int)type); Ensure.Success(status); _type = type; }
/// <summary> /// Gets the value of a number property. /// </summary> /// <param name="property">Property id.</param> /// <returns>The property value.</returns> public int GetNumberProperty(int property) { int value; var status = NativeMethods.d2fobgn_GetNumProp(NdapiContext.GetContext(), _handle, property, out value); Ensure.Success(status); return(value); }
/// <summary> /// Load the program unit library into memory. /// </summary> /// <param name="filename">Library location (.pll file)</param> /// <returns>Loaded library reference.</returns> public new static LibraryModule Open(string filename) { ObjectSafeHandle library; var status = NativeMethods.d2flibld_Load(NdapiContext.GetContext(), out library, filename); Ensure.Success(status); return(new LibraryModule(library)); }
/// <summary> /// Load the object library into memory. /// </summary> /// <param name="filename">Library location (.olb file)</param> /// <returns>Loaded library reference.</returns> public new static ObjectLibrary Open(string filename) { ObjectSafeHandle form; var status = NativeMethods.d2folbld_Load(NdapiContext.GetContext(), out form, filename); Ensure.Success(status); return(new ObjectLibrary(form)); }
/// <summary> /// Load the menu module into memory. /// </summary> /// <param name="filename">Menu module location (.mmb file)</param> /// <returns>Loaded menu module reference.</returns> public new static MenuModule Open(string filename) { ObjectSafeHandle menu; var status = NativeMethods.d2fmmdld_Load(NdapiContext.GetContext(), out menu, filename, false); Ensure.Success(status); return(new MenuModule(menu)); }
/// <summary> /// Load the form module into memory. /// </summary> /// <param name="filename">Form module location (.fmb file)</param> /// <returns>Loaded form module reference.</returns> public new static FormModule Open(string filename) { ObjectSafeHandle form; var status = NativeMethods.d2ffmdld_Load(NdapiContext.GetContext(), out form, filename, false); Ensure.Success(status); return(new FormModule(form)); }
/// <summary> /// Gets the real object type. /// </summary> /// <returns>The object type.</returns> public ObjectType GetObjectType() { if (_type != ObjectType.Undefined) { return(_type); } var status = NativeMethods.d2fobqt_QueryType(NdapiContext.GetContext(), _handle, out _type); Ensure.Success(status); return(_type); }
/// <summary> /// Get the object in the specified position. /// </summary> /// <param name="position">Position.</param> /// <returns>The object found.</returns> public NdapiObject GetObjectByPosition(int position) { ObjectSafeHandle obj; var status = NativeMethods.d2folbf2_Findobjbypos(NdapiContext.GetContext(), _handle, position, out obj); Ensure.Success(status); if (obj.IsInvalid) { return(null); } return(Create <NdapiObject>(obj)); }
/// <summary> /// Gets the value of an object property. /// </summary> /// <param name="property">Property id.</param> /// <returns>The property value.</returns> public T GetObjectProperty <T>(int property) where T : NdapiObject { ObjectSafeHandle handle; var status = NativeMethods.d2fobgo_GetObjProp(NdapiContext.GetContext(), _handle, property, out handle); Ensure.Success(status); if (handle.IsInvalid) { return(null); } return(Create <T>(handle)); }
/// <summary> /// Finds an object by name. /// </summary> /// <param name="name">Name of the object.</param> /// <returns>The object that was found. Returns null if the object doesn't exist.</returns> public T Single(string name) { var type = NdapiMetadata.GetObjectTypeFrom <T>(); ObjectSafeHandle handle; var status = NativeMethods.d2fobfo_FindObj(NdapiContext.GetContext(), _ndapiObject._handle, name, type, out handle); if (status == D2fErrorCode.D2FS_OBJNOTFOUND) { return(null); } Ensure.Success(status); return(NdapiObject.Create <T>(handle)); }
/// <summary> /// Destroy the current object. /// </summary> public virtual void Destroy() { var status = NativeMethods.d2fobde_Destroy(NdapiContext.GetContext(), _handle); Ensure.Success(status); }
/// <summary> /// Change the subclassing parent of an object to the parent object. /// This will cause the property values to be overriden for all properties which are defined on the parent object. /// </summary> /// <param name="parent">Object to subclass.</param> /// <param name="keepPath">Indicates whether the system should refer to the parent object's module by filename or by path+filename. /// The recommended choice is false in most cases.</param> public void Subclass(NdapiObject parent, bool keepPath) { var status = NativeMethods.d2fobsc_SubClass(NdapiContext.GetContext(), _handle, parent._handle, keepPath); Ensure.Success(status); }
/// <summary> /// Reattaches subclassed object. /// </summary> /// <remarks> /// This method must be called if you changed one of the following properties: /// <see cref="ParentFileName"/>, <see cref="ParentFileNamePath"/>, <see cref="ParentModule"/>, <see cref="ParentModuleStorage"/>, /// <see cref="ParentModuleType"/>, <see cref="ParentName"/> or <see cref="ParentType"/>. /// </remarks> public void Reattach() { var status = NativeMethods.d2fobra_Reattach(NdapiContext.GetContext(), _handle); Ensure.Success(status); }
internal D2fErrorCode IsPropertyDefaulted(int property) { return(NativeMethods.d2fobid_IspropDefault(NdapiContext.GetContext(), _handle, property)); }