Exemple #1
0
        protected override bool Read(Rhino.FileIO.BinaryArchiveReader archive)
        {
            Rhino.Collections.ArchivableDictionary dict = archive.ReadDictionary();
            object ho = base.ReadHotLoadData(dict);

            if (dict.ContainsKey("alpha"))
            {
                alpha = (int)dict["alpha"];
            }
            if (dict.ContainsKey("beta"))
            {
                beta = (double)dict["beta"];
            }
            if (dict.ContainsKey("classA"))
            {
                classA = JsonConvert.DeserializeObject <TestClassA>(dict.GetString("classA"));
            }
            if (dict.ContainsKey("classB"))
            {
                classB = JsonConvert.DeserializeObject <TestClassB>(dict.GetString("classB"));
            }
            if (dict.ContainsKey("classC"))
            {
                classC = JsonConvert.DeserializeObject <TestClassC>(dict.GetString("classC"));
            }
            //if (dict.ContainsKey("classD")) classD = JsonConvert.DeserializeObject<TestClassD>(dict.GetString("classD"));
            if (dict.ContainsKey("classE"))
            {
                classE = JsonConvert.DeserializeObject <TestClassE>(dict.GetString("classE"));
            }
            return(true);
        }
Exemple #2
0
        protected object ReadHotLoadData(Rhino.Collections.ArchivableDictionary dict)
        {
            string encAss = "";
            string type   = "";

            if (dict.ContainsKey("EncodedAssembly"))
            {
                encAss = dict.GetString("EncodedAssembly");
            }
            if (dict.ContainsKey("Type"))
            {
                type = dict.GetString("Type");
            }
            byte[] assByt   = Convert.FromBase64String(encAss);
            string tempPath = Path.GetTempFileName();

            File.WriteAllBytes(tempPath, assByt);
            Assembly assembly         = Assembly.LoadFrom(tempPath);
            Type     t                = assembly.GetType(type);
            object   instanceOfMyType = Activator.CreateInstance(t);

            return(instanceOfMyType);
        }