Get WorkflowDesigner from a ModelItem
I am trying to create a custom IExpressionEditor. In order to new one up I need a WorkflowDesigner, All I have is the ModelItem representing my custom activity. Is it possible to access the WorkflowDesigner from a given ModelItem?
List<ModelItem> variables = new List<ModelItem>();
List<ModelItem> nameSpaces = new List<ModelItem>();
// get the activity from the datacontext
CustomActivityDesigner cad = this.DataContext as CustomActivityDesigner;
// try to get the variables
// look for variables collection cant seem to find them
ModelProperty mp = cad.ModelItem.Properties["Variables"];
if(mp != null && mp.PropertyType == typeof(Collection<Variable>))
mp.Collection.ToList().ForEach(i => variables.Add(i));
// get name spaces
ModelProperty mp2 = cad.ModelItem.Properties["NameSpaces"];
if(mp2 != null && mp2.PropertyType == typeof(Collection<NameSpace>))
mp2.Collection.ToList().ForEach(i => nameSpaces.Add(i));
// finally need the WorkflowDesigner object
WorkflowDesigner designer = Modelitem.Root....??? as WorkflowDesigner
// now we have what we need we can create the IExpressionEditor
CustomExpressionEditior ce = new CustomExpressionEditior(designer, variables, nameSpaces)
workflow-foundation-4 workflow-foundation
add a comment |
I am trying to create a custom IExpressionEditor. In order to new one up I need a WorkflowDesigner, All I have is the ModelItem representing my custom activity. Is it possible to access the WorkflowDesigner from a given ModelItem?
List<ModelItem> variables = new List<ModelItem>();
List<ModelItem> nameSpaces = new List<ModelItem>();
// get the activity from the datacontext
CustomActivityDesigner cad = this.DataContext as CustomActivityDesigner;
// try to get the variables
// look for variables collection cant seem to find them
ModelProperty mp = cad.ModelItem.Properties["Variables"];
if(mp != null && mp.PropertyType == typeof(Collection<Variable>))
mp.Collection.ToList().ForEach(i => variables.Add(i));
// get name spaces
ModelProperty mp2 = cad.ModelItem.Properties["NameSpaces"];
if(mp2 != null && mp2.PropertyType == typeof(Collection<NameSpace>))
mp2.Collection.ToList().ForEach(i => nameSpaces.Add(i));
// finally need the WorkflowDesigner object
WorkflowDesigner designer = Modelitem.Root....??? as WorkflowDesigner
// now we have what we need we can create the IExpressionEditor
CustomExpressionEditior ce = new CustomExpressionEditior(designer, variables, nameSpaces)
workflow-foundation-4 workflow-foundation
The ModelItem property is hierarchical so traversing this you can gain access to the root element of your workflow where defined variables can be found. ModelItem also has information about the type of the property so you can just select properties of certain type.
– Kousic
Nov 19 '18 at 13:02
@kousic I can see that I can get the root item from my model item, but I cannot cast that to a WorkflowDesigner, nor do I see any properties to access the WorkflowDesigner object. I would like to get the Designer itself, then any variables defined in the scope of my custom activity, and any namespaces. Not finding much info online though.
– user1336827
Nov 20 '18 at 14:31
Can you give me a sample code of your model item?
– Kousic
Nov 21 '18 at 6:51
@kousic added sample code
– user1336827
Nov 21 '18 at 14:16
add a comment |
I am trying to create a custom IExpressionEditor. In order to new one up I need a WorkflowDesigner, All I have is the ModelItem representing my custom activity. Is it possible to access the WorkflowDesigner from a given ModelItem?
List<ModelItem> variables = new List<ModelItem>();
List<ModelItem> nameSpaces = new List<ModelItem>();
// get the activity from the datacontext
CustomActivityDesigner cad = this.DataContext as CustomActivityDesigner;
// try to get the variables
// look for variables collection cant seem to find them
ModelProperty mp = cad.ModelItem.Properties["Variables"];
if(mp != null && mp.PropertyType == typeof(Collection<Variable>))
mp.Collection.ToList().ForEach(i => variables.Add(i));
// get name spaces
ModelProperty mp2 = cad.ModelItem.Properties["NameSpaces"];
if(mp2 != null && mp2.PropertyType == typeof(Collection<NameSpace>))
mp2.Collection.ToList().ForEach(i => nameSpaces.Add(i));
// finally need the WorkflowDesigner object
WorkflowDesigner designer = Modelitem.Root....??? as WorkflowDesigner
// now we have what we need we can create the IExpressionEditor
CustomExpressionEditior ce = new CustomExpressionEditior(designer, variables, nameSpaces)
workflow-foundation-4 workflow-foundation
I am trying to create a custom IExpressionEditor. In order to new one up I need a WorkflowDesigner, All I have is the ModelItem representing my custom activity. Is it possible to access the WorkflowDesigner from a given ModelItem?
List<ModelItem> variables = new List<ModelItem>();
List<ModelItem> nameSpaces = new List<ModelItem>();
// get the activity from the datacontext
CustomActivityDesigner cad = this.DataContext as CustomActivityDesigner;
// try to get the variables
// look for variables collection cant seem to find them
ModelProperty mp = cad.ModelItem.Properties["Variables"];
if(mp != null && mp.PropertyType == typeof(Collection<Variable>))
mp.Collection.ToList().ForEach(i => variables.Add(i));
// get name spaces
ModelProperty mp2 = cad.ModelItem.Properties["NameSpaces"];
if(mp2 != null && mp2.PropertyType == typeof(Collection<NameSpace>))
mp2.Collection.ToList().ForEach(i => nameSpaces.Add(i));
// finally need the WorkflowDesigner object
WorkflowDesigner designer = Modelitem.Root....??? as WorkflowDesigner
// now we have what we need we can create the IExpressionEditor
CustomExpressionEditior ce = new CustomExpressionEditior(designer, variables, nameSpaces)
workflow-foundation-4 workflow-foundation
workflow-foundation-4 workflow-foundation
edited Nov 21 '18 at 14:16
user1336827
asked Nov 13 '18 at 16:18
user1336827user1336827
5931925
5931925
The ModelItem property is hierarchical so traversing this you can gain access to the root element of your workflow where defined variables can be found. ModelItem also has information about the type of the property so you can just select properties of certain type.
– Kousic
Nov 19 '18 at 13:02
@kousic I can see that I can get the root item from my model item, but I cannot cast that to a WorkflowDesigner, nor do I see any properties to access the WorkflowDesigner object. I would like to get the Designer itself, then any variables defined in the scope of my custom activity, and any namespaces. Not finding much info online though.
– user1336827
Nov 20 '18 at 14:31
Can you give me a sample code of your model item?
– Kousic
Nov 21 '18 at 6:51
@kousic added sample code
– user1336827
Nov 21 '18 at 14:16
add a comment |
The ModelItem property is hierarchical so traversing this you can gain access to the root element of your workflow where defined variables can be found. ModelItem also has information about the type of the property so you can just select properties of certain type.
– Kousic
Nov 19 '18 at 13:02
@kousic I can see that I can get the root item from my model item, but I cannot cast that to a WorkflowDesigner, nor do I see any properties to access the WorkflowDesigner object. I would like to get the Designer itself, then any variables defined in the scope of my custom activity, and any namespaces. Not finding much info online though.
– user1336827
Nov 20 '18 at 14:31
Can you give me a sample code of your model item?
– Kousic
Nov 21 '18 at 6:51
@kousic added sample code
– user1336827
Nov 21 '18 at 14:16
The ModelItem property is hierarchical so traversing this you can gain access to the root element of your workflow where defined variables can be found. ModelItem also has information about the type of the property so you can just select properties of certain type.
– Kousic
Nov 19 '18 at 13:02
The ModelItem property is hierarchical so traversing this you can gain access to the root element of your workflow where defined variables can be found. ModelItem also has information about the type of the property so you can just select properties of certain type.
– Kousic
Nov 19 '18 at 13:02
@kousic I can see that I can get the root item from my model item, but I cannot cast that to a WorkflowDesigner, nor do I see any properties to access the WorkflowDesigner object. I would like to get the Designer itself, then any variables defined in the scope of my custom activity, and any namespaces. Not finding much info online though.
– user1336827
Nov 20 '18 at 14:31
@kousic I can see that I can get the root item from my model item, but I cannot cast that to a WorkflowDesigner, nor do I see any properties to access the WorkflowDesigner object. I would like to get the Designer itself, then any variables defined in the scope of my custom activity, and any namespaces. Not finding much info online though.
– user1336827
Nov 20 '18 at 14:31
Can you give me a sample code of your model item?
– Kousic
Nov 21 '18 at 6:51
Can you give me a sample code of your model item?
– Kousic
Nov 21 '18 at 6:51
@kousic added sample code
– user1336827
Nov 21 '18 at 14:16
@kousic added sample code
– user1336827
Nov 21 '18 at 14:16
add a comment |
1 Answer
1
active
oldest
votes
Following the Using a Custom Expression Editor as reference, it seems you should be able to create a Custom Expression Service (which will be creating the Expression Editor instances) and register it to the Services collection on the WorkflowDesigner.
Once it's registered in the WorkflowDesigner's Services collection, you'll be able to:
- Get the editing context for the ModelItem by using ModelItemExtensions.GetEditingContext
- Access the
Servicesproperty of the returned EditingContext - Retrieve the Custom Expression Service you registered on the WorkflowDesginer
Hope it helps!
Thanks, yes, I was able to grab the ServiceManager, variables and using statements all off the original modelItem and pass them through.
– user1336827
Nov 26 '18 at 18:49
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285216%2fget-workflowdesigner-from-a-modelitem%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Following the Using a Custom Expression Editor as reference, it seems you should be able to create a Custom Expression Service (which will be creating the Expression Editor instances) and register it to the Services collection on the WorkflowDesigner.
Once it's registered in the WorkflowDesigner's Services collection, you'll be able to:
- Get the editing context for the ModelItem by using ModelItemExtensions.GetEditingContext
- Access the
Servicesproperty of the returned EditingContext - Retrieve the Custom Expression Service you registered on the WorkflowDesginer
Hope it helps!
Thanks, yes, I was able to grab the ServiceManager, variables and using statements all off the original modelItem and pass them through.
– user1336827
Nov 26 '18 at 18:49
add a comment |
Following the Using a Custom Expression Editor as reference, it seems you should be able to create a Custom Expression Service (which will be creating the Expression Editor instances) and register it to the Services collection on the WorkflowDesigner.
Once it's registered in the WorkflowDesigner's Services collection, you'll be able to:
- Get the editing context for the ModelItem by using ModelItemExtensions.GetEditingContext
- Access the
Servicesproperty of the returned EditingContext - Retrieve the Custom Expression Service you registered on the WorkflowDesginer
Hope it helps!
Thanks, yes, I was able to grab the ServiceManager, variables and using statements all off the original modelItem and pass them through.
– user1336827
Nov 26 '18 at 18:49
add a comment |
Following the Using a Custom Expression Editor as reference, it seems you should be able to create a Custom Expression Service (which will be creating the Expression Editor instances) and register it to the Services collection on the WorkflowDesigner.
Once it's registered in the WorkflowDesigner's Services collection, you'll be able to:
- Get the editing context for the ModelItem by using ModelItemExtensions.GetEditingContext
- Access the
Servicesproperty of the returned EditingContext - Retrieve the Custom Expression Service you registered on the WorkflowDesginer
Hope it helps!
Following the Using a Custom Expression Editor as reference, it seems you should be able to create a Custom Expression Service (which will be creating the Expression Editor instances) and register it to the Services collection on the WorkflowDesigner.
Once it's registered in the WorkflowDesigner's Services collection, you'll be able to:
- Get the editing context for the ModelItem by using ModelItemExtensions.GetEditingContext
- Access the
Servicesproperty of the returned EditingContext - Retrieve the Custom Expression Service you registered on the WorkflowDesginer
Hope it helps!
answered Nov 22 '18 at 5:52
Itay PodhajcerItay Podhajcer
1,9241412
1,9241412
Thanks, yes, I was able to grab the ServiceManager, variables and using statements all off the original modelItem and pass them through.
– user1336827
Nov 26 '18 at 18:49
add a comment |
Thanks, yes, I was able to grab the ServiceManager, variables and using statements all off the original modelItem and pass them through.
– user1336827
Nov 26 '18 at 18:49
Thanks, yes, I was able to grab the ServiceManager, variables and using statements all off the original modelItem and pass them through.
– user1336827
Nov 26 '18 at 18:49
Thanks, yes, I was able to grab the ServiceManager, variables and using statements all off the original modelItem and pass them through.
– user1336827
Nov 26 '18 at 18:49
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285216%2fget-workflowdesigner-from-a-modelitem%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The ModelItem property is hierarchical so traversing this you can gain access to the root element of your workflow where defined variables can be found. ModelItem also has information about the type of the property so you can just select properties of certain type.
– Kousic
Nov 19 '18 at 13:02
@kousic I can see that I can get the root item from my model item, but I cannot cast that to a WorkflowDesigner, nor do I see any properties to access the WorkflowDesigner object. I would like to get the Designer itself, then any variables defined in the scope of my custom activity, and any namespaces. Not finding much info online though.
– user1336827
Nov 20 '18 at 14:31
Can you give me a sample code of your model item?
– Kousic
Nov 21 '18 at 6:51
@kousic added sample code
– user1336827
Nov 21 '18 at 14:16