Beispiel #1
0
 /// <summary>
 /// Alert this edit interface that its data contents have changed. This will check to see
 /// that the editInterface this is called on is not null before executing.
 /// </summary>
 /// <param name="editInterface">The Edit Interface. Can be null.</param>
 public static void safeAlertDataContentsChanged(this EditInterface editInterface)
 {
     if (editInterface != null)
     {
         editInterface.alertDataContentsChanged();
     }
 }
Beispiel #2
0
 /// <summary>
 /// This extension method allows an easy way to fire the
 /// DataNeedsRefresh function without having to check for null in the
 /// client code.
 /// </summary>
 /// <param name="editInterface">The Edit Interface. Can be null.</param>
 public static void safeFireDataNeedsRefresh(this EditInterface editInterface)
 {
     if (editInterface != null)
     {
         editInterface.fireDataNeedsRefresh();
     }
 }
Beispiel #3
0
 /// <summary>
 /// Alert a sub interface on this specififed by key edit interface that its data contents have changed.
 /// This will check to see that the editInterface this is called on is not null before executing.
 /// </summary>
 /// <param name="parentInterface">The parent edit interface. Can be null.</param>
 /// <param name="key">The key for the sub interface.</param>
 public static void safeAlertSubInterfaceDataContentsChanged(this EditInterface parentInterface, Object key)
 {
     if (parentInterface != null)
     {
         parentInterface.getEditInterfaceFor(key).safeAlertDataContentsChanged();
     }
 }
Beispiel #4
0
        /// <summary>
        /// Create a new EditInterface and add the properties discovered by
        /// scanner. A new one is created every time this function is called.
        /// </summary>
        /// <param name="target">The target object to scan.</param>
        /// <param name="scanner">The scanner to use.</param>
        /// <param name="name">The name of the EditInterface.</param>
        /// <param name="validateCallback">A callback to set for validating.</param>
        /// <returns>A new EditInterface from the scanned info.</returns>
        public static EditInterface createEditInterface(Object target, MemberScanner scanner, String name, Validate validateCallback, ReflectedEditablePropertyProvider customPropProvider)
        {
            EditInterface edit = buildInterface(name, validateCallback);

            addProperties(scanner, target, target.GetType(), edit, customPropProvider);
            return(edit);
        }
Beispiel #5
0
 /// <summary>
 /// Safe version of removeSubInterface. Will check for the calling object to be null first. Will first find the
 /// SubEditInterface specified by key and then remove value from it.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="editInterface"></param>
 /// <param name="value"></param>
 /// <param name="key"></param>
 public static void safeRemoveSubInterfaceForObject <T>(this EditInterface editInterface, Object key, T value)
     where T : class
 {
     if (editInterface != null)
     {
         editInterface.getEditInterfaceFor(key).removeSubInterface <T>(value);
     }
 }
Beispiel #6
0
 /// <summary>
 /// Safe version of addSubInterface. Will check for the calling object to be null first.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="editInterface"></param>
 /// <param name="value"></param>
 public static void safeAddSubInterface <T>(this EditInterface editInterface, T value)
     where T : class
 {
     if (editInterface != null)
     {
         editInterface.addSubInterface <T>(value);
     }
 }
Beispiel #7
0
 /// <summary>
 /// Safe version of removeSubInterface. Will check for the calling object to be null first.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="editInterface"></param>
 /// <param name="key"></param>
 public static void safeRemoveSubInterface <T>(this EditInterface editInterface, T key)
     where T : class
 {
     if (editInterface != null)
     {
         editInterface.removeSubInterface <T>(key);
     }
 }
Beispiel #8
0
 /// <summary>
 /// Add an EditInterface below this one.
 /// </summary>
 /// <param name="editInterface">The subinterface to add.</param>
 public void addSubInterface(EditInterface editInterface)
 {
     subInterfaces.AddLast(editInterface);
     editInterface.ParentEditInterface = this;
     if (OnSubInterfaceAdded != null)
     {
         OnSubInterfaceAdded.Invoke(editInterface);
     }
 }
Beispiel #9
0
 /// <summary>
 /// Add a SubEditInteface for a particluar object. This is most useful to bind to say a list
 /// instance or other value that will not change inside the client object, but the contents might
 /// that you might need to refresh. You could also use it to key a SubEditInterface to an object.
 /// </summary>
 /// <param name="fieldObject">The field's current value.</param>
 /// <param name="editInterface">The EditInteface to bind to that fields value.</param>
 public void addSubInterfaceForObject(Object fieldObject, EditInterface editInterface)
 {
     if (objectSubInterfaces == null)
     {
         objectSubInterfaces = new Dictionary <object, EditInterface>();
     }
     objectSubInterfaces.Add(fieldObject, editInterface);
     addSubInterface(editInterface);
 }
 /// <summary>
 /// Add a subinterface bound to source.
 /// </summary>
 /// <param name="source">The class that provided the subinterface.</param>
 /// <param name="subInterface">The subinterface to bind to source.</param>
 public void addSubInterface(T source, EditInterface subInterface)
 {
     editInterface.addSubInterface(subInterface);
     subInterface.ManagerBinding = source;
     interfaceDictionary.Add(source, subInterface);
     foreach (EditInterfaceCommand command in commandList)
     {
         subInterface.addCommand(command);
     }
 }
Beispiel #11
0
        /// <summary>
        /// Get the edit interface for a given key, if the key does not have an associated EditInterface null
        /// will be returned.
        /// </summary>
        /// <param name="key">The key to lookup.</param>
        /// <returns>The associated EditInterface or null if there isn't one.</returns>
        public EditInterface getEditInterfaceFor(Object key)
        {
            EditInterface ret = null;

            if (objectSubInterfaces != null)
            {
                objectSubInterfaces.TryGetValue(key, out ret);
            }
            return(ret);
        }
Beispiel #12
0
        /// <summary>
        /// Build the EditInterface for the given type.
        /// </summary>
        /// <param name="name">The name to use.</param>
        /// <param name="target">The target object.</param>
        /// <param name="validateCallback">Validate callback.</param>
        /// <returns>An EditInterface for the specific object.</returns>
        private static EditInterface buildInterface(String name, Validate validateCallback)
        {
            EditInterface        createdInterface = new EditInterface(name, null, null, validateCallback);
            EditablePropertyInfo propertyInfo     = new EditablePropertyInfo();

            propertyInfo.addColumn(new EditablePropertyColumn("Name", true));
            propertyInfo.addColumn(new EditablePropertyColumn("Value", false));
            createdInterface.setPropertyInfo(propertyInfo);
            return(createdInterface);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="editInterface">The EditInterface to manage subinterfaces for.</param>
 /// <param name="createEditInterface">The function to call to create EditInterfaces for T types.</param>
 /// <param name="items">The initial list of items, can be null.</param>
 internal EditInterfaceManager(EditInterface editInterface, CreateEditInterfaceDelegate createEditInterface, IEnumerable <T> items)
     : this(editInterface)
 {
     this.createEditInterface = createEditInterface;
     if (items != null)
     {
         foreach (var item in items)
         {
             addItem(item);
         }
     }
 }
Beispiel #14
0
 /// <summary>
 /// Remove a sub interface.
 /// </summary>
 /// <param name="editInterface">The subinterface to remove.</param>
 public void removeSubInterface(EditInterface editInterface)
 {
     if (subInterfaces.Remove(editInterface))
     {
         if (objectSubInterfaces != null)
         {
             //Reverse lookup editInterface in case it is part of the objectSubInterfaces.
             KeyValuePair <Object, EditInterface> fieldRef = objectSubInterfaces.FirstOrDefault(i => i.Value == editInterface);
             if (fieldRef.Key != null)
             {
                 objectSubInterfaces.Remove(fieldRef.Key);
             }
         }
         editInterface.ParentEditInterface = null;
         if (OnSubInterfaceRemoved != null)
         {
             OnSubInterfaceRemoved.Invoke(editInterface);
         }
     }
 }
Beispiel #15
0
 /// <summary>
 /// Add values to an edit interface.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="target">The target object.</param>
 /// <param name="startType">The type to start the scan on. Can be used to specify something higher than the target's type up the hierarchy.</param>
 /// <param name="scanner">The MemberScanner to use.</param>
 /// <param name="edit">The EditInterface that accepts name/value pair properties to add properties to.</param>
 public static void expandEditInterface(Object target, Type startType, MemberScanner scanner, EditInterface edit, ReflectedEditablePropertyProvider customPropProvider)
 {
     addProperties(scanner, target, startType, edit, customPropProvider);
 }
Beispiel #16
0
 /// <summary>
 /// Add values to an edit interface.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="target">The target object.</param>
 /// <param name="startType">The type to start the scan on. Can be used to specify something higher than the target's type up the hierarchy.</param>
 /// <param name="scanner">The MemberScanner to use.</param>
 /// <param name="edit">The EditInterface that accepts name/value pair properties to add properties to.</param>
 public static void expandEditInterface(Object target, Type startType, MemberScanner scanner, EditInterface edit)
 {
     expandEditInterface(target, startType, scanner, edit, DefaultReflectedEditablePropertyProvider.Instance);
 }
 public ReflectedListItemEditableProperty(EditInterface rowEditInterface)
 {
     this.rowEditInterface = rowEditInterface;
 }
Beispiel #18
0
 /// <summary>
 /// Find the key object for the given sub edit interface. You must define a EditInterfaceManager for type T before calling this function
 /// or it will throw an exception.
 /// </summary>
 /// <typeparam name="T">The type of the key object. Must match the type defined for the EditInterfaceManager.</typeparam>
 /// <param name="subInterface">The EditInterface to lookup.</param>
 /// <returns></returns>
 public T resolveSourceObject <T>(EditInterface subInterface)
     where T : class
 {
     return(getEditInterfaceManager <T>().resolveSourceObject(subInterface));
 }
Beispiel #19
0
        /// <summary>
        /// Create an empty EditInterface appropriate to use with the ReflectedEditInterface.
        /// </summary>
        /// <param name="name">The name of the interface.</param>
        /// <param name="validateCallback">A validation callback.</param>
        /// <returns>A new EditInterface.</returns>
        public static EditInterface createUnscannedEditInterface(String name, Validate validateCallback)
        {
            EditInterface edit = buildInterface(name, validateCallback);

            return(edit);
        }
 /// <summary>
 /// Find the source object that was used to create the given EditInterface.
 /// </summary>
 /// <param name="subInterface">The EditInterface to discover the creator of.</param>
 /// <returns>The creator of subInterface according to this binding.</returns>
 public T resolveSourceObject(EditInterface subInterface)
 {
     return(subInterface.ManagerBinding as T);
 }
Beispiel #21
0
        /// <summary>
        /// Add properties to an existing EditInterface.
        /// </summary>
        /// <param name="scanner"></param>
        /// <param name="target"></param>
        /// <param name="edit"></param>
        private static void addProperties(MemberScanner scanner, Object target, Type startType, EditInterface edit, ReflectedEditablePropertyProvider customPropProvider)
        {
            IEnumerable <MemberWrapper> members = scanner.getMatchingMembers(startType);

            foreach (MemberWrapper memberWrapper in members)
            {
                if (!customPropProvider.addProperties(memberWrapper, target, edit))
                {
                    EditableAttribute editable = findEditableAttribute(memberWrapper);
                    bool addAsProperty         = (editable != null && editable.ForceAsProperty) || ReflectedVariable.canCreateVariable(memberWrapper.getWrappedType());
                    if (addAsProperty)
                    {
                        edit.addEditableProperty(editable.createEditableProperty(memberWrapper, target));
                    }
                    else
                    {
                        Object subObject = memberWrapper.getValue(target, null);
                        if (subObject is EditInterfaceOverride)
                        {
                            EditInterfaceOverride custom = (EditInterfaceOverride)subObject;
                            edit.addSubInterface(custom.getEditInterface(memberWrapper.getWrappedName(), scanner));
                        }
                        else if (subObject != null)
                        {
                            edit.addSubInterface(createEditInterface(subObject, scanner, memberWrapper.getWrappedName() + " - " + memberWrapper.getWrappedType(), null));
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="editInterface">The EditInterface to manage subinterfaces for.</param>
 internal EditInterfaceManager(EditInterface editInterface)
 {
     this.editInterface = editInterface;
 }
Beispiel #23
0
 public EditablePropertyManager(EditInterface editInterface)
 {
     this.editInterface = editInterface;
 }
Beispiel #24
0
 /// <summary>
 /// Add a keyed sub edit interface. You must define a EditInterfaceManager for type T before calling this function
 /// or it will throw an exception.
 /// </summary>
 /// <typeparam name="T">The type of the key.</typeparam>
 /// <param name="key">The key value.</param>
 /// <param name="subInterface">The subInterface to add.</param>
 public void addSubInterface <T>(T key, EditInterface subInterface)
     where T : class
 {
     getEditInterfaceManager <T>().addSubInterface(key, subInterface);
 }