public static AnalyzeRequest Deserialize(this IModelSerializer serializer, byte[] bytes)
 {
     using (var ms = new MemoryStream(bytes))
     {
         return(serializer.Deserialize(ms));
     }
 }
Example #2
0
        /// <summary>
        /// Instantiates a model object from the model asset.  Each model object has it's own vertex and index
        /// buffers, so you should aim to share model objects which will always have the same state.
        /// </summary>
        /// <returns>The model object.</returns>
        public IModel InstantiateModel()
        {
            if (PlatformData != null)
            {
                return(_modelSerializer.Deserialize(Name, PlatformData.Data));
            }

            throw new InvalidOperationException("Attempted to instantiate a model, but no platform data was loaded.");
        }
Example #3
0
        /// <summary>
        /// If the model asset has bones for animation, instantiates a new copy of the model asset.  If the
        /// model asset has no bones (and can not be animated with them), returns a shared copy of the model asset.
        /// </summary>
        /// <returns>The model object.</returns>
        public IModel InstantiateModel()
        {
            if (_data != null)
            {
                if (_cachedModel == null)
                {
                    _cachedModel = _modelSerializer.Deserialize(Name, _data);
                }

                if (_cachedModel.Root != null)
                {
                    // Model has bones for animation; we need to pass a unique instance to the caller so they can
                    // modify and apply bone animations which require a unique vertex buffer.
                    return(_modelSerializer.Deserialize(Name, _data));
                }

                // Since this model can not be animated, we can use a shared instance and hence share vertex
                // and index buffers.
                return(_cachedModel);
            }

            throw new InvalidOperationException("Attempted to instantiate a model, but no platform data was loaded.");
        }
Example #4
0
        private async Task <ProgrammingTask> GetTaskFromFile(string fileName)
        {
            ProgrammingTask progTask = null;

            using (var streamReader = new StreamReader(File.Open(fileName, FileMode.Open, FileAccess.Read)))
            {
                var fileContentsTask = streamReader.ReadToEndAsync();
                var pureFileName     = Path.GetFileNameWithoutExtension(fileName);
                var id = new GuidIdentifier(new Guid(pureFileName));

                var fileContents = await fileContentsTask;
                progTask            = _serializer.Deserialize(fileContents);
                progTask.Identifier = id;
            }

            return(progTask);
        }
        public void ConvertFile(string inputFilePath, string targetFilePath, string language)
        {
            // read input file
            var fileContent = _fileHandlerService.ReadFileAsString(inputFilePath);

            // parse file
            var sourceModel = _sourceModelSerializerService.Deserialize(fileContent);

            // convert source to intermediate model
            var intermediateModel = _sourceModelConverterService.ConvertToIntermediate(sourceModel, language);

            // convert intermediate to target model
            var targetModel = _targetModelConverterService.ConvertFromIntermediate(intermediateModel);

            // serialize model
            var serializedTargetModel = _targetModelSerializerService.Serialize(targetModel);

            // save output
            _fileHandlerService.WriteFileAsString(targetFilePath, serializedTargetModel);
        }
Example #6
0
        public async Task ProcessQueueAsync(CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                var result = _model.BasicGet(Constants.MessageQueue, false);

                if (result != null)
                {
                    var request = _serializer.Deserialize(result.Body);

                    try
                    {
                        await _requestProcessor.ProcessAsync(request, token);

                        _model.BasicAck(result.DeliveryTag, false);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }