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


C# ModelItem.GetCurrentValue方法代码示例

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


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

示例1: 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

示例2: CreateTransition

        // referenceTransitionModelItem is used when a connector is re-linked.
        void CreateTransition(ConnectionPoint sourceConnPoint, ConnectionPoint destConnPoint, ModelItem referenceTransitionModelItem, bool isSourceMoved)
        {
            Debug.Assert(this.IsOutmostStateContainerEditor(), "Should only be called by the outmost editor.");

            WorkflowViewElement srcDesigner = sourceConnPoint.ParentDesigner as WorkflowViewElement;
            WorkflowViewElement destDesigner = destConnPoint.ParentDesigner as WorkflowViewElement;
            Debug.Assert(srcDesigner is StateDesigner && destDesigner is StateDesigner, "The source and destination designers should both be StateDesigner");

            ModelItem srcModelItem = srcDesigner.ModelItem;
            ModelItem destModelItem = destDesigner.ModelItem;
            ModelItem transitionModelItem = null;

            // We are moving the connector.
            if (referenceTransitionModelItem != null && referenceTransitionModelItem.ItemType == typeof(Transition))
            {
                transitionModelItem = referenceTransitionModelItem;
                // We are moving the start of the connector. We only preserve the trigger if it is not shared.
                if(isSourceMoved)
                {
                    Transition referenceTransition = referenceTransitionModelItem.GetCurrentValue() as Transition;
                    ModelItem stateModelItem = GetParentStateModelItemForTransition(referenceTransitionModelItem);
                    State state = stateModelItem.GetCurrentValue() as State;
                    bool isTriggerShared = false;
                    foreach (Transition transition in state.Transitions)
                    {
                        if (transition != referenceTransition && transition.Trigger == referenceTransition.Trigger)
                        {
                            isTriggerShared = true;
                            break;
                        }
                    }
                    if (isTriggerShared)
                    {
                        transitionModelItem.Properties[TransitionDesigner.TriggerPropertyName].SetValue(null);
                    }
                }
                transitionModelItem.Properties[TransitionDesigner.ToPropertyName].SetValue(destModelItem);
                srcModelItem.Properties[StateDesigner.TransitionsPropertyName].Collection.Add(transitionModelItem);
            }
            // We are creating a new connector. 
            else
            {
                Transition newTransition = new Transition() { DisplayName = string.Empty };
                newTransition.To = destModelItem.GetCurrentValue() as State;
                // Assign the shared trigger.
                if (sourceConnPoint.AttachedConnectors.Count > 0)
                {
                    Connector connector = sourceConnPoint.AttachedConnectors[0];
                    Transition existingTransition = StateContainerEditor.GetConnectorModelItem(connector).GetCurrentValue() as Transition;
                    newTransition.Trigger = existingTransition.Trigger;
                }
                transitionModelItem = srcModelItem.Properties[StateDesigner.TransitionsPropertyName].Collection.Add(newTransition);
            }
            if (transitionModelItem != null)
            {
                PointCollection connectorViewState = new PointCollection(ConnectorRouter.Route(this.panel, sourceConnPoint, destConnPoint));
                this.StoreConnectorLocationViewState(transitionModelItem, connectorViewState, true);
            }
        }
开发者ID:blacklensama,项目名称:1709,代码行数:60,代码来源:StateContainerEditor.ModelChanges.cs

示例3: EnsureInitialization

        internal static void EnsureInitialization(ModelItem modelItem)
        {
            Contract.Requires(modelItem != null);

            var value = modelItem.GetCurrentValue();
            var ei = value as IEnsureInitialization;
            if (ei != null) ei.EnsureInitialization();
        }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:8,代码来源:InterfaceHelpers.cs

示例4: ValidateCollectionItem

 protected override IEnumerable<IActionableErrorInfo> ValidateCollectionItem(ModelItem mi)
 {
     var dto = mi.GetCurrentValue() as SharepointSearchTo;
     if(dto == null)
     {
         yield break;
     }
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:8,代码来源:SharepointListCreateDesignerViewModel.cs

示例5: RetrieveViewState

        public override object RetrieveViewState(ModelItem modelItem, string key)
        {
            if (modelItem == null)
            {
                throw FxTrace.Exception.AsError(new ArgumentNullException("modelItem"));
            }
            if (key == null)
            {
                throw FxTrace.Exception.AsError(new ArgumentNullException("key"));
            }

            object viewStateObj = null;
            Dictionary<string, object> viewState = WorkflowViewStateService.GetViewState(modelItem.GetCurrentValue());
            if (viewState != null)
            {
                viewState.TryGetValue(key, out viewStateObj);
            }
            return viewStateObj;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:19,代码来源:WorkflowViewStateService.cs

示例6: DoAutoConnect

 private ModelItem DoAutoConnect(UIElement sourceElement, ModelItem droppedModelItem, Transition transitionToCopy, int insertIndex = InvalidIndex)
 {
     ModelItem sourceModelItem = TryGetModelItemFromView(sourceElement);
     if (sourceModelItem != null && droppedModelItem.ItemType == typeof(State))
     {
         if (sourceModelItem.ItemType == typeof(State))
         {
             ModelItem stateMachineModelItem = GetStateMachineModelItem(sourceModelItem);
             Transition transition = new Transition
             {
                 DisplayName = StateContainerEditor.GenerateTransitionName(stateMachineModelItem),
                 To = droppedModelItem.GetCurrentValue() as State
             };
             if (transitionToCopy != null)
             {
                 transition.Action = transitionToCopy.Action;
                 transition.Condition = transitionToCopy.Condition;
                 transition.DisplayName = transitionToCopy.DisplayName;
                 transition.Trigger = transitionToCopy.Trigger;
             }
             ModelItem trasitionModelItem = null;
             if (insertIndex >= 0)
             {
                 trasitionModelItem = sourceModelItem.Properties[StateDesigner.TransitionsPropertyName].Collection.Insert(insertIndex, transition);
             }
             else
             {
                 trasitionModelItem = sourceModelItem.Properties[StateDesigner.TransitionsPropertyName].Collection.Add(transition);
             }
             Fx.Assert(trasitionModelItem != null, "trasitionModelItem");
             return trasitionModelItem;
         }
         // auto-connect from the initial node
         else if (sourceModelItem.ItemType == typeof(StartNode))
         {
             this.ModelItem.Properties[StateMachineDesigner.InitialStatePropertyName].SetValue(droppedModelItem);
             return this.ModelItem;
         }
     }
     return null;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:41,代码来源:StateContainerEditor.xaml.cs

示例7: FindMatchSrcLocation

 private static SourceLocation FindMatchSrcLocation(ModelItem modelItem, Dictionary<object, SourceLocation> mapping)
 {
     object modelObject = modelItem.GetCurrentValue();
     return FindSrcLocation(mapping, (key) =>
         {
             return object.ReferenceEquals(modelObject, key);
         });
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:8,代码来源:ObjectToSourceLocationMapping.cs

示例8: EditCore

        private void EditCore(ModelItem key, ModelItem value, bool updateInstance)
        {
            try
            {
                ModelItem oldValue = this.modelItems[key];
                this.EditInProgress = true;
                Fx.Assert(this.instance != null, "instance should not be null");

                bool wasValueInKeysOrValuesCollection = this.IsInKeysOrValuesCollection(value);

                if (updateInstance)
                {
                    this.instance[(key == null) ? null : key.GetCurrentValue()] = null != value ? value.GetCurrentValue() : null;
                    //this also makes sure ItemsCollectionModelItemCollection is not null 
                    if (ItemsCollectionObject != null)
                    {
                        try
                        {
                            ItemsCollectionObject.ShouldUpdateDictionary = false;

                            foreach (ModelItem item in ItemsCollectionModelItemCollection)
                            {
                                ModelItem keyInCollection = item.Properties["Key"].Value;
                                bool found = (key == keyInCollection);

                                if (!found && key != null && keyInCollection != null)
                                {
                                    object keyValue = key.GetCurrentValue();

                                    // ValueType do not share ModelItem, a ModelItem is always created for a ValueType
                                    // ModelTreeManager always create a ModelItem even for the same string
                                    // So, we compare object instance instead of ModelItem for above cases.
                                    if (keyValue is ValueType || keyValue is string)
                                    {
                                        found = keyValue.Equals(keyInCollection.GetCurrentValue());
                                    }
                                }

                                if (found)
                                {
                                    ModelPropertyImpl valueImpl = item.Properties["Value"] as ModelPropertyImpl;
                                    if (valueImpl != null)
                                    {
                                        valueImpl.SetValueCore(value);
                                    }
                                }
                            }
                        }
                        finally
                        {
                            ItemsCollectionObject.ShouldUpdateDictionary = true;
                        }
                    }
                }

                this.modelItems[key] = null;
                if (oldValue != null && !this.IsInKeysOrValuesCollection(oldValue))
                {
                    this.modelTreeManager.OnItemEdgeRemoved(this, oldValue);
                }

                this.modelItems[key] = value;
                if (value != null && !wasValueInKeysOrValuesCollection)
                {
                    this.modelTreeManager.OnItemEdgeAdded(this, value);
                }

                if (null != this.CollectionChanged)
                {
                    this.CollectionChanged(this,
                        new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace,
                        new KeyValuePair<ModelItem, ModelItem>(key, value),
                        new KeyValuePair<ModelItem, ModelItem>(key, oldValue)));
                }
            }
            finally
            {
                this.EditInProgress = false;
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:80,代码来源:ModelItemDictionaryImpl.cs

示例9: SetValueCore

        internal object SetValueCore(ModelItem newValueModelItem)
        {
            object newValueInstance = (newValueModelItem == null) ? null : newValueModelItem.GetCurrentValue();
            ModelItem oldValueModelItem = this.Value;
            IModelTreeItem parent = (IModelTreeItem)this.Parent;

            // update object instance
            this.PropertyDescriptor.SetValue(this.Parent.GetCurrentValue(), newValueInstance);

            if (oldValueModelItem != null && !this.isAttached)
            {
                parent.ModelPropertyStore.Remove(this.Name);
                parent.ModelTreeManager.OnPropertyEdgeRemoved(this.Name, this.Parent, oldValueModelItem);
            }

            if (newValueModelItem != null && !this.isAttached)
            {
                parent.ModelPropertyStore.Add(this.Name, newValueModelItem);
                parent.ModelTreeManager.OnPropertyEdgeAdded(this.Name, this.Parent, newValueModelItem);
            }

            // notify observers
            ((IModelTreeItem)this.Parent).OnPropertyChanged(this.Name);
            return newValueInstance;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:ModelPropertyImpl.cs

示例10: DynamicArgumentWrapperObject

 public DynamicArgumentWrapperObject(string argumentName, ModelItem argumentItem)
 {
     Fx.Assert(argumentItem != null, "argumentItem canot be null");
     this.isInitializing = true;
     this.IsValidating = false;            
     Argument argument = (Argument)argumentItem.GetCurrentValue();
     this.Name = argumentName;
     this.Direction = argument.Direction;
     this.UseLocationExpression = (this.Direction != ArgumentDirection.In);
     this.Type = argument.ArgumentType;
     this.Expression = argumentItem.Properties[ExpressionPropertyName].Value;
     this.isInitializing = false;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:13,代码来源:DynamicArgumentDesigner.xaml.cs

示例11: GetConnectorViewStateStorageModelItem

 ModelItem GetConnectorViewStateStorageModelItem(ModelItem linkModelItem)
 {
     ModelItem storageModelItem = linkModelItem;
     if (typeof(IFlowSwitchLink).IsAssignableFrom(linkModelItem.ItemType))
     {
         IFlowSwitchLink link = (IFlowSwitchLink)linkModelItem.GetCurrentValue();
         //Getting FlowSwitch ModelItem since there is no CFx object for linkModelItem.
         IModelTreeItem modelTreeItem = this.ModelItem as IModelTreeItem;
         storageModelItem = modelTreeItem.ModelTreeManager.WrapAsModelItem(link.ParentFlowSwitch);
     }
     return storageModelItem;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:FlowchartDesigner.xaml.cs

示例12: RemoveViewState

 public override bool RemoveViewState(ModelItem modelItem, string key)
 {
     if (modelItem == null)
     {
         throw FxTrace.Exception.AsError(new ArgumentNullException("modelItem"));
     }
     if (key == null)
     {
         throw FxTrace.Exception.AsError(new ArgumentNullException("key"));
     }
     bool itemRemoved = false;
     Dictionary<string, object> viewState = WorkflowViewStateService.GetViewState(modelItem.GetCurrentValue());
     if (viewState != null && key != null && viewState.ContainsKey(key))
     {
         itemRemoved = viewState.Remove(key);
         if (viewState.Keys.Count == 0)
         {
             AttachablePropertyServices.RemoveProperty(modelItem.GetCurrentValue(), ViewStateName);
         }
     }
     return itemRemoved;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:22,代码来源:WorkflowViewStateService.cs

示例13: RemoveCore

        internal void RemoveCore(ModelItem item)
        {

            Fx.Assert(instance is IList, "Instance needs to be IList for remove to work");
            Fx.Assert(instance != null, "instance should not be null");

            IList instanceList = (IList)instance;
            int index = instanceList.IndexOf(item.GetCurrentValue());
            instanceList.Remove(item.GetCurrentValue());
            this.modelItems.Remove(item);

            if (!this.modelItems.Contains(item))
            {
                this.modelTreeManager.OnItemEdgeRemoved(this, item);
            }

            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs("Count"));
            }

            if (this.CollectionChanged != null)
            {
                this.CollectionChanged(this, new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Remove, item, index));
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:26,代码来源:ModelItemCollectionImpl.cs

示例14: GetValidationError

 ValidationErrorState GetValidationError(ModelItem modelItem)
 {
     ValidationErrorState validationError = null;
     this.ValidationErrors.TryGetValue(modelItem.GetCurrentValue(), out validationError);
     return validationError;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:6,代码来源:ValidationService.cs

示例15: CanPasteTransition

        private bool CanPasteTransition(ModelItem sourceStateItem, out string errorMessage)
        {
            Fx.Assert(sourceStateItem != null, "sourceStateItem cannot be null");

            if (sourceStateItem.ItemType != typeof(State))
            {
                errorMessage = SR.PasteTransitionOnNonStateItem;
                return false;
            }

            if (!this.modelItemToUIElement.ContainsKey(sourceStateItem))
            {
                errorMessage = SR.PasteTransitionWithoutDestinationState;
                return false;
            }

            State sourceState = (State)sourceStateItem.GetCurrentValue();

            if (sourceState.IsFinal)
            {
                errorMessage = SR.PasteTransitionOnFinalState;
                return false;
            }

            if (GetEmptyConnectionPoints(sourceStateItem.View as UIElement).Count < 1)
            {
                errorMessage = string.Format(CultureInfo.CurrentUICulture, SR.PasteTransitionWithoutAvailableConnectionPoints, sourceState.DisplayName);
                return false;
            }

            errorMessage = null;
            return true;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:33,代码来源:StateContainerEditor.CompositeView.cs


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