ProtoGeometryConfiguration
using Autodesk.DesignScript.Runtime;
using System;
using System.IO;
using System.Xml.Serialization;
namespace Autodesk.DesignScript.Geometry
{
[SupressImportIntoVM]
public class ProtoGeometryConfiguration : IProtoGeometryConfiguration
{
public string GeometryFactoryFileName { get; set; }
public string PersistentManagerFileName { get; set; }
internal static bool Serialize(string filePath, ProtoGeometryConfiguration configuration)
{
try {
XmlSerializer xmlSerializer = new XmlSerializer(typeof(ProtoGeometryConfiguration));
FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);
xmlSerializer.Serialize(fileStream, configuration);
fileStream.Flush();
fileStream.Close();
} catch (Exception) {
return false;
}
return true;
}
internal static ProtoGeometryConfiguration Deserialize(string filePath)
{
ProtoGeometryConfiguration protoGeometryConfiguration = null;
if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
try {
XmlSerializer xmlSerializer = new XmlSerializer(typeof(ProtoGeometryConfiguration));
FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
protoGeometryConfiguration = (xmlSerializer.Deserialize(fileStream) as ProtoGeometryConfiguration);
fileStream.Close();
} catch (Exception) {
}
if (protoGeometryConfiguration == null)
protoGeometryConfiguration = new ProtoGeometryConfiguration();
return protoGeometryConfiguration;
}
private ProtoGeometryConfiguration()
{
GeometryFactoryFileName = "ProtoAcadGeometry.dll";
PersistentManagerFileName = "ProtoAcadGeometry.dll";
}
}
}