/// <summary> /// Creates new document object. Extracts creation method from the collection /// of registered creation methods and use it for creation. /// </summary> /// <param name="typeName"> /// Object type name for the document /// </param> /// <param name="hierarchy"> /// Server explorer facade object to be used for Server Explorer hierarchy interaction. /// Also used to extract connection. /// </param> /// <param name="isNew"> /// Indicates if this instance represents new database object doesn’t fixed in /// database yet. /// </param> /// <param name="id"> /// Array with new object identifier. /// </param> /// <returns> /// Instance of the new document object /// </returns> public IDocument CreateDocument(string typeName, ServerExplorerFacade hierarchy, object[] id, bool isNew) { // Check input paramaters if (typeName == null) { throw new ArgumentNullException("typeName"); } if (hierarchy == null) { throw new ArgumentNullException("hierarchy"); } if (id == null) { throw new ArgumentNullException("id"); } // Retrieve and invoke method CreateDocumentMethod createMethod = createDocumentDictionary[typeName]; if (createMethod == null) { throw new NotSupportedException(String.Format( CultureInfo.CurrentCulture, Resources.Error_DocumentNotRegistered, typeName)); } return(createMethod.Invoke(hierarchy, isNew, id)); }
/// <summary> /// Registers new document creation method for given object type name. /// </summary> /// <param name="typeName">Object type name</param> /// <param name="createMethod">Create method to register</param> public void RegisterDocument(string typeName, CreateDocumentMethod createMethod) { if (typeName == null) { throw new ArgumentNullException("typeName"); } if (createMethod == null) { throw new ArgumentNullException("createMethod"); } // Check, if document already registered if (createDocumentDictionary.ContainsKey(typeName)) { return; } createDocumentDictionary.Add(typeName, createMethod); }
/// <summary> /// Registers new document creation method for given object type name. /// </summary> /// <param name="typeName">Object type name</param> /// <param name="createMethod">Create method to register</param> public void RegisterDocument(string typeName, CreateDocumentMethod createMethod) { if (typeName == null) throw new ArgumentNullException("typeName"); if (createMethod == null) throw new ArgumentNullException("createMethod"); // Check, if document already registered if (createDocumentDictionary.ContainsKey(typeName)) return; createDocumentDictionary.Add(typeName, createMethod); }