示例#1
0
        public void Save()
        {
            lock (appSettingsLock)
            {
                string json = null;

                try
                {
                    json = JsonConvert.SerializeObject(this);
                }
                catch (Exception ex)
                {
                    LoggerUtil.GetAppWideLogger().Error(ex, "Failed to convert object to JSON.");
                    return;
                }

                try
                {
                    IPathProvider paths = PlatformTypes.New <IPathProvider>();

                    string settingsPath = paths.GetPath(@"app.settings");
                    using (StreamWriter writer = new StreamWriter(File.Open(settingsPath, FileMode.Create)))
                    {
                        writer.Write(json);
                    }
                }
                catch (Exception ex)
                {
                    LoggerUtil.GetAppWideLogger().Error(ex, "Failed to save app settings.");
                }
            }
        }
示例#2
0
        private string GetLocalFileName(string attachment)
        {
            string localPath =
                m_LocalPathProvider.GetPath(attachment);

            // Return full path
            return(System.IO.Path.Combine(localPath, attachment));
        }
        void Update()
        {
            if (m_strokeDevice == null)
            {
                SteamVR_Action_Boolean_Source drawStrokeAction = SteamVR_Actions._default.DrawStroke[SteamVR_Input_Sources.Any];

                if (drawStrokeAction.stateDown)
                {
                    if (drawStrokeAction.activeDevice == SteamVR_Input_Sources.Any)
                    {
                        m_strokeDevice = SteamVR_Input_Sources.RightHand;
                    }
                    else
                    {
                        m_strokeDevice = drawStrokeAction.activeDevice;
                    }

                    //Debug.Log($"DOWN: {m_strokeDevice.Value}");

                    PointerPoint pp = CreatePointerPoint();

                    m_inkWriter.OnPointerPressed(ref pp);
                }
            }
            else
            {
                SteamVR_Action_Boolean_Source action = SteamVR_Actions._default.DrawStroke[m_strokeDevice.Value];

                if (action.stateUp)
                {
                    //Debug.Log($"UP: {m_strokeDevice.Value}");

                    PointerPoint pp = CreatePointerPoint();

                    m_inkWriter.OnPointerReleased(ref pp);

                    m_strokeDevice = null;

                    if (m_pathProvider != null)
                    {
                        // copy the path
                        List <float> path = new List <float>(m_pathProvider.GetPath());
                        m_paths.Add(path);
                    }
                }
                else if (action.state)
                {
                    //Debug.Log($"MOVE: {m_strokeDevice.Value}");

                    PointerPoint pp = CreatePointerPoint();

                    m_inkWriter.OnPointerMoved(ref pp);
                }
            }
        }
        public virtual void Serialize(ISerializableItem item)
        {
            // foreach serialization definition
            var serializationDefinitions = _definitionsProvider.
                                           GetSerializationDefinitions(item.Database);

            foreach (var serializationDefinition in serializationDefinitions)
            {
                //see if item needs to be serialized
                if (!serializationDefinition.Evaluate(item))
                {
                    continue;
                }
                // get the right folder

                var path = _pathProvider.GetPath(item, serializationDefinition.Path);
                //serialize it

                item.Dump(path);
            }
        }
        public string GetLocalFileName(string attachmentFile)
        {
            string localPath = Path.GetDirectoryName(attachmentFile);

            if (m_LocalPathProvider is LocalPathLocator)
            {
                if (StringUtil.IsStringInitialized(localPath))
                {
                    return(Path.Combine(((LocalPathLocator)m_LocalPathProvider).DefaultRoot, attachmentFile));
                }

                localPath = m_LocalPathProvider.GetPath(AttachmentsUtil.GetAttachmentType(attachmentFile));
            }
            else
            {
                localPath = m_LocalPathProvider.GetPath(attachmentFile);
            }

            // Return full path
            return(Path.Combine(localPath, attachmentFile));
        }
        /// <summary>
        /// Set path on request and execute request
        /// </summary>
        /// <param name="request">The request</param>
        /// <param name="cancellationToken">The cancellation token</param>
        /// <returns>The response</returns>
        public Task <ApiResponse <TResponse> > Execute(ApiRequest <TRequest> request, CancellationToken cancellationToken)
        {
            Argument.NotNull(request, nameof(request));

            if (request.Context == null)
            {
                request.Context = new RequestContext();
            }

            if (request.Context.Path == null)
            {
                var path = _pathProvider.GetPath(request.Model);

                request.Context.Path = path;
            }

            return(_apiClient.Execute(request, cancellationToken));
        }
示例#7
0
        public static AppSettings Load()
        {
            lock (appSettingsLock)
            {
                IPathProvider paths = PlatformTypes.New <IPathProvider>();

                string settingsPath = paths.GetPath(@"app.settings");

                if (!File.Exists(settingsPath))
                {
                    return(new AppSettings());
                }

                using (StreamReader reader = File.OpenText(settingsPath))
                {
                    string      json   = reader.ReadToEnd();
                    AppSettings loaded = JsonConvert.DeserializeObject <AppSettings>(json);
                    return(loaded ?? new AppSettings());
                }
            }
        }
 private string getTempFolder() => s_paths.GetPath("temp");