System.Func.Invoke(ValueType)

Here are the examples of the csharp api System.Func.Invoke(ValueType) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

19 Source : CommonPropertyEditor.cs
with GNU General Public License v3.0
from mrojkov

protected void SetProperty<ValueType>(Func<ValueType, object> valueProducer)
		{
			ClearWarnings();
			void ValidateAndApply(object o, ValueType current)
			{
				var next = valueProducer(current);
				var result = PropertyValidator.ValidateValue(next, EditorParams.PropertyInfo, out var message);
				if (result !=ValidationResult.Ok) {
					if (!message.IsNullOrWhiteSpace() && o is Node node) {
						message = $"{node.Id}: {message}";
					}
					AddWarning(message, result);
					if (result == ValidationResult.Error) {
						return;
					}
				}
				((IPropertyEditorParamsInternal)EditorParams).PropertySetter(o,
					EditorParams.IsAnimable ? EditorParams.PropertyPath : EditorParams.PropertyName, next);
			}
			DoTransaction(() => {
				if (EditorParams.IsAnimable) {
					foreach (var o in EditorParams.RootObjects) {
						var (p, a, i) = AnimationUtils.GetPropertyByPath((IAnimationHost)o, EditorParams.PropertyPath);
						var current = i == -1 ? p.Info.GetValue(a) : p.Info.GetValue(a, new object[] { i });
						ValidateAndApply(o, (ValueType)current);
					}
				} else {
					foreach (var o in EditorParams.Objects) {
						var current = EditorParams.IndexInList != -1
							? (new IndexedProperty(o, EditorParams.PropertyName, EditorParams.IndexInList)).Value
							: (new Property(o, EditorParams.PropertyName).Value);
						ValidateAndApply(o, (ValueType)current);
					}
				}
			});
		}

19 Source : PickerProvider.cs
with MIT License
from pirhosoft

public List<SearchTreeEntry> CreateSearchTree(SearchWindowContext context)
		{
			var tree = new List<SearchTreeEntry> { new SearchTreeGroupEntry(new GUIContent(_replacedle), 0) };

			if (_paths != null && _items != null)
			{
				var groups = new List<string>();

				for (var i = 0; i < _paths.Count && i < _items.Count; i++)
				{
					var path = _paths[i];
					var item = _items[i];
					var icon = _getIcon(item);

					var menus = path.Split('/');
					var createIndex = -1;

					for (var index = 0; index < menus.Length - 1; index++)
					{
						var group = menus[index];
						if (index >= groups.Count)
						{
							createIndex = index;
							break;
						}

						if (groups[index] != group)
						{
							groups.RemoveRange(index, groups.Count - index);
							createIndex = index;
							break;
						}
					}

					if (createIndex >= 0)
					{
						for (var index = createIndex; index < menus.Length - 1; index++)
						{
							var group = menus[index];
							groups.Add(group);
							tree.Add(new SearchTreeGroupEntry(new GUIContent(group)) { level = index + 1 });
						}
					}

					tree.Add(new SearchTreeEntry(new GUIContent(menus.Last(), icon == null ? _emptyIcon : icon)) { level = menus.Length, userData = item });
				}
			}

			return tree;
		}