コード例 #1
0
        private KeyValues(ParseResult result, KeyValuesFlags flags)
        {
            AssertParser(result, ".Document");

            _root = new Entry();
            _root.AddValue(result[0], flags);
        }
コード例 #2
0
ファイル: KeyValues.cs プロジェクト: ahmadalisaeed/temp
        private KeyValues(ParseResult result, KeyValuesFlags flags)
        {
            AssertParser(result, ".Definition.List");

            _root = new Entry();
            _root.AddValue(result, flags);
        }
コード例 #3
0
        private bool TryGetCompatibleValue(Entry entry, Type type, ref object value)
        {
            var values = entry.Values;

            if (values == null)
            {
                return(false);
            }

            var dictionaryAdapter = null as IDictionaryAdapter;

            // Try to find in the graph a directly assignable value
            foreach (var item in values)
            {
                if (!item.IsInGraph)
                {
                    continue;
                }

                var candidate = item.Value.Target;
                if (candidate == null)
                {
                    continue;
                }

                if (type.IsAssignableFrom(item.Type))
                {
                    if (null != candidate)
                    {
                        return(Try.Success(out value, candidate));
                    }
                }

                if (dictionaryAdapter == null)
                {
                    dictionaryAdapter = candidate as IDictionaryAdapter;
                }
            }

            // Fall back to coercing a DA found in the graph
            if (dictionaryAdapter != null)
            {
                value = dictionaryAdapter.Coerce(type);
                entry.AddValue(type, value, true);
                return(true);
            }

            return(false);
        }
コード例 #4
0
 private void AddValueCore(Entry entry, Type type, object value, bool isInGraph)
 {
     entry.AddValue(type, value, isInGraph);
     entriesByValue.Add(value, entry);
 }
コード例 #5
0
ファイル: XmlReferenceManager.cs プロジェクト: elevine/Core
		private bool TryGetCompatibleValue(Entry entry, Type type, ref object value)
		{
			var values = entry.Values;
			if (values == null)
				return false;

			var dictionaryAdapter = null as IDictionaryAdapter;

			// Try to find in the graph a directly assignable value
			foreach (var item in values)
			{
				if (!item.IsInGraph)
					continue;

				var candidate = item.Value.Target;
				if (candidate == null)
					continue;

				if (type.IsAssignableFrom(item.Type))
					if (null != candidate)
						return Try.Success(out value, candidate);

				if (dictionaryAdapter == null)
					dictionaryAdapter = candidate as IDictionaryAdapter;
			}

			// Fall back to coercing a DA found in the graph
			if (dictionaryAdapter != null)
			{
				value = dictionaryAdapter.Coerce(type);
				entry.AddValue(type, value, true);
				return true;
			}

			return false;
		}
コード例 #6
0
ファイル: XmlReferenceManager.cs プロジェクト: elevine/Core
		private void AddValueCore(Entry entry, Type type, object value, bool isInGraph)
		{
			entry.AddValue(type, value, isInGraph);
			entriesByValue.Add(value, entry);
		}