示例#1
0
        static AutoDropShadowPopup()
        {
            var forType = typeof(AutoDropShadowPopup);

            ChildProperty.OverrideMetadata(
                forType, new FrameworkPropertyMetadata(null, null, CoerceChild));
        }
示例#2
0
 private void UpdateDataSourceInternal(object oldValue, object newValue, string dataField)
 {
     if (DataSource != null)
     {
         if (DataSource is IDictionary <string, string> )
         {
             var dictionary = DataSource as IDictionary <string, string>;
             if (dictionary.ContainsKey(dataField) && !ReferenceEquals(newValue, oldValue))
             {
                 dictionary[dataField] = newValue as string;
             }
         }
         else if (DataSource is IIndexable)
         {
             var indexer = DataSource as IIndexable;
             indexer[dataField] = newValue;
         }
         else
         {
             if (String.IsNullOrEmpty(DataMember))
             {
                 if (Property != null)
                 {
                     if (!ReferenceEquals(newValue, oldValue))
                     {
                         Property.SetValue(DataSource, Convert.ChangeType(newValue, Property.PropertyType), null);
                     }
                 }
             }
             else
             {
                 if (Property != null)
                 {
                     object parentValue = Property.GetValue(DataSource, null);
                     if (parentValue != null)
                     {
                         if (parentValue is IDictionary <string, string> )
                         {
                             var dictionary = parentValue as IDictionary <string, string>;
                             if (dictionary.ContainsKey(dataField) && !ReferenceEquals(newValue, oldValue))
                             {
                                 dictionary[dataField] = newValue as string;
                             }
                         }
                         else if (parentValue is IIndexable)
                         {
                             var indexer = parentValue as IIndexable;
                             indexer[dataField] = newValue;
                         }
                         else if (ChildProperty != null)
                         {
                             ChildProperty.SetValue(parentValue, Convert.ChangeType(newValue, ChildProperty.PropertyType), null);
                         }
                     }
                 }
             }
         }
     }
 }
示例#3
0
        private void editableChildCollectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewObjectDefaults frm = NewObjectDefaults.NewChildListProperties();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                string         collectionName = frm.GetPropertyValue("CollectionName");
                string         itemName       = frm.GetPropertyValue("ItemName");
                string         parentName     = frm.GetPropertyValue("ParentType");
                string         propertyName   = frm.GetPropertyValue("PropertyNameInParentType");
                CslaObjectInfo parent         = _currentUnit.CslaObjects.Find(parentName);
                if (parent == null)
                {
                    MessageBox.Show(@"Parent type not found", @"CslaGenerator", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                NewCollection(CslaObjectType.EditableChildCollection, collectionName, itemName, parentName);
                NewObject(CslaObjectType.EditableChild, itemName, collectionName);
                AddPropertiesForSelectedColumns();
                ArrayList lst = new ArrayList();
                foreach (ValueProperty p in parent.ValueProperties)
                {
                    if (p.PrimaryKey != ValueProperty.UserDefinedKeyBehaviour.Default)
                    {
                        lst.Add(p);
                    }
                }
                foreach (Property p in lst)
                {
                    _currentCslaObject.ParentProperties.Add(p);
                }
                ChildProperty col = new ChildProperty();
                col.TypeName = collectionName;
                if (!string.IsNullOrEmpty(propertyName))
                {
                    col.Name = propertyName;
                }
                else
                {
                    col.Name = collectionName;
                }
                col.ReadOnly = true;
                foreach (var crit in parent.CriteriaObjects)
                {
                    if (crit.GetOptions.Factory || crit.GetOptions.AddRemove || crit.GetOptions.DataPortal)
                    {
                        foreach (var prop in crit.Properties)
                        {
                            col.LoadParameters.Add(new Parameter(crit, prop));
                        }
                    }
                }
                parent.ChildCollectionProperties.Add(col);
            }
        }
示例#4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Breadcrumb != null ? Breadcrumb.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ChildProperty != null ? ChildProperty.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Value1 != null ? Value1.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Value2 != null ? Value2.GetHashCode() : 0);
         return(hashCode);
     }
 }
示例#5
0
        /// <summary>
        /// Checks the text for matches
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private List <TChild> CheckForMatches(string text)
        {
            // create a list of child objects
            List <TChild> childObjs = new List <TChild>();

            if (ParentProperty != null)
            {
                // get parent object matches
                List <TParent> parentObjs = ParentObjectMatcher.GetMatches(text);

                // if there were any parent matches, get child objects
                if (parentObjs != null && parentObjs.Count > 0)
                {
                    // for each parent, check for children
                    foreach (TParent parentObj in parentObjs)
                    {
                        // get the value of the parent linking property
                        object parentPropertyValue = ParentProperty.GetValue(parentObj, null);

                        // if the child property is set
                        if (ChildProperty != null)
                        {
                            // find child object matches
                            List <TChild> childObjMatches = ChildObjectMatcher.GetMatches(text);

                            // if any child matches were found, add them to the collection
                            if (childObjMatches != null && childObjMatches.Count > 0)
                            {
                                // for each child match, set the child's parent property and add to the collection
                                foreach (TChild childObj in childObjMatches)
                                {
                                    ChildProperty.SetValue(childObj, parentPropertyValue, null);
                                    childObjs.Add(childObj);
                                }
                            }
                        }
                    }
                }
            }

            return(childObjs);
        }
示例#6
0
        protected void DataBindInternal(string dataField, ref object value)
        {
            var dictionary = DataSource as IDictionary;

            if (dictionary != null)
            {
                if (!String.IsNullOrEmpty(dataField) && dictionary.Contains(dataField))
                {
                    value = dictionary[dataField];
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(dataField))
                {
                    if (String.IsNullOrEmpty(DataMember))
                    {
                        if (Property != null && Property.GetValue(DataSource, null) != null)
                        {
                            // ReSharper disable PossibleNullReferenceException
                            value = Property.GetValue(DataSource, null);
                            // ReSharper restore PossibleNullReferenceException
                        }
                    }
                    else
                    {
                        if (Property != null && Property.GetValue(DataSource, null) != null)
                        {
                            // ReSharper disable PossibleNullReferenceException
                            object parentValue = Property.GetValue(DataSource, null);
                            if (ChildProperty != null && ChildProperty.GetValue(parentValue, null) != null)
                            {
                                value = ChildProperty.GetValue(parentValue, null);
                            }
                            // ReSharper restore PossibleNullReferenceException
                        }
                    }
                }
            }
        }
        public virtual string GetRelationString(CslaObjectInfo info, ChildProperty child)
        {
            string indent = new string('\t', _indentLevel);

            StringBuilder  sb         = new StringBuilder();
            CslaObjectInfo childInfo  = FindChildInfo(info, child.TypeName);
            string         joinColumn = String.Empty;

            if (child.LoadParameters.Count > 0)
            {
                if (IsCollectionType(childInfo.ObjectType))
                {
                    joinColumn = child.LoadParameters[0].Property.Name;
                    childInfo  = FindChildInfo(info, childInfo.ItemType);
                }
                if (joinColumn == String.Empty)
                {
                    joinColumn = child.LoadParameters[0].Property.Name;
                }
            }

            sb.Append(indent);
            sb.Append("ds.Relations.Add(\"");
            sb.Append(info.ObjectName);
            sb.Append(childInfo.ObjectName);
            sb.Append("\", ds.Tables[");
            sb.Append(_resultSetCount.ToString());
            sb.Append("].Columns[\"");
            sb.Append(joinColumn);
            sb.Append("\"], ds.Tables[");
            sb.Append((_resultSetCount + 1).ToString());
            sb.Append("].Columns[\"");
            sb.Append(joinColumn);
            sb.Append("\"], false);");

            _resultSetCount++;
            return(sb.ToString());
        }
示例#8
0
 set => SetCurrentValue(ChildProperty, value);
 public ChildPropertyBag(ChildProperty obj) : this(new[] { obj })
 {
 }
示例#10
0
文件: Border.cs 项目: ediboko1980/uno
 set => this.SetValue(ChildProperty, value);
示例#11
0
 set => SetValue(ChildProperty, value);
 get => (UIElement)GetValue(ChildProperty); set => SetValue(ChildProperty, value);