コード例 #1
0
        private IList <DependencyPropertyChangedEventHandler> GetPropertyChangedHandlers(DependencyProperty dp)
        {
            if (_propertyChangeds == null)
            {
                return(null);
            }
            IList <DependencyPropertyChangedEventHandler> handlers = null;

            if (!_propertyChangeds.TryGetValue(dp, out handlers))
            {
                return(null);
            }
            return(handlers);
        }
コード例 #2
0
        /// <summary>
        /// Helper for unindexing triples
        /// </summary>
        /// <param name="n">Node to index by</param>
        /// <param name="t">Triple</param>
        /// <param name="index">Index to remove from</param>
        private void Unindex(INode n, Triple t, MultiDictionary <INode, MultiDictionary <Triple, List <Triple> > > index)
        {
            MultiDictionary <Triple, List <Triple> > subtree;

            if (index.TryGetValue(n, out subtree))
            {
                List <Triple> ts;
                if (subtree.TryGetValue(t, out ts))
                {
                    if (ts != null)
                    {
                        ts.Remove(t);
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Helper for unindexing triples
        /// </summary>
        /// <param name="t">Triple</param>
        /// <param name="index">Index to remove from</param>
        private void UnindexCompound(Triple t, MultiDictionary <Triple, List <Triple> > index)
        {
            if (index == null)
            {
                return;
            }

            List <Triple> ts;

            if (index.TryGetValue(t, out ts))
            {
                if (ts != null)
                {
                    ts.Remove(t);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Helper for unindexing triples
        /// </summary>
        /// <param name="n">Node to index by</param>
        /// <param name="t">Triple</param>
        /// <param name="index">Index to remove from</param>
        private void UnindexSimple(INode n, Triple t, MultiDictionary <INode, List <Triple> > index)
        {
            if (index == null)
            {
                return;
            }

            List <Triple> ts;

            if (index.TryGetValue(n, out ts))
            {
                if (ts != null)
                {
                    ts.Remove(t);
                }
            }
        }
コード例 #5
0
        public IEnumerable <ExpressionTransformation> GetTransformations(Expression expression)
        {
            ArgumentUtility.CheckNotNull("expression", expression);

            IList <ExpressionTransformation> matchingTransformations;

            _transformations.TryGetValue(expression.NodeType, out matchingTransformations);

            if (matchingTransformations != null)
            {
                return(matchingTransformations.Concat(_genericTransformations));
            }
            else
            {
                return(_genericTransformations);
            }
        }
コード例 #6
0
 public IEnumerable <IConceptInfo> FindByType(Type conceptType, bool includeDerivations)
 {
     if (includeDerivations)
     {
         return(_conceptsByType
                .Where(conceptsGroup => conceptType.IsAssignableFrom(conceptsGroup.Key))
                .SelectMany(conceptsGroup => conceptsGroup.Value));
     }
     else
     {
         List <IConceptInfo> result = null;
         if (_conceptsByType.TryGetValue(conceptType, out result))
         {
             return(result);
         }
         return(new List <IConceptInfo>());
     }
 }
コード例 #7
0
 /// <summary>
 /// Gets all the triples with a given subject and predicate
 /// </summary>
 /// <param name="subj">Subject</param>
 /// <param name="pred">Predicate</param>
 /// <returns></returns>
 public override IEnumerable <Triple> WithSubjectPredicate(INode subj, INode pred)
 {
     if (_sp != null)
     {
         List <Triple> ts;
         if (_sp.TryGetValue(new Triple(subj, pred.CopyNode(subj.Graph), _objVar.CopyNode(subj.Graph)), out ts))
         {
             return(ts != null ? ts : Enumerable.Empty <Triple>());
         }
         else
         {
             return(Enumerable.Empty <Triple>());
         }
     }
     else
     {
         return(WithSubject(subj).Where(t => t.Predicate.Equals(pred)));
     }
 }
コード例 #8
0
 /// <summary>
 /// Gets all the triples with a given subject
 /// </summary>
 /// <param name="subj">Subject</param>
 /// <returns></returns>
 public override IEnumerable <Triple> WithSubject(INode subj)
 {
     if (_s != null)
     {
         List <Triple> ts;
         if (_s.TryGetValue(subj, out ts))
         {
             return(ts != null ? ts : Enumerable.Empty <Triple>());
         }
         else
         {
             return(Enumerable.Empty <Triple>());
         }
     }
     else
     {
         return(_triples.Keys.Where(t => t.Subject.Equals(subj)));
     }
 }
コード例 #9
0
        /// <summary>
        /// Helper for unindexing triples.
        /// </summary>
        /// <param name="t">Triple.</param>
        /// <param name="index">Index to remove from.</param>
        private void UnindexCompound(Triple t, MultiDictionary <Triple, HashSet <Triple> > index)
        {
            if (index == null)
            {
                return;
            }

            HashSet <Triple> ts;

            if (index.TryGetValue(t, out ts))
            {
                if (ts != null)
                {
                    ts.Remove(t);
                    if (ts.Count == 0)
                    {
                        index.Remove(new KeyValuePair <Triple, HashSet <Triple> >(t, ts));
                    }
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Helper for unindexing triples.
        /// </summary>
        /// <param name="n">Node to index by.</param>
        /// <param name="t">Triple.</param>
        /// <param name="index">Index to remove from.</param>
        private void UnindexSimple(INode n, Triple t, MultiDictionary <INode, HashSet <Triple> > index)
        {
            if (index == null)
            {
                return;
            }

            HashSet <Triple> ts;

            if (index.TryGetValue(n, out ts))
            {
                if (ts != null)
                {
                    ts.Remove(t);
                    if (ts.Count == 0)
                    {
                        index.Remove(new KeyValuePair <INode, HashSet <Triple> >(n, ts));
                    }
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Returns new resolved concepts that were waiting for this concept to be resolved.
        /// </summary>
        private IEnumerable <IConceptInfo> MarkResolvedConcept(ConceptDescription resolved)
        {
            _logger.Trace(() => "New concept with resolved references: " + resolved.Key);

            _resolvedConcepts.Add(resolved.Concept);
            _resolvedConceptsByKey.Add(resolved.Key, resolved.Concept);
            foreach (var index in _dslModelIndexes)
            {
                index.Add(resolved.Concept);
            }

            var newlyResolved = new List <IConceptInfo>();

            List <UnresolvedReference> unresolvedReferences;

            if (_unresolvedConceptsByReference.TryGetValue(resolved.Key, out unresolvedReferences))
            {
                foreach (var unresolved in unresolvedReferences)
                {
                    if (unresolved.Dependant.UnresolvedDependencies <= 0)
                    {
                        throw new FrameworkException($"Internal error while resolving references of '{unresolved.Dependant.Concept.GetUserDescription()}'."
                                                     + $" The concept has {unresolved.Dependant.UnresolvedDependencies} unresolved dependencies,"
                                                     + $" but it is marked as unresolved dependency to '{unresolved.ReferencedStub.GetUserDescription()}'.");
                    }

                    unresolved.Member.SetMemberValue(unresolved.Dependant.Concept, resolved.Concept);

                    if (--unresolved.Dependant.UnresolvedDependencies == 0)
                    {
                        newlyResolved.Add(unresolved.Dependant.Concept);
                        newlyResolved.AddRange(MarkResolvedConcept(unresolved.Dependant));
                    }
                }

                _unresolvedConceptsByReference.Remove(resolved.Key);
            }

            return(newlyResolved);
        }
コード例 #12
0
        /// <summary>
        /// Helper for indexing triples
        /// </summary>
        /// <param name="n">Node to index by</param>
        /// <param name="t">Triple</param>
        /// <param name="index">Index to insert into</param>
        /// <param name="comparer">Comparer for the Index</param>
        /// <param name="hashFunc">Hash Function for the Index</param>
        private void Index(INode n, Triple t, MultiDictionary <INode, MultiDictionary <Triple, List <Triple> > > index, Func <Triple, int> hashFunc, IComparer <Triple> comparer)
        {
            MultiDictionary <Triple, List <Triple> > subtree;

            if (index.TryGetValue(n, out subtree))
            {
                List <Triple> ts;
                if (subtree.TryGetValue(t, out ts))
                {
                    if (ts == null)
                    {
                        subtree[t] = new List <Triple> {
                            t
                        };
                    }
                    else
                    {
                        ts.Add(t);
                    }
                }
                else
                {
                    subtree.Add(t, new List <Triple> {
                        t
                    });
                }
            }
            else
            {
                subtree = new MultiDictionary <Triple, List <Triple> >(hashFunc, false, comparer, MultiDictionaryMode.AVL);
                subtree.Add(t, new List <Triple> {
                    t
                });
                index.Add(n, subtree);
            }
        }
コード例 #13
0
ファイル: Benchmark.cs プロジェクト: thbin/TraceLab
        /// <summary>
        /// Processes the IO.
        /// </summary>
        /// <param name="componentTemplateIODictionary">The io dictionary of either Inputs of Outputs of the component template.</param>
        /// <param name="settings">input or output settings for the composite component that is being defined</param>
        /// <param name="benchmarkMappingSettingsCollection">The benchmark setting collection .</param>
        private static void ProcessIO(IDictionary <string, IOItem> componentTemplateIODictionary, SortedDictionary <string, ItemSetting> settings, BenchmarkSettingCollection <IOItem> benchmarkMappingSettingsCollection)
        {
            MultiDictionary <string, ItemSetting> lookupByType = new MultiDictionary <string, ItemSetting>();

            //first prepare lookup by type
            foreach (KeyValuePair <string, ItemSetting> pair in settings)
            {
                ItemSetting item = pair.Value;
                //as default don't include it
                item.Include = false;
                lookupByType.Add(item.Type, item);
            }

            foreach (string itemKey in componentTemplateIODictionary.Keys)
            {
                IOItem item = componentTemplateIODictionary[itemKey];

                //check if there are any item settings with matching type
                IEnumerable <ItemSetting> matchingItemSettings;
                if (lookupByType.TryGetValue(item.IOItemDefinition.Type, out matchingItemSettings))
                {
                    ItemSettingCollection list = new ItemSettingCollection(matchingItemSettings);

                    //add all to the candidate matching items - these are items that user can choose from
                    var setting = new BenchmarkItemSetting <IOItem>(item, list);
                    benchmarkMappingSettingsCollection.Add(setting);
                    setting.SelectedSetting = setting.CandidateSettings[0];
                }
                else
                {
                    //add empty list - no matching items - benchmarking cannot be executed
                    var setting = new BenchmarkItemSetting <IOItem>(item, new ItemSettingCollection());
                    benchmarkMappingSettingsCollection.Add(setting);
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Processes the IO.
        /// </summary>
        /// <param name="componentTemplateIODictionary">The io dictionary of either Inputs of Outputs of the component template.</param>
        /// <param name="settings">input or output settings for the composite component that is being defined</param>
        /// <param name="benchmarkMappingSettingsCollection">The benchmark setting collection .</param>
        private static void ProcessIO(IDictionary<string, IOItem> componentTemplateIODictionary, SortedDictionary<string, ItemSetting> settings, BenchmarkSettingCollection<IOItem> benchmarkMappingSettingsCollection)
        {
            MultiDictionary<string, ItemSetting> lookupByType = new MultiDictionary<string, ItemSetting>();

            //first prepare lookup by type 
            foreach (KeyValuePair<string, ItemSetting> pair in settings)
            {
                ItemSetting item = pair.Value;
                //as default don't include it
                item.Include = false;
                lookupByType.Add(item.Type, item);
            }

            foreach (string itemKey in componentTemplateIODictionary.Keys)
            {
                IOItem item = componentTemplateIODictionary[itemKey];

                //check if there are any item settings with matching type
                IEnumerable<ItemSetting> matchingItemSettings;
                if (lookupByType.TryGetValue(item.IOItemDefinition.Type, out matchingItemSettings))
                {
                    ItemSettingCollection list = new ItemSettingCollection(matchingItemSettings);

                    //add all to the candidate matching items - these are items that user can choose from
                    var setting = new BenchmarkItemSetting<IOItem>(item, list);
                    benchmarkMappingSettingsCollection.Add(setting);
                    setting.SelectedSetting = setting.CandidateSettings[0];
                }
                else
                {
                    //add empty list - no matching items - benchmarking cannot be executed
                    var setting = new BenchmarkItemSetting<IOItem>(item, new ItemSettingCollection());
                    benchmarkMappingSettingsCollection.Add(setting);
                }
            }
        }