text:
namespace Evelyn.Core.Tests.ReadModel.EventStream.Handlers
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading;
    using System.Threading.Tasks;
    using AutoFixture;
    using Evelyn.Core.ReadModel.EventStream;
    using Evelyn.Core.ReadModel.EventStream.Handlers;
    using FluentAssertions;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Hosting;
    using Polly;
    using TestStack.BDDfy;
    using Xunit;

    public class EventStreamHandlerSpecs
    {
        private readonly Fixture _dataFixture;
        private readonly ServiceProvider _serviceProvider;
        private CancellationTokenSource _stoppingTokenSource;

        private EventStream _eventStream;
        private EventStreamHandler _eventStreamHandler;
        private StubbedEventHandler _eventHandler;

        private List<EventEnvelope> _eventsAddedToStream;
        private EventEnvelope _eventBeingHandleAtTimeOfSutdownd;
        private Task _eventStreamHandlerStoppingTask;

        public EventStreamHandlerSpecs()
        {
            _dataFixture = new Fixture();
            _eventHandler = new StubbedEventHandler();
            _stoppingTokenSource = new CancellationTokenSource();

            IServiceCollection services = new ServiceCollection();
            services.AddHostedService<EventStreamHandler>();
            services.AddSingleton<IEventStreamFactory, EventStreamFactory>();
            services.AddSingleton<IEventHandler<EventStreamHandler>>(_eventHandler);
            services.AddLogging();

            _serviceProvider = services.BuildServiceProvider();
            _eventStreamHandler = _serviceProvider.GetService<IHostedService>() as EventStreamHandler;
            _eventStream = _serviceProvider.GetService<IEventStreamFactory>().GetEventStream<EventStreamHandler>();

            _eventsAddedToStream = new List<EventEnvelope>();
        }

        [Fact]
        public void EventAddedToStreamBeforeHandlerIsStarted()
        {
            try
            {
                this.Given(_ => _.GivenMultipleEventsAreAddedToTheEventStream())
                    .When(_ => _.WhenTheEventStreamHandlerIsStarted())
                    .Then(_ => _.ThenAllTheEventsAreHandledByTheEventHandlerInTheCorrectOrder())
                    .And(_ => _.ThenThereAreNoQueuedEventsInTheEventStream())
                    .BDDfy();
            }
            finally
            {
                _stoppingTokenSource.Cancel();
            }
        }

        [Fact]
        public void EventAddedToStreamAfterHandlerIsStarted()
        {
            try
            {
                this.Given(_ => _.GivenTheEventStreamHandlerIsStarted())
                    .When(_ => _.WhenAnEventIsAddedToTheEventStream())
                    .Then(_ => _.ThenTheEventIsHandledByTheEventHandler())
                    .And(_ => _.ThenThereAreNoQueuedEventsInTheEventStream())
                    .BDDfy();
            }
            finally
            {
                _stoppingTokenSource.Cancel();
            }
        }

        [Fact]
        public void ExceptionThrownByEventHandler()
        {
            try
            {
                this.Given(_ => _.GivenTheEventStreamHandlerIsStarted())
                    .And(_ => _.GivenTheEventHandlerWillThrowAnException())
                    .When(_ => _.WhenMultipleEventsAreAddedToTheEventStream())
                    .Then(_ => _.ThenTheEventStreamHandlerStops())
                    .BDDfy();
            }
            finally
            {
                _stoppingTokenSource.Cancel();
            }
        }

        [Fact]
        public void StoppingWhenNoEventsInStream()
        {
            try
            {
                this.Given(_ => _.GivenTheEventStreamHandlerIsStarted())
                    .When(_ => _.WhenTheEventStreamHandlerIsStopped())
                    .Then(_ => _.ThenTheEventStreamHandlerStops())
                    .BDDfy();
            }
            finally
            {
                _stoppingTokenSource.Cancel();
            }
        }

        [Fact]
        public void StoppingWhenEventsInStream()
        {
            try
            {
                this.Given(_ => _.GivenTheEventStreamHandlerIsStarted())
                    .And(_ => _.GivenThereAreManyEventsInTheStream())
                    .And(_ => _.GivenTheCurrentEventWillTakeAWhileToBeHandled())
                    .When(_ => _.WhenTheEventStreamHandlerIsStopped())
                    .And(_ => _.WhenTheCurrentEventIsCompleted())
                    .Then(_ => _.ThenTheEventStreamHandlerStops())
                    .And(_ => _.TheEventHandlerDoesntProcessAnyMoreEventsFromTheQueue())
                    .BDDfy();
            }
            finally
            {
                _stoppingTokenSource.Cancel();
            }
        }

        private void GivenTheEventHandlerWillThrowAnException()
        {
            _eventHandler.ThrowOnHandleEventAttempt(1);
        }

        private async Task GivenTheEventStreamHandlerIsStarted()
        {
            await StartEventStreamHandler();
        }

        private void GivenMultipleEventsAreAddedToTheEventStream()
        {
            AddEventsToTheEventStream();
        }

        private void GivenThereAreManyEventsInTheStream()
        {
            AddEventsToTheEventStream(1000);
        }

        private void GivenTheCurrentEventWillTakeAWhileToBeHandled()
        {
            _eventHandler.Block();

            while (_eventBeingHandleAtTimeOfSutdownd == null)
            {
                _eventBeingHandleAtTimeOfSutdownd = _eventHandler.CurrentEvent;
            }
        }

        private async Task WhenTheEventStreamHandlerIsStarted()
        {
            await StartEventStreamHandler();
        }

        private void WhenAnEventIsAddedToTheEventStream()
        {
            var @event = new EventEnvelope(
                _dataFixture.Create<long>(),
                new SomeEvent());

            _eventStream.Enqueue(@event);

            _eventsAddedToStream.Add(@event);
        }

        private void WhenMultipleEventsAreAddedToTheEventStream()
        {
            AddEventsToTheEventStream();
        }

        private void WhenTheCurrentEventIsCompleted()
        {
            _eventHandler.Unblock();
        }

        private void WhenTheEventStreamHandlerIsStopped()
        {
            _eventStreamHandlerStoppingTask = _eventStreamHandler.StopAsync(default);
        }

        private void ThenTheEventIsHandledByTheEventHandler()
        {
            AssertHandledEvents(new[] { _eventsAddedToStream.First() });
        }

        private void ThenAllTheEventsAreHandledByTheEventHandlerInTheCorrectOrder()
        {
            AssertHandledEvents(_eventsAddedToStream);
        }

        private void TheEventHandlerDoesntProcessAnyMoreEventsFromTheQueue()
        {
            AssertLastHandledEvent(_eventBeingHandleAtTimeOfSutdownd);
            _eventHandler.HandledEvents.Count().Should().BeLessThan(_eventsAddedToStream.Count());
        }

        private async Task ThenTheEventStreamHandlerStops()
        {
            if (_eventStreamHandlerStoppingTask != null)
            {
                await _eventStreamHandlerStoppingTask;
            }

            var policy = Policy
                .Handle<Exception>()
                .WaitAndRetry(50, retryAttempt => TimeSpan.FromMilliseconds(10));

            policy.Execute(() =>
            {
                _eventStreamHandler.Status.Should().Be(EventStreamHandlerStatus.Stopped);
            });
        }

        private async Task StartEventStreamHandler()
        {
            await _eventStreamHandler.StartAsync(_stoppingTokenSource.Token);
        }

        private void AddEventsToTheEventStream(int quantity = 2)
        {
            var events = new List<EventEnvelope>();

            int added = 0;
            while (added < quantity)
            {
                events.Add(
                    new EventEnvelope(
                    _dataFixture.Create<long>(),
                    new SomeEvent()));
                added++;
            }

            _eventStream.EnqueueRange(events);
            _eventsAddedToStream.AddRange(events);
        }

        private void AssertHandledEvents(IEnumerable<EventEnvelope> expectedOrderedEvents)
        {
            var policy = Policy
                .Handle<Exception>()
                .WaitAndRetry(50, retryAttempt => TimeSpan.FromMilliseconds(10));

            policy.Execute(() =>
            {
                _eventHandler.HandledEvents.Should().ContainInOrder(expectedOrderedEvents);
            });
        }

        private void AssertLastHandledEvent(EventEnvelope expectedLastHandledEvent)
        {
            var policy = Policy
                .Handle<Exception>()
                .WaitAndRetry(50, retryAttempt => TimeSpan.FromMilliseconds(10));

            policy.Execute(() =>
            {
                _eventHandler.HandledEvents.Last().Should().Be(expectedLastHandledEvent);
            });
        }

        private void ThenThereAreNoQueuedEventsInTheEventStream()
        {
            _eventStream.QueueSize.Should().Be(0);
        }

        private class SomeEvent : CQRSlite.Events.IEvent
        {
            public Guid Id { get; set; }

            public int Version { get; set; }

            public DateTimeOffset TimeStamp { get; set; }
        }

        private class StubbedEventHandler : IEventHandler<EventStreamHandler>
        {
            private int _handleEventAttempt = 0;
            private List<int> _throwOnHandleEventAttempts = new List<int>();
            private List<EventEnvelope> _handledEvents = new List<EventEnvelope>();
            private bool _block = false;

            public IList<EventEnvelope> HandledEvents => _handledEvents;

            public EventEnvelope CurrentEvent { get; private set; }

            public void ThrowOnHandleEventAttempt(int handleEventAttemptNumber)
            {
                _throwOnHandleEventAttempts.Add(handleEventAttemptNumber);
            }

            public void Block()
            {
                _block = true;
            }

            public void Unblock()
            {
                _block = false;
            }

            public async Task HandleEvent(EventEnvelope eventEnvelope, CancellationToken stoppingToken)
            {
                _handleEventAttempt++;

                if (_throwOnHandleEventAttempts.Contains(_handleEventAttempt))
                {
                    throw new Exception("bang");
                }

                while (_block)
                {
                    CurrentEvent = eventEnvelope;
                    await Task.Delay(5);
                }

                await Task.Delay(5);

                CurrentEvent = null;

                _handledEvents.Add(eventEnvelope);
            }
        }
    }
}


text:
Extend [unclead/yii2-multiple-input](https://github.com/unclead/yii2-multiple-input) for related model backend & client validation

Init validation:
Add to model rules:
[['attribute_related'], 'infinitydevphp\MultipleModelValidator\MultipleModelValidator']
And use widget (extend from [\unclead\widgets\MultipleInput](https://github.com/unclead/yii2-multiple-input/blob/master/src/MultipleInput.php)) in form

```php
$options = [];

$form->field($model, 'attribute_name')
    ->widget(\infinitydevphp\MultipleModelValidator\widgets\MultipleInput::className(), $options);
```

# Widget options
| Option name | Type | Description |
| ----------- | ---- | ----------- |
| baseModel | string | base model for create instance next repeater model |
| jsOptions | array/null | event listener for add new row and delete row |
| skipAttributes | array/null | skip attribute on render if not set $columns |

JS options declared two key:
1. afterAddRow: fired after add row
2. afterDeleteRow: fired after delete row

Other options see in [https://github.com/unclead/yii2-multiple-input](base package)

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="utf-8"?>
<!--Generated by crowdin.net-->
<resources>
  <string-array name="toggle">
    <item>Desligado</item>
    <item>Ligado</item>
  </string-array>
  <string-array name="toggleDefault">
    <item>Padrão</item>
    <item>Desligado</item>
    <item>Ligado</item>
  </string-array>
  <string-array name="difficultyLevel">
    <item>Iniciante</item>
    <item>Fácil</item>
    <item>Médio</item>
    <item>Difícil</item>
    <item>Impossível</item>
  </string-array>
  <string-array name="randomize">
    <item>Desligado</item>
    <item>Estático</item>
    <item>Dinâmico</item>
  </string-array>
  <string-array name="gameMode">
    <item>Invertido/Descendo</item>
    <item>Padrão/Subindo</item>
    <item>osu! Mod</item>
    <item>osu! Mod Aleatório</item>
  </string-array>
  <string-array name="noteskin">
    <item>Padrão</item>
    <item>Original</item>
    <item>Personalizado</item>
  </string-array>
  <string-array name="backgroundImage">
    <item>Azul</item>
    <item>Vermelho</item>
    <item>Branco</item>
  </string-array>
  <string-array name="orientation">
    <item>Horizontal</item>
    <item>Vertical</item>
    <item>Automática</item>
  </string-array>
  <string-array name="tapboxLayout">
    <item>Direcional</item>
    <item>Curvado</item>
    <item>Curvado-R</item>
    <item>Padrão</item>
    <item>Tela cheia</item>
  </string-array>
  <string-array name="noteAppearance">
    <item>Visíveis</item>
    <item>Ocultas</item>
    <item>Súbitas</item>
    <item>Invisíveis</item>
  </string-array>
  <string-array name="vibrateMiss">
    <item>Forte</item>
    <item>Fraco</item>
    <item>Desligado</item>
  </string-array>
  <string-array name="accuracyLevel">
    <item>Muito Fácil</item>
    <item>Fácil</item>
    <item>Normal</item>
    <item>Difícil</item>
    <item>Muito Difícil</item>
    <item>Impossível</item>
  </string-array>
  <string-array name="appPriority">
    <item>Normal</item>
    <item>Alta</item>
    <item>Muito alta</item>
    <item>Máxima (Instável)</item>
  </string-array>
</resources>


text:
package kubernetes

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"sync"
	"time"

	"github.com/influxdata/telegraf"
	"github.com/influxdata/telegraf/internal"
	"github.com/influxdata/telegraf/internal/errchan"
	"github.com/influxdata/telegraf/plugins/inputs"
)

// Kubernetes represents the config object for the plugin
type Kubernetes struct {
	URL string

	// Bearer Token authorization file path
	BearerToken string `toml:"bearer_token"`

	// Path to CA file
	SSLCA string `toml:"ssl_ca"`
	// Path to host cert file
	SSLCert string `toml:"ssl_cert"`
	// Path to cert key file
	SSLKey string `toml:"ssl_key"`
	// Use SSL but skip chain & host verification
	InsecureSkipVerify bool

	RoundTripper http.RoundTripper
}

var sampleConfig = `
  ## URL for the kubelet
  url = "http://1.1.1.1:10255"

  ## Use bearer token for authorization
  # bearer_token = /path/to/bearer/token

  ## Optional SSL Config
  # ssl_ca = /path/to/cafile
  # ssl_cert = /path/to/certfile
  # ssl_key = /path/to/keyfile
  ## Use SSL but skip chain & host verification
  # insecure_skip_verify = false
`

const (
	summaryEndpoint = `%s/stats/summary`
)

func init() {
	inputs.Add("kubernetes", func() telegraf.Input {
		return &Kubernetes{}
	})
}

//SampleConfig returns a sample config
func (k *Kubernetes) SampleConfig() string {
	return sampleConfig
}

//Description returns the description of this plugin
func (k *Kubernetes) Description() string {
	return "Read metrics from the kubernetes kubelet api"
}

//Gather collects kubernetes metrics from a given URL
func (k *Kubernetes) Gather(acc telegraf.Accumulator) error {
	var wg sync.WaitGroup
	errChan := errchan.New(1)
	wg.Add(1)
	go func(k *Kubernetes) {
		defer wg.Done()
		errChan.C <- k.gatherSummary(k.URL, acc)
	}(k)
	wg.Wait()
	return errChan.Error()
}

func buildURL(endpoint string, base string) (*url.URL, error) {
	u := fmt.Sprintf(endpoint, base)
	addr, err := url.Parse(u)
	if err != nil {
		return nil, fmt.Errorf("Unable to parse address '%s': %s", u, err)
	}
	return addr, nil
}

func (k *Kubernetes) gatherSummary(baseURL string, acc telegraf.Accumulator) error {
	url := fmt.Sprintf("%s/stats/summary", baseURL)
	var req, err = http.NewRequest("GET", url, nil)
	var token []byte
	var resp *http.Response

	tlsCfg, err := internal.GetTLSConfig(k.SSLCert, k.SSLKey, k.SSLCA, k.InsecureSkipVerify)
	if err != nil {
		return err
	}

	if k.RoundTripper == nil {
		k.RoundTripper = &http.Transport{
			TLSHandshakeTimeout:   5 * time.Second,
			TLSClientConfig:       tlsCfg,
			ResponseHeaderTimeout: time.Duration(3 * time.Second),
		}
	}

	if k.BearerToken != "" {
		token, err = ioutil.ReadFile(k.BearerToken)
		if err != nil {
			return err
		}
		req.Header.Set("Authorization", "Bearer "+string(token))
	}

	resp, err = k.RoundTripper.RoundTrip(req)
	if err != nil {
		return fmt.Errorf("error making HTTP request to %s: %s", url, err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		return fmt.Errorf("%s returned HTTP status %s", url, resp.Status)
	}

	summaryMetrics := &SummaryMetrics{}
	err = json.NewDecoder(resp.Body).Decode(summaryMetrics)
	if err != nil {
		return fmt.Errorf(`Error parsing response: %s`, err)
	}
	buildSystemContainerMetrics(summaryMetrics, acc)
	buildNodeMetrics(summaryMetrics, acc)
	buildPodMetrics(summaryMetrics, acc)
	return nil
}

func buildSystemContainerMetrics(summaryMetrics *SummaryMetrics, acc telegraf.Accumulator) {
	for _, container := range summaryMetrics.Node.SystemContainers {
		tags := map[string]string{
			"node_name":      summaryMetrics.Node.NodeName,
			"container_name": container.Name,
		}
		fields := make(map[string]interface{})
		fields["cpu_usage_nanocores"] = container.CPU.UsageNanoCores
		fields["cpu_usage_core_nanoseconds"] = container.CPU.UsageCoreNanoSeconds
		fields["memory_usage_bytes"] = container.Memory.UsageBytes
		fields["memory_working_set_bytes"] = container.Memory.WorkingSetBytes
		fields["memory_rss_bytes"] = container.Memory.RSSBytes
		fields["memory_page_faults"] = container.Memory.PageFaults
		fields["memory_major_page_faults"] = container.Memory.MajorPageFaults
		fields["rootfs_available_bytes"] = container.RootFS.AvailableBytes
		fields["rootfs_capacity_bytes"] = container.RootFS.CapacityBytes
		fields["logsfs_avaialble_bytes"] = container.LogsFS.AvailableBytes
		fields["logsfs_capacity_bytes"] = container.LogsFS.CapacityBytes
		acc.AddFields("kubernetes_system_container", fields, tags)
	}
}

func buildNodeMetrics(summaryMetrics *SummaryMetrics, acc telegraf.Accumulator) {
	tags := map[string]string{
		"node_name": summaryMetrics.Node.NodeName,
	}
	fields := make(map[string]interface{})
	fields["cpu_usage_nanocores"] = summaryMetrics.Node.CPU.UsageNanoCores
	fields["cpu_usage_core_nanoseconds"] = summaryMetrics.Node.CPU.UsageCoreNanoSeconds
	fields["memory_available_bytes"] = summaryMetrics.Node.Memory.AvailableBytes
	fields["memory_usage_bytes"] = summaryMetrics.Node.Memory.UsageBytes
	fields["memory_working_set_bytes"] = summaryMetrics.Node.Memory.WorkingSetBytes
	fields["memory_rss_bytes"] = summaryMetrics.Node.Memory.RSSBytes
	fields["memory_page_faults"] = summaryMetrics.Node.Memory.PageFaults
	fields["memory_major_page_faults"] = summaryMetrics.Node.Memory.MajorPageFaults
	fields["network_rx_bytes"] = summaryMetrics.Node.Network.RXBytes
	fields["network_rx_errors"] = summaryMetrics.Node.Network.RXErrors
	fields["network_tx_bytes"] = summaryMetrics.Node.Network.TXBytes
	fields["network_tx_errors"] = summaryMetrics.Node.Network.TXErrors
	fields["fs_available_bytes"] = summaryMetrics.Node.FileSystem.AvailableBytes
	fields["fs_capacity_bytes"] = summaryMetrics.Node.FileSystem.CapacityBytes
	fields["fs_used_bytes"] = summaryMetrics.Node.FileSystem.UsedBytes
	fields["runtime_image_fs_available_bytes"] = summaryMetrics.Node.Runtime.ImageFileSystem.AvailableBytes
	fields["runtime_image_fs_capacity_bytes"] = summaryMetrics.Node.Runtime.ImageFileSystem.CapacityBytes
	fields["runtime_image_fs_used_bytes"] = summaryMetrics.Node.Runtime.ImageFileSystem.UsedBytes
	acc.AddFields("kubernetes_node", fields, tags)
}

func buildPodMetrics(summaryMetrics *SummaryMetrics, acc telegraf.Accumulator) {
	for _, pod := range summaryMetrics.Pods {
		for _, container := range pod.Containers {
			tags := map[string]string{
				"node_name":      summaryMetrics.Node.NodeName,
				"namespace":      pod.PodRef.Namespace,
				"container_name": container.Name,
				"pod_name":       pod.PodRef.Name,
			}
			fields := make(map[string]interface{})
			fields["cpu_usage_nanocores"] = container.CPU.UsageNanoCores
			fields["cpu_usage_core_nanoseconds"] = container.CPU.UsageCoreNanoSeconds
			fields["memory_usage_bytes"] = container.Memory.UsageBytes
			fields["memory_working_set_bytes"] = container.Memory.WorkingSetBytes
			fields["memory_rss_bytes"] = container.Memory.RSSBytes
			fields["memory_page_faults"] = container.Memory.PageFaults
			fields["memory_major_page_faults"] = container.Memory.MajorPageFaults
			fields["rootfs_available_bytes"] = container.RootFS.AvailableBytes
			fields["rootfs_capacity_bytes"] = container.RootFS.CapacityBytes
			fields["rootfs_used_bytes"] = container.RootFS.UsedBytes
			fields["logsfs_avaialble_bytes"] = container.LogsFS.AvailableBytes
			fields["logsfs_capacity_bytes"] = container.LogsFS.CapacityBytes
			fields["logsfs_used_bytes"] = container.LogsFS.UsedBytes
			acc.AddFields("kubernetes_pod_container", fields, tags)
		}

		for _, volume := range pod.Volumes {
			tags := map[string]string{
				"node_name":   summaryMetrics.Node.NodeName,
				"pod_name":    pod.PodRef.Name,
				"namespace":   pod.PodRef.Namespace,
				"volume_name": volume.Name,
			}
			fields := make(map[string]interface{})
			fields["available_bytes"] = volume.AvailableBytes
			fields["capacity_bytes"] = volume.CapacityBytes
			fields["used_bytes"] = volume.UsedBytes
			acc.AddFields("kubernetes_pod_volume", fields, tags)
		}

		tags := map[string]string{
			"node_name": summaryMetrics.Node.NodeName,
			"pod_name":  pod.PodRef.Name,
			"namespace": pod.PodRef.Namespace,
		}
		fields := make(map[string]interface{})
		fields["rx_bytes"] = pod.Network.RXBytes
		fields["rx_errors"] = pod.Network.RXErrors
		fields["tx_bytes"] = pod.Network.TXBytes
		fields["tx_errors"] = pod.Network.TXErrors
		acc.AddFields("kubernetes_pod_network", fields, tags)
	}
}


text:
Staging::Conversation::UnlockCondition * Staging::Conversation::UnlockCondition::LoadFromXml(XmlReader *pReader)
{
    if (pReader->ElementExists("FlagSetUnlockCondition"))
    {
        return new Staging::Conversation::FlagSetUnlockCondition(pReader);
    }
    else if (pReader->ElementExists("PartnerPresentUnlockCondition"))
    {
        return new Staging::Conversation::PartnerPresentUnlockCondition(pReader);
    }
    else
    {
        throw MLIException("Unknown unlock condition type.");
    }
}

Staging::Conversation::FlagSetUnlockCondition::FlagSetUnlockCondition(XmlReader *pReader)
{
    pReader->StartElement("FlagSetUnlockCondition");
    FlagId = pReader->ReadTextElement("FlagId");

    if (!CaseContentLoadingStager::GetCurrent()->FlagIdToFlagMap.contains(FlagId))
    {
        CaseContentLoadingStager::GetCurrent()->FlagIdToFlagMap.insert(FlagId, new Flag(FlagId));
    }

    pReader->EndElement();
}

Staging::Conversation::PartnerPresentUnlockCondition::PartnerPresentUnlockCondition(XmlReader *pReader)
{
    pReader->StartElement("PartnerPresentUnlockCondition");
    PartnerId = pReader->ReadTextElement("PartnerId");
    pReader->EndElement();
}

Staging::Conversation::Conversation(XmlReader *pReader)
{
    pReader->StartElement("Conversation");
    LoadFromXmlCore(pReader);
    pReader->EndElement();
}

Staging::Conversation::~Conversation()
{
    for (Action *pAction : ActionList)
    {
        delete pAction;
    }

    ActionList.clear();
}

Staging::Conversation * Staging::Conversation::LoadFromXml(XmlReader *pReader)
{
    if (pReader->ElementExists("Conversation"))
    {
        return new Staging::Conversation(pReader);
    }
    else if (pReader->ElementExists("Interrogation"))
    {
        return new Staging::Interrogation(pReader);
    }
    else if (pReader->ElementExists("Confrontation"))
    {
        return new Staging::Confrontation(pReader);
    }
    else
    {
        throw MLIException("Invalid conversation type.");
    }
}

void Staging::Conversation::AddDialogPaths(QMap<QString, QString> &dialogIdToSavePathMap)
{
    for (Action *pAction : ActionList)
    {
        pAction->AddDialogPaths(dialogIdToSavePathMap);
    }
}

void Staging::Conversation::LoadFromXmlCore(XmlReader *pReader)
{
    if (pReader->ElementExists("Id"))
    {
        Id = pReader->ReadTextElement("Id");
    }

    if (pReader->ElementExists("Name"))
    {
        Name = pReader->ReadTextElement("Name");
    }

    IsEnabled = pReader->ReadBooleanElement("IsEnabled");
    HasBeenCompleted = pReader->ReadBooleanElement("HasBeenCompleted");

    pReader->StartElement("ActionList");
    pReader->StartList("Entry");

    while (pReader->MoveToNextListItem())
    {
        ActionList.push_back(GetActionForNextElement(pReader));
    }

    pReader->EndElement();
}

Staging::Conversation::Action * Staging::Conversation::GetActionForNextElement(XmlReader *pReader)
{
    if (pReader->ElementExists("MultipleCharacterChangeAction"))
    {
        return new MultipleCharacterChangeAction(pReader);
    }
    else if (pReader->ElementExists("CharacterChangeAction"))
    {
        return new CharacterChangeAction(pReader);
    }
    else if (pReader->ElementExists("SetFlagAction"))
    {
        return new SetFlagAction(pReader);
    }
    else if (pReader->ElementExists("BranchOnConditionAction"))
    {
        return new BranchOnConditionAction(pReader);
    }
    else if (pReader->ElementExists("BranchIfTrueAction"))
    {
        return new BranchIfTrueAction(pReader);
    }
    else if (pReader->ElementExists("BranchIfFalseAction"))
    {
        return new BranchIfFalseAction(pReader);
    }
    else if (pReader->ElementExists("EndBranchOnConditionAction"))
    {
        return new EndBranchOnConditionAction(pReader);
    }
    else if (pReader->ElementExists("ShowDialogAction"))
    {
        return new ShowDialogAction(pReader);
    }
    else if (pReader->ElementExists("ShowDialogAutomaticAction"))
    {
        return new ShowDialogAutomaticAction(pReader);
    }
    else if (pReader->ElementExists("MustPresentEvidenceAction"))
    {
        return new MustPresentEvidenceAction(pReader);
    }
    else if (pReader->ElementExists("SkipWrongEvidencePresentedAction"))
    {
        return new SkipWrongEvidencePresentedAction(pReader);
    }
    else if (pReader->ElementExists("BeginWrongEvidencePresentedAction"))
    {
        return new BeginWrongEvidencePresentedAction(pReader);
    }
    else if (pReader->ElementExists("EndWrongEvidencePresentedAction"))
    {
        return new EndWrongEvidencePresentedAction(pReader);
    }
    else if (pReader->ElementExists("SkipEndRequestedAction"))
    {
        return new SkipEndRequestedAction(pReader);
    }
    else if (pReader->ElementExists("BeginEndRequestedAction"))
    {
        return new BeginEndRequestedAction(pReader);
    }
    else if (pReader->ElementExists("EndEndRequestedAction"))
    {
        return new EndEndRequestedAction(pReader);
    }
    else if (pReader->ElementExists("EndMustPresentEvidenceAction"))
    {
        return new EndMustPresentEvidenceAction(pReader);
    }
    else if (pReader->ElementExists("EnableConversationAction"))
    {
        return new EnableConversationAction(pReader);
    }
    else if (pReader->ElementExists("EnableEvidenceAction"))
    {
        return new EnableEvidenceAction(pReader);
    }
    else if (pReader->ElementExists("UpdateEvidenceAction"))
    {
        return new UpdateEvidenceAction(pReader);
    }
    else if (pReader->ElementExists("DisableEvidenceAction"))
    {
        return new DisableEvidenceAction(pReader);
    }
    else if (pReader->ElementExists("EnableCutsceneAction"))
    {
        return new EnableCutsceneAction(pReader);
    }
    else if (pReader->ElementExists("NotificationAction"))
    {
        return new NotificationAction(pReader);
    }
    else if (pReader->ElementExists("PlayBgmAction"))
    {
        return new PlayBgmAction(pReader);
    }
    else if (pReader->ElementExists("PauseBgmAction"))
    {
        return new PauseBgmAction(pReader);
    }
    else if (pReader->ElementExists("ResumeBgmAction"))
    {
        return new ResumeBgmAction(pReader);
    }
    else if (pReader->ElementExists("StopBgmAction"))
    {
        return new StopBgmAction(pReader);
    }
    else if (pReader->ElementExists("PlayAmbianceAction"))
    {
        return new PlayAmbianceAction(pReader);
    }
    else if (pReader->ElementExists("PauseAmbianceAction"))
    {
        return new PauseAmbianceAction(pReader);
    }
    else if (pReader->ElementExists("ResumeAmbianceAction"))
    {
        return new ResumeAmbianceAction(pReader);
    }
    else if (pReader->ElementExists("StopAmbianceAction"))
    {
        return new StopAmbianceAction(pReader);
    }
    else if (pReader->ElementExists("StartAnimationAction"))
    {
        return new StartAnimationAction(pReader);
    }
    else if (pReader->ElementExists("StopAnimationAction"))
    {
        return new StopAnimationAction(pReader);
    }
    else if (pReader->ElementExists("SetPartnerAction"))
    {
        return new SetPartnerAction(pReader);
    }
    else if (pReader->ElementExists("GoToPresentWrongEvidenceAction"))
    {
        return new GoToPresentWrongEvidenceAction(pReader);
    }
    else if (pReader->ElementExists("LockConversationAction"))
    {
        return new LockConversationAction(pReader);
    }
    else if (pReader->ElementExists("ExitEncounterAction"))
    {
        return new ExitEncounterAction(pReader);
    }
    else if (pReader->ElementExists("MoveToLocationAction"))
    {
        return new MoveToLocationAction(pReader);
    }
    else if (pReader->ElementExists("MoveToZoomedViewAction"))
    {
        return new MoveToZoomedViewAction(pReader);
    }
    else if (pReader->ElementExists("EndCaseAction"))
    {
        return new EndCaseAction(pReader);
    }
    else if (pReader->ElementExists("BeginMultipleChoiceAction"))
    {
        return new BeginMultipleChoiceAction(pReader);
    }
    else if (pReader->ElementExists("BeginMultipleChoiceOptionAction"))
    {
        return new BeginMultipleChoiceOptionAction(pReader);
    }
    else if (pReader->ElementExists("ExitMultipleChoiceAction"))
    {
        return new ExitMultipleChoiceAction(pReader);
    }
    else if (pReader->ElementExists("EndMultipleChoiceOptionAction"))
    {
        return new EndMultipleChoiceOptionAction(pReader);
    }
    else if (pReader->ElementExists("EndMultipleChoiceAction"))
    {
        return new EndMultipleChoiceAction(pReader);
    }
    else if (pReader->ElementExists("EnableFastForwardAction"))
    {
        return new EnableFastForwardAction(pReader);
    }
    else if (pReader->ElementExists("DisableFastForwardAction"))
    {
        return new DisableFastForwardAction(pReader);
    }
    else if (pReader->ElementExists("BeginBreakdownAction"))
    {
        return new BeginBreakdownAction(pReader);
    }
    else if (pReader->ElementExists("EndBreakdownAction"))
    {
        return new EndBreakdownAction(pReader);
    }
    else
    {
        throw MLIException("Unknown action type.");
    }
}

Staging::Conversation::MultipleCharacterChangeAction::MultipleCharacterChangeAction(XmlReader *pReader)
{
    pReader->StartElement("MultipleCharacterChangeAction");

    pReader->StartElement("CharacterChangeList");
    pReader->StartList("Entry");

    while (pReader->MoveToNextListItem())
    {
        CharacterChangeList.push_back(new CharacterChangeAction(pReader));
    }

    pReader->EndElement();

    pReader->EndElement();
}

Staging::Conversation::MultipleCharacterChangeAction::~MultipleCharacterChangeAction()
{
    for (CharacterChangeAction *pCharacterChangeAction : CharacterChangeList)
    {
        delete pCharacterChangeAction;
    }

    CharacterChangeList.clear();
}

Staging::Conversation::CharacterChangeAction::CharacterChangeAction(XmlReader *pReader)
{
    pReader->StartElement("CharacterChangeAction");
    Position = StringToCharacterPosition(pReader->ReadTextElement("Position"));
    CharacterIdToChangeTo = pReader->ReadTextElement("CharacterIdToChangeTo");

    if (CharacterIdToChangeTo == "None")
    {
        CharacterIdToChangeTo = "";
    }

    InitialEmotionId = pReader->ReadTextElement("InitialEmotionId");

    if (pReader->ElementExists("SfxId"))
    {
        SfxId = pReader->ReadTextElement("SfxId");
    }

    pReader->EndElement();
}

Staging::Conversation::SetFlagAction::SetFlagAction(XmlReader *pReader)
{
    pReader->StartElement("SetFlagAction");
    FlagId = pReader->ReadTextElement("FlagId");

    if (!CaseContentLoadingStager::GetCurrent()->FlagIdToFlagMap.contains(FlagId))
    {
        CaseContentLoadingStager::GetCurrent()->FlagIdToFlagMap.insert(FlagId, new Flag(FlagId));
    }

    pReader->EndElement();
}

Staging::Conversation::BranchOnConditionAction::BranchOnConditionAction(XmlReader *pReader)
{
    pReader->StartElement("BranchOnConditionAction");

    pReader->StartElement("Condition");
    pCondition = new Condition(pReader);
    pReader->EndElement();

    TrueIndex = pReader->ReadIntElement("TrueIndex");
    FalseIndex = pReader->ReadIntElement("FalseIndex");
    pReader->EndElement();
}

Staging::Conversation::BranchOnConditionAction::~BranchOnConditionAction()
{
    delete pCondition;
    pCondition = NULL;
}

Staging::Conversation::BranchIfTrueAction::BranchIfTrueAction(XmlReader *pReader)
{
    pReader->StartElement("BranchIfTrueAction");
    EndIndex = pReader->ReadIntElement("EndIndex");
    pReader->EndElement();
}

Staging::Conversation::BranchIfFalseAction::BranchIfFalseAction(XmlReader *pReader)
{
    pReader->StartElement("BranchIfFalseAction");
    EndIndex = pReader->ReadIntElement("EndIndex");
    pReader->EndElement();
}

Staging::Conversation::EndBranchOnConditionAction::EndBranchOnConditionAction(XmlReader *pReader)
{
    pReader->StartElement("EndBranchOnConditionAction");
    pReader->EndElement();
}

void Staging::Conversation::ShowDialogAction::AddDialogPaths(QMap<QString, QString> &dialogIdToSavePathMap)
{
    if (FilePath.length() > 0)
    {
        dialogIdToSavePathMap[Id] = FilePath;
    }
}

void Staging::Conversation::ShowDialogAction::LoadFromXmlCore(XmlReader *pReader)
{
    Id = pReader->ReadTextElement("Id");

    SpeakerPosition = StringToCharacterPosition(pReader->ReadTextElement("SpeakerPosition"));
    RawDialog = pReader->ReadTextElement("RawDialog");

    if (pReader->ElementExists("FilePath"))
    {
        FilePath = pReader->ReadTextElement("FilePath");
    }

    LeadInTime = pReader->ReadIntElement("LeadInTime");

    if (pReader->ElementExists("CharacterId"))
    {
        CharacterId = pReader->ReadTextElement("CharacterId");
    }

    IsInConfrontation = pReader->ReadBooleanElement("IsInConfrontation");
}

Staging::Conversation::ShowDialogAction::ShowDialogAction(XmlReader *pReader)
{
    pReader->StartElement("ShowDialogAction");
    LoadFromXmlCore(pReader);
    pReader->EndElement();
}

Staging::Conversation::ShowDialogAutomaticAction::ShowDialogAutomaticAction(XmlReader *pReader)
{
    pReader->StartElement("ShowDialogAutomaticAction");
    LoadFromXmlCore(pReader);
    DelayBeforeContinuing = pReader->ReadIntElement("DelayBeforeContinuing");
    pReader->EndElement();
}

void Staging::Conversation::MustPresentEvidenceAction::LoadFromXmlCore(XmlReader *pReader)
{
    ShowDialogAction::LoadFromXmlCore(pReader);

    pReader->StartElement("CorrectEvidenceIdList");
    pReader->StartList("Entry");

    while (pReader->MoveToNextListItem())
    {
        CorrectEvidenceIdList.push_back(pReader->ReadTextElement("CorrectEvidenceId"));
    }

    pReader->EndElement();

    CorrectEvidencePresentedIndex = pReader->ReadIntElement("CorrectEvidencePresentedIndex");
    WrongEvidencePresentedIndex = pReader->ReadIntElement("WrongEvidencePresentedIndex");
    EndRequestedIndex = pReader->ReadIntElement("EndRequestedIndex");
}

Staging::Conversation::MustPresentEvidenceAction::MustPresentEvidenceAction(XmlReader *pReader)
{
    pReader->StartElement("MustPresentEvidenceAction");
    LoadFromXmlCore(pReader);
    pReader->EndElement();
}

Staging::Conversation::SkipWrongEvidencePresentedAction::SkipWrongEvidencePresentedAction(XmlReader *pReader)
{
    pReader->StartElement("SkipWrongEvidencePresentedAction");
    AfterWrongEvidencePresentedIndex = pReader->ReadIntElement("AfterWrongEvidencePresentedIndex");
    pReader->EndElement();
}

Staging::Conversation::BeginWrongEvidencePresentedAction::BeginWrongEvidencePresentedAction(XmlReader *pReader)
{
    pReader->StartElement("BeginWrongEvidencePresentedAction");
    pReader->EndElement();
}

Staging::Conversation::EndWrongEvidencePresentedAction::EndWrongEvidencePresentedAction(XmlReader *pReader)
{
    pReader->StartElement("EndWrongEvidencePresentedAction");
    pReader->EndElement();
}

Staging::Conversation::SkipEndRequestedAction::SkipEndRequestedAction(XmlReader *pReader)
{
    pReader->StartElement("SkipEndRequestedAction");
    AfterEndRequestedIndex = pReader->ReadIntElement("AfterEndRequestedIndex");
    pReader->EndElement();
}

Staging::Conversation::BeginEndRequestedAction::BeginEndRequestedAction(XmlReader *pReader)
{
    pReader->StartElement("BeginEndRequestedAction");
    pReader->EndElement();
}

Staging::Conversation::EndEndRequestedAction::EndEndRequestedAction(XmlReader *pReader)
{
    pReader->StartElement("EndEndRequestedAction");
    pReader->EndElement();
}

Staging::Conversation::EndMustPresentEvidenceAction::EndMustPresentEvidenceAction(XmlReader *pReader)
{
    pReader->StartElement("EndMustPresentEvidenceAction");
    pReader->EndElement();
}

Staging::Conversation::EnableConversationAction::EnableConversationAction(XmlReader *pReader)
{
    pReader->StartElement("EnableConversationAction");
    ConversationId = pReader->ReadTextElement("ConversationId");
    pReader->EndElement();
}

Staging::Conversation::EnableEvidenceAction::EnableEvidenceAction(XmlReader *pReader)
{
    pReader->StartElement("EnableEvidenceAction");
    EvidenceId = pReader->ReadTextElement("EvidenceId");
    pReader->EndElement();
}

Staging::Conversation::UpdateEvidenceAction::UpdateEvidenceAction(XmlReader *pReader)
{
    pReader->StartElement("UpdateEvidenceAction");
    EvidenceId = pReader->ReadTextElement("EvidenceId");
    NewEvidenceId = pReader->ReadTextElement("NewEvidenceId");
    pReader->EndElement();
}

Staging::Conversation::DisableEvidenceAction::DisableEvidenceAction(XmlReader *pReader)
{
    pReader->StartElement("DisableEvidenceAction");
    EvidenceId = pReader->ReadTextElement("EvidenceId");
    pReader->EndElement();
}

Staging::Conversation::EnableCutsceneAction::EnableCutsceneAction(XmlReader *pReader)
{
    pReader->StartElement("EnableCutsceneAction");
    CutsceneId = pReader->ReadTextElement("CutsceneId");
    pReader->EndElement();
}

Staging::Conversation::NotificationAction::NotificationAction(XmlReader *pReader)
{
    pReader->StartElement("NotificationAction");
    RawNotificationText = pReader->ReadTextElement("RawNotificationText");

    if (pReader->ElementExists("PartnerId"))
    {
        PartnerId = pReader->ReadTextElement("PartnerId");
    }

    if (pReader->ElementExists("OldEvidenceId"))
    {
        OldEvidenceId = pReader->ReadTextElement("OldEvidenceId");
    }

    if (pReader->ElementExists("NewEvidenceId"))
    {
        NewEvidenceId = pReader->ReadTextElement("NewEvidenceId");
    }

    pReader->EndElement();
}

Staging::Conversation::PlayBgmAction::PlayBgmAction(XmlReader *pReader)
{
    pReader->StartElement("PlayBgmAction");
    BgmId = pReader->ReadTextElement("BgmId");
    PreserveBgm = pReader->ReadBooleanElement("PreserveBgm");
    pReader->EndElement();
}

Staging::Conversation::PauseBgmAction::PauseBgmAction(XmlReader *pReader)
{
    pReader->StartElement("PauseBgmAction");
    pReader->EndElement();
}

Staging::Conversation::ResumeBgmAction::ResumeBgmAction(XmlReader *pReader)
{
    pReader->StartElement("ResumeBgmAction");
    pReader->EndElement();
}

Staging::Conversation::StopBgmAction::StopBgmAction(XmlReader *pReader)
{
    pReader->StartElement("StopBgmAction");
    IsInstant = pReader->ReadBooleanElement("IsInstant");
    PreserveBgm = pReader->ReadBooleanElement("PreserveBgm");
    pReader->EndElement();
}

Staging::Conversation::PlayAmbianceAction::PlayAmbianceAction(XmlReader *pReader)
{
    pReader->StartElement("PlayAmbianceAction");
    AmbianceSfxId = pReader->ReadTextElement("AmbianceSfxId");
    PreserveAmbiance = pReader->ReadBooleanElement("PreserveAmbiance");
    pReader->EndElement();
}

Staging::Conversation::PauseAmbianceAction::PauseAmbianceAction(XmlReader *pReader)
{
    pReader->StartElement("PauseAmbianceAction");
    pReader->EndElement();
}

Staging::Conversation::ResumeAmbianceAction::ResumeAmbianceAction(XmlReader *pReader)
{
    pReader->StartElement("ResumeAmbianceAction");
    pReader->EndElement();
}

Staging::Conversation::StopAmbianceAction::StopAmbianceAction(XmlReader *pReader)
{
    pReader->StartElement("StopAmbianceAction");
    IsInstant = pReader->ReadBooleanElement("IsInstant");
    PreserveAmbiance = pReader->ReadBooleanElement("PreserveAmbiance");
    pReader->EndElement();
}

Staging::Conversation::StartAnimationAction::StartAnimationAction(XmlReader *pReader)
{
    pReader->StartElement("StartAnimationAction");
    AnimationId = pReader->ReadTextElement("AnimationId");
    pReader->EndElement();
}

Staging::Conversation::StopAnimationAction::StopAnimationAction(XmlReader *pReader)
{
    pReader->StartElement("StopAnimationAction");
    pReader->EndElement();
}

Staging::Conversation::SetPartnerAction::SetPartnerAction(XmlReader *pReader)
{
    pReader->StartElement("SetPartnerAction");
    PartnerId = pReader->ReadTextElement("PartnerId");
    pReader->EndElement();
}

Staging::Conversation::GoToPresentWrongEvidenceAction::GoToPresentWrongEvidenceAction(XmlReader *pReader)
{
    pReader->StartElement("GoToPresentWrongEvidenceAction");
    pReader->EndElement();
}

Staging::Conversation::LockConversationAction::LockConversationAction(XmlReader *pReader)
{
    pReader->StartElement("LockConversationAction");

    pReader->StartElement("UnlockCondition");
    pUnlockCondition = Conversation::UnlockCondition::LoadFromXml(pReader);
    pReader->EndElement();

    pReader->EndElement();
}

Staging::Conversation::LockConversationAction::~LockConversationAction()
{
    delete pUnlockCondition;
    pUnlockCondition = NULL;
}

Staging::Conversation::ExitEncounterAction::ExitEncounterAction(XmlReader *pReader)
{
    pReader->StartElement("ExitEncounterAction");
    pReader->EndElement();
}

Staging::Conversation::MoveToLocationAction::MoveToLocationAction(XmlReader *pReader)
{
    pReader->StartElement("MoveToLocationAction");
    NewAreaId = pReader->ReadTextElement("NewAreaId");
    NewLocationId = pReader->ReadTextElement("NewLocationId");
    TransitionId = pReader->ReadTextElement("TransitionId");
    pReader->EndElement();
}

Staging::Conversation::MoveToZoomedViewAction::MoveToZoomedViewAction(XmlReader *pReader)
{
    pReader->StartElement("MoveToZoomedViewAction");
    ZoomedViewId = pReader->ReadTextElement("ZoomedViewId");
    pReader->EndElement();
}

Staging::Conversation::EndCaseAction::EndCaseAction(XmlReader *pReader)
{
    pReader->StartElement("EndCaseAction");
    CompletesCase = pReader->ReadBooleanElement("CompletesCase");
    pReader->EndElement();
}

Staging::Conversation::BeginMultipleChoiceAction::BeginMultipleChoiceAction(XmlReader *pReader)
{
    pReader->StartElement("BeginMultipleChoiceAction");

    pReader->StartElement("OptionTexts");
    pReader->StartList("Entry");

    while (pReader->MoveToNextListItem())
    {
        OptionTexts.push_back(pReader->ReadTextElement("Text"));
    }

    pReader->EndElement();

    pReader->StartElement("OptionIndexes");
    pReader->StartList("Entry");

    while (pReader->MoveToNextListItem())
    {
        OptionIndexes.push_back(pReader->ReadIntElement("Index"));
    }

    pReader->EndElement();

    pReader->EndElement();

    if (OptionTexts.size() != OptionIndexes.size())
    {
        throw MLIException("OptionTexts and OptionIndexes must be the same size.");
    }
}

Staging::Conversation::BeginMultipleChoiceOptionAction::BeginMultipleChoiceOptionAction(XmlReader *pReader)
{
    pReader->StartElement("BeginMultipleChoiceOptionAction");
    pReader->EndElement();
}

Staging::Conversation::ExitMultipleChoiceAction::ExitMultipleChoiceAction(XmlReader *pReader)
{
    pReader->StartElement("ExitMultipleChoiceAction");
    ExitIndex = pReader->ReadIntElement("ExitIndex");
    pReader->EndElement();
}

Staging::Conversation::EndMultipleChoiceOptionAction::EndMultipleChoiceOptionAction(XmlReader *pReader)
{
    pReader->StartElement("EndMultipleChoiceOptionAction");
    StartIndex = pReader->ReadIntElement("StartIndex");
    pReader->EndElement();
}

Staging::Conversation::EndMultipleChoiceAction::EndMultipleChoiceAction(XmlReader *pReader)
{
    pReader->StartElement("EndMultipleChoiceAction");
    pReader->EndElement();
}

Staging::Conversation::EnableFastForwardAction::EnableFastForwardAction(XmlReader *pReader)
{
    pReader->StartElement("EnableFastForwardAction");
    pReader->EndElement();
}

Staging::Conversation::DisableFastForwardAction::DisableFastForwardAction(XmlReader *pReader)
{
    pReader->StartElement("DisableFastForwardAction");
    pReader->EndElement();
}

Staging::Conversation::BeginBreakdownAction::BeginBreakdownAction(XmlReader *pReader)
{
    pReader->StartElement("BeginBreakdownAction");
    CharacterPositionValue = StringToCharacterPosition(pReader->ReadTextElement("CharacterPosition"));
    pReader->EndElement();
}

Staging::Conversation::EndBreakdownAction::EndBreakdownAction(XmlReader *pReader)
{
    pReader->StartElement("EndBreakdownAction");
    pReader->EndElement();
}

Staging::Interrogation::Interrogation(XmlReader *pReader)
{
    pReader->StartElement("Interrogation");
    LoadFromXmlCore(pReader);
    pReader->EndElement();
}

Staging::Conversation::Action * Staging::Interrogation::GetActionForNextElement(XmlReader *pReader)
{
    if (pReader->ElementExists("BeginInterrogationRepeatAction"))
    {
        return new BeginInterrogationRepeatAction(pReader);
    }
    else if (pReader->ElementExists("ShowInterrogationAction"))
    {
        return new ShowInterrogationAction(pReader);
    }
    else if (pReader->ElementExists("BeginPressForInfoAction"))
    {
        return new BeginPressForInfoAction(pReader);
    }
    else if (pReader->ElementExists("EndPressForInfoAction"))
    {
        return new EndPressForInfoAction(pReader);
    }
    else if (pReader->ElementExists("BeginPresentEvidenceAction"))
    {
        return new BeginPresentEvidenceAction(pReader);
    }
    else if (pReader->ElementExists("EndPresentEvidenceAction"))
    {
        return new EndPresentEvidenceAction(pReader);
    }
    else if (pReader->ElementExists("BeginUsePartnerAction"))
    {
        return new BeginUsePartnerAction(pReader);
    }
    else if (pReader->ElementExists("EndUsePartnerAction"))
    {
        return new EndUsePartnerAction(pReader);
    }
    else if (pReader->ElementExists("EndShowInterrogationBranchesAction"))
    {
        return new EndShowInterrogationBranchesAction(pReader);
    }
    else if (pReader->ElementExists("ExitInterrogationRepeatAction"))
    {
        return new ExitInterrogationRepeatAction(pReader);
    }
    else if (pReader->ElementExists("SkipWrongPartnerUsedAction"))
    {
        return new SkipWrongPartnerUsedAction(pReader);
    }
    else if (pReader->ElementExists("BeginWrongPartnerUsedAction"))
    {
        return new BeginWrongPartnerUsedAction(pReader);
    }
    else if (pReader->ElementExists("EndWrongPartnerUsedAction"))
    {
        return new EndWrongPartnerUsedAction(pReader);
    }
    else if (pReader->ElementExists("EndInterrogationRepeatAction"))
    {
        return new EndInterrogationRepeatAction(pReader);
    }
    else
    {
        return Conversation::GetActionForNextElement(pReader);
    }
}

Staging::Interrogation::BeginInterrogationRepeatAction::BeginInterrogationRepeatAction(XmlReader *pReader)
{
    pReader->StartElement("BeginInterrogationRepeatAction");
    pReader->EndElement();
}

void Staging::Interrogation::ShowInterrogationAction::LoadFromXmlCore(XmlReader *pReader)
{
    Conversation::ShowDialogAction::LoadFromXmlCore(pReader);
    pReader->StartElement("EvidencePresentedIndexes");
    pReader->StartList("Entry");

    while (pReader->MoveToNextListItem())
    {
        QString evidenceId = pReader->ReadTextElement("EvidenceId");
        int index = pReader->ReadIntElement("Index");
        EvidencePresentedIndexes[evidenceId] = index;
    }

    pReader->EndElement();

    pReader->StartElement("PartnerUsedIndexes");
    pReader->StartList("Entry");

    while (pReader->MoveToNextListItem())
    {
        QString partnerId = pReader->ReadTextElement("PartnerId");
        int index = pReader->ReadIntElement("Index");
        PartnerUsedIndexes[partnerId] = index;
    }

    pReader->EndElement();

    if (pReader->ElementExists("ConditionFlag"))
    {
        ConditionFlag = pReader->ReadTextElement("ConditionFlag");
    }

    PreviousInterrogationIndex = pReader->ReadIntElement("PreviousInterrogationIndex");
    NextInterrogationIndex = pReader->ReadIntElement("NextInterrogationIndex");
    InterrogationFinishIndex = pReader->ReadIntElement("InterrogationFinishIndex");
    PressForInfoIndex = pReader->ReadIntElement("PressForInfoIndex");
    WrongEvidencePresentedIndex = pReader->ReadIntElement("WrongEvidencePresentedIndex");
    WrongPartnerUsedIndex = pReader->ReadIntElement("WrongPartnerUsedIndex");
    EndRequestedIndex = pReader->ReadIntElement("EndRequestedIndex");
}

Staging::Interrogation::ShowInterrogationAction::ShowInterrogationAction(XmlReader *pReader)
{
    pReader->StartElement("ShowInterrogationAction");
    LoadFromXmlCore(pReader);
    pReader->EndElement();
}

Staging::Interrogation::BeginPressForInfoAction::BeginPressForInfoAction(XmlReader *pReader)
{
    pReader->StartElement("BeginPressForInfoAction");
    pReader->EndElement();
}

Staging::Interrogation::EndPressForInfoAction::EndPressForInfoAction(XmlReader *pReader)
{
    pReader->StartElement("EndPressForInfoAction");
    NextDialogIndex = pReader->ReadIntElement("NextDialogIndex");
    pReader->EndElement();
}

Staging::Interrogation::BeginPresentEvidenceAction::BeginPresentEvidenceAction(XmlReader *pReader)
{
    pReader->StartElement("BeginPresentEvidenceAction");
    pReader->EndElement();
}

Staging::Interrogation::EndPresentEvidenceAction::EndPresentEvidenceAction(XmlReader *pReader)
{
    pReader->StartElement("EndPresentEvidenceAction");
    NextDialogIndex = pReader->ReadIntElement("NextDialogIndex");
    pReader->EndElement();
}

Staging::Interrogation::BeginUsePartnerAction::BeginUsePartnerAction(XmlReader *pReader)
{
    pReader->StartElement("BeginUsePartnerAction");
    pReader->EndElement();
}

Staging::Interrogation::EndUsePartnerAction::EndUsePartnerAction(XmlReader *pReader)
{
    pReader->StartElement("EndUsePartnerAction");
    NextDialogIndex = pReader->ReadIntElement("NextDialogIndex");
    pReader->EndElement();
}

Staging::Interrogation::EndShowInterrogationBranchesAction::EndShowInterrogationBranchesAction(XmlReader *pReader)
{
    pReader->StartElement("EndShowInterrogationBranchesAction");
    pReader->EndElement();
}

Staging::Interrogation::ExitInterrogationRepeatAction::ExitInterrogationRepeatAction(XmlReader *pReader)
{
    pReader->StartElement("ExitInterrogationRepeatAction");
    AfterEndInterrogationRepeatIndex = pReader->ReadIntElement("AfterEndInterrogationRepeatIndex");
    pReader->EndElement();
}

Staging::Interrogation::SkipWrongPartnerUsedAction::SkipWrongPartnerUsedAction(XmlReader *pReader)
{
    pReader->StartElement("SkipWrongPartnerUsedAction");
    AfterWrongPartnerUsedIndex = pReader->ReadIntElement("AfterWrongPartnerUsedIndex");
    pReader->EndElement();
}

Staging::Interrogation::BeginWrongPartnerUsedAction::BeginWrongPartnerUsedAction(XmlReader *pReader)
{
    pReader->StartElement("BeginWrongPartnerUsedAction");
    pReader->EndElement();
}

Staging::Interrogation::EndWrongPartnerUsedAction::EndWrongPartnerUsedAction(XmlReader *pReader)
{
    pReader->StartElement("EndWrongPartnerUsedAction");
    pReader->EndElement();
}

Staging::Interrogation::EndInterrogationRepeatAction::EndInterrogationRepeatAction(XmlReader *pReader)
{
    pReader->StartElement("EndInterrogationRepeatAction");
    BeginInterrogationRepeatIndex = pReader->ReadIntElement("BeginInterrogationRepeatIndex");
    pReader->EndElement();
}

Staging::Confrontation::Topic::Topic(XmlReader *pReader)
{
    pReader->StartElement("ConfrontationTopic");

    if (pReader->ElementExists("Id"))
    {
        Id = pReader->ReadTextElement("Id");
    }

    if (pReader->ElementExists("Name"))
    {
        Name = pReader->ReadTextElement("Name");
    }

    ActionIndex = pReader->ReadIntElement("ActionIndex");
    IsEnabled = pReader->ReadBooleanElement("IsEnabled");

    pReader->EndElement();
}

Staging::Confrontation::Confrontation(XmlReader *pReader)
{
    pReader->StartElement("Confrontation");
    LoadFromXmlCore(pReader);
    pReader->EndElement();
}

void Staging::Confrontation::LoadFromXmlCore(XmlReader *pReader)
{
    Interrogation::LoadFromXmlCore(pReader);

    pReader->StartElement("ConfrontationTopicNamesById");
    pReader->StartList("Entry");

    while (pReader->MoveToNextListItem())
    {
        QString id = pReader->ReadTextElement("Id");
        QString confrontationTopicName = pReader->ReadTextElement("ConfrontationTopicName");
        ConfrontationTopicNamesById[id] = confrontationTopicName;
    }

    pReader->EndElement();
}

Staging::Conversation::Action * Staging::Confrontation::GetActionForNextElement(XmlReader *pReader)
{
    if (pReader->ElementExists("SetParticipantsAction"))
    {
        return new SetParticipantsAction(pReader);
    }
    else if (pReader->ElementExists("SetIconOffsetAction"))
    {
        return new SetIconOffsetAction(pReader);
    }
    else if (pReader->ElementExists("SetHealthAction"))
    {
        return new SetHealthAction(pReader);
    }
    else if (pReader->ElementExists("InitializeBeginConfrontationTopicSelectionAction"))
    {
        return new InitializeBeginConfrontationTopicSelectionAction(pReader);
    }
    else if (pReader->ElementExists("BeginConfrontationTopicSelectionAction"))
    {
        return new BeginConfrontationTopicSelectionAction(pReader);
    }
    else if (pReader->ElementExists("BeginConfrontationTopicAction"))
    {
        return new BeginConfrontationTopicAction(pReader);
    }
    else if (pReader->ElementExists("EndConfrontationTopicAction"))
    {
        return new EndConfrontationTopicAction(pReader);
    }
    else if (pReader->ElementExists("SkipPlayerDefeatedAction"))
    {
        return new SkipPlayerDefeatedAction(pReader);
    }
    else if (pReader->ElementExists("BeginPlayerDefeatedAction"))
    {
        return new BeginPlayerDefeatedAction(pReader);
    }
    else if (pReader->ElementExists("EndPlayerDefeatedAction"))
    {
        return new EndPlayerDefeatedAction(pReader);
    }
    else if (pReader->ElementExists("EndConfrontationTopicSelectionAction"))
    {
        return new EndConfrontationTopicSelectionAction(pReader);
    }
    else if (pReader->ElementExists("EnableTopicAction"))
    {
        return new EnableTopicAction(pReader);
    }
    else if (pReader->ElementExists("RestartConfrontationAction"))
    {
        return new RestartConfrontationAction(pReader);
    }
    else
    {
        return Interrogation::GetActionForNextElement(pReader);
    }
}

Staging::Confrontation::SetParticipantsAction::SetParticipantsAction(XmlReader *pReader)
{
    pReader->StartElement("SetParticipantsAction");
    PlayerCharacterId = pReader->ReadTextElement("PlayerCharacterId");
    OpponentCharacterId = pReader->ReadTextElement("OpponentCharacterId");
    pReader->EndElement();
}

Staging::Confrontation::SetIconOffsetAction::SetIconOffsetAction(XmlReader *pReader)
{
    pReader->StartElement("SetIconOffsetAction");

    pReader->StartElement("Offset");
    Offset = Vector2(pReader);
    pReader->EndElement();

    IsPlayer = pReader->ReadBooleanElement("IsPlayer");
    pReader->EndElement();
}

Staging::Confrontation::SetHealthAction::SetHealthAction(XmlReader *pReader)
{
    pReader->StartElement("SetHealthAction");
    InitialHealth = pReader->ReadIntElement("InitialHealth");
    IsPlayer = pReader->ReadBooleanElement("IsPlayer");
    pReader->EndElement();
}

Staging::Confrontation::InitializeBeginConfrontationTopicSelectionAction::InitializeBeginConfrontationTopicSelectionAction(XmlReader *pReader)
{
    pReader->StartElement("InitializeBeginConfrontationTopicSelectionAction");
    pReader->EndElement();
}

Staging::Confrontation::BeginConfrontationTopicSelectionAction::BeginConfrontationTopicSelectionAction(XmlReader *pReader)
{
    pInitialTopic = NULL;
    InitialTopicIsEnabled = false;

    pReader->StartElement("BeginConfrontationTopicSelectionAction");
    PlayerDefeatedIndex = pReader->ReadIntElement("PlayerDefeatedIndex");
    EndActionIndex = pReader->ReadIntElement("EndActionIndex");

    if (pReader->ElementExists("InitialTopic"))
    {
        pReader->StartElement("InitialTopic");
        pInitialTopic = new Confrontation::Topic(pReader);
        InitialTopicIsEnabled = pInitialTopic->IsEnabled;
        pReader->EndElement();
    }

    pReader->StartElement("TopicList");
    pReader->StartList("Entry");

    while (pReader->MoveToNextListItem())
    {
        Confrontation::Topic *pTopic = new Confrontation::Topic(pReader);
        TopicList.push_back(pTopic);
        TopicToInitialEnabledStateMap[pTopic] = pInitialTopic->IsEnabled;
    }

    pReader->EndElement();

    pReader->EndElement();
}

Staging::Confrontation::BeginConfrontationTopicAction::BeginConfrontationTopicAction(XmlReader *pReader)
{
    pReader->StartElement("BeginConfrontationTopicAction");
    pReader->EndElement();
}

Staging::Confrontation::EndConfrontationTopicAction::EndConfrontationTopicAction(XmlReader *pReader)
{
    pReader->StartElement("EndConfrontationTopicAction");
    BeginConfrontationTopicSelectionActionIndex = pReader->ReadIntElement("BeginConfrontationTopicSelectionActionIndex");
    pReader->EndElement();
}

Staging::Confrontation::SkipPlayerDefeatedAction::SkipPlayerDefeatedAction(XmlReader *pReader)
{
    pReader->StartElement("SkipPlayerDefeatedAction");
    SkipToIndex = pReader->ReadIntElement("SkipToIndex");
    pReader->EndElement();
}

Staging::Confrontation::BeginPlayerDefeatedAction::BeginPlayerDefeatedAction(XmlReader *pReader)
{
    pReader->StartElement("BeginPlayerDefeatedAction");
    pReader->EndElement();
}

Staging::Confrontation::EndPlayerDefeatedAction::EndPlayerDefeatedAction(XmlReader *pReader)
{
    pReader->StartElement("EndPlayerDefeatedAction");
    pReader->EndElement();
}

Staging::Confrontation::EndConfrontationTopicSelectionAction::EndConfrontationTopicSelectionAction(XmlReader *pReader)
{
    pReader->StartElement("EndConfrontationTopicSelectionAction");
    pReader->EndElement();
}

Staging::Confrontation::EnableTopicAction::EnableTopicAction(XmlReader *pReader)
{
    pReader->StartElement("EnableTopicAction");
    TopicId = pReader->ReadTextElement("TopicId");
    pReader->EndElement();
}

Staging::Confrontation::RestartConfrontationAction::RestartConfrontationAction(XmlReader *pReader)
{
    pReader->StartElement("RestartConfrontationAction");
    pReader->EndElement();
}


text:
<!DOCTYPE html>

  <title>My DBC Website</title>
  <meta charset="UTF-8">
  <link rel="stylesheet" type="text/css" href="../Stylesheets/default.css">

Thinking Style

01/10/2015

    In my Pre-Phase 0 work, I learned that my Gregoric Thinking is almost entirely Concrete Random (CR). Before writing this blog entry I re-read the characteristics of a CR thinker. I couldn't agree more. I think in some aspects of my life I might fall into multiple categories. But not for coding. My thinking style is definitely an advantage but probably equally a disadvantage. I think the most advantagious would be the ability to take on other characteristics when needed. But I'll just focus on the advantages I naturally have with me thinking style in regards to my Phase 0 experience.

   The biggest advatage is my ability to experiment and use trial-and-error. In Phase 0 I have been doing a lot of this. And since we are working remotely, most of the work is done independently. This is great for me since I've always had problems keeping formal routines and schedules. What has pushed me compared to other people has always been competition. So I don't necissarily always compete for the end result but rather to just be better than others. This is a little different since I'm not worried at all about being the best. That would just be discouraging since there's really no reward. But I am competing to not be in last place. That's been more than enough motivation for me to get into a routine and try to keep it.

   My biggest struggle has also been my ability to experiment. When I think I know something and I'm on the right track I start experimenting with the code. When it doesn't work I try more stuff. 2 hours later (or longer) I'll realize that I haven't gotten anywhere. And when I try to go back I don't even know where start. What makes it worse is that it's always been extremely difficult for me to learn by reading first then applying it after. So I'm pretty worried about how things will go for the remainder. When I learn best is when I can experiment with others. And even better is when someone is immediately available to give dirrection when I get off course. This is what I'm really looking forward to after phase 0.

  I have constantly kept the idea of growth vs. fixed mindset in my mind. I'm determined to stay in the growth mindset and not drift into thinking in a fixed mindset when I get discouraged. What's great is that the more I keep myself focused on growth mindset, the more it actually supports the idea of growth....does that make sense. But no matter how much I stick to the growth mindset I have to be aware that I have certain character traits that may and may not be helpful. As mentioned earlier, I have a CR thinking style. I need to try more to adopt some of the strengths and abilities of the other mindsets to become more well-rounded.


text:
#include "util.h"
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

void checklang(void)
{
  char *langsuff = NULL;
  char *lang = getenv("LANG");

#ifdef HAVE_LOCALE_H
  // Set the locale in accordance with environment
  setlocale(LC_ALL, "");
#endif
#ifdef HAVE_LANGINFO_H
  langsuff = nl_langinfo(CODESET);
#else
  /*
   * Check environment variables $LANG and $LC_CTYPE
   * to see if we want to support UTF-8 unicode
   */
  if (lang != NULL) {
    if (strlen(lang) > 5) {
      langsuff = &lang[strlen(lang)-5];
    }
  }
#endif
  if (langsuff == NULL) {
    printf("Could not determine language suffix for your system. Please check your setup!\n");
  } else if (strcmp(langsuff, "UTF-8")) {
    printf("Your system does not appear to have UTF-8 enabled ($LANG=\"%s\")\n", lang);
    printf("If you want to have support for diacritics and Unicode characters,\n");
    printf("please switch your locale to an UTF-8 locale, e.g. \"en_US.UTF-8\".\n");
  }
}


text:
<?php

namespace Imos\Invoice\Tests;

use Imos\Invoice\LineItem;

class LineItemTest extends \PHPUnit_Framework_TestCase
{

    public function testGettersSetters()
    {
        $item = new LineItem;

        $this->assertTrue($item === $item->setDescription('Internet Widget'));
        $this->assertEquals('Internet Widget', $item->getDescription());

        $this->assertTrue($item === $item->setReference('IW-42'));
        $this->assertEquals('IW-42', $item->getReference());

        $this->assertTrue($item === $item->setQuantity(1));
        $this->assertEquals(1, $item->getQuantity());

        $this->assertTrue($item === $item->setUnit('pc.'));
        $this->assertEquals('pc.', $item->getUnit());

        $this->assertTrue($item === $item->setTaxRate(19));
        $this->assertEquals(19, $item->getTaxRate());

        $this->assertTrue($item === $item->setTaxName('VAT (DE)'));
        $this->assertEquals('VAT (DE)', $item->getTaxName());

        $this->assertTrue($item === $item->setDiscount(25));
        $this->assertEquals(25, $item->getDiscount());

        $this->assertTrue($item === $item->setUnitPrice(127.29));
        $this->assertEquals(127.29, $item->getUnitPrice());

    }

    public function testLineTotals()
    {
        bcscale(10);

        $item = (new LineItem)->setUnitPrice('25');

        $this->assertEquals('25', $item->getTotal());

        $item->setTaxRate(19);
        $this->assertEquals('25', $item->getTotal());

        $item->setQuantity(2);
        $this->assertEquals('50', $item->getTotal());

        $item->setDiscount(25);
        $this->assertEquals('37.5', $item->getTotal());

    }
}


text:
import {TimeScale} from '../time_scale';

import {DragStrategy} from './drag_strategy';

export class BorderDragStrategy extends DragStrategy {
  private moveStart = false;

  constructor(timeScale: TimeScale, private pixelBounds: [number, number]) {
    super(timeScale);
  }

  onDrag(x: number) {
    let tStart =
        this.timeScale.pxToTime(this.moveStart ? x : this.pixelBounds[0]);
    let tEnd =
        this.timeScale.pxToTime(!this.moveStart ? x : this.pixelBounds[1]);
    if (tStart > tEnd) {
      this.moveStart = !this.moveStart;
      [tEnd, tStart] = [tStart, tEnd];
    }
    super.updateGlobals(tStart, tEnd);
    this.pixelBounds =
        [this.timeScale.timeToPx(tStart), this.timeScale.timeToPx(tEnd)];
  }

  onDragStart(x: number) {
    this.moveStart =
        Math.abs(x - this.pixelBounds[0]) < Math.abs(x - this.pixelBounds[1]);
  }
}


text:
module.exports = function() {
	var $stateProvider = arguments[0];

	$stateProvider
		.state('state1', {
			url: "/state1",
			templateUrl: "templates/state1.html"
		})
		.state('state1.list', {
			url: "/list",
			templateUrl: "templates/state1.list.html",
			controller: 'State1Controller'
		});
};

module.exports.$inject = ['$stateProvider'];


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExtendedToolbar.Defs
{
    public static class GameObjectDefs
    {
        public const string ID_TSBAR = "TSBar";
        public const string ID_TSCLOSEBUTTON = "TSCloseButton";
        public const string ID_TSCONTAINER = "TSContainer";
    }
}


text:
module Spree
  CheckoutController.class_eval do
    before_filter :confirm_sisow, :only => [:update]

    def sisow_return
      handle_sisow_response
      @order.next
      if @order.complete?
        flash.notice = Spree.t(:order_processed_successfully)
        redirect_to order_path(@order, :token => @order.token)
      else
        redirect_to checkout_state_path(@order.state)
      end
    end

    def sisow_cancel
      handle_sisow_response
      redirect_to checkout_state_path(@order.state)
    end

    private
    def handle_sisow_response
      sisow = BillingIntegration::SisowBilling.new(@order)
      sisow.process_response(params)

      if sisow.cancelled?
        flash.alert = Spree.t(:payment_has_been_cancelled)
      end
    end

    def confirm_sisow
      return unless (params[:state] == "payment") && params[:order][:payments_attributes]

      payment_method = PaymentMethod.find(params[:order][:payments_attributes].first[:payment_method_id])
      opts = {}
      opts[:return_url] = sisow_return_order_checkout_url(@order)
      opts[:cancel_url] = sisow_cancel_order_checkout_url(@order)
      opts[:notify_url] = sisow_status_update_url(@order)
      opts[:callback_url] = sisow_status_update_url(@order)

      if payment_method.kind_of?(BillingIntegration::SisowBilling::Ideal)
        opts[:issuer_id] = params[:issuer_id]
        redirect_to payment_method.redirect_url(@order, opts)
      elsif payment_method.kind_of?(BillingIntegration::SisowBilling::Sofort)
        redirect_to payment_method.redirect_url(@order, opts)
      elsif payment_method.kind_of?(BillingIntegration::SisowBilling::Bancontact)
        redirect_to payment_method.redirect_url(@order, opts)
      end
    end

  end
end


text:
<?php
/**
 * Extend form class.
 *
 * @author Vee W.
 * @license http://opensource.org/licenses/MIT
 *
 */

namespace Extension;

class Form extends \Fuel\Core\Form
{

    /**
     * if method is in array. get called method, arguments and set input type from method.
     *
     * @param string $method
     * @param array $arguments
     * @return mixed
     */
    public static function __callStatic($method, $arguments)
    {
        $html5_input_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'range', 'search', 'tel', 'time', 'url', 'week');

        if (!method_exists(self::forge(), $method) && in_array($method, $html5_input_types)) {
            unset($html5_input_types);

            // compare arguments to input(arguments)
            $field = '';
            if (isset($arguments[0])) {
                $field = $arguments[0];
            }

            $value = '';
            if (isset($arguments[1])) {
                $value = $arguments[1];
            }

            $attributes = '';
            if (isset($arguments[2])) {
                $attributes = $arguments[2];
            }

            // add input attribute type.
            $attributes['type'] = $method;

            // clear
            $method = '';
            $arguments = '';

            return parent::input($field, $value, $attributes);
        } else {
            \Error::error_handler(500, 'Call to undefined method', __FILE__, __LINE__);
        }
    }// __callStatic

    /**
     * open enctype multipart form.
     *
     * @param array $attributes
     * @param array $hidden
     * @return string
     */
    public static function openMultipart($attributes = array(), $hidden = array())
    {
        $attributes['enctype'] = 'multipart/form-data';

        return \Form::open($attributes, $hidden);
    }// openMultipart

}


text:
from pyromancer.objects import Connection, User

class MockObject(object):

    def __init__(self, **kwargs):
        for key, val in kwargs.items():
            setattr(self, key, val)

class MockConnection(Connection):

    def __init__(self, *args, **kwargs):
        self.outbox = []
        self.me = User('')

    def write(self, data):
        self.outbox.append(data)

    @property
    def last(self):
        return self.outbox[-1:][0]


text:
/*!
 * baguetteBox.js
 * @author  feimosi
 * @version 1.8.1
 * @url https://github.com/feimosi/baguetteBox.js
 */

/* global define, module */

(function (root, factory) {
    'use strict';
    if (typeof define === 'function' && define.amd) {
        define(factory);
    } else if (typeof exports === 'object') {
        module.exports = factory();
    } else {
        root.baguetteBox = factory();
    }
}(this, function () {
    'use strict';

    // SVG shapes used on the buttons
    var leftArrow = '<svg width="44" height="60">' +
            '<polyline points="30 10 10 30 30 50" stroke="rgba(255,255,255,0.5)" stroke-width="4"' +
              'stroke-linecap="butt" fill="none" stroke-linejoin="round"/>' +
            '</svg>',
        rightArrow = '<svg width="44" height="60">' +
            '<polyline points="14 10 34 30 14 50" stroke="rgba(255,255,255,0.5)" stroke-width="4"' +
              'stroke-linecap="butt" fill="none" stroke-linejoin="round"/>' +
            '</svg>',
        closeX = '<svg width="30" height="30">' +
            '<g stroke="rgb(160,160,160)" stroke-width="4">' +
            '<line x1="5" y1="5" x2="25" y2="25"/>' +
            '<line x1="5" y1="25" x2="25" y2="5"/>' +
            '</g></svg>';
    // Global options and their defaults
    var options = {},
        defaults = {
            captions: true,
            fullScreen: false,
            noScrollbars: false,
            titleTag: false,
            buttons: 'auto',
            async: false,
            preload: 2,
            animation: 'slideIn',
            afterShow: null,
            afterHide: null,
            // callback when image changes with `currentIndex` and `imagesElements.length` as parameters
            onChange: null,
            overlayBackgroundColor: 'rgba(0,0,0,.8)'
        };
    // Object containing information about features compatibility
    var supports = {};
    // DOM Elements references
    var overlay, slider, previousButton, nextButton, closeButton;
    // An array with all images in the current gallery
    var currentGallery = [];
    // Current image index inside the slider
    var currentIndex = 0;
    // Touch event start position (for slide gesture)
    var touch = {};
    // If set to true ignore touch events because animation was already fired
    var touchFlag = false;
    // Regex pattern to match image files
    var regex = /.+\.(gif|jpe?g|png|webp)/i;
    // Object of all used galleries
    var data = {};
    // Array containing temporary images DOM elements
    var imagesElements = [];
    // The last focused element before opening the overlay
    var documentLastFocus = null;
    var overlayClickHandler = function(event) {
        // Close the overlay when user clicks directly on the background
        if (event.target.id.indexOf('baguette-img') !== -1) {
            hideOverlay();
        }
    };
    var previousButtonClickHandler = function(event) {
        event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true; // jshint ignore:line
        showPreviousImage();
    };
    var nextButtonClickHandler = function(event) {
        event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true; // jshint ignore:line
        showNextImage();
    };
    var closeButtonClickHandler = function(event) {
        event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true; // jshint ignore:line
        hideOverlay();
    };
    var touchstartHandler = function(event) {
        touch.count++;
        if (touch.count > 1) {
            touch.multitouch = true;
        }
        // Save x and y axis position
        touch.startX = event.changedTouches[0].pageX;
        touch.startY = event.changedTouches[0].pageY;
    };
    var touchmoveHandler = function(event) {
        // If action was already triggered or multitouch return
        if (touchFlag || touch.multitouch) {
            return;
        }
        event.preventDefault ? event.preventDefault() : event.returnValue = false; // jshint ignore:line
        var touchEvent = event.touches[0] || event.changedTouches[0];
        // Move at least 40 pixels to trigger the action
        if (touchEvent.pageX - touch.startX > 40) {
            touchFlag = true;
            showPreviousImage();
        } else if (touchEvent.pageX - touch.startX < -40) {
            touchFlag = true;
            showNextImage();
        // Move 100 pixels up to close the overlay
        } else if (touch.startY - touchEvent.pageY > 100) {
            hideOverlay();
        }
    };
    var touchendHandler = function() {
        touch.count--;
        if (touch.count <= 0) {
            touch.multitouch = false;
        }
        touchFlag = false;
    };

    var trapFocusInsideOverlay = function(event) {
        if (overlay.style.display === 'block' && !overlay.contains(event.target)) {
            event.stopPropagation();
            initFocus();
        }
    };

    // forEach polyfill for IE8
    // http://stackoverflow.com/a/14827443/1077846
    /* jshint ignore:start */
    if (![].forEach) {
        Array.prototype.forEach = function(callback, thisArg) {
            for (var i = 0; i < this.length; i++) {
                callback.call(thisArg, this[i], i, this);
            }
        };
    }

    // filter polyfill for IE8
    // https://gist.github.com/eliperelman/1031656
    if (![].filter) {
        Array.prototype.filter = function(a, b, c, d, e) {
            c = this;
            d = [];
            for (e = 0; e < c.length; e++)
                a.call(b, c[e], e, c) && d.push(c[e]);
            return d;
        };
    }
    /* jshint ignore:end */

    // Script entry point
    function run(selector, userOptions) {
        // Fill supports object
        supports.transforms = testTransformsSupport();
        supports.svg = testSVGSupport();

        buildOverlay();
        removeFromCache(selector);
        bindImageClickListeners(selector, userOptions);
    }

    function bindImageClickListeners(selector, userOptions) {
        // For each gallery bind a click event to every image inside it
        var galleryNodeList = document.querySelectorAll(selector);
        var selectorData = {
            galleries: [],
            nodeList: galleryNodeList
        };
        data[selector] = selectorData;

        [].forEach.call(galleryNodeList, function(galleryElement) {
            if (userOptions && userOptions.filter) {
                regex = userOptions.filter;
            }

            // Get nodes from gallery elements or single-element galleries
            var tagsNodeList = [];
            if (galleryElement.tagName === 'A') {
                tagsNodeList = [galleryElement];
            } else {
                tagsNodeList = galleryElement.getElementsByTagName('a');
            }

            // Filter 'a' elements from those not linking to images
            tagsNodeList = [].filter.call(tagsNodeList, function(element) {
                return regex.test(element.href);
            });
            if (tagsNodeList.length === 0) {
                return;
            }

            var gallery = [];
            [].forEach.call(tagsNodeList, function(imageElement, imageIndex) {
                var imageElementClickHandler = function(event) {
                    event.preventDefault ? event.preventDefault() : event.returnValue = false; // jshint ignore:line
                    prepareOverlay(gallery, userOptions);
                    showOverlay(imageIndex);
                };
                var imageItem = {
                    eventHandler: imageElementClickHandler,
                    imageElement: imageElement
                };
                bind(imageElement, 'click', imageElementClickHandler);
                gallery.push(imageItem);
            });
            selectorData.galleries.push(gallery);
        });
    }

    function clearCachedData() {
        for (var selector in data) {
            if (data.hasOwnProperty(selector)) {
                removeFromCache(selector);
            }
        }
    }

    function removeFromCache(selector) {
        if (!data.hasOwnProperty(selector)) {
            return;
        }
        var galleries = data[selector].galleries;
        [].forEach.call(galleries, function(gallery) {
            [].forEach.call(gallery, function(imageItem) {
                unbind(imageItem.imageElement, 'click', imageItem.eventHandler);
            });

            if (currentGallery === gallery) {
                currentGallery = [];
            }
        });

        delete data[selector];
    }

    function buildOverlay() {
        overlay = getByID('baguetteBox-overlay');
        // Check if the overlay already exists
        if (overlay) {
            slider = getByID('baguetteBox-slider');
            previousButton = getByID('previous-button');
            nextButton = getByID('next-button');
            closeButton = getByID('close-button');
            return;
        }
        // Create overlay element
        overlay = create('div');
        overlay.setAttribute('role', 'dialog');
        overlay.id = 'baguetteBox-overlay';
        document.getElementsByTagName('body')[0].appendChild(overlay);
        // Create gallery slider element
        slider = create('div');
        slider.id = 'baguetteBox-slider';
        overlay.appendChild(slider);
        // Create all necessary buttons
        previousButton = create('button');
        previousButton.setAttribute('type', 'button');
        previousButton.id = 'previous-button';
        previousButton.setAttribute('aria-label', 'Previous');
        previousButton.innerHTML = supports.svg ? leftArrow : '<';
        overlay.appendChild(previousButton);

        nextButton = create('button');
        nextButton.setAttribute('type', 'button');
        nextButton.id = 'next-button';
        nextButton.setAttribute('aria-label', 'Next');
        nextButton.innerHTML = supports.svg ? rightArrow : '>';
        overlay.appendChild(nextButton);

        closeButton = create('button');
        closeButton.setAttribute('type', 'button');
        closeButton.id = 'close-button';
        closeButton.setAttribute('aria-label', 'Close');
        closeButton.innerHTML = supports.svg ? closeX : '×';
        overlay.appendChild(closeButton);

        previousButton.className = nextButton.className = closeButton.className = 'baguetteBox-button';

        bindEvents();
    }

    function keyDownHandler(event) {
        switch (event.keyCode) {
            case 37: // Left arrow
                showPreviousImage();
                break;
            case 39: // Right arrow
                showNextImage();
                break;
            case 27: // Esc
                hideOverlay();
                break;
        }
    }

    function bindEvents() {
        bind(overlay, 'click', overlayClickHandler);
        bind(previousButton, 'click', previousButtonClickHandler);
        bind(nextButton, 'click', nextButtonClickHandler);
        bind(closeButton, 'click', closeButtonClickHandler);
        bind(overlay, 'touchstart', touchstartHandler);
        bind(overlay, 'touchmove', touchmoveHandler);
        bind(overlay, 'touchend', touchendHandler);
        bind(document, 'focus', trapFocusInsideOverlay, true);
    }

    function unbindEvents() {
        unbind(overlay, 'click', overlayClickHandler);
        unbind(previousButton, 'click', previousButtonClickHandler);
        unbind(nextButton, 'click', nextButtonClickHandler);
        unbind(closeButton, 'click', closeButtonClickHandler);
        unbind(overlay, 'touchstart', touchstartHandler);
        unbind(overlay, 'touchmove', touchmoveHandler);
        unbind(overlay, 'touchend', touchendHandler);
        unbind(document, 'focus', trapFocusInsideOverlay, true);
    }

    function prepareOverlay(gallery, userOptions) {
        // If the same gallery is being opened prevent from loading it once again
        if (currentGallery === gallery) {
            return;
        }
        currentGallery = gallery;
        // Update gallery specific options
        setOptions(userOptions);
        // Empty slider of previous contents (more effective than .innerHTML = "")
        while (slider.firstChild) {
            slider.removeChild(slider.firstChild);
        }
        imagesElements.length = 0;

        var imagesFiguresIds = [];
        var imagesCaptionsIds = [];
        // Prepare and append images containers and populate figure and captions IDs arrays
        for (var i = 0, fullImage; i < gallery.length; i++) {
            fullImage = create('div');
            fullImage.className = 'full-image';
            fullImage.id = 'baguette-img-' + i;
            imagesElements.push(fullImage);

            imagesFiguresIds.push('baguetteBox-figure-' + i);
            imagesCaptionsIds.push('baguetteBox-figcaption-' + i);
            slider.appendChild(imagesElements[i]);
        }
        overlay.setAttribute('aria-labelledby', imagesFiguresIds.join(' '));
        overlay.setAttribute('aria-describedby', imagesCaptionsIds.join(' '));
    }

    function setOptions(newOptions) {
        if (!newOptions) {
            newOptions = {};
        }
        // Fill options object
        for (var item in defaults) {
            options[item] = defaults[item];
            if (typeof newOptions[item] !== 'undefined') {
                options[item] = newOptions[item];
            }
        }
        /* Apply new options */
        // Change transition for proper animation
        slider.style.transition = slider.style.webkitTransition = (options.animation === 'fadeIn' ? 'opacity .4s ease' :
            options.animation === 'slideIn' ? '' : 'none');
        // Hide buttons if necessary
        if (options.buttons === 'auto' && ('ontouchstart' in window || currentGallery.length === 1)) {
            options.buttons = false;
        }
        // Set buttons style to hide or display them
        previousButton.style.display = nextButton.style.display = (options.buttons ? '' : 'none');
        // Set overlay color
        try {
            overlay.style.backgroundColor = options.overlayBackgroundColor;
        } catch (e) {}
    }

    function showOverlay(chosenImageIndex) {
        if (options.noScrollbars) {
            document.documentElement.style.overflowY = 'hidden';
            document.body.style.overflowY = 'scroll';
        }
        if (overlay.style.display === 'block') {
            return;
        }

        bind(document, 'keydown', keyDownHandler);
        currentIndex = chosenImageIndex;
        touch = {
            count: 0,
            startX: null,
            startY: null
        };
        loadImage(currentIndex, function() {
            preloadNext(currentIndex);
            preloadPrev(currentIndex);
        });

        updateOffset();
        overlay.style.display = 'block';
        if (options.fullScreen) {
            enterFullScreen();
        }
        // Fade in overlay
        setTimeout(function() {
            overlay.className = 'visible';
            if (options.afterShow) {
                options.afterShow();
            }
        }, 50);
        if (options.onChange) {
            options.onChange(currentIndex, imagesElements.length);
        }
        documentLastFocus = document.activeElement;
        initFocus();
    }

    function initFocus() {
        if (options.buttons) {
            previousButton.focus();
        } else {
            closeButton.focus();
        }
    }

    function enterFullScreen() {
        if (overlay.requestFullscreen) {
            overlay.requestFullscreen();
        } else if (overlay.webkitRequestFullscreen) {
            overlay.webkitRequestFullscreen();
        } else if (overlay.mozRequestFullScreen) {
            overlay.mozRequestFullScreen();
        }
    }

    function exitFullscreen() {
        if (document.exitFullscreen) {
            document.exitFullscreen();
        } else if (document.mozCancelFullScreen) {
            document.mozCancelFullScreen();
        } else if (document.webkitExitFullscreen) {
            document.webkitExitFullscreen();
        }
    }

    function hideOverlay() {
        if (options.noScrollbars) {
            document.documentElement.style.overflowY = 'auto';
            document.body.style.overflowY = 'auto';
        }
        if (overlay.style.display === 'none') {
            return;
        }

        unbind(document, 'keydown', keyDownHandler);
        // Fade out and hide the overlay
        overlay.className = '';
        setTimeout(function() {
            overlay.style.display = 'none';
            exitFullscreen();
            if (options.afterHide) {
                options.afterHide();
            }
        }, 500);
        documentLastFocus.focus();
    }

    function loadImage(index, callback) {
        var imageContainer = imagesElements[index];
        if (typeof imageContainer === 'undefined') {
            return;
        }

        // If image is already loaded run callback and return
        if (imageContainer.getElementsByTagName('img')[0]) {
            if (callback) {
                callback();
            }
            return;
        }

        // Get element reference, optional caption and source path
        var imageElement = currentGallery[index].imageElement;
        var thumbnailElement = imageElement.getElementsByTagName('img')[0];
        var imageCaption = typeof options.captions === 'function' ?
                            options.captions.call(currentGallery, imageElement) :
                            imageElement.getAttribute('data-caption') || imageElement.title;
        var imageSrc = getImageSrc(imageElement);

        // Prepare figure element
        var figure = create('figure');
        figure.id = 'baguetteBox-figure-' + index;
        figure.innerHTML = '
' +
            '

' +
            '

' +
            '
';
        // Insert caption if available
        if (options.captions && imageCaption) {
            var figcaption = create('figcaption');
            figcaption.id = 'baguetteBox-figcaption-' + index;
            figcaption.innerHTML = imageCaption;
            figure.appendChild(figcaption);
        }
        imageContainer.appendChild(figure);

        // Prepare gallery img element
        var image = create('img');
        image.onload = function() {
            // Remove loader element
            var spinner = document.querySelector('#baguette-img-' + index + ' .baguetteBox-spinner');
            figure.removeChild(spinner);
            if (!options.async && callback) {
                callback();
            }
        };
        image.setAttribute('src', imageSrc);
        image.alt = thumbnailElement ? thumbnailElement.alt || '' : '';
        if (options.titleTag && imageCaption) {
            image.title = imageCaption;
        }
        figure.appendChild(image);

        // Run callback
        if (options.async && callback) {
            callback();
        }
    }

    // Get image source location, mostly used for responsive images
    function getImageSrc(image) {
        // Set default image path from href
        var result = image.href;
        // If dataset is supported find the most suitable image
        if (image.dataset) {
            var srcs = [];
            // Get all possible image versions depending on the resolution
            for (var item in image.dataset) {
                if (item.substring(0, 3) === 'at-' && !isNaN(item.substring(3))) {
                    srcs[item.replace('at-', '')] = image.dataset[item];
                }
            }
            // Sort resolutions ascending
            var keys = Object.keys(srcs).sort(function(a, b) {
                return parseInt(a, 10) < parseInt(b, 10) ? -1 : 1;
            });
            // Get real screen resolution
            var width = window.innerWidth * window.devicePixelRatio;
            // Find the first image bigger than or equal to the current width
            var i = 0;
            while (i < keys.length - 1 && keys[i] < width) {
                i++;
            }
            result = srcs[keys[i]] || result;
        }
        return result;
    }

    // Return false at the right end of the gallery
    function showNextImage() {
        var returnValue;
        // Check if next image exists
        if (currentIndex <= imagesElements.length - 2) {
            currentIndex++;
            updateOffset();
            preloadNext(currentIndex);
            returnValue = true;
        } else if (options.animation) {
            slider.className = 'bounce-from-right';
            setTimeout(function() {
                slider.className = '';
            }, 400);
            returnValue = false;
        }
        if (options.onChange) {
            options.onChange(currentIndex, imagesElements.length);
        }
        return returnValue;
    }

    // Return false at the left end of the gallery
    function showPreviousImage() {
        var returnValue;
        // Check if previous image exists
        if (currentIndex >= 1) {
            currentIndex--;
            updateOffset();
            preloadPrev(currentIndex);
            returnValue = true;
        } else if (options.animation) {
            slider.className = 'bounce-from-left';
            setTimeout(function() {
                slider.className = '';
            }, 400);
            returnValue = false;
        }
        if (options.onChange) {
            options.onChange(currentIndex, imagesElements.length);
        }
        return returnValue;
    }

    function updateOffset() {
        var offset = -currentIndex * 100 + '%';
        if (options.animation === 'fadeIn') {
            slider.style.opacity = 0;
            setTimeout(function() {
                /* jshint -W030 */
                supports.transforms ?
                    slider.style.transform = slider.style.webkitTransform = 'translate3d(' + offset + ',0,0)'
                    : slider.style.left = offset;
                slider.style.opacity = 1;
            }, 400);
        } else {
            /* jshint -W030 */
            supports.transforms ?
                slider.style.transform = slider.style.webkitTransform = 'translate3d(' + offset + ',0,0)'
                : slider.style.left = offset;
        }
    }

    // CSS 3D Transforms test
    function testTransformsSupport() {
        var div = create('div');
        return typeof div.style.perspective !== 'undefined' || typeof div.style.webkitPerspective !== 'undefined';
    }

    // Inline SVG test
    function testSVGSupport() {
        var div = create('div');
        div.innerHTML = '<svg/>';
        return (div.firstChild && div.firstChild.namespaceURI) === 'http://www.w3.org/2000/svg';
    }

    function preloadNext(index) {
        if (index - currentIndex >= options.preload) {
            return;
        }
        loadImage(index + 1, function() {
            preloadNext(index + 1);
        });
    }

    function preloadPrev(index) {
        if (currentIndex - index >= options.preload) {
            return;
        }
        loadImage(index - 1, function() {
            preloadPrev(index - 1);
        });
    }

    function bind(element, event, callback, useCapture) {
        if (element.addEventListener) {
            element.addEventListener(event, callback, useCapture);
        } else {
            // IE8 fallback
            element.attachEvent('on' + event, callback);
        }
    }

    function unbind(element, event, callback, useCapture) {
        if (element.removeEventListener) {
            element.removeEventListener(event, callback, useCapture);
        } else {
            // IE8 fallback
            element.detachEvent('on' + event, callback);
        }
    }

    function getByID(id) {
        return document.getElementById(id);
    }

    function create(element) {
        return document.createElement(element);
    }

    function destroyPlugin() {
        unbindEvents();
        clearCachedData();
        unbind(document, 'keydown', keyDownHandler);
        document.getElementsByTagName('body')[0].removeChild(document.getElementById('baguetteBox-overlay'));
        data = {};
        currentGallery = [];
        currentIndex = 0;
    }

    return {
        run: run,
        destroy: destroyPlugin,
        showNext: showNextImage,
        showPrevious: showPreviousImage
    };

}));


text:
function OnConfig($stateProvider, $locationProvider, $urlRouterProvider, $compileProvider) {
  'ngInject';

  /* This needs to remain disabled for bundled apps, as the base is disabled in the index.html */
  $locationProvider.html5Mode(false);

  $stateProvider
  .state('Home', {
    url: '/',
    controller: 'HomeController as home',
    templateUrl: 'home/home.html',
    title: 'Home'
  });

  $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel):/);

  $urlRouterProvider.otherwise('/');

}

export default OnConfig;