internal object GetValue(object item) { var propertyValue = RuntimeProperty?.GetValue(item); var transformedValue = TransformValue?.Invoke(propertyValue) ?? propertyValue; return(transformedValue); }
protected override void ProcessPropertyAnnotations( Dictionary <string, object?> annotations, IProperty property, RuntimeProperty runtimeProperty, bool runtime) { base.ProcessPropertyAnnotations(annotations, property, runtimeProperty, runtime); if (!runtime) { annotations.Remove(SqliteAnnotationNames.Srid); } }
/// <summary> /// Initializes a new instance of the <see cref="RuntimeRelationalPropertyOverrides" /> class. /// </summary> /// <param name="property">The property for which the overrides are applied.</param> /// <param name="columnNameOverriden">Whether the column name is overridden.</param> /// <param name="columnName">The column name.</param> public RuntimeRelationalPropertyOverrides( RuntimeProperty property, bool columnNameOverriden, string?columnName) { Property = property; if (columnNameOverriden) { SetAnnotation(RelationalAnnotationNames.ColumnName, columnName); } }
protected override void ProcessPropertyAnnotations( Dictionary <string, object?> annotations, IProperty property, RuntimeProperty runtimeProperty, bool runtime) { base.ProcessPropertyAnnotations(annotations, property, runtimeProperty, runtime); if (!runtime) { annotations.Remove(SqlServerAnnotationNames.IdentityIncrement); annotations.Remove(SqlServerAnnotationNames.IdentitySeed); annotations.Remove(SqlServerAnnotationNames.Sparse); if (!annotations.ContainsKey(SqlServerAnnotationNames.ValueGenerationStrategy)) { annotations[SqlServerAnnotationNames.ValueGenerationStrategy] = property.GetValueGenerationStrategy(); } } }
/// <inheritdoc /> protected override void ProcessPropertyAnnotations( Dictionary <string, object?> annotations, IProperty property, RuntimeProperty runtimeProperty, bool runtime) { base.ProcessPropertyAnnotations(annotations, property, runtimeProperty, runtime); if (!runtime) { annotations.Remove(NpgsqlAnnotationNames.IdentityOptions); annotations.Remove(NpgsqlAnnotationNames.TsVectorConfig); annotations.Remove(NpgsqlAnnotationNames.TsVectorProperties); if (!annotations.ContainsKey(NpgsqlAnnotationNames.ValueGenerationStrategy)) { annotations[NpgsqlAnnotationNames.ValueGenerationStrategy] = property.GetValueGenerationStrategy(); } } }
public static void RefactorProperty(uNodeProperty property, string name) { name = uNodeUtility.AutoCorrectName(name); var graph = property.owner; bool hasVariable = false; if (graph.Properties != null && graph.Properties.Count > 0) { foreach (var V in graph.Properties) { if (V.Name == name) { hasVariable = true; break; } } } if (graph.Variables != null && graph.Variables.Count > 0) { foreach (var V in graph.Variables) { if (V.Name == name) { hasVariable = true; break; } } } if (hasVariable) { return; } Undo.SetCurrentGroupName("Rename Property: " + property.Name); HashSet <GameObject> referencedGraphs = new HashSet <GameObject>(); if (graph != null) { RuntimeProperty runtime = null; if (graph is IIndependentGraph) { if (GraphUtility.IsTempGraphObject(graph.gameObject)) { var prefab = uNodeEditorUtility.GetGameObjectSource(graph.gameObject, null); if (prefab != null) { var oriGraph = prefab.GetComponent <uNodeRoot>(); if (oriGraph != null) { runtime = ReflectionUtils.GetRuntimeType(oriGraph).GetProperty(property.Name) as RuntimeProperty; } } } else { runtime = ReflectionUtils.GetRuntimeType(graph).GetProperty(property.Name) as RuntimeProperty; } } PropertyInfo nativeMember = null; if (graph.GeneratedTypeName.ToType(false) != null) { var type = graph.GeneratedTypeName.ToType(false); nativeMember = type.GetProperty(property.Name, MemberData.flags); } var graphPrefabs = uNodeEditorUtility.FindPrefabsOfType <uNodeRoot>(); foreach (var prefab in graphPrefabs) { var gameObject = prefab; GameObject prefabContent = null; if (GraphUtility.HasTempGraphObject(prefab)) { gameObject = GraphUtility.GetTempGraphObject(prefab); } else if (uNodeEditorUtility.IsPrefab(prefab)) { prefabContent = PrefabUtility.LoadPrefabContents(AssetDatabase.GetAssetPath(prefab)); gameObject = prefabContent; } var scripts = gameObject.GetComponentsInChildren <MonoBehaviour>(true); bool hasUndo = false; Func <object, bool> scriptValidation = (obj) => { MemberData member = obj as MemberData; if (member != null && member.startType is RuntimeType) { var members = member.GetMembers(false); if (members != null) { for (int i = 0; i < members.Length; i++) { var m = members[i]; if (member.namePath.Length > i + 1) { if (m == runtime || m == nativeMember) { if (!hasUndo && prefabContent == null) { uNodeEditorUtility.RegisterFullHierarchyUndo(gameObject); hasUndo = true; } var path = member.namePath; path[i + 1] = name; member.name = string.Join(".", path); if (m == nativeMember) { referencedGraphs.Add(prefab); } return(true); } } } } } return(false); }; if (runtime != null || nativeMember != null) { bool hasChanged = false; Array.ForEach(scripts, script => { bool flag = AnalizerUtility.AnalizeObject(script, scriptValidation); if (flag) { hasChanged = true; hasUndo = false; uNodeGUIUtility.GUIChanged(script); uNodeEditorUtility.MarkDirty(script); } }); if (hasChanged) { if (gameObject != prefab) { uNodeEditorUtility.RegisterFullHierarchyUndo(prefab); if (prefabContent == null) { //Save the temporary graph GraphUtility.AutoSaveGraph(gameObject); } else { //Save the prefab contents and unload it uNodeEditorUtility.SavePrefabAsset(gameObject, prefab); } } uNodeEditorUtility.MarkDirty(prefab); } } if (prefabContent != null) { PrefabUtility.UnloadPrefabContents(prefabContent); } } } uNodeEditorUtility.RegisterFullHierarchyUndo(graph.gameObject); string oldVarName = property.Name; property.Name = name; graph.Refresh(); Func <object, bool> validation = delegate(object OBJ) { return(CallbackRenameProperty(OBJ, graph, property.name, oldVarName)); }; Array.ForEach(graph.nodes, item => AnalizerUtility.AnalizeObject(item, validation)); if (GraphUtility.IsTempGraphObject(graph.gameObject)) { var prefab = uNodeEditorUtility.GetGameObjectSource(graph.gameObject, null); uNodeEditorUtility.RegisterFullHierarchyUndo(prefab); GraphUtility.AutoSaveGraph(graph.gameObject); } uNodeEditor.ClearGraphCache(); uNodeEditor.window?.Refresh(true); DoCompileReferences(graph, referencedGraphs); }