예제 #1
0
        public int Compare(TreeNode x, TreeNode y, SortColumnDescription sortDescription)
        {
            int         c  = 0;
            IComparable xc = null;
            IComparable yc = null;

#if WPF
            PropertyDescriptorCollection descriptor1 = TypeDescriptor.GetProperties(x.Item.GetType());
#else
            PropertyInfoCollection descriptor1 = new PropertyInfoCollection(x.Item.GetType());
#endif
            xc = descriptor1.GetValue(x.Item, sortDescription.ColumnName) as IComparable;

#if WPF
            PropertyDescriptorCollection descriptor2 = TypeDescriptor.GetProperties(y.Item.GetType());
#else
            PropertyInfoCollection descriptor2 = new PropertyInfoCollection(y.Item.GetType());
#endif
            yc = descriptor1.GetValue(y.Item, sortDescription.ColumnName) as IComparable;

            if (xc != null)
            {
                c = xc.CompareTo(yc);
            }
            else if (yc != null)
            {
                c = -1;
            }

            if (sortDescription.SortDirection == ListSortDirection.Descending)
            {
                c = -c;
            }
            return(c);
        }
예제 #2
0
        /// <summary>
        /// Sets the property and save.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <param name="prop">The prop.</param>
        /// <param name="save">if set to <c>true</c> [save].</param>
        private void SetPropertyAndSave(PropertyInfoCollection collection, PropertyInfo property, bool save, bool overwrite)
        {
            if (collection != null)
            {
                PropertyInfo setProperty = collection[property.Name];

                if (setProperty == null)
                {
                    collection.Add(property);
                }
                else if (overwrite == true)
                {
                    setProperty.Namespace = property.Namespace;
                    //Calculated property not set
                    if (property.Calculated == false)
                    {
                        setProperty.Value = property.Value;
                    }
                }

                if (save == true)
                {
                    SavePropertyCollection(collection);
                }
            }
        }
예제 #3
0
        public override Mediachase.Net.Wdom.PropertyInfoCollection GetProperties(Mediachase.Net.Wdom.WebDavElementInfo element)
        {
            PropertyInfoCollection retVal = new PropertyInfoCollection();
            PropertyInfo           prop   = null;

            #region CreateDefaultProperties
            foreach (PropertyInfo defaultProp in PropertyInfo.CreateDefaultProperties(element))
            {
                SetProperty(retVal, defaultProp, false);
            }
            #endregion
            //Add <supportedlock> property
            if (((int)(WebDavApplication.Class & WebDavServerClass.Class2)) != 0)
            {
                prop            = PropertyInfo.CreateSupportedLockProperty();
                prop.Calculated = false;
                SetProperty(retVal, prop, false);
            }

            //Add <resourcetype> property
            prop = PropertyInfo.CreateResourceTypeProperty(element);
            SetProperty(retVal, prop, false);

            retVal.ElementInfo = element;
            return(retVal);
        }
예제 #4
0
        public override Mediachase.Net.Wdom.PropertyInfoCollection GetProperties(Mediachase.Net.Wdom.WebDavElementInfo element)
        {
            PropertyInfoCollection retVal = new PropertyInfoCollection();
            PropertyInfo prop = null;
            #region CreateDefaultProperties
            foreach (PropertyInfo defaultProp in PropertyInfo.CreateDefaultProperties(element))
            {
                SetProperty(retVal, defaultProp, false);
            }
            #endregion
            //Add <supportedlock> property
            if (((int)(WebDavApplication.Class & WebDavServerClass.Class2)) != 0)
            {
                prop = PropertyInfo.CreateSupportedLockProperty();
                prop.Calculated = false;
                SetProperty(retVal, prop, false);
            }

            //Add <resourcetype> property
            prop = PropertyInfo.CreateResourceTypeProperty(element);
            SetProperty(retVal, prop, false);

            retVal.ElementInfo = element;
            return retVal;
        }
예제 #5
0
        internal void GetGroupResult(object ItemData)
        {
            var    descriptor = ListView.DataSource.GroupDescriptors[0];
            object key;

            if (descriptor.KeySelector == null)
            {
                var propertyInfoCollection = new PropertyInfoCollection(ItemData.GetType());
                key = propertyInfoCollection.GetValue(ItemData, descriptor.PropertyName);
            }
            else
            {
                key = descriptor.KeySelector(ItemData);
            }

            for (int i = 0; i < this.ListView.DataSource.Groups.Count; i++)
            {
                var group = this.ListView.DataSource.Groups[i];
                if ((group.Key != null && group.Key.Equals(key)) || group.Key == key)
                {
                    itemGroup = group;
                    break;
                }
                group = null;
            }
            descriptor = null;
            key        = null;
        }
        /// <summary>
        /// This method is used to perform the paste operation for the copied cell value to selected record cell.
        /// </summary>
        /// <param name="value">
        /// Contains copied cell value to paste.</param>
        /// <param name="column">
        /// Contains the corresponding column of the selected cell.</param>
        /// <param name="record">
        /// Contains the record of the selected cell.
        /// </param>
        protected virtual void PasteCell(object record, TreeGridColumn column, object value)
        {
            if (this.TreeGrid.View == null)
            {
                return;
            }
            var    provider = this.TreeGrid.View.GetPropertyAccessProvider();
            object properyCollection;

            if (!(TreeGrid.View is TreeGridUnboundView))
            {
                properyCollection = this.TreeGrid.View.GetItemProperties();
            }
            else
            {
#if UWP
                PropertyInfoCollection typeInfos = new PropertyInfoCollection(record.GetType());
                properyCollection = typeInfos.GetItemPropertyInfo();
#else
                PropertyDescriptorCollection typeInfos = TypeDescriptor.GetProperties(record);
                properyCollection = typeInfos.GetItemPropertyInfo();
#endif
            }
            if (properyCollection == null)
            {
                return;
            }
            var pasteargs = this.RaisePasteGridCellContentEvent(column, record, value);
            value = pasteargs.ClipBoardValue;
            if (!pasteargs.Handled)
            {
                CommitValue(record, column, value);
            }
        }
예제 #7
0
 public Entity(string name)
 {
     Name       = name;
     Key        = null;
     Properties = new PropertyInfoCollection(Enumerable.Empty <PropertyInfo>(),
                                             StringComparer.InvariantCultureIgnoreCase);
 }
예제 #8
0
        internal void CommitValue(object record, string propName, object value)
        {
#if UWP
            PropertyInfoCollection descriptor = new PropertyInfoCollection(record.GetType());
#else
            PropertyDescriptorCollection descriptor = TypeDescriptor.GetProperties(record.GetType());
#endif
            var    propertyinfo   = descriptor.GetPropertyDescriptor(propName);
            object convertedValue = null;
            if (propertyinfo == null)
            {
                if (View.IsDynamicBound)
                {
                    var type = (value == null) ? null : value.GetType();
                    convertedValue = ValueConvert.ChangeType(value, type, null);
                    if (convertedValue != null || (NullableHelperInternal.IsNullableType(type) && convertedValue == null))
                    {
                        SetValue(record, propName, convertedValue);
                    }
                }
                return;
            }

            convertedValue = ValueConvert.ChangeType(value, propertyinfo.PropertyType, null);
            if (value != null || (NullableHelperInternal.IsNullableType(propertyinfo.PropertyType) && value == null))
            {
                SetValue(record, propName, convertedValue);
            }
        }
예제 #9
0
        /// <summary>
        /// Locks the specified depth.
        /// </summary>
        /// <param name="depth">The depth.</param>
        /// <param name="timeout">The timeout.</param>
        /// <param name="lockInfoEl">The lock info el.</param>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public override OpaqueLockToken Lock(Mediachase.Net.Wdom.DepthValue depth, string timeout, Mediachase.Net.Wdom.LockInfoElement lockInfoEl, Mediachase.Net.Wdom.WebDavElementInfo element)
        {
            ReplaceLockOwner(lockInfoEl);
            PropertyInfoCollection collection = GetProperties(element);

            return(WebDavLockManager.Lock(this, depth, timeout, lockInfoEl, collection));
        }
예제 #10
0
        private static McLockElement GetMcLockElement(OpaqueLockToken lockToken, PropertyInfoCollection propInfoColl)
        {
            if (propInfoColl == null)
            {
                throw new ArgumentNullException("propInfoColl");
            }

            McLockElement retVal         = null;
            PropertyInfo  mcLockDateProp = propInfoColl[PropertyInfo.McLockDateProperty];

            if (mcLockDateProp != null)
            {
                WebDavDocument    document     = WebDavDocument.CreateDocument();
                McLockDateElement mcLockDateEl = (McLockDateElement)
                                                 document.ImportNode((XmlElement)mcLockDateProp.Value, true);

                //Try to find McLock element with same token as lockToken
                foreach (McLockElement lockEl in mcLockDateEl.GetLocks())
                {
                    if (lockEl.Token == lockToken.ToString())
                    {
                        retVal = lockEl;
                        break;
                    }
                }
            }

            return(retVal);
        }
예제 #11
0
        private void ListView_SelectionChanging(object sender, ItemSelectionChangingEventArgs e)
        {
            GroupResult actualGroup   = null;
            object      key           = null;
            var         selectedItems = listView.SelectedItems;

            //To Cancel the Deselection
            if (e.RemovedItems.Count > 0 && selectedItems.Contains(e.RemovedItems[0]))
            {
                e.Cancel = true;
                return;
            }

            //To return when SelectedItems is zero
            if (e.AddedItems.Count <= 0)
            {
                return;
            }

            var itemData = (e.AddedItems[0] as Contacts);

            var descriptor = listView.DataSource.GroupDescriptors[0];

            if (descriptor.KeySelector == null)
            {
                var pbCollection = new PropertyInfoCollection(itemData.GetType());
                key = pbCollection.GetValue(itemData, descriptor.PropertyName);
            }
            else
            {
                key = descriptor.KeySelector(itemData);
            }

            for (int i = 0; i < listView.DataSource.Groups.Count; i++)
            {
                var group = listView.DataSource.Groups[i];

                if ((group.Key != null && group.Key.Equals(key)) || group.Key == key)
                {
                    actualGroup = group;
                    break;
                }
            }

            if (selectedItems.Count > 0)
            {
                foreach (var item in actualGroup.Items)
                {
                    var groupItem = item;

                    if (selectedItems.Contains(groupItem))
                    {
                        listView.SelectedItems.Remove(groupItem);
                        break;
                    }
                }
            }
        }
예제 #12
0
        /// <summary>
        /// Saves the property collection.
        /// </summary>
        /// <param name="collection">The collection.</param>
        private void SavePropertyCollection(PropertyInfoCollection collection)
        {
            if (collection == null)
            {
                return;
            }

            bool haveStoredProp = false;
            WebDavStorageElementPropertiesRow row = null;

            foreach (PropertyInfo prop in collection)
            {
                if (prop.Calculated == false)
                {
                    haveStoredProp = true;
                    try
                    {
                        WebDavTicket ticket = WebDavTicket.Parse(collection.ElementInfo.AbsolutePath);
                        using (TransactionScope tran = DataContext.Current.BeginTransaction())
                        {
                            row = GetWebDavStoragePropertyRow(ticket.AbsolutePath.StorageType, ticket.AbsolutePath.UniqueId);
                            if (row == null)
                            {
                                row = new WebDavStorageElementPropertiesRow();
                                row.ObjectTypeId = (int)ticket.AbsolutePath.StorageType;
                                row.ObjectId     = ticket.AbsolutePath.UniqueId;
                                row.Key          = "propertyCollection";
                            }
                            string value = Mediachase.Ibn.Data.McXmlSerializer.GetString <PropertyInfoCollection>(collection);
                            row.Value = value;
                            row.Update();

                            tran.Commit();
                        }
                    }
                    catch (Exception)
                    {
                        throw new HttpException(500, "Internal Server Error");
                    }
                    break;
                }
            }

            //remove property file if empty
            if (haveStoredProp == false)
            {
                try
                {
                    DeleteWebDavStorageElementPropertiesRow(row);
                }
                catch (Exception)
                {
                    throw new HttpException(500, "Unable to delete property");
                }
            }
        }
예제 #13
0
        internal static InformationApi.Collections.PropertyInfoCollection BuildPropInfoCol(Type t)
        {
            var props = t.GetProperties();
            var ret   = new PropertyInfoCollection();

            foreach (var p in props)
            {
                ret.Add(BuildPropInfo(p));
            }

            return(ret);
        }
        /// <summary>
        /// To commit the copied value for the dropdown column
        /// </summary>
        /// <param name="column">Contains particular column</param>
        /// <param name="changedValue">Conatins copied value</param>
        /// <param name="type">contains type of selected column</param>
        private void CommitValueDropDownColumn(TreeGridColumn column, ref object changedValue, Type type)
        {
            IEnumerable list = null;
            string      displayMemberPath;
            string      valueMemberPath;

            if (column is TreeGridComboBoxColumn)
            {
                list = (column as TreeGridComboBoxColumn).ItemsSource;
            }
            displayMemberPath = (column as TreeGridComboBoxColumn).DisplayMemberPath;
            valueMemberPath   = (column as TreeGridComboBoxColumn).SelectedValuePath;
            if (list == null)
            {
                return;
            }
            var enumerator = list.GetEnumerator();
            var value      = Convert.ChangeType(changedValue, type);

#if WPF
            PropertyDescriptorCollection pdc = null;
#else
            PropertyInfoCollection pdc = null;
#endif
            if (!string.IsNullOrEmpty(valueMemberPath))
            {
                while (enumerator.MoveNext())
                {
                    if (pdc == null)
                    {
#if WPF
                        pdc = TypeDescriptor.GetProperties(enumerator.Current.GetType());
#else
                        pdc = new PropertyInfoCollection(enumerator.Current.GetType());
#endif
                    }
                    if (value.Equals(pdc.GetValue(enumerator.Current, valueMemberPath)))
                    {
                        break;
                    }
                }
            }
            else if (string.IsNullOrEmpty(displayMemberPath))
            {
                while (enumerator.MoveNext())
                {
                    if (value.Equals(enumerator.Current))
                    {
                        break;
                    }
                }
            }
        }
예제 #15
0
        internal Type GetPropertyType(object rowData, string childPropertyName)
        {
#if WPF
            PropertyDescriptorCollection typeInfos = TreeGrid.View.GetItemProperties();
#else
            PropertyInfoCollection typeInfos = TreeGrid.View.GetItemProperties();
#endif
            var typeInfo = typeInfos.GetPropertyDescriptor(childPropertyName);
            if (typeInfo != null)
            {
                return(typeInfo.PropertyType);
            }
            return(null);
        }
예제 #16
0
        /// <summary>
        /// Gets the properties.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public override Mediachase.Net.Wdom.PropertyInfoCollection GetProperties(Mediachase.Net.Wdom.WebDavElementInfo element)
        {
            PropertyInfoCollection retVal = null;
            PropertyInfo           prop   = null;
            WebDavDocument         tmpDoc = WebDavDocument.CreateDocument();

            if (element == null)
            {
                return(retVal);
            }

            retVal = new PropertyInfoCollection();
            //FileInfo fileInfo = !!!!(FileInfo)element.Tag;!!!
            WebDavTicket ticket = WebDavTicket.Parse(element.AbsolutePath);

            WebDavStorageElementPropertiesRow row = GetWebDavStoragePropertyRow(ticket.AbsolutePath.StorageType, ticket.AbsolutePath.UniqueId);

            if (row != null)
            {
                retVal = Mediachase.Ibn.Data.McXmlSerializer.GetObject <PropertyInfoCollection>(row.Value);
            }

            #region CreateDefaultProperties
            foreach (PropertyInfo defaultProp in PropertyInfo.CreateDefaultProperties(element))
            {
                SetPropertyAndSave(retVal, defaultProp, false, false);
            }
            #endregion

            //Add <supportedlock> property
            if (((int)(WebDavApplication.Class & WebDavServerClass.Class2)) != 0)
            {
                prop            = PropertyInfo.CreateSupportedLockProperty();
                prop.Calculated = false;
                SetPropertyAndSave(retVal, prop, false, false);
            }

            //Add <resourcetype> property
            prop = PropertyInfo.CreateResourceTypeProperty(element);
            SetPropertyAndSave(retVal, prop, false, false);

            //Assign context and set closure to class member
            retVal.ElementInfo = element;


            return(retVal);
        }
예제 #17
0
        internal static bool SetValue(object data, string propertyName, object value)
        {
            if (DynamicHelper.CheckIsDynamicObject(data.GetType()))
            {
                return(new DynamicHelper().SetValue(data, propertyName, value));
                //return DynamicPropertiesProvider.SetDynamicValue(data, propertyName, value);
            }
            else
            {
#if WPF
                PropertyDescriptorCollection descriptor = TypeDescriptor.GetProperties(data.GetType());
#else
                PropertyInfoCollection descriptor = new PropertyInfoCollection(data.GetType());
#endif
                return(descriptor.SetValue(data, value, propertyName));
            }
        }
예제 #18
0
        /// <summary>
        /// Gets the properties.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public override Mediachase.Net.Wdom.PropertyInfoCollection GetProperties(Mediachase.Net.Wdom.WebDavElementInfo element)
        {
            PropertyInfoCollection retVal = null;
            PropertyInfo prop = null;
            WebDavDocument tmpDoc = WebDavDocument.CreateDocument();

            if (element == null)
                return retVal;

            retVal = new PropertyInfoCollection();
            //FileInfo fileInfo = !!!!(FileInfo)element.Tag;!!!
            WebDavTicket ticket = WebDavTicket.Parse(element.AbsolutePath);

            WebDavStorageElementPropertiesRow row = GetWebDavStoragePropertyRow(ticket.AbsolutePath.StorageType, ticket.AbsolutePath.UniqueId);
            if (row != null)
            {
                retVal = Mediachase.Ibn.Data.McXmlSerializer.GetObject<PropertyInfoCollection>(row.Value);
            }

            #region CreateDefaultProperties
            foreach (PropertyInfo defaultProp in PropertyInfo.CreateDefaultProperties(element))
            {
                SetPropertyAndSave(retVal, defaultProp, false, false);
            }
            #endregion

            //Add <supportedlock> property
            if (((int)(WebDavApplication.Class & WebDavServerClass.Class2)) != 0)
            {
                prop = PropertyInfo.CreateSupportedLockProperty();
                prop.Calculated = false;
                SetPropertyAndSave(retVal, prop, false, false);
            }

            //Add <resourcetype> property
            prop = PropertyInfo.CreateResourceTypeProperty(element);
            SetPropertyAndSave(retVal, prop, false, false);

            //Assign context and set closure to class member
            retVal.ElementInfo = element;

            return retVal;
        }
예제 #19
0
        private static PropertyInfoCollection GetCloneableProperties(Type destinationType, Type baseType)
        {
            PropertyInfoCollection descriptor;

            if (!PropertiesDescriptorCache.TryGetValue(destinationType, out descriptor))
            {
                descriptor = new PropertyInfoCollection();
                foreach (var propertyInfo in destinationType.GetProperties())
                {
                    var item = GetCloneableProperty(propertyInfo, baseType);
                    if (item != null)
                    {
                        descriptor.Add(item.Name, item);
                    }
                }
                PropertiesDescriptorCache.Add(destinationType, descriptor);
            }
            return(descriptor);
        }
예제 #20
0
        /// <summary>
        /// Gets the active locks.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public override IEnumerable <ActiveLockElement> GetActiveLocks(WebDavElementInfo element)
        {
            List <ActiveLockElement> retVal     = new List <ActiveLockElement>();
            WebDavDocument           document   = WebDavDocument.CreateDocument();
            PropertyInfoCollection   collection = GetProperties(element);

            //Remove obsolete lock
            WebDavLockManager.RemoveObsoleteLock(this, collection);
            PropertyInfo lockDiscoveryProp = collection[PropertyInfo.LockDiscoveryProperty];

            if (lockDiscoveryProp != null)
            {
                LockDiscoveryPropertyElement lockDiscoveryEl = (LockDiscoveryPropertyElement)
                                                               document.ImportNode((XmlElement)lockDiscoveryProp.Value, true);
                foreach (ActiveLockElement activeLockEl in lockDiscoveryEl.GetActiveLocks())
                {
                    yield return(activeLockEl);
                }
            }
        }
        /// <summary>
        /// Gets the corresponding property type for the specified row data and column.
        /// </summary>
        /// <param name="column">
        /// The corresponding column to get property type.
        /// </param>
        /// <param name="rowData">
        /// The corresponding row data to get property type.
        /// </param>
        /// <returns>
        /// Returns the corresponding property type.
        /// </returns>
        protected virtual Type GetPropertyType(object rowData, TreeGridColumn column)
        {
            if (this.TreeGrid.View == null)
            {
                return(null);
            }
            //Get the Type of particular column
            var provider = TreeGrid.View.GetPropertyAccessProvider();

#if UWP
            PropertyInfoCollection typeInfos = null;
            if (TreeGrid.View is TreeGridUnboundView)
            {
                typeInfos = new PropertyInfoCollection(rowData.GetType());
            }
            else
            {
                typeInfos = TreeGrid.View.GetItemProperties();
            }
#else
            PropertyDescriptorCollection typeInfos = null;
            if (TreeGrid.View is TreeGridUnboundView)
            {
                typeInfos = TypeDescriptor.GetProperties(rowData);
            }
            else
            {
                typeInfos = TreeGrid.View.GetItemProperties();
            }
#endif
            var typeInfo = typeInfos.GetPropertyDescriptor(column.MappingName);
            if (typeInfo != null)
            {
                return(typeInfo.PropertyType);
            }

            var cellvalue = provider.GetValue(rowData, column.MappingName);
            return(cellvalue != null?cellvalue.GetType() : null);
        }
예제 #22
0
        protected override List <DataFormItemBase> GenerateDataFormItems(PropertyInfoCollection itemProperties, List <DataFormItemBase> dataFormItems)
        {
            var items = dataFormItems;

            foreach (var propertyInfo in itemProperties)
            {
                DataFormItem dataFormItem;
                if (propertyInfo.Key == "Monto")
                {
                    dataFormItem = new DataFormNumericItem()
                    {
                        Name = propertyInfo.Key, Editor = "Numeric", MaximumNumberDecimalDigits = 0
                    };
                    items.Add(dataFormItem);
                    var newDocImage = new Image {
                        Aspect = Aspect.AspectFit, Source = "ic_action_map.png"
                    };
                    //beachImage.Source = ImageSource.FromFile("waterfront.jpg");
                }
            }

            return(items);
        }
        protected override List <DataFormItemBase> GenerateDataFormItems(PropertyInfoCollection itemProperties, List <DataFormItemBase> dataFormItems)
        {
            var items = new List <DataFormItemBase>();

            foreach (var key in dataFormDictionary.Keys)
            {
                DataFormItem dataFormItem;
                if (key == "ID")
                {
                    dataFormItem = new DataFormNumericItem()
                    {
                        Name = key, Editor = "Numeric", MaximumNumberDecimalDigits = 0
                    }
                }
                ;
                else if (key == "Name")
                {
                    dataFormItem = new DataFormTextItem()
                    {
                        Name = key, Editor = "Text"
                    }
                }
                ;
                else
                {
                    dataFormItem = new DataFormTextItem()
                    {
                        Name = key, Editor = "Text"
                    }
                };

                items.Add(dataFormItem);
            }

            return(items);
        }
예제 #24
0
        /// <summary>
        /// Unlocks the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="lockToken">The lock token.</param>
        public override void Unlock(Mediachase.Net.Wdom.WebDavElementInfo element, OpaqueLockToken lockToken)
        {
            PropertyInfoCollection collection = GetProperties(element);

            WebDavLockManager.Unlock(this, collection, lockToken);
        }
        /// <summary>
        /// This method is called when the cut operation performed for the particular row data and column.
        /// </summary>
        /// <param name="rowData">
        /// Contains the row data of the selected record to perform cut operation.
        /// </param>
        /// <param name="column">
        /// The corresponding column of the selected record to perform cut operation.
        /// </param>
        protected virtual void ClearCell(object rowData, TreeGridColumn column)
        {
            if (this.TreeGrid.View == null)
            {
                return;
            }
            var provider = this.TreeGrid.View.GetPropertyAccessProvider();

#if UWP
            PropertyInfoCollection properyCollection = null;
            if (TreeGrid.View is TreeGridUnboundView)
            {
                properyCollection = new PropertyInfoCollection(rowData.GetType());
            }
            else
            {
                properyCollection = TreeGrid.View.GetItemProperties();
            }
#else
            PropertyDescriptorCollection properyCollection = null;
            if (TreeGrid.View is TreeGridUnboundView)
            {
                properyCollection = TypeDescriptor.GetProperties(rowData);
            }
            else
            {
                properyCollection = TreeGrid.View.GetItemProperties();
            }
#endif
            if (column.IsHidden || properyCollection == null)
            {
                return;
            }

            Type type      = null;
            var  cellvalue = provider.GetValue(rowData, column.MappingName);
#if WPF
            if (cellvalue == null || cellvalue == DBNull.Value)
#else
            if (cellvalue == null)
#endif
            { return; }
            //Getting type of the column using GetPropertyType().
            type = GetPropertyType(rowData, column);
            if (type == null)
            {
                return;
            }
#if UWP
            if (properyCollection.Find(column.MappingName, false) != null && !properyCollection.Find(column.MappingName, false).CanWrite)
#else
            if (properyCollection.Find(column.MappingName, false) != null && properyCollection.Find(column.MappingName, false).IsReadOnly)
#endif
            { return; }
            if (type.IsValueType())
            {
                provider.SetValue(rowData, column.MappingName, Activator.CreateInstance(type));
            }
            else if (type == typeof(string))
            {
                provider.SetValue(rowData, column.MappingName, string.Empty);
            }
        }
예제 #26
0
 public Entity(string name, PropertyInfo key, PropertyInfoCollection properties)
 {
     Name       = name;
     Key        = key;
     Properties = properties;
 }
예제 #27
0
        /// <summary>
        /// Saves the property collection.
        /// </summary>
        /// <param name="collection">The collection.</param>
        private void SavePropertyCollection(PropertyInfoCollection collection)
        {
            if (collection == null)
                return;

            bool haveStoredProp = false;
            WebDavStorageElementPropertiesRow row = null;

            foreach (PropertyInfo prop in collection)
            {
                if (prop.Calculated == false)
                {
                    haveStoredProp = true;
                    try
                    {
                        WebDavTicket ticket = WebDavTicket.Parse(collection.ElementInfo.AbsolutePath);
                        using (TransactionScope tran = DataContext.Current.BeginTransaction())
                        {
                            row = GetWebDavStoragePropertyRow(ticket.AbsolutePath.StorageType, ticket.AbsolutePath.UniqueId);
                            if (row == null)
                            {
                                row = new WebDavStorageElementPropertiesRow();
                                row.ObjectTypeId = (int)ticket.AbsolutePath.StorageType;
                                row.ObjectId = ticket.AbsolutePath.UniqueId;
                                row.Key = "propertyCollection";
                            }
                            string value = Mediachase.Ibn.Data.McXmlSerializer.GetString<PropertyInfoCollection>(collection);
                            row.Value = value;
                            row.Update();

                            tran.Commit();
                        }
                    }
                    catch (Exception)
                    {
                        throw new HttpException(500, "Internal Server Error");
                    }
                    break;
                }
            }

            //remove property file if empty
            if (haveStoredProp == false)
            {
                try
                {
                    DeleteWebDavStorageElementPropertiesRow(row);
                }
                catch (Exception)
                {
                    throw new HttpException(500, "Unable to delete property");
                }
            }
        }
예제 #28
0
        /// <summary>
        /// Refreshes the lock.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="lockToken">The lock token.</param>
        /// <param name="timeout">The timeout.</param>
        public override void RefreshLock(Mediachase.Net.Wdom.WebDavElementInfo element, OpaqueLockToken lockToken, string timeout)
        {
            PropertyInfoCollection collection = GetProperties(element);

            WebDavLockManager.RefreshLock(this, collection, lockToken, timeout);
        }
예제 #29
0
        internal static void SetPropertyValue(SvgElement element, string attributeName, string attributeValue, SvgDocument document)
        {
            var elementType = element.GetType();

            PropertyInfoCollection properties;

            lock (syncLock)
            {
                if (!_propertyDescriptors.Keys.Contains(elementType))
                {
                    _propertyDescriptors.Add(elementType, new Dictionary <string, PropertyInfoCollection>());
                }

                if (_propertyDescriptors[elementType].Keys.Contains(attributeName))
                {
                    properties = _propertyDescriptors[elementType][attributeName];
                }
                else
                {
                    properties = new PropertyInfoCollection(elementType);//, new[] { new SvgAttributeAttribute(attributeName) });
                    _propertyDescriptors[elementType].Add(attributeName, properties);
                }
            }

            if (properties.Count > 0)
            {
                PropertyInfo descriptor = properties[0];

                try
                {
                    if (attributeName == "opacity" && attributeValue == "undefined")
                    {
                        attributeValue = "1";
                    }

                    throw new NotImplementedException();
                    //descriptor.SetValue(element, descriptor.Converter.ConvertFrom(document, CultureInfo.InvariantCulture, attributeValue));
                }
                catch
                {
                    //Trace.TraceWarning(string.Format("Attribute '{0}' cannot be set - type '{1}' cannot convert from string '{2}'.", attributeName, descriptor.PropertyType.FullName, attributeValue));
                }
            }
            else
            {
                //check for namespace declaration in svg element
                if (string.Equals(element.ElementName, "svg", StringComparison.OrdinalIgnoreCase))
                {
                    if (string.Equals(attributeName, "xmlns", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(attributeName, "xlink", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(attributeName, "xmlns:xlink", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(attributeName, "version", StringComparison.OrdinalIgnoreCase))
                    {
                        //nothing to do
                    }
                    else
                    {
                        //attribute is not a svg attribute, store it in custom attributes
                        element.CustomAttributes[attributeName] = attributeValue;
                    }
                }
                else
                {
                    //attribute is not a svg attribute, store it in custom attributes
                    element.CustomAttributes[attributeName] = attributeValue;
                }
            }
        }
예제 #30
0
        private static McLockElement GetMcLockElement(OpaqueLockToken lockToken, PropertyInfoCollection propInfoColl)
        {
            if (propInfoColl == null)
            {
                throw new ArgumentNullException("propInfoColl");
            }

            McLockElement retVal = null;
            PropertyInfo mcLockDateProp = propInfoColl[PropertyInfo.McLockDateProperty];

            if (mcLockDateProp != null)
            {
                WebDavDocument document = WebDavDocument.CreateDocument();
                McLockDateElement mcLockDateEl = (McLockDateElement)
                                document.ImportNode((XmlElement)mcLockDateProp.Value, true);

                //Try to find McLock element with same token as lockToken
                foreach (McLockElement lockEl in mcLockDateEl.GetLocks())
                {
                    if (lockEl.Token == lockToken.ToString())
                    {
                        retVal = lockEl;
                        break;
                    }
                }
            }

            return retVal;
        }
예제 #31
0
        internal bool ValidateColumn(object rowData, string columnName, TreeGridCell currentCell, RowColumnIndex currentCellIndex)
        {
            var  propertyName     = columnName;
            bool isValid          = true;
            var  errorMessage     = string.Empty;
            bool isAttributeError = false;

            if (rowData == null || string.IsNullOrEmpty(columnName) || currentCell == null || currentCellIndex == RowColumnIndex.Empty)
            {
                return(isValid);
            }
#if UWP
            PropertyInfoCollection itemProperties;
#else
            PropertyDescriptorCollection itemProperties;
#endif
            if (this.treeGrid.HasView)
            {
                itemProperties = this.treeGrid.View.GetItemProperties();
                if (itemProperties == null)
                {
                    return(isValid);
                }
            }
            else
            {
#if WPF
                itemProperties = TypeDescriptor.GetProperties(rowData.GetType());
#else
                itemProperties = new PropertyInfoCollection(rowData.GetType());
#endif
            }

            if (columnName.Contains('.'))
            {
                var propNames = columnName.Split('.');
                columnName = propNames[propNames.Length - 1];
                Array.Resize(ref propNames, propNames.Length - 1);
                var pName = string.Join(".", propNames);
#if WPF
                rowData = PropertyDescriptorExtensions.GetValue(itemProperties, rowData, pName);
#else
                rowData = Syncfusion.Data.PropertyInfoExtensions.GetValue(itemProperties, rowData, pName);
#endif
            }

            PropertyInfo      propertyinfo      = null;
            ValidationContext validationContext = null;
#if WPF
            if (rowData != null)
            {
                propertyinfo      = rowData.GetType().GetProperty(columnName);
                validationContext = new ValidationContext(rowData, null, null)
                {
                    MemberName = columnName
                };
            }
#else
            if (rowData != null)
            {
                propertyinfo      = rowData.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name == columnName);
                validationContext = new ValidationContext(rowData)
                {
                    MemberName = columnName
                };
            }
#endif
            if (errorMessages != null && rowIndex == currentCellIndex.RowIndex && errorMessages.Keys.Contains(columnName) && IsCurrentRowValidated)
            {
                errorMessage = errorMessages[columnName];
            }
            if ((this.treeGrid.Columns[propertyName] as TreeGridColumn).GridValidationMode != GridValidationMode.None)
            {
                if (propertyinfo != null)
                {
                    var validationAttribute = propertyinfo.GetCustomAttributes(false).OfType <ValidationAttribute>();
                    var value   = propertyinfo.GetValue(rowData, null);
                    var results = new List <System.ComponentModel.DataAnnotations.ValidationResult>();
                    try
                    {
                        if (!Validator.TryValidateValue(value, validationContext, results, validationAttribute))
                        {
                            foreach (var result in results)
                            {
                                errorMessage = !string.IsNullOrEmpty(errorMessage) ? errorMessage + string.Format("\n") + result.ErrorMessage : errorMessage + result.ErrorMessage;
                            }
                            isValid          = false;
                            isAttributeError = true;
                        }
                    }
                    catch (Exception e)
                    {
                        errorMessage     = e.Message;
                        isValid          = false;
                        isAttributeError = true;
                    }
                }
            }

            if (currentCell != null)
            {
                if (!isValid || !string.IsNullOrEmpty(errorMessage))
                {
                    currentCell.SetError(errorMessage, isAttributeError);
                }
                else
                {
                    currentCell.RemoveError(true);
                }
            }
#if !SyncfusionFramework4_0 || UWP
            if (rowData is INotifyDataErrorInfo)
            {
                isValid = isValid && TreeGridDataValidation.ValidateINotifyDataErrorInfo(currentCell, columnName, rowData);
            }
#endif
            return(isValid);
        }
예제 #32
0
        private void SetProperty(PropertyInfoCollection collection, PropertyInfo property, bool overwrite)
        {
            if (collection != null)
            {
                PropertyInfo setProperty = collection[property.Name];

                if (setProperty == null)
                {
                    collection.Add(property);
                }
                else if (overwrite == true)
                {
                    setProperty.Namespace = property.Namespace;
                    //Calculated property not set
                    if (property.Calculated == false)
                        setProperty.Value = property.Value;
                }
            }
        }