Example #1
0
        public DevelopmentInformationAttribute[] GetDevelopmentInformations(Type aType)
        {
            ArrayList res = new ArrayList();

            Attribute[] attrs = (Attribute[])aType.GetCustomAttributes(false);
            foreach (Attribute attr in attrs)
            {
                if (TypeValidator.IsCompatible(attr.GetType(), typeof(DevelopmentInformationAttribute)) == true)
                {
                    res.Add(attr);
                }
            }
            DevelopmentInformationAttribute[] arr = new DevelopmentInformationAttribute[res.Count];
            for (int i = 0; i < Count; i++)
            {
                arr[i] = (DevelopmentInformationAttribute)res[i];
            }
            res.Clear();
            res = null;
            return(arr);
        }
 /// <summary>
 /// Resolves property info, description and range
 /// </summary>
 private void Resolve()
 {
     if ((DataSourceType != null) && (PropertyName != ""))
     {
         if (TypeValidator.IsCompatible(DataSourceType, typeof(DataRow)) == true)
         {
             throw new NotSupportedException("DataRow is not supported");
         }
         if (TypeValidator.IsCompatible(DataSourceType, typeof(IVirtualObject)) == true)
         {
             throw new NotSupportedException("IVirtualObject is not supported");
         }
         propertyInfo = DataSourceType.GetProperty(PropertyName);
         if (State == PropertyDefinition.ReadWrite)
         {
             if (propertyInfo != null)
             {
                 if (propertyInfo.CanWrite == false)
                 {
                     State = PropertyDefinition.ReadOnly;
                 }
             }
         }
         if (propertyInfo != null)
         {
             description = propertyInfo.GetPropertyDescription();
             range       = propertyInfo.GetPropertyRange();
         }
         else
         {
             description = null;
             range       = null;
         }
         return;
     }
     propertyInfo = null;
     description  = null;
     range        = null;
 }
        /// <summary>
        /// Resolves final target for Adaptor
        /// </summary>
        /// <returns>
        /// Object of the final target this adaptor is pointing to <see cref="System.Object"/>
        /// </returns>
        protected override object DoGetFinalTarget(out bool aCallControl)
        {
            aCallControl = false;
            if (GetDefaultProperty() == null)
            {
                return(null);
            }
            object res = base.DoGetFinalTarget(out aCallControl);

            finalTarget.Target = null;
            if (res == null)
            {
                return(null);
            }
            // Resolve forward if mapped property is adaptor
            object tgt = null;

            if (GetDefaultProperty() == null)
            {
                return(null);
            }
            if (CachedProperty.UncachedGetValue(res, GetDefaultProperty().Name, out tgt) == false)
            {
                tgt = ConnectionProvider.ResolveTargetForObject(tgt);
            }
            // set checks
            if (DataSourceType != null)
            {
                if (TypeValidator.IsCompatible(tgt.GetType(), DataSourceType) == true)
                {
                    return(tgt);
                }
                return(null);
            }
            else
            {
                return(tgt);
            }
        }
        public static void DisconnectEventFromObserveableList(IObserveableList aList, object aObject)
        {
            if ((aList == null) || (aObject == null))
            {
                return;
            }
            int i = 0;

            foreach (object o in aList)
            {
                if (o == aObject)
                {
                    i++;
                }
            }
            if (i > 1)
            {
                return;
            }
            if (TypeValidator.IsCompatible(aList.GetType(), typeof(ObserveableList)) == false)
            {
                return;
            }
            if (aObject is INotifyPropertyChanged)
            {
                (aObject as INotifyPropertyChanged).PropertyChanged -= (aList as ObserveableList).ListItemPropertyChangedMethod;
            }
            else
            {
                // Disconnect from all PropertyChangedEventHandler properties
                foreach (EventInfo ev in aObject.GetType().GetEvents())
                {
                    if (ev.EventHandlerType is PropertyChangedEventHandler)
                    {
                        ev.RemoveEventHandler(aObject, (aList as ObserveableList).ListItemPropertyChangedMethod);
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// Copies all data to object
        /// </summary>
        /// <param name="a_From">
        /// Source object <see cref="IVirtualObject"/>
        /// </param>
        /// <param name="a_To">
        /// Destination object <see cref="System.Object"/>
        /// </param>
        public static void CopyDataTo(IVirtualObject a_From, object a_To)
        {
            if ((a_From == null) && (a_To == null))
            {
                return;
            }

            foreach (PropertyInfo prop in a_To.GetType().GetProperties())
            {
                VirtualProperty vp = a_From[prop.Name];
                if ((prop != null) && (vp != null))
                {
                    if (prop.CanWrite == true)
                    {
                        if (TypeValidator.IsCompatible(vp.PropertyType, prop.PropertyType) == true)
                        {
                            prop.SetValue(a_To, vp.Value, null);
                        }
                    }
                }
                vp = null;
            }
        }
Example #6
0
 /// <summary>
 /// Calls controls PutDataToDataSource, in case of gtk this handles being called
 /// in the right thread
 /// </summary>
 /// <param name="aControl">
 /// Control to call PutDataToDataSource <see cref="IPostableControl"/>
 /// </param>
 /// <param name="aSender">
 /// Sender object <see cref="System.Object"/>
 /// </param>
 /// <remarks>
 /// By overriding this method one can handle things differently. Specific
 /// example of this is GTK+ which needs to call control changes in its master thread
 /// </remarks>
 public virtual void InvokeDirectControlDataChange(IPostableControl aControl, object aSender)
 {
     if (TypeValidator.IsCompatible(aControl.GetType(), typeof(ICustomPostData)) == true)
     {
         if (ActivateUserPostData() == true)
         {
             return;
         }
     }
     // Since control will load new values clear flag that data has changed
     DataChanged = false;
     // Transfer data
     aControl.PutDataToDataSource(aSender);
     if (DisableMappingsDataTransfer == false)
     {
         if (TypeValidator.IsCompatible(adaptor.GetType(), typeof(Adaptor)) == true)
         {
             if ((adaptor as Adaptor).SingleMappingOnly == false)
             {
                 PutValuesToDataSource();
             }
         }
     }
 }