//
// (C) Copyright 2003-2019 by Autodesk, Inc. All rights reserved.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM 'AS IS' AND WITH ALL ITS FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB.ExtensibleStorage;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.IO;
using System.ComponentModel;
namespace SchemaWrapperTools
{
///
/// A class to store a list of FieldData objects as well as the top level data (name, access levels, SchemaId, etc..)
/// of an Autodesk.Revit.DB.ExtensibleStorage.Schema
///
[Serializable]
public class SchemaDataWrapper
{
#region Constructors
///
/// For serialization only -- Do not use.
///
internal SchemaDataWrapper() { }
///
/// Create a new SchemaDataWrapper
///
/// The Guid of the Schema
/// The access level for read permission
/// The access level for write permission
/// The user-registered vendor ID string
/// The application ID from the application manifest
/// The name of the schema
/// Descriptive details on the schema
public SchemaDataWrapper(Guid schemaId, AccessLevel readAccess, AccessLevel writeAccess, string vendorId, string applicationId, string name, string documentation)
{
DataList = new System.Collections.Generic.List();
SchemaId = schemaId.ToString();
ReadAccess = readAccess;
WriteAccess = writeAccess;
VendorId = vendorId;
ApplicationId = applicationId;
Name = name;
Documentation = documentation;
}
#endregion
#region Data addition
///
/// Adds a new field to the wrapper's list of fields.
///
/// the name of the field
/// the data type of the field
/// The unit type of the Field (set to UT_Undefined for non-floating point types
/// The SchemaWrapper of the field's subSchema, if the field is of type "Entity"
public void AddData(string name, System.Type typeIn, ForgeTypeId spec, SchemaWrapper subSchema)
{
m_DataList.Add(new FieldData(name, typeIn.FullName, spec.TypeId, subSchema));
}
#endregion
#region Properties
///
/// The list of FieldData objects in the wrapper
///
public List DataList
{
get { return m_DataList; }
set { m_DataList = value; }
}
///
/// The schemaId Guid of the Schema
///
public string SchemaId
{
get { return m_schemaId; }
set { m_schemaId = value; }
}
///
/// The read access of the Schema
///
public AccessLevel ReadAccess
{
get { return m_ReadAccess; }
set { m_ReadAccess = value; }
}
///
/// The write access of the Schema
///
public AccessLevel WriteAccess
{
get { return m_WriteAccess; }
set { m_WriteAccess = value; }
}
///
/// Vendor Id
///
public string VendorId
{
get { return m_vendorId; }
set
{
m_vendorId = value;
}
}
///
/// Application Id
///
public string ApplicationId
{
get { return m_applicationId; }
set { m_applicationId = value; }
}
///
/// The documentation string for the schema
///
public string Documentation
{
get { return m_Documentation; }
set
{
m_Documentation = value;
}
}
///
/// The name of the schema
///
public string Name
{
get { return m_Name; }
set
{
m_Name = value;
}
}
#endregion
#region Data
private AccessLevel m_ReadAccess;
private AccessLevel m_WriteAccess;
private System.Collections.Generic.List m_DataList;
private string m_applicationId;
private string m_schemaId;
private string m_vendorId;
private string m_Name;
private string m_Documentation;
#endregion
}
}