Exemple #1
0
 public void SetValue(object val)
 {
     if (val is LambdaObject)
     {
         mObject = (LambdaObject)val;
     }
 }
Exemple #2
0
        virtual public bool TryCloneEntry(out object clone)
        {
            LambdaObject copy = new LambdaObject(mParentName, mParentType, null);

            List <INamedTypedProperty> copyProps = new List <INamedTypedProperty>();

            foreach (INamedTypedProperty prop in mProperties)
            {
                ICloneTemplate cl = prop as ICloneTemplate;
                object         newChild;
                if (cl.TryCloneEntry(out newChild))
                {
                    if (newChild is INamedTypedProperty)
                    {
                        copyProps.Add((INamedTypedProperty)newChild);
                    }
                }
            }
            copy.mProperties = copyProps.ToArray();
            clone            = copy;
            return(true);
        }
Exemple #3
0
        private void LoadSettings(LambdaObject lambdaObject)
        {
            string parentName = "";
            string parentType = "";

            INamedTypedProperty[] properties = null;

            if (lambdaObject != null)
            {
                parentName = lambdaObject.mParentName;
                parentType = lambdaObject.mParentType;
                properties = lambdaObject.mProperties;
            }

            if (properties == null || properties.Length == 0)
            {
                this.Visible = false;
                this.SuspendLayout();
                mControls.Clear();
                this.ClearUI();
                this.ResumeLayout();
                return;
            }

            this.Visible = true;

            List <Control> temp = new List <Control>();

            //could we refactor this section:....

            mProps = new List <HighLevelProperty>();
            foreach (INamedTypedProperty ip in properties)
            {
                ApplyMetadata(ip, parentType);
                if (ip.MetaData.ContainsKey("Ignore") && (bool)(ip.MetaData["Ignore"]) == true)
                {
                    continue;
                }

                //This code is for supporting arrays:
                IPropertyArray ar2 = ip as IPropertyArray;
                if (ar2 != null)
                {
                    foreach (INamedTypedProperty inner in ar2.GetProperties())
                    {
                        if (inner.GetValue() == null)
                        {
                            continue;
                        }
                        IPropertyArray propertyArray = inner.GetValue() as IPropertyArray;
                        if (propertyArray != null)
                        {
                            foreach (INamedTypedProperty inner2 in ((IPropertyArray)inner.GetValue()).GetProperties())
                            {
                                Dictionary <string, object> innerData;
                                if (mSpecificPropertyMetadata[ip.MetaData["ArrayType"].ToString()].TryGetValue(inner2.GetName(), out innerData))
                                {
                                    inner2.MetaData = innerData;
                                }
                            }
                        }
                    }
                }
                //Nested logic:  This pushes complext type metadata inwards
                else if (ip.MetaData.ContainsKey("ComplexType") == true)
                {
                    IPropertyArray ar = ip.GetValue() as IPropertyArray;
                    if (ar != null)
                    {
                        foreach (INamedTypedProperty inner in ar.GetProperties())
                        {
                            Dictionary <string, object> innerData;
                            if (mSpecificPropertyMetadata[ip.MetaData["ComplexType"].ToString()].TryGetValue(inner.GetName(), out innerData))
                            {
                                inner.MetaData = innerData;
                            }
                        }
                    }
                }


                HighLevelProperty p = GetHighLevelProperty(ip, parentType);


                //////events
                //if (ip.MetaData.ContainsKey("UpdateEvent"))
                //   p.Changed += new HighLevelProperty.HighLevelPropertyEvent(p_Changed);

                p.Changed += new HighLevelProperty.HighLevelPropertyEvent(p_AnyChanged);
                /////events

                if (ip.MetaData.ContainsKey("Ignore") && (bool)(ip.MetaData["Ignore"]) == true)
                {
                    continue;
                }


                mProps.Add(p);
                string  bindName;
                Control c = p.GetEditor(out bindName);

                if (ip.MetaData.ContainsKey("Alias"))
                {
                    c.Name = ip.MetaData["Alias"].ToString();
                }
                else
                {
                    c.Name = ip.GetName();
                }

                //Set editor properties:
                Type edtiorType = c.GetType();
                foreach (string s in ip.MetaData.Keys)
                {
                    if (s.Contains("EditorProperty."))
                    {
                        string       editorProp         = s.Replace("EditorProperty.", "");
                        PropertyInfo editorPropertyInfo = edtiorType.GetProperty(editorProp);
                        object       convertedValue     = ip.MetaData[s];
                        convertedValue = Convert.ChangeType(convertedValue, editorPropertyInfo.PropertyType);
                        editorPropertyInfo.SetValue(c, convertedValue, null);
                    }
                }

                temp.Add(c);
            }

            mControls.Clear();
            this.SuspendLayout();
            this.AddControls(temp);
            this.ResumeLayout();
        }
Exemple #4
0
 public LamdaObjectProperty(LambdaObject obj)
 {
     mObject = obj;
 }