示例#1
0
        public void unpack(TTypedValue src)
        {
            ApsimType Data = (ApsimType)Property.Get;

            Data.unpack(src);
            Property.SetObject(Data);
        }
示例#2
0
        public override void unpack(byte[] messageData)
        {
            DDMLValue.setData(messageData, messageData.Length, 0);
            setPropertyValue(); //store the Value property
            T Data = Value;

            Property.SetObject(Data);
        }
示例#3
0
    // --------------------------------------------------------------------
    /// <summary>
    /// Go through all child XML nodes for the node passed in and set
    /// the corresponding property values in the Obj instance passed in.
    /// </summary>
    /// <param name="Obj"></param>
    /// <param name="Node"></param>
    /// <param name="HostComponent"></param>
    // --------------------------------------------------------------------
    private void PopulateParams(Instance Obj, XmlNode Node, ApsimComponent ParentComponent)
    {
        // Look for an XmlNode param. If found then given it our current 'Node'.
        bool HavePassedXMLToObj = false;

        foreach (FactoryProperty Property in RegisteredProperties)
        {
            if ((String.Compare(Property.TypeName, "XmlNode", StringComparison.Ordinal) == 0) && (Property.OutputName.Contains(Node.Name)))
            {
                Property.SetObject(Node);
                HavePassedXMLToObj = true;
            }
        }

        // Go through all child XML nodes for the node passed in and set
        // the corresponding property values in the Obj instance passed in.
        if (!HavePassedXMLToObj)
        {
            foreach (XmlNode Child in Node.ChildNodes)
            {
                if (Child.GetType() != typeof(XmlComment))
                {
                    Type t = GetTypeOfChild(Child, Obj);
                    if ((t != null) && (t.IsSubclassOf(typeof(Instance)) || t.IsClass))
                    {
                        // Create a child instance - indirect recursion.
                        Instance ChildInstance = CreateInstance(Child, Child, Obj, ParentComponent);
                        Obj.Add(ChildInstance);

                        FactoryProperty Parameter = FindProperty(Child);
                        if (XmlHelper.Name(Child).Contains("["))
                        {
                            String ArrayName = XmlHelper.Name(Child);
                            StringManip.SplitOffBracketedValue(ref ArrayName, '[', ']');
                            XmlHelper.SetName(Child, ArrayName);
                            Parameter = FindProperty(Child);
                            if (Parameter != null)
                            {
                                Parameter.AddToList(ChildInstance);
                            }
                            else
                            {
                                // Parameter must be an array link to child nodes e.g.
                                // [Link] LeafCohort[] InitialLeaves;
                            }
                        }

                        else if ((Parameter != null) && (Parameter.IsParam && !Parameter.TypeName.Contains("System::")))
                        {
                            Parameter.SetObject(ChildInstance.Model);
                        }
                    }
                    else if (Child.Name == "Memo")
                    {
                        // Ignore memo fields.
                    }
                    else
                    {
                        FactoryProperty Parameter = FindProperty(Child);
                        if (Parameter != null)
                        {
                            Parameter.Name = XmlHelper.Name(Child);
                            Parameter.Set(Child);
                        }
                    }
                }
            }
        }
    }