private ExcelWorkBookSchema GetWorkBookSchema(IPipelineContext pContext, IFormulaEvaluator formulaEvaluator) { if (String.IsNullOrEmpty(DocumentSpecName.AssemblyName)) { string assemblyName = pContext.PipelineName.Substring(pContext.PipelineName.IndexOf(",") + 1).TrimStart(); DocumentSpecName = new Schema(Assembly.CreateQualifiedName(assemblyName, DocumentSpecName.DocSpecName)); } if (CachedSchemas.ContainsKey(DocumentSpecName.SchemaName)) { return(CachedSchemas[DocumentSpecName.SchemaName]); } lock (schemalock) { if (CachedSchemas.ContainsKey(DocumentSpecName.SchemaName)) { return(CachedSchemas[DocumentSpecName.SchemaName]); } ObjectHandle result = Activator.CreateInstance(DocumentSpecName.AssemblyName, DocumentSpecName.DocSpecName); Microsoft.XLANGs.BaseTypes.SchemaBase schemaBase = (Microsoft.XLANGs.BaseTypes.SchemaBase)result.Unwrap(); XmlSchema schema = schemaBase.CreateResolvedSchema(); CachedSchemas.TryAdd(DocumentSpecName.SchemaName, new ExcelWorkBookSchema(schema, formulaEvaluator)); } return(CachedSchemas[DocumentSpecName.SchemaName]); }
/// <summary> /// Get the namespace from a schema type /// </summary> /// <param name="schemaType"></param> /// <returns></returns> public static string GetSchemaNamespaceFromBizTalkType(Type schemaType) { // First check if this is actually a BizTalk assembly if (schemaType.BaseType != typeof(Microsoft.XLANGs.BaseTypes.SchemaBase) && schemaType.BaseType != typeof(Microsoft.BizTalk.TestTools.Schema.TestableSchemaBase)) { throw new Exception("Expected type: Microsoft.XLANGs.BaseTypes.SchemaBase"); } Object schemaobject = schemaType.InvokeMember(null, System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance, null, null, null); Microsoft.XLANGs.BaseTypes.SchemaBase schemaBase = schemaobject as Microsoft.XLANGs.BaseTypes.SchemaBase; return(schemaBase.Schema.TargetNamespace); }