コード例 #1
0
        void AddEntriesForVariables(ModelItem modelItem)
        {
            ModelItemCollection variables = VariableHelper.GetVariableCollection(modelItem);

            if (variables != null)
            {
                foreach (ModelItem variable in variables)
                {
                    entries.Add(CreateSearchableEntry(SearchableEntryOption.Variable, variable, null,
                                                      TypeNameHelper.GetDisplayName(variable.Properties[DesignTimeVariable.VariableTypeProperty].ComputedValue as Type, false), null));

                    entries.Add(CreateSearchableEntry(SearchableEntryOption.Variable, variable, null,
                                                      variable.Properties[DesignTimeVariable.VariableNameProperty].ComputedValue.ToString(), null));

                    object propertyValue = variable.Properties[DesignTimeVariable.VariableDefaultProperty].ComputedValue;

                    if (propertyValue != null)
                    {
                        entries.Add(CreateSearchableEntry(SearchableEntryOption.Variable, variable, null,
                                                          ExpressionToString(propertyValue), null));
                    }

                    if (this.editingContext.Services.GetService <DesignerConfigurationService>().AnnotationEnabled)
                    {
                        string annotationText = (string)variable.Properties[Annotation.AnnotationTextPropertyName].ComputedValue;
                        if (!string.IsNullOrEmpty(annotationText))
                        {
                            entries.Add(CreateSearchableEntry(SearchableEntryOption.Variable, variable, null, annotationText, null));
                        }
                    }
                }
            }
        }
コード例 #2
0
        internal static bool TryGetPropertyValue(this ModelItem item, out ModelItemCollection value, params string[] path)
        {
            ModelItem temp;

            value = null;
            bool result = TryGetPropertyValue(item, out temp, path);

            if (null != item)
            {
                value = (ModelItemCollection)temp;
            }
            return(result);
        }
コード例 #3
0
        private static ModelItem GetModelItemFromSegment(ModelItem currentModelItem, string segment)
        {
            ModelItem modelItemFromSegment  = null;
            int       indexOfSquareBrackets = segment.IndexOf('[');

            // e.g Sequence.Activities[0] segment = "Activities[0]"
            if (indexOfSquareBrackets > 0)
            {
                string collectionProperty = segment.Substring(0, indexOfSquareBrackets);
                // find the value of the collection property
                ModelItemCollection segmentCollection = GetModelItemFromSegment(currentModelItem, collectionProperty) as ModelItemCollection;
                if (segmentCollection != null)
                {
                    try
                    {
                        // parse the [index] to find the index
                        string indexString = segment.Substring(indexOfSquareBrackets + 1);
                        indexString = indexString.Substring(0, indexString.Length - 1);
                        int index = Int32.Parse(indexString, CultureInfo.InvariantCulture);
                        if (index >= 0 && index < segmentCollection.Count)
                        {
                            // now index into the collection
                            modelItemFromSegment = segmentCollection[index];
                        }
                    }
                    // dont crash ever.
                    catch (FormatException)
                    {
                    }
                    catch (OverflowException)
                    {
                    }
                }
            }
            // e.g SomeFoo.Then segment = "Then"
            else
            {
                ModelProperty property = currentModelItem.Properties[segment];
                if (property != null)
                {
                    modelItemFromSegment = property.Value;
                }
            }
            return(modelItemFromSegment);
        }
コード例 #4
0
        void AddEntriesForArguments(Selection selection, ref int startIndex)
        {
            ModelProperty argumentsProperty = this.modelService.Root.Properties["Properties"];

            if (argumentsProperty == null)
            {
                return;
            }
            ModelItemCollection arguments = argumentsProperty.Collection;

            if (arguments != null)
            {
                ModelItem selectedArgument = this.GetTopmostSelectedArgument(selection, arguments);
                foreach (ModelItem argument in arguments)
                {
                    // Do this check to make sure we start from the topmost selected item.
                    if (startIndex == StartIndexUnchangeMark && argument == selectedArgument && argument != lastNavigatedItem)
                    {
                        startIndex = index;
                    }
                    entries.Add(CreateSearchableEntry(SearchableEntryOption.Argument, argument, null,
                                                      TypeNameHelper.GetDisplayName(argument.Properties["Type"].ComputedValue as Type, false), null));

                    entries.Add(CreateSearchableEntry(SearchableEntryOption.Argument, argument, null,
                                                      argument.Properties[DesignTimeArgument.ArgumentNameProperty].ComputedValue.ToString(), null));

                    IList <string> argumentValues = GetSearchableStrings(argument.Properties[DesignTimeArgument.ArgumentDefaultValueProperty].ComputedValue);
                    if (argumentValues.Count == 1)
                    {
                        AddEntriesForPropertyValue(argumentValues[0],
                                                   argument, null, SearchableEntryOption.Argument, null);
                    }

                    if (this.editingContext.Services.GetService <DesignerConfigurationService>().AnnotationEnabled)
                    {
                        string annotationText = (string)argument.Properties[Annotation.AnnotationTextPropertyName].ComputedValue;
                        if (!string.IsNullOrEmpty(annotationText))
                        {
                            entries.Add(CreateSearchableEntry(SearchableEntryOption.Argument, argument, null, annotationText, null));
                        }
                    }
                }
            }
        }
コード例 #5
0
 private ModelItem GetTopmostSelectedArgument(Selection selection, ModelItemCollection arguments)
 {
     foreach (ModelItem argument in arguments)
     {
         foreach (ModelItem candidateArgument in selection.SelectedObjects)
         {
             if (candidateArgument.ItemType == typeof(DesignTimeArgument))
             {
                 // since for arguments, the selection is not the modelitem, it is the fakemodelitem, we cannot do a
                 // simple reference comparing to find the selected argument.
                 DesignTimeArgument designTimeArgument = candidateArgument.GetCurrentValue() as DesignTimeArgument;
                 if (designTimeArgument.ReflectedObject == argument)
                 {
                     return(argument);
                 }
             }
         }
     }
     return(null);
 }
コード例 #6
0
 internal static string GetUniqueName(this ModelItemCollection collection, string nameDefaultPrefix, Func <ModelItem, string> nameGetter)
 {
     return(collection.GetUniqueName <ModelItem>(nameDefaultPrefix, nameGetter));
 }