public static void WriteToFile(string filePath, ArExperienceGroup arExperienceGroup)
 {
     using (Stream stream = File.Open(filePath, FileMode.Create))
     {
         BinaryFormatter binaryFormatter = new BinaryFormatter();
         binaryFormatter.Serialize(stream, arExperienceGroup);
     }
 }
Ejemplo n.º 2
0
 public static byte[] Serialize(ArExperienceGroup experienceGroup)
 {
     using (var stream = new MemoryStream())
     {
         var formatter = new BinaryFormatter();
         formatter.Serialize(stream, experienceGroup);
         return(stream.ToArray());
     }
 }
        public static List <ArExperienceGroup> ParseExampleDefintion(string defintions)
        {
            var experienceGroups = new List <ArExperienceGroup>();

            JsonArray sampleGroups = (JsonArray)JsonValue.Parse(defintions);

            foreach (JsonObject sampleGroup in sampleGroups)
            {
                string    groupName   = sampleGroup["windowTitle"];
                JsonArray experiences = (JsonArray)sampleGroup["samples"];

                var arExperiences = new List <ArExperience>();

                foreach (JsonObject experience in experiences)
                {
                    string experienceName      = experience["title"];
                    string experiencePath      = experience["path"];
                    string experienceExtension = null;
                    if (experience.TryGetValue("requiredExtension", out JsonValue extension))
                    {
                        experienceExtension = extension;
                    }
                    JsonArray  featuresArray = (JsonArray)experience["requiredFeatures"];
                    JsonObject startupConfig = (JsonObject)experience["startupConfiguration"];

                    Features         experienceFeatures = ParseFeatures(featuresArray);
                    CameraPosition   cameraPosition     = ParseCameraPosition(startupConfig);
                    CameraResolution cameraResolution   = ParseCameraResolution(startupConfig);

                    var arExperience = new ArExperience(experienceName, experiencePath, experienceFeatures, cameraPosition, cameraResolution, extension: experienceExtension);
                    arExperiences.Add(arExperience);
                }

                var arExperienceGroup = new ArExperienceGroup(groupName, arExperiences);
                experienceGroups.Add(arExperienceGroup);
            }


            return(experienceGroups);
        }