Ejemplo n.º 1
0
        private static object rebuildElement(string dataString, object replacement, bool cleanup)
        {
            string[] data = splitElemets(dataString);

            if (cleanup)
            {
                return(null);
            }

            try
            {
                Type T = Type.GetType(data[2]);

                if (T == null)
                {
                    Monitor.Log("Couldn't load: " + data[2]);
                    return(replacement);
                }

                ISaveElement newElement = (ISaveElement)Activator.CreateInstance(T);

                Dictionary <string, string> additionalSaveData = new Dictionary <string, string>();

                if (data.Length > 3)
                {
                    for (int i = 3; i < data.Length; i++)
                    {
                        if (!data[i].Contains("="))
                        {
                            continue;
                        }
                        string[] entry = data[i].Split('=');
                        additionalSaveData.Add(entry[0], entry[1]);
                    }
                }

                if (replacement == null)
                {
                    replacement = new Chest(true);
                }

                newElement.rebuild(additionalSaveData, replacement);

                return(newElement);
            }
            catch (Exception e)
            {
                Monitor.Log("Exception while rebuilding element: " + e.Message, LogLevel.Error);
                Monitor.Log("" + e.StackTrace, LogLevel.Error);
                return(replacement);
            }
        }
Ejemplo n.º 2
0
        private static object rebuildElement(string[] data, object replacement)
        {
            Type T = Type.GetType(data[2]);

            if (T == null)
            {
                return(replacement);
            }

            ISaveElement newElement = (ISaveElement)Activator.CreateInstance(T);

            Dictionary <string, string> additionalSaveData = new Dictionary <string, string>();

            for (int i = 3; i < data.Length; i++)
            {
                string[] entry = data[i].Split('=');
                additionalSaveData.Add(entry[0], entry[1]);
            }

            newElement.rebuild(additionalSaveData, replacement);

            return(newElement);
        }