Skip to content

Instantly share code, notes, and snippets.

View ThuCommix's full-sized avatar

Kevin Scholz ThuCommix

View GitHub Profile
using System.Collections.Generic;
using System.Linq;
using Nightingale.Entities;
namespace Nightingale.Sessions
{
/// <summary>
/// Represents a graph node within the <see cref="SessionGraph"/>.
/// </summary>
public class SessionGraphNode
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Nightingale.Entities;
namespace Nightingale.Sessions
{
/// <summary>
/// Represents the session graph which contains the order of the entity hierarchy.
/// </summary>
public class SessionGraph : IEnumerable<Entity>
{
/// <summary>
/// Gets the session graph nodes.
/// </summary>
public List<SessionGraphNode> Nodes { get; }
/// <summary>
/// Initializes a new SessionGraph class.
/// </summary>
/// <summary>
/// Represents a graph node within the <see cref="SessionGraph"/>.
/// </summary>
public class SessionGraphNode
{
/// <summary>
/// Gets the entity for this session graph node.
/// </summary>
public Entity Entity { get; }
private void TraverseSessionGraphNodes(List<SessionGraphNode> nodes, List<Entity> entities)
{
foreach (var sessionGraphNode in nodes)
{
TraverseSessionGraphNodes(sessionGraphNode.Nodes, entities);
entities.Add(sessionGraphNode.Entity);
}
}
<?xml version="1.0" encoding="utf-8" ?>
<Entity Name="Address" Namespace="ConsoleApp1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../ThuCommix.EntityFramework/Entity.xsd">
<Fields>
<Field Name="Person" FieldType="Person" Mandatory="true" Cascade="None" />
<Field Name="IsValid" FieldType="bool" Mandatory="true" Cascade="None" />
<Field Name="ValidFrom" FieldType="DateTime" Mandatory="true" DateOnly="true" Cascade="None" />
<Field Name="ValidTo" FieldType="DateTime" Mandatory="false" DateOnly="false" Cascade="None" />
<Field Name="Zip" FieldType="string" MaxLength="12" Mandatory="true" Cascade="None" />
<Field Name="Town" FieldType="string" MaxLength="50" Mandatory="true" Cascade="None" />
<Field Name="Street" FieldType="string" MaxLength="100" Mandatory="true" Cascade="None" />
<?xml version="1.0" encoding="utf-8" ?>
<Entity Name="Person" Namespace="ConsoleApp1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../ThuCommix.EntityFramework/Entity.xsd">
<Fields>
<Field Name="FirstName" FieldType="string" Mandatory="true" MaxLength="50" Cascade="None" />
<Field Name="Name" FieldType="string" Mandatory="true" MaxLength="50" Cascade="None" />
<Field Name="Age" FieldType="int" Mandatory="false" Cascade="None" />
<Field Name="IsLegalAge" FieldType="bool" Mandatory="false" Cascade="None" />
</Fields>
<ListFields>
<ListField Name="Addresses" FieldType="Address" ReferenceField="Person" Cascade="SaveDelete" />
private void ReadHeader()
{
var reader = new BinaryReader(_stream);
if (ReadChunk(reader) != "RIFF")
{
throw new Exception("Invalid file format.");
}
reader.ReadInt32();
// Copyright (c) 2012-2015 Sharpex2D - Kevin Scholz (ThuCommix)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// Copyright (c) 2012-2015 Sharpex2D - Kevin Scholz (ThuCommix)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in