コード例 #1
0
        internal static ProtoGeometryConfiguration Deserialize(string filePath)
        {
            ProtoGeometryConfiguration configuration = null;

            if (!string.IsNullOrEmpty(filePath) && (File.Exists(filePath) != false))
            {
                try
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(ProtoGeometryConfiguration));
                    FileStream    fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                    configuration = serializer.Deserialize(fileStream) as ProtoGeometryConfiguration;
                    fileStream.Close();
                }
                catch (Exception)
                {
                }
            }

            if (null == configuration) // Default settings.
            {
                configuration = new ProtoGeometryConfiguration();
            }

            return(configuration);
        }
コード例 #2
0
        static ProtoGeometryConfigurationManager()
        {
            string fullPath = ConfigFileFullPath;

            Settings = ProtoGeometryConfiguration.Deserialize(fullPath);

            if (!File.Exists(fullPath))
            {
                ProtoGeometryConfiguration.Serialize(fullPath, Settings);
            }
        }
コード例 #3
0
        internal static bool Serialize(string filePath, ProtoGeometryConfiguration configuration)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(ProtoGeometryConfiguration));
                FileStream    fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);
                serializer.Serialize(fileStream, configuration);
                fileStream.Flush();
                fileStream.Close();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
コード例 #4
0
        internal static bool Serialize(string filePath, ProtoGeometryConfiguration configuration)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(ProtoGeometryConfiguration));
                FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);
                serializer.Serialize(fileStream, configuration);
                fileStream.Flush();
                fileStream.Close();
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
コード例 #5
0
        internal static ProtoGeometryConfiguration Deserialize(string filePath)
        {
            ProtoGeometryConfiguration configuration = null;
            if (!string.IsNullOrEmpty(filePath) && (File.Exists(filePath) != false))
            {
                try
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(ProtoGeometryConfiguration));
                    FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                    configuration = serializer.Deserialize(fileStream) as ProtoGeometryConfiguration;
                    fileStream.Close();
                }
                catch (Exception)
                {
                }
            }

            if (null == configuration) // Default settings.
                configuration = new ProtoGeometryConfiguration();

            return configuration;
        }
コード例 #6
0
 public static void Save()
 {
     ProtoGeometryConfiguration.Serialize(ConfigFileFullPath, Settings);
 }