public ISchema GetSchemaForDesignDataFile(IProjectItem designDataFile, IProjectContext projectContext) { DocumentNode documentNode = (DocumentNode)null; bool flag = false; DesignDataSchemaManager.SchemaAndOpenState schemaAndOpenState; if (this.designDataCache.TryGetValue(designDataFile, out schemaAndOpenState)) { if (!designDataFile.IsOpen && !schemaAndOpenState.IsOpen) { return(schemaAndOpenState.Schema); } schemaAndOpenState.IsOpen = designDataFile.IsOpen; ClrObjectSchema clrObjectSchema = schemaAndOpenState.Schema as ClrObjectSchema; if (clrObjectSchema != null) { documentNode = DesignDataHelper.GetRootDesignDataNode(designDataFile, projectContext); flag = true; if (clrObjectSchema.DataSource.UpdateDocumentNode(documentNode)) { return((ISchema)clrObjectSchema); } } } if (!flag) { documentNode = DesignDataHelper.GetRootDesignDataNode(designDataFile, projectContext); } ISchema schema = documentNode == null || documentNode.Type.RuntimeType == (Type)null ? (ISchema) new EmptySchema() : (ISchema) new ClrObjectSchema(documentNode.Type.RuntimeType, documentNode); this.designDataCache[designDataFile] = new DesignDataSchemaManager.SchemaAndOpenState(schema, designDataFile.IsOpen); return(schema); }
public void Refresh(SampleDataSet changedSampleData) { List <IProjectItem> list = new List <IProjectItem>(); foreach (KeyValuePair <IProjectItem, DesignDataSchemaManager.SchemaAndOpenState> keyValuePair in this.designDataCache) { ClrObjectSchema clrObjectSchema = keyValuePair.Value.Schema as ClrObjectSchema; bool flag = false; if (clrObjectSchema != null) { DocumentNode rootDesignDataNode = DesignDataHelper.GetRootDesignDataNode(keyValuePair.Key, (IProjectContext)clrObjectSchema.DataSource.DocumentNode.TypeResolver); if (rootDesignDataNode == null || rootDesignDataNode != clrObjectSchema.DataSource.DocumentNode) { flag = true; } else if (changedSampleData != null) { SampleNonBasicType sampleNonBasicType = rootDesignDataNode.Type as SampleNonBasicType; if (sampleNonBasicType != null && sampleNonBasicType.DeclaringDataSet == changedSampleData) { flag = true; } } } else { flag = true; } if (flag) { list.Add(keyValuePair.Key); } } foreach (IProjectItem key in list) { this.designDataCache.Remove(key); } }