Esempio n. 1
0
        /// <summary>
        /// Deserializes OSD in to a list of primitives
        /// </summary>
        /// <param name="osd">Structure holding the serialized primitive list,
        /// must be of the SDMap type</param>
        /// <returns>A list of deserialized primitives</returns>
        public static List <Primitive> OSDToPrimList(StructuredData.OSD osd)
        {
            if (osd.Type != StructuredData.OSDType.Map)
            {
                throw new ArgumentException("LLSD must be in the Map structure");
            }

            StructuredData.OSDMap map   = (StructuredData.OSDMap)osd;
            List <Primitive>      prims = new List <Primitive>(map.Count);

            foreach (KeyValuePair <string, StructuredData.OSD> kvp in map)
            {
                Primitive prim = Primitive.FromOSD(kvp.Value);
                prim.LocalID = UInt32.Parse(kvp.Key);
                prims.Add(prim);
            }

            return(prims);
        }
Esempio n. 2
0
        public static new Avatar FromOSD(OSD O)
        {
            OSDMap tex = (OSDMap)O;

            Avatar A = new Avatar();

            Primitive P = Primitive.FromOSD(O);

            Type Prim = typeof(Primitive);

            FieldInfo[] Fields = Prim.GetFields();

            for (int x = 0; x < Fields.Length; x++)
            {
                Logger.Log("Field Matched in FromOSD: " + Fields[x].Name, Helpers.LogLevel.Debug);
                Fields[x].SetValue(A, Fields[x].GetValue(P));
            }

            A.Groups = new List <UUID>();

            foreach (OSD U in (OSDArray)tex["groups"])
            {
                A.Groups.Add(U.AsUUID());
            }

            A.ProfileStatistics = Statistics.FromOSD(tex["profile_statistics"]);
            A.ProfileProperties = AvatarProperties.FromOSD(tex["profile_properties"]);
            A.ProfileInterests  = Interests.FromOSD(tex["profile_interest"]);
            A.ControlFlags      = (AgentManager.ControlFlags)tex["control_flags"].AsInteger();

            OSDArray vp = (OSDArray)tex["visual_parameters"];

            A.VisualParameters = new byte[vp.Count];

            for (int i = 0; i < vp.Count; i++)
            {
                A.VisualParameters[i] = (byte)vp[i].AsInteger();
            }

            // *********************From Code Above *******************************

            /*if (NameValues[i].Name == "FirstName" && NameValues[i].Type == NameValue.ValueType.String)
             *                firstName = (string)NameValues[i].Value;
             *            else if (NameValues[i].Name == "LastName" && NameValues[i].Type == NameValue.ValueType.String)
             *                lastName = (string)NameValues[i].Value;*/
            // ********************************************************************

            A.NameValues = new NameValue[3];

            NameValue First = new NameValue();

            First.Name  = "FirstName";
            First.Type  = NameValue.ValueType.String;
            First.Value = tex["first_name"].AsString();

            NameValue Last = new NameValue();

            Last.Name  = "LastName";
            Last.Type  = NameValue.ValueType.String;
            Last.Value = tex["last_name"].AsString();

            // ***************From Code Above***************
            // if (NameValues[i].Name == "Title" && NameValues[i].Type == NameValue.ValueType.String)
            // *********************************************

            NameValue Group = new NameValue();

            Group.Name  = "Title";
            Group.Type  = NameValue.ValueType.String;
            Group.Value = tex["group_name"].AsString();



            A.NameValues[0] = First;
            A.NameValues[1] = Last;
            A.NameValues[2] = Group;

            return(A);
        }