在C#中是否有于C++ 函数DgnECManager.ReadSchemaFromXmlFile对应的函数?
Bentley.ECObjects.ECObjects Class
Assembly Bentley.ECObjects3.dll
// // Summary: // Locates an ECXML schema. // // Parameters: // schemaName: // The name of the desired schema. // // versionMajor: // The major version of the desired schema. // // versionMinor: // The minor version of the desired schema. // // matchType: // The SchemaMatchType. // // parentSchema: // The schema where the schema reference was located, if resolving a schema reference. // // context: // An object passed to the LocateSchema method by the requestor. It is useful when // a schema requestor and a schema locater are designed to cooperate. // // Remarks: // The LocateSchema method, using the installed IECSchemaLocaters registered by // calling Bentley.ECObjects.ECObjects.AddSchemaLocater(Bentley.ECObjects.Schema.IECSchemaLocater), // provides a way for finding known IECSchemas. // Schemas have a major and minor version number, and the matchType argument specifies // how those version numbers are used when searching for a schema. // The ECObjects system internally searches for referenced schemas while deserializing // XML Schema files. public static IECSchema LocateSchema(string schemaName, int versionMajor, int versionMinor, SchemaMatchType matchType, IECSchema parentSchema, object context);
// Summary: // Locates an ECXML schema. // // Parameters: // fullSchemaName: // The name of the desired schema including version number. // // matchType: // The SchemaMatchType. // // parentSchema: // The schema where the schema reference was located, if resolving a schema reference. // // context: // An object passed to the LocateSchema method by the requestor. It is useful when // a schema requestor and a schema locater are designed to cooperate. // // Remarks: // The LocateSchema method, using the installed IECSchemaLocaters registered by // calling Bentley.ECObjects.ECObjects.AddSchemaLocater(Bentley.ECObjects.Schema.IECSchemaLocater), // provides a way for finding known IECSchemas. // Schemas have a major and minor version number, and the matchType argument specifies // how those version numbers are used when searching for a schema. // The ECObjects system internally searches for referenced schemas while deserializing // XML Schema files. public static IECSchema LocateSchema(string fullSchemaName, SchemaMatchType matchType, IECSchema parentSchema, object context);
public static IECSchema LocateSchema(string schemaName, int versionMajor, int versionMinor, SchemaMatchType matchType, IECSchema parentSchema, object context);
参数中的context如何使用?如何指定外部文件的路径名?
没有在.NET封装中找到与您所列的C++完全对应的函数。但SDK的例子C:\Program Files\Bentley\MicroStationCONNECTSDK\examples\DgnEC\DgnECManagedCrudExample\DgnECManagedCrudExample.cs中有如下函数(或叫方法)供参考:
public static void LocateAndLoadSchema(string parser) { try { Assembly assembly = Assembly.GetExecutingAssembly(); string schemaSearchPath = Path.GetDirectoryName(assembly.Location); IECSchemaLocater searchLocater = new SearchPathSchemaFileLocater(schemaSearchPath); if (null == searchLocater) return; ECObjects.AddSchemaLocater(searchLocater); /*ECSchema is data that describes data (i.e. metadata). ECSchema provides a way to express the structure, context, and to some extent, the meaning of EC data, allowing programmatic understanding, presentation, analysis, and even manipulation of that data. Locates an ECXML Schema */ ecSimpleSchema = ECObjects.LocateSchema(schemaName, SchemaMatchType.Exact, null, null); if (null == ecSimpleSchema) MessageCenter.Instance.StatusMessage = DgnECManagedCrudExample.rm.GetString("ERROR_SCHEMANOTFOUND"); else { DgnECManager dgnECManager = DgnECManager.Manager; if (null == dgnECManager) return; DgnFile activeDgnFile = Session.Instance.GetActiveDgnFile(); SchemaImportStatus schemaImportStatus = dgnECManager.ImportSchema(ecSimpleSchema, activeDgnFile, new ImportSchemaOptions(true)); MessageCenter.Instance.StatusMessage = DgnECManagedCrudExample.rm.GetString("Success_Schema_Import"); } } catch (Exception ex) { MessageCenter.Instance.StatusMessage = ex.Message; MessageCenter.Instance.StatusWarning = ex.Message; } } #endregion
Answer Verified By: DawsenSu