Ejemplo n.º 1
0
        /// <summary>
        /// Creates a copy of <paramref name="data"/> with the same columns and column types
        /// The returned object is of type DataTable and does not copy any derived type
        /// for <paramref name="data"/>.  If <paramref name="createIFrameImplementation"/> is true, the returned
        /// table will be an IFrame implementation of a DataTable.
        /// </summary>
        /// <returns>An empty DataTable with the table structure</returns>
        internal DataTable CreateStructure(IDataAttributes<IEdge> data, bool includeEdgeIndices, bool createIFrameImplementation)
        {
            var srcTable = data as DataTable;
            DataTable table = null;

            if (createIFrameImplementation)
            {
                using (var fac = new BasicFrameFactory())
                {
                    table = fac.CreateTable(Guid.NewGuid(), srcTable.TableName);
                }
            }
            else
                table = new DataTable(srcTable.TableName);

            DataColumn srcCol = null;
            DataColumn newCol = null;
            if (includeEdgeIndices)
            {
                var indexColName = BlueSpider.Blob.Common.NamingHelper.MakeUnique(data.ColumnNames, "Edge Index");
                var indexCol = new DataColumn(indexColName);
                indexCol.DataType = typeof(int);
                table.Columns.Add(indexCol);
            }
            for (int i = 0; i < srcTable.Columns.Count; i++)
            {
                srcCol = srcTable.Columns[i];
                newCol = new DataColumn(srcCol.ColumnName);
                newCol.DataType = srcCol.DataType;
                newCol.DateTimeMode = srcCol.DateTimeMode;
                newCol.DefaultValue = srcCol.DefaultValue;
                newCol.Caption = srcCol.Caption;
                newCol.ColumnMapping = srcCol.ColumnMapping;
                newCol.AllowDBNull = srcCol.AllowDBNull;
                newCol.Expression = srcCol.Expression;
                newCol.MaxLength = srcCol.MaxLength;
                newCol.Namespace = srcCol.Namespace;
                newCol.Prefix = srcCol.Prefix;
                newCol.ReadOnly = srcCol.ReadOnly;
                newCol.Unique = srcCol.Unique;

                table.Columns.Add(newCol);
            }

            return table;
        }
Ejemplo n.º 2
0
        internal virtual void WriteNode(INode node, IDataAttributes<INode> nodeData, XmlWriter writer)
        {
            string keyId = null;
            writer.WriteStartElement("node");

            writer.WriteStartAttribute("id");
            writer.WriteValue(node.Index);
            writer.WriteEndAttribute();

            if (nodeData != null && nodeData.ColumnCount>0)
            {
                for (int i = 0; i < nodeData.ColumnCount; i++)
                {
                    // get the data key id for the respective data col
                    keyId = NodeDataKeys[i];
                    WriteNodeDataElement(keyId, nodeData[node, i], writer);
                }
            }

            writer.WriteEndElement();
        }
Ejemplo n.º 3
0
        internal virtual void WriteEdge(IEdge edge, int edgeId, IDataAttributes<IEdge> edgeData, XmlWriter writer)
        {
            string keyId = null;
            writer.WriteStartElement("edge");

            writer.WriteStartAttribute("id");
            writer.WriteValue(edgeId);
            writer.WriteStartAttribute("source");
            writer.WriteValue(edge.SourceNode.Index);
            writer.WriteStartAttribute("target");
            writer.WriteValue(edge.DestinationNode.Index);
            writer.WriteEndAttribute();

            if (edgeData != null && edgeData.ColumnCount > 0)
            {
                for (int i = 0; i < edgeData.ColumnCount; i++)
                {
                    // get the data key id for the respective data col
                    keyId = EdgeDataKeys[i];
                    WriteEdgeDataElement(keyId, edgeData[edge, i], writer);
                }
            }

            writer.WriteEndElement();
        }
Ejemplo n.º 4
0
        protected virtual void Dispose(bool disposing)
        {
            if (!this._disposed)
            {
                if (disposing)
                {
                    // Dispose managed resources here and free other state (managed objects).
                    _networkChanged = null;
                    IDisposable disposable = _nodeData as IDisposable;
                    if (disposable!=null)
                        disposable.Dispose();
                    _nodeData = null;

                    disposable = _edgeData as IDisposable;
                    if (disposable != null)
                        disposable.Dispose();
                    _edgeData = null;

                    if (_nodes != null)
                    {
                        _nodes.Clear();
                        _nodes = null;
                    }
                    if (_edges != null)
                    {
                        _edges.Clear();
                        _edges = null;
                    }
                }
                // Free your own state (unmanaged objects) and set large fields to null.
            }
            _disposed = true;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Writes out the line of data preceded by the node Id (i.e. vna key), the data attribs written out
 /// are defined by attribColMap
 /// </summary>
 /// <param name="writer">The writer</param>
 /// <param name="node">the node for which to write out the line of data</param>
 /// <param name="nodeData">the node data attribs</param>
 /// <param name="attribColMap">the map of which data attribs to write out</param>
 internal void WriteNodeLine(TextWriter writer, INode node, IDataAttributes<INode> nodeData, IDictionary<int, string> attribColMap, bool exportAttribs)
 {
     if (nodeData == null)
     {
         writer.WriteLine(FormatNode(node));
     }
     else if (!exportAttribs)
     {
         writer.WriteLine(FormatNode(node));
     }
     else if (attribColMap.Count < 5)
     {
         string result = FormatNode(node);
         foreach (var kvp in attribColMap)
         {
             result = string.Format("{0} {1}", result, FormatAttribute(nodeData[node, kvp.Key]));
         }
         writer.WriteLine(result);
     }
     else
     {
         var sb = new StringBuilder();
         sb.Append(FormatNode(node));
         foreach (var kvp in attribColMap)
         {
             sb.Append(" ");
             sb.Append(FormatAttribute(nodeData[node, kvp.Key]));
         }
         writer.WriteLine(sb.ToString());
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Writes out the line of data preceded by the edge Id (i.e. vna key), the data attribs written out
 /// are defined by attribColMap.  This is for writing out a line of data in the *Tie property section.
 /// </summary>
 /// <param name="writer">The writer</param>
 /// <param name="edge">the edge for which to write out the line of data</param>
 /// <param name="edgeData">the edge data attribs</param>
 /// <param name="attribColMap">the map of which data attribs to write out</param>
 internal void WriteEdgePropertySectionLine(TextWriter writer, IEdge edge, IDataAttributes<IEdge> edgeData, IDictionary<int, string> attribColMap, bool exportAttribs)
 {
     if (edgeData == null)
     {
         writer.WriteLine(FormatEdge(edge, false));
     }
     else if (!exportAttribs)
     {
         writer.WriteLine(FormatEdge(edge, false));
     }
     else if (attribColMap.Count < 5)
     {
         string result = FormatEdge(edge, false);
         foreach (var kvp in attribColMap)
         {
             result = string.Format("{0} {1}", result, FormatAttribute(edgeData[edge, kvp.Key]));
         }
         writer.WriteLine(result);
     }
     else
     {
         var sb = new StringBuilder();
         sb.Append(FormatEdge(edge, false));
         foreach (var kvp in attribColMap)
         {
             sb.Append(" ");
             sb.Append(FormatAttribute(edgeData[edge, kvp.Key]));
         }
         writer.WriteLine(sb.ToString());
     }
 }
Ejemplo n.º 7
0
 public IDataAttributeCopier GetCopier(IDataAttributes<IEdge> srcDataAttribs)
 {
     return new DataAttributeTableCopier();
 }