예제 #1
0
 public static byte[] Serialize(ArExperience experience)
 {
     using (var stream = new MemoryStream())
     {
         var formatter = new BinaryFormatter();
         formatter.Serialize(stream, experience);
         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);
        }