internal Array TableToArray(object luaParamValue, Type paramArrayType)
        {
            Array array;

            if (luaParamValue is LuaTable)
            {
                LuaTable luaTable = (LuaTable)luaParamValue;
                IDictionaryEnumerator enumerator = luaTable.GetEnumerator();
                enumerator.Reset();
                array = Array.CreateInstance(paramArrayType, luaTable.Values.get_Count());
                int num = 0;
                while (enumerator.MoveNext())
                {
                    object obj = enumerator.get_Value();
                    if (paramArrayType == typeof(object) && obj != null && obj.GetType() == typeof(double) && MetaFunctions.IsInteger((double)obj))
                    {
                        obj = Convert.ToInt32((double)obj);
                    }
                    array.SetValue(Convert.ChangeType(obj, paramArrayType), num);
                    num++;
                }
            }
            else
            {
                array = Array.CreateInstance(paramArrayType, 1);
                array.SetValue(luaParamValue, 0);
            }
            return(array);
        }
Exemple #2
0
        protected static bool serializeObject(Hashtable anObject, StringBuilder builder)
        {
            builder.Append("{");
            IDictionaryEnumerator enumerator = anObject.GetEnumerator();
            bool flag = true;

            while (enumerator.MoveNext())
            {
                string aString = enumerator.get_Key().ToString();
                object value   = enumerator.get_Value();
                if (!flag)
                {
                    builder.Append(", ");
                }
                MiniJSON.serializeString(aString, builder);
                builder.Append(":");
                if (!MiniJSON.serializeValue(value, builder))
                {
                    return(false);
                }
                flag = false;
            }
            builder.Append("}");
            return(true);
        }
        private static void Write(BinaryWriter InWriterRef, SecurityElement InElement, byte InType)
        {
            InWriterRef.Write(InType);
            InWriterRef.WriteString(InElement.get_Tag());
            InWriterRef.WriteString(InElement.get_Text());
            Hashtable attributes = InElement.get_Attributes();
            int       num        = (attributes != null) ? attributes.get_Count() : 0;

            InWriterRef.Write(num);
            if (attributes != null)
            {
                IDictionaryEnumerator enumerator = attributes.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    string text  = enumerator.get_Key() as string;
                    string text2 = enumerator.get_Value() as string;
                    DebugHelper.Assert(text != null && text2 != null, "Invalid Attributes");
                    InWriterRef.WriteString(text);
                    InWriterRef.WriteString(text2);
                }
            }
            ArrayList children = InElement.get_Children();
            int       num2     = (children != null) ? children.get_Count() : 0;

            InWriterRef.Write(num2);
            if (children != null)
            {
                IEnumerator enumerator2 = children.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    SecurityElement securityElement = enumerator2.get_Current() as SecurityElement;
                    DebugHelper.Assert(securityElement != null, "Invalid Security Element.");
                    SecurityTools.Write(InWriterRef, securityElement, 1);
                }
            }
        }