Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 10
0
 /// <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);
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 13
0
 /// <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);
         }
     }
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 20
0
 /// <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);
 }
Ejemplo n.º 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));
                        }
                    }
                }
            }
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="editInterface">The EditInterface to manage subinterfaces for.</param>
 internal EditInterfaceManager(EditInterface editInterface)
 {
     this.editInterface = editInterface;
 }
Ejemplo n.º 23
0
 public EditablePropertyManager(EditInterface editInterface)
 {
     this.editInterface = editInterface;
 }
Ejemplo n.º 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);
 }