Example #1
0
        private static void LoadDefaultDataTemplate(IDictionary <FileMetadataDataTemplateKey, DataTemplate> fileDestination, IDictionary <StreamMetadataDataTemplateKey, DataTemplate> streamDestination, string resourceKey, Type valueType)
        {
            DebugHelper.AssertUIThread();

            Debug.Assert(fileDestination != null);
            Debug.Assert(streamDestination != null);
            Debug.Assert(resourceKey != null);
            Debug.Assert(valueType != null);

            DataTemplate dataTemplate = Application.Current.TryFindResource(resourceKey) as DataTemplate;

            if (dataTemplate != null)
            {
                if (fileDestination != null)
                {
                    FileMetadataDataTemplateKey key = new FileMetadataDataTemplateKey(valueType);
                    fileDestination.Add(key, dataTemplate);
                }

                if (streamDestination != null)
                {
                    StreamMetadataDataTemplateKey key = new StreamMetadataDataTemplateKey(valueType);
                    streamDestination.Add(key, dataTemplate);
                }
            }
        }
Example #2
0
        private DataTemplate GetStreamMetadataDataTemplate(IDictionary <StreamMetadataDataTemplateKey, DataTemplate> source, Type valueType, string keyName, Guid dataTypeId, Guid semanticId)
        {
            DebugHelper.AssertUIThread();

            DataTemplate result = null;

            if (this.plugins != null)
            {
                Debug.Assert(source != null);
                Debug.Assert(valueType != null);
                Debug.Assert(!String.IsNullOrWhiteSpace(keyName));
                Debug.Assert(dataTypeId != Guid.Empty);
                Debug.Assert(semanticId != Guid.Empty);

                StreamMetadataDataTemplateKey key;

                lock (this.plugins)
                {
                    key = new StreamMetadataDataTemplateKey(valueType, keyName, dataTypeId, semanticId);

                    if (!source.TryGetValue(key, out result))
                    {
                        key = new StreamMetadataDataTemplateKey(valueType, keyName, dataTypeId);

                        if (!source.TryGetValue(key, out result))
                        {
                            key = new StreamMetadataDataTemplateKey(valueType, keyName);

                            if (!source.TryGetValue(key, out result))
                            {
                                key = new StreamMetadataDataTemplateKey(valueType);

                                if (!source.TryGetValue(key, out result))
                                {
                                    result = null;
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
Example #3
0
        public override bool Equals(object obj)
        {
            bool result = base.Equals(obj);

            if (result)
            {
                StreamMetadataDataTemplateKey other = obj as StreamMetadataDataTemplateKey;
                if (other == null)
                {
                    result = false;
                }
                else
                {
                    result = (this.dataTypeId == other.dataTypeId) &&
                             (this.semanticId == other.semanticId);
                }
            }

            return(result);
        }