문제

Visual Studio 2005 용 DSL 도구를 사용하고 있습니다.

특정 지점에서 사용자 정의 코드를 사용하여 새 다이어그램을 만들고 싶은 DSL이 있습니다.

지금까지, 나는 이미 열린 현재 열린 다이어그램을 덮어 써서 새 다이어그램을 만들 수있었습니다. 코드는 다음과 같습니다.

FEGeneratorDiagram diag = new FEGeneratorDiagram(ThisElem.Store);
diag.Associate(ThisElem);
FEGeneratorDiagram currentDiag = (FEGeneratorDiagram)ThisElem.Store.ElementDirectory.FindElements<FEGeneratorDiagram>(false)[0];
currentDiag = diag;

그러나 내가 정말로하고 싶은 것은

새 인스턴스 Fegeneratordiagram으로 새 DSL 문서를 작성한 다음 요소를 추가하고 속성을 설정하는 논리를 유지합니다.

도움이 있습니까?

도움이 되었습니까?

해결책

//Create a Store
Type[] modelTypes = new Type[] { typeof(CoreDesignSurfaceDomainModel), typeof(FEGeneratorDomainModel) };
Store store = new Store(modelTypes);
RootElement root;
using (Transaction t =
store.TransactionManager.BeginTransaction("Create Elements"))
{
    root = FEGeneratorSerializationHelper.Instance.LoadModel(store, diagramPath, null, null);
    t.Commit();
}
//Do whatever custom things you want!

SerializationResult result = new SerializationResult();
//Save the file
FEGeneratorSerializationHelper.Instance.SaveModel(result, root, diagramPath);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top