当前位置: 首页>>代码示例>>C#>>正文


C# ModelItem.GetEditingContext方法代码示例

本文整理汇总了C#中System.Activities.Presentation.Model.ModelItem.GetEditingContext方法的典型用法代码示例。如果您正苦于以下问题:C# ModelItem.GetEditingContext方法的具体用法?C# ModelItem.GetEditingContext怎么用?C# ModelItem.GetEditingContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Activities.Presentation.Model.ModelItem的用法示例。


在下文中一共展示了ModelItem.GetEditingContext方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateTypeArgument

        private static void UpdateTypeArgument(ModelItem modelItem, Type value)
        {
            if (value != null)
            {
                Type oldModelItemType = modelItem.ItemType;
                Fx.Assert(oldModelItemType.GetGenericArguments().Count() == 1, "we only support changing a single type parameter ?");
                Type newModelItemType = oldModelItemType.GetGenericTypeDefinition().MakeGenericType(value);
                Fx.Assert(newModelItemType != null, "New model item type needs to be non null or we cannot proceed further");
                ModelItem newModelItem = ModelFactory.CreateItem(modelItem.GetEditingContext(), Activator.CreateInstance(newModelItemType));
                MorphHelper.MorphObject(modelItem, newModelItem);
                MorphHelper.MorphProperties(modelItem, newModelItem);

                if (oldModelItemType.IsSubclassOf(typeof(Activity)) && newModelItemType.IsSubclassOf(typeof(Activity)))
                {
                    if (string.Equals((string)modelItem.Properties["DisplayName"].ComputedValue, GetActivityDefaultName(oldModelItemType), StringComparison.Ordinal))
                    {
                        newModelItem.Properties["DisplayName"].SetValue(GetActivityDefaultName(newModelItemType));
                    }
                }

                DesignerView designerView = modelItem.GetEditingContext().Services.GetService<DesignerView>();
                if (designerView != null)
                {
                    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() =>
                    {
                        if (designerView.RootDesigner != null && ((WorkflowViewElement)designerView.RootDesigner).ModelItem == modelItem)
                        {
                            designerView.MakeRootDesigner(newModelItem, true);
                        }
                        Selection.SelectOnly(modelItem.GetEditingContext(), newModelItem);
                    }));
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:34,代码来源:GenericArgumentsUpdater.cs

示例2: MorphArgument

        internal static Argument MorphArgument(ModelItem originalValue, Type targetType)
        {
            Argument morphed = null;
            Argument original = (Argument)originalValue.GetCurrentValue();
            ActivityWithResult originalExpression = original.Expression;
            
            if (originalExpression != null)
            {
                Type expressionType = originalExpression.GetType();
                Type expressionGenericType = expressionType.IsGenericType ? expressionType.GetGenericTypeDefinition() : null;

                if (expressionGenericType != null)
                {       
                    bool isLocation = ExpressionHelper.IsGenericLocationExpressionType(originalExpression);
                    ActivityWithResult morphedExpression;
                    EditingContext context = originalValue.GetEditingContext();
                    morphed = Argument.Create(targetType, original.Direction);
                    if (ExpressionHelper.TryMorphExpression(originalExpression, isLocation, targetType, 
                        context, out morphedExpression))
                    {                        
                        morphed.Expression = morphedExpression;
                    }
                    //[....] 

                }
            }
            return morphed;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:28,代码来源:MorphHelpers.cs

示例3: ActivityActionMorphHelper

        public static object ActivityActionMorphHelper(ModelItem originalValue, ModelProperty newModelProperty)
        {
            Fx.Assert(newModelProperty.PropertyType.GetGenericArguments().Count() == 1, "This should only be applied for ActivityAction<T>");
            Type activityActionTypeArgument = newModelProperty.PropertyType.GetGenericArguments()[0];
            Type activityActionType = typeof(ActivityAction<>).MakeGenericType(activityActionTypeArgument);
            object activityAction = Activator.CreateInstance(activityActionType);
            ModelItem morphed = ModelFactory.CreateItem(originalValue.GetEditingContext(), activityAction);

            ModelItem originalActivityActionArgument = originalValue.Properties[PropertyNames.ActionArgument].Value;
            if (originalActivityActionArgument != null)
            {
                Type variableType = typeof(DelegateInArgument<>).MakeGenericType(activityActionTypeArgument);
                DelegateInArgument iterationDelegateArgument = (DelegateInArgument)Activator.CreateInstance(variableType);
                iterationDelegateArgument.Name = (string)originalActivityActionArgument.Properties[PropertyNames.NameProperty].Value.GetCurrentValue();
                morphed.Properties[PropertyNames.ActionArgument].SetValue(iterationDelegateArgument);
            }

            ModelItem originalActivityActionHandler = originalValue.Properties[PropertyNames.ActionHandler].Value;
            if (originalActivityActionHandler != null)
            {
                morphed.Properties[PropertyNames.ActionHandler].SetValue(originalActivityActionHandler);
                originalValue.Properties[PropertyNames.ActionHandler].SetValue(null);
            }

            return morphed;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:26,代码来源:MorphHelpers.cs

示例4: ClearViewState

        /// <summary>
        /// Clean key in modelitem's view state
        /// </summary>
        public static void ClearViewState(ModelItem model, string key)
        {
            Contract.Requires(model != null);
            Contract.Requires(key != null);

            ViewStateService vss = model.GetEditingContext().Services.GetService<ViewStateService>();
            vss.RemoveViewState(model, key);
        }
开发者ID:barbarossia,项目名称:CWF,代码行数:11,代码来源:CompositeService.cs

示例5: Initialize

 public bool Initialize(ModelItem modelItem)
 {
     this.baseModelItem = modelItem;
     if (null != modelItem)
     {
         this.context = modelItem.GetEditingContext();
     }
     return (null != this.baseModelItem);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:9,代码来源:ParserContext.cs

示例6: OnAddAnnotationCommandExecuted

        public static void OnAddAnnotationCommandExecuted(ExecutedRoutedEventArgs e, ModelItem modelItem)
        {
            ModelProperty property = modelItem.Properties.Find(Annotation.AnnotationTextPropertyName);
            if (property != null)
            {
                using (ModelEditingScope editingScope = modelItem.BeginEdit(SR.AddAnnotationDescription))
                {
                    property.SetValue(string.Empty);
                    ViewStateService viewStateService = modelItem.GetEditingContext().Services.GetService<ViewStateService>();
                    viewStateService.StoreViewStateWithUndo(modelItem, Annotation.IsAnnotationDockedViewStateName, false);
                    editingScope.Complete();
                }

                if (modelItem.View != null)
                {
                    WorkflowViewElement element = modelItem.View as WorkflowViewElement;
                    if (element != null)
                    {
                        element.OnEditAnnotation();
                    }
                }
            }

            e.Handled = true;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:25,代码来源:ContextMenuUtilities.cs

示例7: OnDeleteAnnotationCommandExecuted

        public static void OnDeleteAnnotationCommandExecuted(ExecutedRoutedEventArgs e, ModelItem modelItem)
        {
            using (ModelEditingScope editingScope = modelItem.BeginEdit(SR.DeleteAnnotationDescription))
            {
                modelItem.Properties[Annotation.AnnotationTextPropertyName].SetValue(null);
                ViewStateService viewStateService = modelItem.GetEditingContext().Services.GetService<ViewStateService>();
                viewStateService.StoreViewStateWithUndo(modelItem, Annotation.IsAnnotationDockedViewStateName, null);
                editingScope.Complete();
            }

            e.Handled = true;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:ContextMenuUtilities.cs

示例8: GetVariablesInScope

        internal static List<ModelItem> GetVariablesInScope(ModelItem ownerActivity)
        {
            List<ModelItem> declaredVariables = new List<ModelItem>();
            if (ownerActivity != null)
            {
                bool includeArguments = !(ownerActivity.GetCurrentValue() is ActivityBuilder);
                FrameworkName targetFramework = WorkflowDesigner.GetTargetFramework(ownerActivity.GetEditingContext());
                if ((targetFramework != null) && (targetFramework.IsLessThan45()))
                {
                    declaredVariables.AddRange(VariableHelper.FindVariablesInScope(ownerActivity));
                    declaredVariables.AddRange(VariableHelper.FindActivityDelegateArgumentsInScope(ownerActivity));
                    if (includeArguments)
                    {
                        declaredVariables.AddRange(VisualBasicEditor.GetVariablesForArguments(ownerActivity.Root));
                    }
                }
                else
                {
                    declaredVariables.AddRange(VisualBasicEditor.GetVariablesInScopeWithShadowing(ownerActivity, includeArguments));
                }
            }

            return declaredVariables;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:24,代码来源:VisualBasicEditor.xaml.cs

示例9: GetPropertyData

 void GetPropertyData(PropertyEntry property, out ModelItem activityItem, out ModelItem propertyParentItem, out EditingContext context)
 {
     activityItem = (ModelItem)this.propertyEntryConverter.Convert(property, typeof(ModelItem), false, null);
     propertyParentItem = (ModelItem)this.propertyEntryConverter.Convert(property, typeof(ModelItem), true, null);
     context = activityItem.GetEditingContext();
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:6,代码来源:ModelPropertyEntryToModelItemConverter.cs

示例10: ActivityFuncMorphHelper

        public static object ActivityFuncMorphHelper(ModelItem originalValue, ModelProperty newModelProperty)
        {
            Fx.Assert(newModelProperty.PropertyType.GetGenericArguments().Count() == 2, "This should only be applied for ActivityFunc<TArgument, TResult>");
            Type activityFuncArgumentType = newModelProperty.PropertyType.GetGenericArguments()[0];
            Type activityFuncResultType = newModelProperty.PropertyType.GetGenericArguments()[1];
            Type activityFuncType = typeof(ActivityFunc<,>).MakeGenericType(activityFuncArgumentType, activityFuncResultType);
            object activityFunc = Activator.CreateInstance(activityFuncType);
            ModelItem morphed = ModelFactory.CreateItem(originalValue.GetEditingContext(), activityFunc);

            ModelItem originalActivityFuncArgument = originalValue.Properties[PropertyNames.ActionArgument].Value;
            if (originalActivityFuncArgument != null)
            {
                Type argumentType = typeof(DelegateInArgument<>).MakeGenericType(activityFuncArgumentType);
                DelegateInArgument newActivityActionArgument = (DelegateInArgument)Activator.CreateInstance(argumentType);
                newActivityActionArgument.Name = (string)originalActivityFuncArgument.Properties[PropertyNames.NameProperty].Value.GetCurrentValue();
                morphed.Properties[PropertyNames.ActionArgument].SetValue(newActivityActionArgument);
            }

            ModelItem originalActivityFuncResult = originalValue.Properties[PropertyNames.ResultProperty].Value;
            if (originalActivityFuncResult != null)
            {
                Type resultType = typeof(DelegateOutArgument<>).MakeGenericType(activityFuncResultType);
                DelegateOutArgument newActivityActionResult = (DelegateOutArgument)Activator.CreateInstance(resultType);
                newActivityActionResult.Name = (string)originalActivityFuncResult.Properties[PropertyNames.NameProperty].Value.GetCurrentValue();
                morphed.Properties[PropertyNames.ResultProperty].SetValue(newActivityActionResult);
            }

            ModelItem originalActivityActionHandler = originalValue.Properties[PropertyNames.ActionHandler].Value;
            if (originalActivityActionHandler != null)
            {
                morphed.Properties[PropertyNames.ActionHandler].SetValue(originalActivityActionHandler);
                originalValue.Properties[PropertyNames.ActionHandler].SetValue(null);
            }

            return morphed;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:36,代码来源:MorphHelpers.cs

示例11: GetViewState

 private static object GetViewState(ModelItem model, string key)
 {
     ViewStateService vss = model.GetEditingContext().Services.GetService<ViewStateService>();
     return vss.RetrieveViewState(model, key);
 }
开发者ID:barbarossia,项目名称:CWF,代码行数:5,代码来源:CompositeService.cs

示例12: UpdateModelItem

        /// <summary>
        /// Replace modelitem by activity
        /// </summary>
        /// <param name="oldModelItem"></param>
        public static ModelItem UpdateModelItem(ModelItem oldModelItem, object newItem)
        {
            Contract.Requires(oldModelItem != null);
            Contract.Requires(newItem != null);

            ModelItem newModelItem = WrapAsModelItem(oldModelItem.GetEditingContext(), newItem, oldModelItem.Parent);

            try
            {
                foreach (ModelProperty modelProperty in oldModelItem.Sources.ToList())
                {
                    modelProperty.SetValue(newModelItem);
                }

                var collectionParents = from parent in oldModelItem.Parents
                                        where parent is ModelItemCollection
                                        select (ModelItemCollection)parent;
                foreach (ModelItemCollection collectionParent in collectionParents.ToList())
                {
                    int index = collectionParent.IndexOf(oldModelItem);
                    collectionParent.Insert(index, newModelItem);
                    collectionParent.Remove(oldModelItem);
                }
            }
            catch
            {
                throw new UserFacingException("Cannot make selected activity as a task.");
            }

            return newModelItem;
        }
开发者ID:barbarossia,项目名称:CWF,代码行数:35,代码来源:CompositeService.cs

示例13: StoreViewState

        /// <summary>
        /// Save key object in modelitem's view state
        /// </summary>
        public static void StoreViewState(ModelItem model, string key, object value)
        {
            Contract.Requires(model != null);
            Contract.Requires(key != null);
            Contract.Requires(value != null);

            ViewStateService vss = model.GetEditingContext().Services.GetService<ViewStateService>();
            vss.StoreViewState(model, key, value);
        }
开发者ID:barbarossia,项目名称:CWF,代码行数:12,代码来源:CompositeService.cs


注:本文中的System.Activities.Presentation.Model.ModelItem.GetEditingContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。