public void Resolve(IDictionary <Identifier, IReferencable> referencables) { if (referencables.ContainsKey(identifier)) { IsResolved = true; IReferencable referencable = referencables[identifier]; var property = referencable as Property; if (property == null) { throw new InvalidOperationException("Cannot resolve to '" + referencable.GetType().FullName + "'"); } ReturnType = property.ReturnType; if (!ReturnType.IsResolved) { ReturnType.Resolve(referencables); } if (!Summary.IsResolved) { Summary.Resolve(referencables); } if (!Remarks.IsResolved) { Remarks.Resolve(referencables); } } else { ConvertToExternalReference(); } }
public void Resolve(IDictionary<Identifier, IReferencable> referencables) { if (referencables.ContainsKey(identifier)) { IsResolved = true; var referencable = referencables[identifier]; var field = referencable as Field; if (field == null) throw new InvalidOperationException("Cannot resolve to '" + referencable.GetType().FullName + "'"); ReturnType = field.ReturnType; if (!ReturnType.IsResolved) ReturnType.Resolve(referencables); if (!Summary.IsResolved) Summary.Resolve(referencables); if (!Remarks.IsResolved) Remarks.Resolve(referencables); } else ConvertToExternalReference(); }
public MethodParameter(string name, bool hasDefault, object defualtValue, IReferencable reference) : base(new NullIdentifier(name)) { Reference = reference; HasDefault = hasDefault; DefualtValue = defualtValue; }
protected static void HandleReferencing(IReferencable p_reference, FieldInfo p_fieldInfo, bool p_directExpression = false, Parameter p_parameter = null) { if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && Event.current.button == 1 && Event.current.type == EventType.MouseDown) { RuntimeGenericMenu menu = new RuntimeGenericMenu(); menu.AddItem(new GUIContent("Copy reference"), false, () => { DashEditorCore.propertyReference = "[$" + p_reference.Id + "." + p_fieldInfo.Name + "]"; }); if (p_parameter != null && !string.IsNullOrEmpty(DashEditorCore.propertyReference)) { menu.AddItem(new GUIContent("Paste reference"), false, () => { p_parameter.isExpression = true; p_parameter.expression = DashEditorCore.propertyReference; }); } if (p_directExpression && !string.IsNullOrEmpty(DashEditorCore.propertyReference)) { menu.AddItem(new GUIContent("Paste reference"), false, () => { p_fieldInfo.SetValue(p_reference, DashEditorCore.propertyReference); }); } //menu.ShowAsContext(); GenericMenuPopup.Show(menu, "", Event.current.mousePosition, 240, 300, false, false); } }
public static Method Unresolved(MethodIdentifier methodIdentifier, DeclaredType type, MethodInfo representedMethod, IReferencable returnType) { return new Method(methodIdentifier, type) { IsResolved = false, representedMethod = representedMethod, ReturnType = returnType }; }
public void addSymbol(string name, IReferencable ref_) { if (this.symbols.has(name)) { this.throw_($"Symbol shadowing: {name}"); } this.symbols.set(name, ref_); this.currLevel.push(name); }
public virtual bool Unresolve() { IReferencable dependentMetadataNode = this.DependentMetadataNode as IReferencable; if (dependentMetadataNode != null) { dependentMetadataNode.RemoveReferencedConstraint(this); } this.DependentMetadataNode = null; this.IsResolved = false; return(true); }
/// <summary> /// Returns a hyperlink to another symbol /// </summary> /// <remarks>The format of the URL in the returned hyperlink can be controlled by the methods <see cref="SetNamespaceUrlFormat"/>, <see cref="SetTypeUrlFormat"/>, <see cref="SetPropertyUrlFormat"/>, <see cref="SetMethodUrlFormat"/>, <see cref="SetFieldUrlFormat"/> and <see cref="SetEventUrlFormat"/></remarks> /// <param name="referencable"></param> /// <returns></returns> public string Format(IReferencable referencable, params Expression <Func <object, string> >[] attributes) { var attributeDictionary = new Dictionary <string, string>(); attributes.ForEach(exp => { var name = exp.Parameters.First().Name; var value = ((ConstantExpression)exp.Body).Value.ToString(); attributeDictionary.Add(name, value); }); return(Formatter.FormatReferencable(referencable, attributeDictionary)); }
public void Resolve(IDictionary <Identifier, IReferencable> referencables) { if (referencables.ContainsKey(identifier)) { IsResolved = true; IReferencable referencable = referencables[identifier]; var method = referencable as Method; if (method == null) { throw new InvalidOperationException("Cannot resolve to '" + referencable.GetType().FullName + "'"); } ReturnType = method.ReturnType; if (ReturnType != null && !ReturnType.IsResolved) { ReturnType.Resolve(referencables); } declaration = method.declaration; if (declaration != null && declaration.IsDefined(typeof(ObsoleteAttribute))) { ObsoleteReason = declaration.GetCustomAttribute <ObsoleteAttribute>().Message; } if (!Summary.IsResolved) { Summary.Resolve(referencables); } if (!Remarks.IsResolved) { Remarks.Resolve(referencables); } foreach (MethodParameter para in Parameters) { if ((para.Reference != null) && (!para.Reference.IsResolved)) { para.Reference.Resolve(referencables); } } } else { ConvertToExternalReference(); } }
public void Resolve(IDictionary <Identifier, IReferencable> referencables) { if (referencables.ContainsKey(identifier)) { IsResolved = true; IReferencable referencable = referencables[identifier]; var property = referencable as Property; if (property == null) { throw new InvalidOperationException("Cannot resolve to '" + referencable.GetType().FullName + "'"); } ReturnType = property.ReturnType; if (!ReturnType.IsResolved) { ReturnType.Resolve(referencables); } declaration = property.declaration; try { if (declaration != null && declaration.IsDefined(typeof(ObsoleteAttribute))) { ObsoleteReason = declaration.GetCustomAttribute <ObsoleteAttribute>().Message; } } catch (Exception ex) { Console.WriteLine("Cannot perform check for custom attributes"); ConvertToExternalReference(); } if (!Summary.IsResolved) { Summary.Resolve(referencables); } if (!Remarks.IsResolved) { Remarks.Resolve(referencables); } } else { ConvertToExternalReference(); } }
public void Resolve(IDictionary <Identifier, IReferencable> referencables) { if (referencables.ContainsKey(identifier)) { IsResolved = true; IReferencable referencable = referencables[identifier]; var method = referencable as Method; if (method == null) { throw new InvalidOperationException("Cannot resolve to '" + referencable.GetType().FullName + "'"); } ReturnType = method.ReturnType; if (!ReturnType.IsResolved) { ReturnType.Resolve(referencables); } representedMethod = method.representedMethod; if (!Summary.IsResolved) { Summary.Resolve(referencables); } if (!Remarks.IsResolved) { Remarks.Resolve(referencables); } foreach (var para in Parameters) { if ((para.Reference != null) && (!para.Reference.IsResolved)) { para.Reference.Resolve(referencables); } } } else { ConvertToExternalReference(); } }
public string Format(IReferencable reference) { string url = ""; string name = reference.PrettyName; if (reference is Namespace) url = Format(NamespaceUrlFormat, new Dictionary<string, string> { { "namespace", reference.Name } }); else if (reference is DeclaredType) url = Format(TypeUrlFormat, new Dictionary<string, string> { { "type.namespace", ((DeclaredType)reference).Namespace.Name }, { "type", reference.Name } }); if (reference.IsExternal) return "<span title=\"" + reference.FullName + "\">" + Escape(reference.PrettyName) + "</span>"; return "<a href=\"" + url + "\">" + Escape(name) + "</a>"; }
public virtual bool Resolve() { if (this.IsResolved || !this.IsResolvable) { return(this.IsResolved); } IMetadataNode node = this.ResolveNodeSource.Find(a => this.IsSatisfiedBy(a.Metadata)); if (node != null) { this.DependentMetadataNode = node; IReferencable referencable = node as IReferencable; if (referencable != null) { referencable.AddReferencedConstraint(this); } this.IsResolved = true; } else { this.IsResolvable = false; } return(this.IsResolvable); }
public static int ReleaseInternal([NotNull] this IReferencable referencable) { return(referencable.Release()); }
public static Property Unresolved( PropertyIdentifier propertyIdentifier, DeclaredType type, IReferencable returnType) { return new Property(propertyIdentifier, type) { IsResolved = false, ReturnType = returnType }; }
static public bool PropertyField(FieldInfo p_fieldInfo, Object p_object, IReferencable p_reference, FieldInfo p_parentInfo = null) //string p_name = null, bool p_drawLabel = true) { if (IsHidden(p_fieldInfo)) { return(false); } if (!MeetsDependencies(p_fieldInfo, p_object)) { return(false); } FieldInfo nameInfo = p_parentInfo != null ? p_parentInfo : p_fieldInfo; LabelAttribute labelAttribute = nameInfo.GetCustomAttribute <LabelAttribute>(); string nameString = ObjectNames.NicifyVariableName(nameInfo.Name); nameString = labelAttribute == null ? nameString.Substring(0, 1).ToUpper() + nameString.Substring(1) : labelAttribute.Label; TooltipAttribute tooltipAttribute = nameInfo.GetCustomAttribute <TooltipAttribute>(); var name = tooltipAttribute == null ? new GUIContent(nameString) : new GUIContent(nameString, tooltipAttribute.tooltip); if (IsParameterProperty(p_fieldInfo)) { return(ParameterProperty(p_fieldInfo, p_object, name, p_reference)); } if (p_parentInfo == null && IsExpressionProperty(p_fieldInfo)) { return(ExpressionProperty(p_fieldInfo, p_object, name, p_reference)); } if (IsPopupProperty(p_fieldInfo)) { return(PopupProperty(p_fieldInfo, p_object, name)); } if (p_fieldInfo.FieldType == typeof(Type)) { return(SupportedTypeProperty(p_fieldInfo, p_object, name)); } if (IsEnumProperty(p_fieldInfo)) { return(EnumProperty(p_fieldInfo, p_object, name)); } if (IsUnityObjectProperty(p_fieldInfo)) { return(UnityObjectProperty(p_fieldInfo, p_object, name)); } if (IsExposedReferenceProperty(p_fieldInfo)) { return(ExposedReferenceProperty(p_fieldInfo, p_object, name, p_reference)); } return(ValueProperty(p_fieldInfo, p_object, name, p_reference, p_parentInfo)); }
static bool ParameterProperty(FieldInfo p_fieldInfo, Object p_object, GUIContent p_name, IReferencable p_reference) { if (!IsParameterProperty(p_fieldInfo)) { return(false); } Parameter param = (Parameter)p_fieldInfo.GetValue(p_object); if (param == null) { RecreateParameter(p_fieldInfo, p_object); return(true); } // Can happen due to serialization/migration error if (param != null) { EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); if (param.isExpression) { GUILayout.BeginHorizontal(); GUI.color = DashEditorCore.EditorConfig.theme.ParameterColor; GUILayout.Label(p_name, GUILayout.Width(160)); HandleReferencing(p_reference, p_fieldInfo, false, param); param.expression = GUILayout.TextArea(param.expression, GUILayout.ExpandWidth(true)); GUI.color = Color.white; GUILayout.EndHorizontal(); } else { ButtonAttribute button = p_fieldInfo.GetAttribute <ButtonAttribute>(); if (button != null) { GUILayout.Label(p_name, GUILayout.Width(160)); if (param.IsDefault()) { GUI.color = Color.yellow; if (GUILayout.Button(button.NullLabel)) { MethodInfo method = p_object.GetType().GetMethod(button.MethodName, BindingFlags.Instance | BindingFlags.NonPublic); param.GetValueFieldInfo().SetValue(param, method.Invoke(p_object, null)); } GUI.color = Color.white; } else { if (GUILayout.Button(button.NonNullLabel)) { MethodInfo method = p_object.GetType().GetMethod(button.MethodName, BindingFlags.Instance | BindingFlags.NonPublic); param.GetValueFieldInfo().SetValue(param, method.Invoke(p_object, null)); } } } else { PropertyField(param.GetValueFieldInfo(), param, p_reference, p_fieldInfo); } } GUI.color = param.isExpression ? DashEditorCore.EditorConfig.theme.ParameterColor : Color.gray; if (GUILayout.Button(IconManager.GetIcon("Settings_Icon"), GUIStyle.none, GUILayout.Height(16), GUILayout.MaxWidth(16))) { param.isExpression = !param.isExpression; } //param.isExpression = GUILayout.Toggle(param.isExpression, "", GUILayout.MaxWidth(14)); GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(4); if (EditorGUI.EndChangeCheck()) { return(true); } } else { GUI.color = Color.red; GUILayout.Label("Serialization error on " + p_fieldInfo.Name + "\nYou can use SerializationInvalidation in menu to try fix this."); EditorGUILayout.Space(2); GUI.color = Color.white; } return(false); }
public static Property Unresolved(PropertyIdentifier propertyIdentifier, DeclaredType type, IReferencable returnType, List<Attribute> attributes) { return new Property(propertyIdentifier, type) { IsResolved = false, ReturnType = returnType, Attributes = attributes }; }
public static Field Unresolved(FieldIdentifier fieldIdentifier, DeclaredType type, IReferencable returnType) { return(new Field(fieldIdentifier, type) { IsResolved = false, ReturnType = returnType }); }
public static Method Unresolved(MethodIdentifier methodIdentifier, DeclaredType type, MethodInfo representedMethod, IReferencable returnType) { return(new Method(methodIdentifier, type) { IsResolved = false, representedMethod = representedMethod, ReturnType = returnType }); }
public string WriteReference(IReferencable reference) { return Formatter.Format(reference); }
public See(IReferencable reference) { this.Reference = reference; }
public static Method Unresolved(MethodIdentifier methodIdentifier, DeclaredType type, MethodBase declaration, IReferencable returnType) { return new Method(methodIdentifier, type) { IsResolved = false, declaration = declaration, ReturnType = returnType }; }
public static Field Unresolved(FieldIdentifier fieldIdentifier, DeclaredType type, IReferencable returnType) { return new Field(fieldIdentifier, type) { IsResolved = false, ReturnType = returnType }; }
public static Enumeration Unresolved(EnumIdentifier fieldIdentifier, DeclaredType type, IReferencable returnType) { return(new Enumeration(fieldIdentifier, type) { IsResolved = false, ReturnType = returnType }); }
/// <summary> /// Returns a hyperlink to another symbol /// </summary> /// <remarks>The format of the URL in the returned hyperlink can be controlled by the methods <see cref="SetNamespaceUrlFormat"/>, <see cref="SetTypeUrlFormat"/>, <see cref="SetPropertyUrlFormat"/>, <see cref="SetMethodUrlFormat"/>, <see cref="SetFieldUrlFormat"/> and <see cref="SetEventUrlFormat"/></remarks> /// <param name="referencable"></param> /// <returns></returns> public string Format(IReferencable referencable, params Expression<Func<object, string>>[] attributes) { var attributeDictionary = new Dictionary<string, string>(); attributes.ForEach(exp => { var name = exp.Parameters.First().Name; var value = ((ConstantExpression)exp.Body).Value.ToString(); attributeDictionary.Add(name, value); }); return Formatter.FormatReferencable(referencable, attributeDictionary); }
public string FormatReferencable(IReferencable reference) { return FormatReferencable(reference, new KeyValuePair<string, string>[0]); }
public string FormatReferencable(IReferencable reference) { string url = ""; string name = reference.PrettyName; if (reference is Namespace) url = Format(NamespaceUrlFormat, new Replacement("namespace", reference.Name)); else if (reference is DeclaredType) url = Format(TypeUrlFormat, new Replacement("type.namespace", ((DeclaredType)reference).Namespace.Name), new Replacement("type", reference.Name)); else if (reference is Method) { var type = ((Method)reference).Type; url = Format(MethodUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("method", reference.Name)); } else if (reference is Property) { var type = ((Property)reference).Type; url = Format(PropertyUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("property", reference.Name)); } else if (reference is Field) { var type = ((Field)reference).Type; url = Format(FieldUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("field", reference.Name)); } else if (reference is Event) { var type = ((Event)reference).Type; url = Format(EventUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("event", reference.Name)); } if (reference.IsExternal) return "<span title=\"" + reference.FullName + "\">" + Escape(reference.PrettyName) + "</span>"; return "<a href=\"" + url + "\">" + Escape(name) + "</a>"; }
public MethodParameter(string name, IReferencable reference) : base(new NullIdentifier(name)) { Reference = reference; }
public string FormatReferencable(IReferencable reference) { return(FormatReferencable(reference, new KeyValuePair <string, string> [0])); }
static bool ExposedReferenceProperty(FieldInfo p_fieldInfo, Object p_object, GUIContent p_name, IReferencable p_reference) { if (!IsExposedReferenceProperty(p_fieldInfo)) { return(false); } IExposedPropertyTable propertyTable = DashEditorCore.EditorConfig.editingController; var exposedReference = p_fieldInfo.GetValue(p_object); PropertyName exposedName = (PropertyName)exposedReference.GetType().GetField("exposedName").GetValue(exposedReference); bool isDefault = PropertyName.IsNullOrEmpty(exposedName); GUILayout.BeginHorizontal(); GUILayout.Label(p_name, GUILayout.Width(160)); HandleReferencing(p_reference, p_fieldInfo); EditorGUI.BeginChangeCheck(); UnityEngine.Object exposedValue = (UnityEngine.Object)exposedReference.GetType().GetMethod("Resolve") .Invoke(exposedReference, new object[] { propertyTable }); var newValue = EditorGUILayout.ObjectField(exposedValue, p_fieldInfo.FieldType.GetGenericArguments()[0], true); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { if (propertyTable != null) { Undo.RegisterCompleteObjectUndo(propertyTable as UnityEngine.Object, "Set Exposed Property"); } if (!isDefault) { if (newValue == null) { propertyTable.ClearReferenceValue(exposedName); exposedReference.GetType().GetField("exposedName").SetValue(exposedReference, null); p_fieldInfo.SetValue(p_object, exposedReference); } else { propertyTable.SetReferenceValue(exposedName, newValue); } } else { if (newValue != null) { PropertyName newExposedName = new PropertyName(GUID.Generate().ToString()); exposedReference.GetType().GetField("exposedName") .SetValue(exposedReference, newExposedName); propertyTable.SetReferenceValue(newExposedName, newValue); p_fieldInfo.SetValue(p_object, exposedReference); } } return(true); } return(false); }
public string FormatReferencable(IReferencable reference, IEnumerable <KeyValuePair <string, string> > attributes) { string url = ""; string name = reference.PrettyName; if (reference is Namespace) { url = Format(NamespaceUrlFormat, new Replacement("namespace", reference.Name)); } else if (reference is DeclaredType) { url = Format(TypeUrlFormat, new Replacement("type.namespace", ((DeclaredType)reference).Namespace.Name), new Replacement("type", reference.Name)); } else if (reference is Method) { var type = ((Method)reference).Type; url = Format(MethodUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("method", reference.Name)); } else if (reference is Property) { var type = ((Property)reference).Type; url = Format(PropertyUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("property", reference.Name)); } else if (reference is Field) { var type = ((Field)reference).Type; url = Format(FieldUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("field", reference.Name)); } else if (reference is Event) { var type = ((Event)reference).Type; url = Format(EventUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("event", reference.Name)); } if (reference.IsExternal) { return("<span title=\"" + reference.FullName + "\">" + Escape(reference.PrettyName) + "</span>"); } var attributeHtml = ""; attributes.ForEach(x => attributeHtml += " " + x.Key + "=\"" + x.Value + "\""); return("<a href=\"" + view.SiteResource(url) + "\"" + attributeHtml + ">" + Escape(name) + "</a>"); }
static bool ExpressionProperty(FieldInfo p_fieldInfo, Object p_object, GUIContent p_name, IReferencable p_reference) { ExpressionAttribute expressionAttribute = p_fieldInfo.GetAttribute <ExpressionAttribute>(); if (expressionAttribute == null) { return(false); } FieldInfo expressionField = p_object.GetType().GetField(expressionAttribute.expression); FieldInfo useExpressionField = p_object.GetType().GetField(expressionAttribute.useExpression); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); if ((bool)useExpressionField.GetValue(p_object)) { GUILayout.BeginHorizontal(); GUI.color = DashEditorCore.EditorConfig.theme.ParameterColor; GUILayout.Label(p_name, GUILayout.Width(160)); HandleReferencing(p_reference, expressionField, true); string expression = GUILayout.TextArea((string)expressionField.GetValue(p_object), GUILayout.ExpandWidth(true)); GUI.color = Color.white; expressionField.SetValue(p_object, expression); GUILayout.EndHorizontal(); } else { PropertyField(p_fieldInfo, p_object, p_reference, p_fieldInfo); } bool useExpression = (bool)useExpressionField.GetValue(p_object); GUI.color = useExpression ? DashEditorCore.EditorConfig.theme.ParameterColor : Color.gray; if (GUILayout.Button(IconManager.GetIcon("Settings_Icon"), GUIStyle.none, GUILayout.Height(16), GUILayout.MaxWidth(16))) { useExpressionField.SetValue(p_object, !useExpression); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(4); if (EditorGUI.EndChangeCheck()) { return(true); } return(false); }
public void Resolve(IDictionary <Identifier, IReferencable> referencables) { if (referencables.ContainsKey(identifier)) { IsResolved = true; IReferencable referencable = referencables[identifier]; var type = referencable as DeclaredType; if (type == null) { throw new InvalidOperationException("Cannot resolve to '" + referencable.GetType().FullName + "'"); } Namespace = type.Namespace; representedType = type.representedType; ParentType = type.ParentType; Interfaces = type.Interfaces; if (!Namespace.IsResolved) { Namespace.Resolve(referencables); } if (ParentType != null && !ParentType.IsResolved) { ParentType.Resolve(referencables); } foreach (IReferencable face in Interfaces) { if (!face.IsResolved) { face.Resolve(referencables); } } if (!Summary.IsResolved) { Summary.Resolve(referencables); } foreach (var method in Methods) { if (!method.IsResolved) { method.Resolve(referencables); } } foreach (var property in Properties) { if (!property.IsResolved) { property.Resolve(referencables); } } foreach (var ev in Events) { if (!ev.IsResolved) { ev.Resolve(referencables); } } foreach (var field in Fields) { if (!field.IsResolved) { field.Resolve(referencables); } } } else { ConvertToExternalReference(); } }
static bool ValueProperty(FieldInfo p_fieldInfo, Object p_object, GUIContent p_name, IReferencable p_reference, FieldInfo p_parameterInfo = null) { FieldInfo referenceInfo = p_parameterInfo != null ? p_parameterInfo : p_fieldInfo; string type = p_fieldInfo.FieldType.ToString(); switch (type) { case "System.String": EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(p_name, GUILayout.Width(160)); HandleReferencing(p_reference, referenceInfo, false, p_parameterInfo == null ? null : (Parameter)p_object); var stringValue = GUILayout.TextField((String)p_fieldInfo.GetValue(p_object)); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { p_fieldInfo.SetValue(p_object, stringValue); return(true); } // // Looking for hierarchy objects // if (inspectorAttribute != null && inspectorAttribute.isGameObject) // { // if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) // { // if (Event.current.type == EventType.DragExited) // { // DragAndDrop.PrepareStartDrag(); // } // // switch (Event.current.type) // { // case EventType.DragUpdated: // DragAndDrop.visualMode = DragAndDropVisualMode.Link; // //else DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; // // Event.current.Use(); // break; // case EventType.DragPerform: // DragAndDrop.AcceptDrag(); // // Debug.Log(DragAndDrop.objectReferences.Length); // Debug.Log(DragAndDrop.objectReferences[0]); // // Event.current.Use(); // break; // case EventType.MouseUp: // // Clean up, in case MouseDrag never occurred: // DragAndDrop.PrepareStartDrag(); // break; // } // } // } return(false); case "System.Int32": EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(p_name, GUILayout.Width(160)); HandleReferencing(p_reference, referenceInfo, false, p_parameterInfo == null ? null : (Parameter)p_object); var intValue = EditorGUILayout.IntField((int)p_fieldInfo.GetValue(p_object)); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { p_fieldInfo.SetValue(p_object, intValue); return(true); } return(false); case "System.Single": EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(p_name, GUILayout.Width(160)); HandleReferencing(p_reference, referenceInfo, false, p_parameterInfo == null ? null : (Parameter)p_object); var singleValue = EditorGUILayout.FloatField((float)p_fieldInfo.GetValue(p_object)); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { p_fieldInfo.SetValue(p_object, singleValue); return(true); } return(false); case "System.Boolean": EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(p_name, GUILayout.Width(160)); HandleReferencing(p_reference, referenceInfo, false, p_parameterInfo == null ? null : (Parameter)p_object); var boolValue = EditorGUILayout.Toggle((bool)p_fieldInfo.GetValue(p_object)); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { p_fieldInfo.SetValue(p_object, boolValue); return(true); } return(false); case "UnityEngine.Vector2": EditorGUI.BeginChangeCheck(); var vector2Value = EditorGUILayout.Vector2Field(p_name, (Vector2)p_fieldInfo.GetValue(p_object)); HandleReferencing(p_reference, referenceInfo, false, p_parameterInfo == null ? null : (Parameter)p_object); if (EditorGUI.EndChangeCheck()) { p_fieldInfo.SetValue(p_object, vector2Value); return(true); } return(false); case "UnityEngine.Vector3": EditorGUI.BeginChangeCheck(); var vector3Value = EditorGUILayout.Vector3Field(p_name, (Vector3)p_fieldInfo.GetValue(p_object)); HandleReferencing(p_reference, referenceInfo, false, p_parameterInfo == null ? null : (Parameter)p_object); if (EditorGUI.EndChangeCheck()) { p_fieldInfo.SetValue(p_object, vector3Value); return(true); } return(false); case "UnityEngine.Vector4": EditorGUI.BeginChangeCheck(); var vector4Value = EditorGUILayout.Vector4Field(p_name, (Vector3)p_fieldInfo.GetValue(p_object)); HandleReferencing(p_reference, referenceInfo, false, p_parameterInfo == null ? null : (Parameter)p_object); if (EditorGUI.EndChangeCheck()) { p_fieldInfo.SetValue(p_object, vector4Value); return(true); } return(false); case "UnityEngine.Color": GUILayout.BeginHorizontal(); GUILayout.Label(p_name, GUILayout.Width(160)); EditorGUI.BeginChangeCheck(); var colorValue = EditorGUILayout.ColorField("", (Color)p_fieldInfo.GetValue(p_object), GUILayout.Width(60)); HandleReferencing(p_reference, referenceInfo, false, p_parameterInfo == null ? null : (Parameter)p_object); if (EditorGUI.EndChangeCheck()) { p_fieldInfo.SetValue(p_object, colorValue); return(true); } GUILayout.EndHorizontal(); return(false); default: Debug.Log(type + " type inspection not implemented. Field: " + p_fieldInfo.Name); return(false); } }
public MethodParameter(string name, IReferencable reference) { Name = name; Reference = reference; Summary = new List<IComment>(); }
public static Property Unresolved(PropertyIdentifier propertyIdentifier, DeclaredType type, PropertyInfo declaration, IReferencable returnType) { return(new Property(propertyIdentifier, type) { IsResolved = false, declaration = declaration, ReturnType = returnType }); }
public static Method Unresolved(MethodIdentifier methodIdentifier, DeclaredType type, MethodBase declaration, IReferencable returnType) { return(new Method(methodIdentifier, type) { IsResolved = false, declaration = declaration, ReturnType = returnType }); }
public static int AddReferenceInternal([NotNull] this IReferencable referencable) { return(referencable.AddReference()); }
public See(IReferencable reference) { Reference = reference; }
public void Resolve(IDictionary <Identifier, IReferencable> referencables) { if (referencables.ContainsKey(identifier)) { IsResolved = true; IReferencable referencable = referencables[identifier]; var type = referencable as DeclaredType; if (type == null) { throw new InvalidOperationException("Cannot resolve to '" + referencable.GetType().FullName + "'"); } Namespace = type.Namespace; declaration = type.declaration; ParentType = type.ParentType; Interfaces = type.Interfaces; if (!Namespace.IsResolved) { Namespace.Resolve(referencables); } if (ParentType != null && !ParentType.IsResolved) { ParentType.Resolve(referencables); } foreach (IReferencable face in Interfaces) { if (!face.IsResolved) { face.Resolve(referencables); } } if (declaration != null && declaration.IsDefined(typeof(ObsoleteAttribute))) { ObsoleteReason = declaration.GetCustomAttribute <ObsoleteAttribute>().Message; } if (!Summary.IsResolved) { Summary.Resolve(referencables); } foreach (Method method in Methods) { if (!method.IsResolved) { method.Resolve(referencables); } } foreach (Property property in Properties) { if (!property.IsResolved) { property.Resolve(referencables); } } foreach (Event ev in Events) { if (!ev.IsResolved) { ev.Resolve(referencables); } } foreach (Field field in Fields) { if (!field.IsResolved) { field.Resolve(referencables); } } } else { ConvertToExternalReference(); } }
public string Format(IReferencable referencable) { return Formatter.FormatReferencable(referencable); }
public string FormatReferencable(IReferencable reference, IEnumerable<KeyValuePair<string, string>> attributes) { string url = ""; string name = reference.PrettyName; if (reference is Namespace) url = Format(NamespaceUrlFormat, new Replacement("namespace", reference.Name)); else if (reference is DeclaredType) url = Format(TypeUrlFormat, new Replacement("type.namespace", ((DeclaredType)reference).Namespace.Name), new Replacement("type", reference.Name)); else if (reference is Method) { var type = ((Method)reference).Type; url = Format(MethodUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("method", reference.Name)); } else if (reference is Property) { var type = ((Property)reference).Type; url = Format(PropertyUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("property", reference.Name)); } else if (reference is Field) { var type = ((Field)reference).Type; url = Format(FieldUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("field", reference.Name)); } else if (reference is Event) { var type = ((Event)reference).Type; url = Format(EventUrlFormat, new Replacement("type.namespace", type.Namespace.Name), new Replacement("type", type.Name), new Replacement("event", reference.Name)); } if (reference.IsExternal) return "<span title=\"" + reference.FullName + "\">" + Escape(reference.PrettyName) + "</span>"; var attributeHtml = ""; attributes.ForEach(x => attributeHtml += " " + x.Key + "=\"" + x.Value + "\""); return "<a href=\"" + view.SiteResource(url) + "\"" + attributeHtml + ">" + Escape(name) + "</a>"; }
public static Enumeration Unresolved(EnumIdentifier fieldIdentifier, DeclaredType type, IReferencable returnType) { return new Enumeration(fieldIdentifier, type) { IsResolved = false, ReturnType = returnType }; }