text:
from scipy import interpolate, signal,ndimage
import scipy as sci
import json
import numpy as np
from collections import Counter
from apps.calc.measurement.calculus import get_average_delta,get_decimal_delta
from apps.calc.tess_module.tess import tess

class Measurement(object):
    def __init__(self, raw, Column_Names, Unit_Names, time=0):
        self.timeIndex = int(time)
        self.data = np.array(json.loads(raw), dtype=np.float64)
        self.colUnits = np.array(json.loads(Unit_Names))
        self.colNames = np.array(json.loads(Column_Names))

    def save_to_db(self):
        return True

    def resample_data(self,scale = 1.0):
        '''
        This function resamples the data it.colNames_User Within this it uses the already most frequently used time interval.
        It can also upscale the datapoints (get more Datapoints)[scale > 1] or downscale the data [scale <1]

        If the scale is 1.0 it projects it only on a constant intervall
        e.g. if it is already constant, there will be no changes.

        the used function is described here: https://dsp.stackexchange.com/questions/8488/what-is-an-algorithm-to-re
        -sample-from-a-variable-rate-to-a-fixed-rate
        /process/
        :param scale: The scale, the Data should be resampled
        '''
        begin = np.float64(self.data[0,self.timeIndex])
        end = np.float64(self.data[-1,self.timeIndex])
        cnt=Counter(get_decimal_delta(self.data,self.timeIndex,3))
        X_new = np.linspace(begin, end , int(
            (round((end-begin) / cnt.most_common(1)[0][0])) * scale))

        new_data = []

        for i in range(0,len(self.data[0])):
            if i == self.timeIndex:
                new_data.append(np.array(X_new))
            else:
                s = interpolate.splrep(self.data[:,self.timeIndex],self.data[:,i])
                new_data.append(np.array(interpolate.splev(X_new,s)))

        self.data = np.asarray(new_data,dtype="float64").transpose()

    def fourier_transform(self,fourierval = 'imaginary'):
        '''
        This Method Applies a fourier transformation on an data interval in the data
        :param data: the pandas DataFrame of the data
        :param data_index: The index of the data intervall of
        :return: the list of fourrier transformed values

        Example:
        import matplotlib.pyplot as plt
        def fourier_example(data):
            plt.figure
            n = len(data.iloc[:, 0])
            plt.plot(data.iloc[:round(n/2), 0], data.iloc[:round(n/2), 1], 'b', alpha=0.75)
            plt.plot(data.iloc[:round(n/2), 0], fourier_transform(data, 1), 'r')
            plt.legend(('noisy signal', 'fourier'), loc='best')
            plt.grid(True)
            plt.show()
        '''
        new_data = []
        n = len(self.data[:, 0])
        cut = int(n/2)
        for i in range(0,len(self.data[0])):
            if i == self.timeIndex:
                X_new = np.fft.fftfreq(len(self.data[:,i]), d=get_average_delta(self.data,i))[:cut]
                new_data.append(np.array(X_new))
            elif(fourierval == 'absolute'):
                fft = [(np.abs(x)/n)*2 for x in sci.fft(self.data[:, i])]
                new_data.append(np.array(fft[:cut]))
                fft[0] = fft[0] / 2
            elif fourierval == 'real':
                fft = [(np.real(x)/n)*2 for x in sci.fft(self.data[:, i])]
                new_data.append(np.array(fft[:cut]))
                fft[0] = fft[0] / 2
            elif fourierval == 'imaginary':
                fft = [(np.imag(x)/n)*2 for x in sci.fft(self.data[:, i])]
                fft[0] = fft[0]/2
                new_data.append(np.array(fft[:cut]))

        self.colUnits[self.timeIndex] = 'Hz'
        self.colNames[self.timeIndex] = 'Frequenz'
        self.data = np.asarray(new_data,dtype="float64").transpose()

    def call_tess(self,data_index_1,data_index_2):
        '''
        TESS is a software project that is part of the OpenAdaptronics program, conducted at the Fraunhofer LBF.
        Its preliminary title is an acronym for "Tool zur Empfehlung von Strategien zur Schwingungsberuhigung"

        :param time: time data
        :param data_index_1: acceleration of the instrument
        :param data_index_2: exciting acceleration'''

        return tess.tess(self.data[:,self.timeIndex],self.data[:,data_index_1],self.data[:,data_index_2])

    def gaussian_filter(self, index, gauss_std=2 , gauss_M=None):
        '''
        The gaussian filter with the default number of points in the output window (Equal the points of the input)
        :param index: The index of interest for the data
        :param gauss_std: The standard deviation, sigma.
        :return: The filtered Data

        Example:
        import matplotlib.pyplot as plt
        def gaussian_example(data):
            plt.figure
            plt.plot(data[0], data[1], 'b', alpha=0.75)
            plt.plot(data[0], gaussian_filter(data, 1), 'r')
            plt.legend(('noisy signal', 'Gauß'), loc='best')
            plt.grid(True)
            plt.show()
        '''
        daten = np.asarray(self.data[:,index], dtype=np.float64)
        if gauss_M == None:
            b = signal.gaussian(len(self.data[:,0]), gauss_std)
        else:
            b = signal.gaussian(gauss_M, gauss_std)
        self.data[:,index] = ndimage.convolve1d(daten, b / b.sum())

    def butterworth_band_filter(self,data_index, order=4, lowcut=None, highcut=None):
        '''
        Filters high and lowpass
        :param data: The data array
        :param data_index: The index of interest for the data
        :param ti   me_index: the index of the sampling time
        :param order: The order of the butter filter.
        :param lowcut: The low frequency cutoff, default 10% of the input frequency
        :param highcut: The high frequency cutoff, default 90% of the input frequency
        :return: the filtered data sequence

        Example:
        import matplotlib.pyplot as plt
        def butterworth_example(data):
            plt.figure
            plt.plot(data.iloc[:, 0], data.iloc[:, 1], 'b', alpha=0.75)
            plt.plot(data.iloc[:, 0], butterworth_band_filter(data, 1,), 'g')
            plt.legend(('noisy signal', 'high_butterworth', 'low_butterworth' , 'band_butterworth'), loc='best')
            plt.grid(True)
            plt.show()
        '''
        fs = 1 / get_average_delta(self.data, self.timeIndex)
        nyq = 0.5 * fs

        # Default Values
        if lowcut == None:
            lowcut = 0.1 * nyq
        if highcut == None:
            highcut = 0.9 * nyq

        low = lowcut / nyq
        high = highcut / nyq
        b, a = signal.butter(order, [low, high], btype='band', analog=False)
        self.data[:,data_index] = signal.filtfilt(b, a, np.float64(self.data[:,data_index]))

    def butterworth_filter(self, data_index, order=4, cofreq=None, mode='low'):
        '''
        Filters high or lowpass
        :param data_index: The index of interest for the data
        :param order: The order of the butter filter.
        :param cofreq: The cuttoff frequency
        :param mode: disdinguish between 'high' for highpass and 'low' for lowpass
        :return: the filtered data sequence

        Example:
        import matplotlib.pyplot as plt
        def butterworth_example(data):
            plt.figure
            plt.plot(data.iloc[:, 0], data.iloc[:, 1], 'b', alpha=0.75)
            plt.plot(data.iloc[:, 0], butterworth_filter(data, 1, mode='high'), 'r')
            plt.plot(data.iloc[:, 0], butterworth_filter(data, 1, mode='low'), 'y')
            plt.legend(('noisy signal', 'high_butterworth', 'low_butterworth' , 'band_butterworth'), loc='best')
            plt.grid(True)
            plt.show()
        '''
        fs = 1 / get_average_delta(self.data, self.timeIndex)
        nyq = 0.5 * fs

        # Default Values
        if cofreq == None:
            if mode == 'low':
                cofreq = nyq * 0.9
            elif mode == 'high':
                cofreq = nyq * 0.1
            else:
                print('Wrong Input format: butterworth_filter : ', mode, cofreq)

        cut = cofreq / nyq
        b, a = signal.butter(order, cut, btype=mode, analog=False)
        self.data[:,data_index] = signal.filtfilt(b, a, np.float64(self.data[:, data_index]))


text:
html {
	padding: 0;
	margin: 0;
	height: 100%;
}

body {
	font-size: 10pt;
	font-family: Arial, Helvetica, sans-serif;
	height: 100%;
	margin: 0;
	padding: 0;
	min-width: 1300px;
	background-color: #DF8C00;
}

#ininvid_mainContentWrapper{
	width: 100%;
	height: 100%;
	background-image: url('img/panel_small.png');
	background-attachment: fixed;
	background-position: center top;
	padding: 0;
	margin: 0;
}

#ininvid_headerMessage {
	text-align: center;
}

#ininvid_headerMessage h1 {
	font-style: italic;
}

#ininvid_header img {
	margin: 30px auto;
	display: block;
}

#ininvid_mainContentColumn {
	width: 1280px;
	margin: 0 auto; /*Margins for content column. Should be "0 RightColumnWidth 0 LeftColumnWidth*/
}

#ininvid_mainContentColumn iframe {
	margin: 0 auto;
	display: block;
}

redpajama_set_name: RedPajamaGithub


text:
import struct

from .bitstring import pack

BROADCAST_MAC = "00:00:00:00:00:00"
BROADCAST_SOURCE_ID = 0

HEADER_SIZE_BYTES = 36

class Message(object):
    def __init__(self, msg_type, target_addr, source_id, seq_num, ack_requested=False, response_requested=False):

        # Frame
        self.frame_format = ["16", "2, 1, 1, 12", "32"]
        self.size = None                                                # 16 bits/uint16
        self.origin = 0                                                 # 2 bits/uint8, must be zero
        self.tagged = 1 if target_addr == BROADCAST_MAC else 0          # 1 bit/bool, also must be one if getservice
        self.addressable = 1                                            # 1 bit/bool, must be one
        self.protocol = 1024                                            # 12 bits/uint16
        self.source_id = source_id                                      # 32 bits/uint32, unique ID set by client. If zero, broadcast reply requested. If non-zero, unicast reply requested.

        # Frame Address
        self.frame_addr_format = ["64", "48", "6, 1, 1", "8"]
        self.target_addr = target_addr                                  # 64 bits/uint64, either single MAC address or all zeroes for broadcast.
        self.reserved = 0                                               # 48 bits/uint8 x 6, all zero
        self.reserved = 0                                               # 6 bits, all zero
        self.ack_requested = 1 if ack_requested else 0                  # 1 bit/bool, 1 = yes
        self.response_requested = 1 if response_requested else 0        # 1 bit/bool, 1 = yes
        self.seq_num = seq_num                                          # 8 bits/uint8, wraparound

        # Protocol Header
        self.protocol_header_format = ["64", "16", "16"]
        self.reserved = 0                                               # 64 bits/uint64, all zero
        self.message_type = msg_type                                    # 16 bits/uint16
        self.reserved = 0                                               # 16 bits/uint16, all zero

        self.payload_fields = [] # tuples of ("label", value)

        self.packed_message = self.generate_packed_message()

    def generate_packed_message(self):
        self.payload = self.get_payload()
        self.header = self.get_header()
        packed_message = self.header + self.payload
        return packed_message

    # frame (and thus header) needs to be generated after payload (for size field)
    def get_header(self):
        if self.size == None:
            self.size = self.get_msg_size()
        frame_addr = self.get_frame_addr()
        frame = self.get_frame()
        protocol_header = self.get_protocol_header()
        header = frame + frame_addr + protocol_header
        return header

    # Default: No payload unless method overridden
    def get_payload(self):
        return little_endian(pack(""))

    def get_frame(self):
        size_format = self.frame_format[0]
        flags_format = self.frame_format[1]
        source_id_format = self.frame_format[2]
        size = little_endian(pack(size_format, self.size))
        flags = little_endian(pack(flags_format, self.origin, self.tagged, self.addressable, self.protocol))
        source_id = little_endian(pack(source_id_format, self.source_id))
        frame = size + flags + source_id
        return frame

    def get_frame_addr(self):
        mac_addr_format = self.frame_addr_format[0]
        reserved_48_format = self.frame_addr_format[1]
        response_flags_format = self.frame_addr_format[2]
        seq_num_format = self.frame_addr_format[3]
        mac_addr = little_endian(pack(mac_addr_format, convert_MAC_to_int(self.target_addr)))
        reserved_48 = little_endian(pack(reserved_48_format, self.reserved))
        response_flags = little_endian(pack(response_flags_format, self.reserved, self.ack_requested, self.response_requested))
        seq_num = little_endian(pack(seq_num_format, self.seq_num))
        frame_addr = mac_addr + reserved_48 + response_flags + seq_num
        return frame_addr

    def get_protocol_header(self):
        reserved_64_format = self.protocol_header_format[0]
        message_type_format = self.protocol_header_format[1]
        reserved_16_format = self.protocol_header_format[2]
        reserved_64 = little_endian(pack(reserved_64_format, self.reserved))
        message_type = little_endian(pack(message_type_format, self.message_type))
        reserved_16 = little_endian(pack(reserved_16_format, self.reserved))
        protocol_header = reserved_64 + message_type + reserved_16
        return protocol_header

    def get_msg_size(self):
        payload_size_bytes = len(self.payload)
        return HEADER_SIZE_BYTES + payload_size_bytes

    def __str__(self):
        indent = "  "
        s = self.__class__.__name__ + "\n"
        s += indent + "Size: {}\n".format(self.size)
        s += indent + "Origin: {}\n".format(self.origin)
        s += indent + "Tagged: {}\n".format(self.tagged)
        s += indent + "Protocol: {}\n".format(self.protocol)
        s += indent + "Source ID: {}\n".format(self.source_id)
        s += indent + "Target MAC Address: {}\n".format(self.target_addr)
        s += indent + "Ack Requested: {}\n".format(self.ack_requested)
        s += indent + "Response Requested: {}\n".format(self.response_requested)
        s += indent + "Seq Num: {}\n".format(self.seq_num)
        s += indent + "Message Type: {}\n".format(self.message_type)
        s += indent + "Payload:"
        for field in self.payload_fields:
            s += "\n" + indent*2 + "{}: {}".format(field[0], field[1])
        if len(self.payload_fields) == 0:
            s += "\n" + indent*2 + "<empty>"
        s += "\n"
        s += indent + "Bytes:\n"
        s += indent*2 + str([hex(b) for b in struct.unpack("B"*(len(self.packed_message)),self.packed_message)])
        s += "\n"
        return s

# reverses bytes for little endian, then converts to int
def convert_MAC_to_int(addr):
    reverse_bytes_str = addr.split(':')
    reverse_bytes_str.reverse()
    addr_str = "".join(reverse_bytes_str)
    return int(addr_str, 16)

def little_endian(bs):
    shifts = [i*8 for i in range(int(len(bs)/8))]
    int_bytes_little_endian = [int(bs.uintbe >> i & 0xff) for i in shifts]
    packed_message_little_endian = b""
    for b in int_bytes_little_endian:
        packed_message_little_endian += struct.pack("B", b)
    return packed_message_little_endian


text:
using System;
using System.Data;

namespace FileDbUploader.Tests
{
    public class MockDbConnection : IDbConnection
    {
        private ConnectionState state;
        public MockDbCommand Command;

        public MockDbConnection(string connectionString)
        {
        }

        #region IDbConnection implementation

        IDbTransaction IDbConnection.BeginTransaction()
        {
            throw new NotImplementedException();
        }

        IDbTransaction IDbConnection.BeginTransaction(IsolationLevel il)
        {
            throw new NotImplementedException();
        }

        void IDbConnection.ChangeDatabase(string databaseName)
        {
            throw new NotImplementedException();
        }

        void IDbConnection.Close()
        {
            state = ConnectionState.Closed;
        }

        IDbCommand IDbConnection.CreateCommand()
        {
            Command = new MockDbCommand();

            return Command;
        }

        void IDbConnection.Open()
        {
            state = ConnectionState.Open;
        }

        string IDbConnection.ConnectionString { get; set; }

        int IDbConnection.ConnectionTimeout
        {
            get { throw new NotImplementedException(); }
        }

        string IDbConnection.Database
        {
            get { throw new NotImplementedException(); }
        }

        ConnectionState IDbConnection.State
        {
            get { return state; }
        }

        #endregion

        #region IDisposable implementation

        void IDisposable.Dispose()
        {
        }

        #endregion
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Uses of Class org.apache.solr.client.solrj.request.CollectionAdminRequest.CollectionShardAdminRequest (Solr 6.0.0 API)</title>
<meta name="date" content="2016-04-01">
<link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Help

Prev

Next

Frames

No Frames

All Classes

Uses of Class
org.apache.solr.client.solrj.request.CollectionAdminRequest.CollectionShardAdminRequest

Packages that use CollectionAdminRequest.CollectionShardAdminRequest

Package
Description

org.apache.solr.client.solrj.request

Convenience classes for dealing with various types of Solr requests.

Uses of CollectionAdminRequest.CollectionShardAdminRequest in org.apache.solr.client.solrj.request

Subclasses of CollectionAdminRequest.CollectionShardAdminRequest in org.apache.solr.client.solrj.request

Modifier and Type
Class and Description

static class
CollectionAdminRequest.AddReplica

static class
CollectionAdminRequest.AddReplicaProp

protected static class
CollectionAdminRequest.CollectionShardAsyncAdminRequest<T extends CollectionAdminRequest<T>>

static class
CollectionAdminRequest.CreateShard

static class
CollectionAdminRequest.DeleteReplica

static class
CollectionAdminRequest.DeleteReplicaProp

static class
CollectionAdminRequest.DeleteShard

static class
CollectionAdminRequest.ForceLeader

static class
CollectionAdminRequest.MigrateClusterState

static class
CollectionAdminRequest.SplitShard

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Help

Prev

Next

Frames

No Frames

All Classes

          Copyright © 2000-2016 Apache Software Foundation.  All Rights Reserved.


text:
package org.keycloak.testsuite.util.cli;

import java.util.Map;
import java.util.Set;

import org.infinispan.Cache;
import org.keycloak.connections.infinispan.InfinispanConnectionProvider;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;

/**
 * @author Marek Posolda
 */
public class CacheCommands {

    public static class ListCachesCommand extends AbstractCommand {

        @Override
        public String getName() {
            return "listCaches";
        }

        @Override
        protected void doRunCommand(KeycloakSession session) {
            InfinispanConnectionProvider ispnProvider = session.getProvider(InfinispanConnectionProvider.class);
            Set<String> cacheNames = ispnProvider.getCache("realms").getCacheManager().getCacheNames();
            log.infof("Available caches: %s", cacheNames);
        }

    }

    public static class GetCacheCommand extends AbstractCommand {

        @Override
        public String getName() {
            return "getCache";
        }

        @Override
        protected void doRunCommand(KeycloakSession session) {
            String cacheName = getArg(0);
            InfinispanConnectionProvider ispnProvider = session.getProvider(InfinispanConnectionProvider.class);
            Cache<Object, Object> cache = ispnProvider.getCache(cacheName);
            if (cache == null) {
                log.errorf("Cache '%s' doesn't exist", cacheName);
                throw new HandledException();
            }

            printCache(cache);
        }

        private void printCache(Cache<Object, Object> cache) {
            int size = cache.size();
            log.infof("Cache %s, size: %d", cache.getName(), size);

            if (size > 50) {
                log.info("Skip printing cache recors due to big size");
            } else {
                for (Map.Entry<Object, Object> entry : cache.entrySet()) {
                    log.infof("%s=%s", entry.getKey(), entry.getValue());
                }
            }
        }

        @Override
        public String printUsage() {
            return super.printUsage() + " <cache-name> . cache-name is name of the infinispan cache provided by InfinispanConnectionProvider";
        }

    }

    public static class CacheRealmObjectsCommand extends AbstractCommand {

        @Override
        public String getName() {
            return "cacheRealmObjects";
        }

        @Override
        protected void doRunCommand(KeycloakSession session) {
            String realmName = getArg(0);
            RealmModel realm = session.realms().getRealmByName(realmName);
            if (realm == null) {
                log.errorf("Realm not found: %s", realmName);
                throw new HandledException();
            }

            TestCacheUtils.cacheRealmWithEverything(session, realmName);
        }

        @Override
        public String printUsage() {
            return super.printUsage() + " <realm-name>";
        }
    }
}


text:
package org.jkiss.dbeaver.model.auth;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.DBPObject;
import org.jkiss.dbeaver.model.app.DBPProject;

/**
 * Access session.
 */
public interface SMSession extends DBPObject {

    /**
     * Session space
     */
    @NotNull
    SMAuthSpace getSessionSpace();

    @NotNull
    SMSessionContext getSessionContext();

    SMSessionPrincipal getSessionPrincipal();

    /**
     * Session unique ID
     */
    @NotNull
    String getSessionId();

    /**
     * Application session is a global singleton session
     */
    boolean isApplicationSession();

    /**
     * Singleton session project
     */
    @Nullable
    DBPProject getSingletonProject();

}


text:
/*----------Form Reset & Form Default Elements----------*/

/* All Defaults */

button,
input,
optgroup,
select,
textarea {
  background: inherit;
  color: inherit;
  box-sizing: inherit;
  line-height: inherit;
  font-family: inherit;
  font-size: 100%;
  margin: 0;
}

button[disabled],
input[disabled] {
  cursor: default;
}

/* Input Fields */

input[type='search'],
input[type='text'],
input[type='number'],
input[type='email'],
input[type='password'] {
  appearance: none;
}

/* Textareas */

textarea {
  overflow: auto;
}

/* Selects */

select { appearance: menulist; }
optgroup { font-weight: bold; }

/* Buttons & Submissions */

button { overflow: visible; }

button,
input[type='button'],
input[type='reset'],
input[type='submit'] {
  cursor: pointer;
  appearance: none;
}

/* Other */

fieldset {
  border: 1px solid;
  margin: 0;
  padding: calc(var(--base-spacing) / 4);
}

legend {
  border: 0;
  padding: 0;
}


text:
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Introduction to Boost.Regex and MFC Strings</title>
<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../../../../index.html" title="Boost.Regex">
<link rel="up" href="../mfc_strings.html" title="Using Boost Regex With MFC Strings">
<link rel="prev" href="../mfc_strings.html" title="Using Boost Regex With MFC Strings">
<link rel="next" href="mfc_regex_types.html" title="Regex Types Used With MFC Strings">

Home
Libraries
People
FAQ
More

Introduction
          to Boost.Regex and MFC Strings

            The header <boost/regex/mfc.hpp> provides Boost.Regex support for
            MFC string types: note that this support requires Visual Studio .NET
            (Visual C++ 7) or later, where all of the MFC and ATL string types are
            based around the CSimpleStringT class template.

            In the following documentation, whenever you see CSimpleStringT<charT>,
            then you can substitute any of the following MFC/ATL types (all of which
            inherit from CSimpleStringT):

CString
CStringA
CStringW
CAtlString
CAtlStringA
CAtlStringW
CStringT<charT,traits>
CFixedStringT<charT,N>
CSimpleStringT<charT>

Copyright © 1998-2010 John Maddock

        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)


text: Rails.application.config.session_store :cookie_store, key: '_games-http-cards-war_session'


text:
Easy autobind function for jsx template

```js
autobind(fn, ...params)
```

## Usage in React Component
```js
import autobind from 'jsx-autobind'

class Home extends Component {
  test(param) {
    console.log(param);
  }
  render() {
    const param = 'Hello'
    return <div>{autobind(this.test, param)}</div>
  }
}
```


text:
.. _promiscuous_interface:

Promiscuous Mode
################

.. contents::
    :local:
    :depth: 2

Overview
********

Promiscuous mode is a mode for a network interface controller that
causes it to pass all traffic it receives to the application rather than
passing only the frames that the controller is specifically programmed
to receive. This mode is normally used for packet sniffing as used
to diagnose network connectivity issues by showing an application
all the data being transferred over the network.  (See the
`Wikipedia article on promiscuous mode
<https://en.wikipedia.org/wiki/Promiscuous_mode>`_ for more information.)

The network promiscuous APIs are used to enable and disable this mode,
and to wait for and receive a network data to arrive. Not all network
technologies or network device drivers support promiscuous mode.

Sample usage
************

First the promiscuous mode needs to be turned ON by the application like this:

.. code-block:: c

	ret = net_promisc_mode_on(iface);
	if (ret < 0) {
		if (ret == -EALREADY) {
			printf("Promiscuous mode already enabled\n");
		} else {
			printf("Cannot enable promiscuous mode for "
			       "interface %p (%d)\n", iface, ret);
		}
	}

If there is no error, then the application can start to wait for network data:

.. code-block:: c

	while (true) {
		pkt = net_promisc_mode_wait_data(K_FOREVER);
		if (pkt) {
			print_info(pkt);
		}

		net_pkt_unref(pkt);
	}

Finally the promiscuous mode can be turned OFF by the application like this:

.. code-block:: c

	ret = net_promisc_mode_off(iface);
	if (ret < 0) {
		if (ret == -EALREADY) {
			printf("Promiscuous mode already disabled\n");
		} else {
			printf("Cannot disable promiscuous mode for "
			       "interface %p (%d)\n", iface, ret);
		}
	}

See :ref:`net-promiscuous-mode-sample` for a more comprehensive example.

API Reference
*************

.. doxygengroup:: promiscuous
   :project: Zephyr


text:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/ioport.h>

#include <asm/prom.h>
#include <asm/of_device.h>
#include <asm/io.h>
#include <asm/auxio.h>

void __iomem *auxio_register = NULL;
EXPORT_SYMBOL(auxio_register);

enum auxio_type {
	AUXIO_TYPE_NODEV,
	AUXIO_TYPE_SBUS,
	AUXIO_TYPE_EBUS
};

static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV;
static DEFINE_SPINLOCK(auxio_lock);

static void __auxio_sbus_set(u8 bits_on, u8 bits_off)
{
	if (auxio_register) {
		unsigned char regval;
		unsigned long flags;
		unsigned char newval;

		spin_lock_irqsave(&auxio_lock, flags);

		regval =  sbus_readb(auxio_register);
		newval =  regval | bits_on;
		newval &= ~bits_off;
		newval &= ~AUXIO_AUX1_MASK;
		sbus_writeb(newval, auxio_register);

		spin_unlock_irqrestore(&auxio_lock, flags);
	}
}

static void __auxio_ebus_set(u8 bits_on, u8 bits_off)
{
	if (auxio_register) {
		unsigned char regval;
		unsigned long flags;
		unsigned char newval;

		spin_lock_irqsave(&auxio_lock, flags);

		regval =  (u8)readl(auxio_register);
		newval =  regval | bits_on;
		newval &= ~bits_off;
		writel((u32)newval, auxio_register);

		spin_unlock_irqrestore(&auxio_lock, flags);
	}
}

static inline void __auxio_ebus_set_led(int on)
{
	(on) ? __auxio_ebus_set(AUXIO_PCIO_LED, 0) :
		__auxio_ebus_set(0, AUXIO_PCIO_LED) ;
}

static inline void __auxio_sbus_set_led(int on)
{
	(on) ? __auxio_sbus_set(AUXIO_AUX1_LED, 0) :
		__auxio_sbus_set(0, AUXIO_AUX1_LED) ;
}

void auxio_set_led(int on)
{
	switch(auxio_devtype) {
	case AUXIO_TYPE_SBUS:
		__auxio_sbus_set_led(on);
		break;
	case AUXIO_TYPE_EBUS:
		__auxio_ebus_set_led(on);
		break;
	default:
		break;
	}
}

static inline void __auxio_sbus_set_lte(int on)
{
	(on) ? __auxio_sbus_set(AUXIO_AUX1_LTE, 0) :
		__auxio_sbus_set(0, AUXIO_AUX1_LTE) ;
}

void auxio_set_lte(int on)
{
	switch(auxio_devtype) {
	case AUXIO_TYPE_SBUS:
		__auxio_sbus_set_lte(on);
		break;
	case AUXIO_TYPE_EBUS:
		/* FALL-THROUGH */
	default:
		break;
	}
}

static struct of_device_id auxio_match[] = {
	{
		.name = "auxio",
	},
	{},
};

MODULE_DEVICE_TABLE(of, auxio_match);

static int __devinit auxio_probe(struct of_device *dev, const struct of_device_id *match)
{
	struct device_node *dp = dev->node;
	unsigned long size;

	if (!strcmp(dp->parent->name, "ebus")) {
		auxio_devtype = AUXIO_TYPE_EBUS;
		size = sizeof(u32);
	} else if (!strcmp(dp->parent->name, "sbus")) {
		auxio_devtype = AUXIO_TYPE_SBUS;
		size = 1;
	} else {
		printk("auxio: Unknown parent bus type [%s]\n",
		       dp->parent->name);
		return -ENODEV;
	}
	auxio_register = of_ioremap(&dev->resource[0], 0, size, "auxio");
	if (!auxio_register)
		return -ENODEV;

	printk(KERN_INFO "AUXIO: Found device at %s\n",
	       dp->full_name);

	if (auxio_devtype == AUXIO_TYPE_EBUS)
		auxio_set_led(AUXIO_LED_ON);

	return 0;
}

static struct of_platform_driver auxio_driver = {
	.name		= "auxio",
	.match_table	= auxio_match,
	.probe		= auxio_probe,
};

static int __init auxio_init(void)
{
	return of_register_driver(&auxio_driver, &of_bus_type);
}

/* Must be after subsys_initcall() so that busses are probed.  Must
 * be before device_initcall() because things like the floppy driver
 * need to use the AUXIO register.
 */
fs_initcall(auxio_init);


text:
/*	TL.DomUtil
	Inspired by Leaflet
	TL.DomUtil contains various utility functions for working with DOM
================================================== */

TL.DomUtil = {
	get: function (id) {
		return (typeof id === 'string' ? document.getElementById(id) : id);
	},

	getStyle: function (el, style) {
		var value = el.style[style];
		if (!value && el.currentStyle) {
			value = el.currentStyle[style];
		}
		if (!value || value === 'auto') {
			var css = document.defaultView.getComputedStyle(el, null);
			value = css ? css[style] : null;
		}
		return (value === 'auto' ? null : value);
	},

	getViewportOffset: function (element) {
		var top = 0,
			left = 0,
			el = element,
			docBody = document.body;

		do {
			top += el.offsetTop || 0;
			left += el.offsetLeft || 0;

			if (el.offsetParent === docBody &&
					TL.DomUtil.getStyle(el, 'position') === 'absolute') {
				break;
			}
			el = el.offsetParent;
		} while (el);

		el = element;

		do {
			if (el === docBody) {
				break;
			}

			top -= el.scrollTop || 0;
			left -= el.scrollLeft || 0;

			el = el.parentNode;
		} while (el);

		return new TL.Point(left, top);
	},

	create: function (tagName, className, container) {
		var el = document.createElement(tagName);
		el.className = className;
		if (container) {
			container.appendChild(el);
		}
		return el;
	},

	disableTextSelection: function () {
		if (document.selection && document.selection.empty) {
			document.selection.empty();
		}
		if (!this._onselectstart) {
			this._onselectstart = document.onselectstart;
			document.onselectstart = TL.Util.falseFn;
		}
	},

	enableTextSelection: function () {
		document.onselectstart = this._onselectstart;
		this._onselectstart = null;
	},

	hasClass: function (el, name) {
		return (el.className.length > 0) &&
				new RegExp("(^|\\s)" + name + "(\\s|$)").test(el.className);
	},

	addClass: function (el, name) {
		if (!TL.DomUtil.hasClass(el, name)) {
			el.className += (el.className ? ' ' : '') + name;
		}
	},

	removeClass: function (el, name) {
		el.className = el.className.replace(/(\S+)\s*/g, function (w, match) {
			if (match === name) {
				return '';
			}
			return w;
		}).replace(/^\s+/, '');
	},

	setOpacity: function (el, value) {
		if (TL.Browser.ie) {
			el.style.filter = 'alpha(opacity=' + Math.round(value * 100) + ')';
		} else {
			el.style.opacity = value;
		}
	},

	testProp: function (props) {
		var style = document.documentElement.style;

		for (var i = 0; i < props.length; i++) {
			if (props[i] in style) {
				return props[i];
			}
		}
		return false;
	},

	getTranslateString: function (point) {

		return TL.DomUtil.TRANSLATE_OPEN +
				point.x + 'px,' + point.y + 'px' +
				TL.DomUtil.TRANSLATE_CLOSE;
	},

	getScaleString: function (scale, origin) {
		var preTranslateStr = TL.DomUtil.getTranslateString(origin),
			scaleStr = ' scale(' + scale + ') ',
			postTranslateStr = TL.DomUtil.getTranslateString(origin.multiplyBy(-1));

		return preTranslateStr + scaleStr + postTranslateStr;
	},

	setPosition: function (el, point) {
		el._tl_pos = point;
		if (TL.Browser.webkit3d) {
			el.style[TL.DomUtil.TRANSFORM] =  TL.DomUtil.getTranslateString(point);

			if (TL.Browser.android) {
				el.style['-webkit-perspective'] = '1000';
				el.style['-webkit-backface-visibility'] = 'hidden';
			}
		} else {
			el.style.left = point.x + 'px';
			el.style.top = point.y + 'px';
		}
	},

	getPosition: function (el) {
		return el._tl_pos;
	}
};


text:
<?php

namespace SSystems\BackendBundle\Controller\AdminImages;

use Admingenerated\SSystemsBackendBundle\BaseAdminImagesController\ActionsController as BaseActionsController;

/**
 * ActionsController
 */
class ActionsController extends BaseActionsController
{
}


text:
module.exports = {
    localDb: 'cards',
    serverDb: 'http://localhost:5984/cards',
    syncOptions: { live: true }
};


text:
[CmdletBinding()]
param(
    [Parameter()]
    [string]
    $SharePointCmdletModule = (Join-Path -Path $PSScriptRoot `
                                         -ChildPath "..\Stubs\SharePoint\15.0.4805.1000\Microsoft.SharePoint.PowerShell.psm1" `
                                         -Resolve)
)

Import-Module -Name (Join-Path -Path $PSScriptRoot `
                                -ChildPath "..\UnitTestHelper.psm1" `
                                -Resolve)

$Global:SPDscHelper = New-SPDscUnitTestHelper -SharePointStubModule $SharePointCmdletModule `
                                              -DscResource "SPProductUpdate"

Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture {
    InModuleScope -ModuleName $Global:SPDscHelper.ModuleName -ScriptBlock {
        Invoke-Command -ScriptBlock $Global:SPDscHelper.InitializeScript -NoNewScope

        # Mocks for all contexts
        Mock -CommandName Test-Path {
            return $true
        }

        Mock -CommandName Get-Service -MockWith {
            $service = @{
                    Status = "Running"
            }
            $service = $service | Add-Member -MemberType ScriptMethod `
                                                -Name Stop `
                                                -Value {
                                                    return $null
                                                } -PassThru
            $service = $service | Add-Member -MemberType ScriptMethod `
                                                -Name Start `
                                                -Value {
                                                    return $null
                                                } -PassThru
            $service = $service | Add-Member -MemberType ScriptMethod `
                                                -Name WaitForStatus `
                                                -Value {
                                                    return $null
                                                } -PassThru
            return $service
        }

        Mock -CommandName Set-Service {
            return $null
        }

        Mock -CommandName Start-Process {
            return @{
                ExitCode = 0
            }
        }

        Mock -CommandName Get-SPDSCRegistryKey -MockWith {
            if ($Value -eq "SetupType")
            {
                return "CLEAN_INSTALL"
            }

            if ($Value -eq "LanguagePackInstalled")
            {
                return 0
            }
        }

        Mock -CommandName Get-SPDscFarmVersionInfo -MockWith {
            return @{
                Lowest = $Global:SPDscHelper.CurrentStubBuildNumber
            }
        }

        # Test contexts
        Context -Name "Specified update file not found" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Test-Path -MockWith {
                return $false
            }

            It "Should throw exception in the get method" {
                { Get-TargetResource @testParams } | Should Throw "Setup file cannot be found."
            }

            It "Should throw exception in the set method" {
                { Set-TargetResource @testParams } | Should Throw "Setup file cannot be found."
            }

            It "Should throw exception in the test method"  {
                { Test-TargetResource @testParams } | Should Throw "Setup file cannot be found."
            }
        }

        Context -Name "Specified update file is blocked" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Test-Path -MockWith {
                return $true
            }

            Mock -CommandName Get-Item -MockWith {
                return "Zone data"
            }

            It "Should throw exception in the get method" {
                { Get-TargetResource @testParams } | Should Throw "Setup file is blocked! Please use Unblock-File to unblock the file"
            }

            It "Should throw exception in the set method" {
                { Set-TargetResource @testParams } | Should Throw "Setup file is blocked! Please use Unblock-File to unblock the file"
            }

            It "Should throw exception in the test method"  {
                { Test-TargetResource @testParams } | Should Throw "Setup file is blocked! Please use Unblock-File to unblock the file"
            }
        }

        Context -Name "Ensure is set to Absent" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Absent"
            }

            It "Should throw exception in the get method" {
                { Get-TargetResource @testParams } | Should Throw "SharePoint does not support uninstalling updates."
            }

            It "Should throw exception in the set method" {
                { Set-TargetResource @testParams } | Should Throw "SharePoint does not support uninstalling updates."
            }

            It "Should throw exception in the test method"  {
                { Test-TargetResource @testParams } | Should Throw "SharePoint does not support uninstalling updates."
            }
        }

        Context -Name "Update CU has lower version, update not required" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = $Global:SPDscHelper.CurrentStubBuildNumber
                            FileDescription = "Cumulative Update"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = $Global:SPDscHelper.CurrentStubBuildNumber
                            FileDescription = "Cumulative Update"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016")
                }
            }

            It "Should return Ensure is Present from the get method" {
                $result = Get-TargetResource @testParams
                $result.Ensure | Should Be "Present"
            }

            It "Should return true from the test method"  {
                Test-TargetResource @testParams | Should Be $true
            }
        }

        Context -Name "Update CU has higher version, update executed successfully" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "15.0.8000"
                            FileDescription = "Cumulative Update"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "16.0.8000"
                            FileDescription = "Cumulative Update"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016")
                }
            }

            It "Should return Ensure is Present from the get method" {
                $result = Get-TargetResource @testParams
                $result.Ensure | Should Be "Absent"
            }

            It "Should run the Start-Process function in the set method" {
                Set-TargetResource @testParams
                Assert-MockCalled Start-Process
            }

            It "Should return true from the test method"  {
                Test-TargetResource @testParams | Should Be $false
            }
        }

        Context -Name "Update CU has higher version, update executed, reboot required" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "15.0.8000"
                            FileDescription = "Cumulative Update"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "16.0.8000"
                            FileDescription = "Cumulative Update"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016")
                }
            }

            Mock -CommandName Start-Process {
                return @{
                    ExitCode = 17022
                }
            }

            It "Should return Ensure is Present from the get method" {
                $result = Get-TargetResource @testParams
                $result.Ensure | Should Be "Absent"
            }

            It "Should run the Start-Process function in the set method" {
                Set-TargetResource @testParams
                Assert-MockCalled Start-Process
            }

            It "Should return true from the test method"  {
                Test-TargetResource @testParams | Should Be $false
            }
        }

        Context -Name "Update CU has higher version, update executed, which failed" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "15.0.8000"
                            FileDescription = "Cumulative Update"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "16.0.8000"
                            FileDescription = "Cumulative Update"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016")
                }
            }

            Mock -CommandName Start-Process {
                return @{
                    ExitCode = 1
                }
            }

            It "Should return Ensure is Present from the get method" {
                $result = Get-TargetResource @testParams
                $result.Ensure | Should Be "Absent"
            }

            It "Should run the Start-Process function in the set method" {
                { Set-TargetResource @testParams } | Should Throw "SharePoint update install failed, exit code was 1"
                Assert-MockCalled Start-Process
            }

            It "Should return true from the test method"  {
                Test-TargetResource @testParams | Should Be $false
            }
        }

        Context -Name "Update SP has lower version, update not required" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = $Global:SPDscHelper.CurrentStubBuildNumber
                            FileDescription = "Service Pack"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = $Global:SPDscHelper.CurrentStubBuildNumber
                            FileDescription = "Service Pack"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016")
                }
            }

            It "Should return Ensure is Present from the get method" {
                $result = Get-TargetResource @testParams
                $result.Ensure | Should Be "Present"
            }

            It "Should return true from the test method"  {
                Test-TargetResource @testParams | Should Be $true
            }
        }

        Context -Name "Update SP has higher version, update executed" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "15.0.8000"
                            FileDescription = "Service Pack"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "16.0.8000"
                            FileDescription = "Service Pack"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-en-us.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016")
                }
            }

            It "Should return Ensure is Present from the get method" {
                $result = Get-TargetResource @testParams
                $result.Ensure | Should Be "Absent"
            }

            It "Should run the Start-Process function in the set method" {
                Set-TargetResource @testParams
                Assert-MockCalled Start-Process
            }

            It "Should return true from the test method"  {
                Test-TargetResource @testParams | Should Be $false
            }
        }

        Context -Name "Update SP for LP has lower version, update not required" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = $Global:SPDscHelper.CurrentStubBuildNumber
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-nl-nl.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = $Global:SPDscHelper.CurrentStubBuildNumber
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-nl-nl.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013", "Language Pack for SharePoint and Project Server 2013  - Dutch/Nederlands")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016", "Language Pack for SharePoint and Project Server 2016  - Dutch/Nederlands")
                }
            }

            It "Should return Ensure is Present from the get method" {
                $result = Get-TargetResource @testParams
                $result.Ensure | Should Be "Present"
            }

            It "Should return true from the test method"  {
                Test-TargetResource @testParams | Should Be $true
            }
        }

        Context -Name "Update SP for LP has higher version, update required" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "15.0.8000"
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-nl-nl.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "16.0.8000"
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-nl-nl.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013", "Language Pack for SharePoint and Project Server 2013  - Dutch/Nederlands")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016", "Language Pack for SharePoint and Project Server 2016  - Dutch/Nederlands")
                }
            }

            It "Should return Ensure is Present from the get method" {
                $result = Get-TargetResource @testParams
                $result.Ensure | Should Be "Absent"
            }

            It "Should run the Start-Process function in the set method" {
                Set-TargetResource @testParams
                Assert-MockCalled Start-Process
            }

            It "Should return true from the test method"  {
                Test-TargetResource @testParams | Should Be $false
            }
        }

        Context -Name "Update SP LP does not have language in the name, throws exception" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "15.0.8000"
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "16.0.8000"
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013", "Language Pack for SharePoint and Project Server 2013  - Dutch/Nederlands")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016", "Language Pack for SharePoint and Project Server 2016  - Dutch/Nederlands")
                }
            }

            It "Should throw exception in the get method" {
                { Get-TargetResource @testParams } | Should Throw "Update does not contain the language code in the correct format."
            }
        }

        Context -Name "Update SP LP has unknown language in the name, throws exception" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "15.0.8000"
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-ab-yz.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "16.0.8000"
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-ab-yz.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013", "Language Pack for SharePoint and Project Server 2013  - Dutch/Nederlands")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016", "Language Pack for SharePoint and Project Server 2016  - Dutch/Nederlands")
                }
            }

            It "Should throw exception in the get method" {
                { Get-TargetResource @testParams } | Should Throw "Error while converting language information:"
            }
        }

        Context -Name "Update SP LP specified language is not installed, throws exception" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "15.0.8000"
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-fr-fr.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "16.0.8000"
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-fr-fr.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDscFarmProductsInfo -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @("Microsoft SharePoint Server 2013", "Language Pack for SharePoint and Project Server 2013  - Dutch/Nederlands")
                }
                else
                {
                    return @("Microsoft SharePoint Server 2016", "Language Pack for SharePoint and Project Server 2016  - Dutch/Nederlands")
                }
            }

            It "Should throw exception in the get method" {
                { Get-TargetResource @testParams } | Should Throw "Error: Product for language fr-fr is not found."
            }
        }

        Context -Name "Upgrade pending - Skipping install" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                Ensure               = "Present"
            }

            Mock -CommandName Get-ItemProperty -MockWith {
                if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq  15)
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "15.0.8000"
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2013-kb2880554-fullfile-x64-fr-fr.exe"
                    }
                }
                else
                {
                    return @{
                        VersionInfo = @{
                            FileVersion = "16.0.8000"
                            FileDescription = "Service Pack Language Pack"
                        }
                        Name = "serverlpksp2016-kb2880554-fullfile-x64-fr-fr.exe"
                    }
                }
            }

            Mock -CommandName Get-SPDSCRegistryKey -MockWith {
                if ($Value -eq "SetupType")
                {
                    return "CLEAN_INSTALL"
                }

                if ($Value -eq "LanguagePackInstalled")
                {
                    return 1
                }
            }

            It "Should return null from  the set method" {
                Set-TargetResource @testParams | Should BeNullOrEmpty
            }
        }

        Context -Name "BinaryInstallDays outside range" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                BinaryInstallDays    = "mon"
                Ensure               = "Present"
            }

            $testDate = Get-Date -Day 17 -Month 7 -Year 2016 -Hour 12 -Minute 00 -Second 00

            Mock -CommandName Get-Date -MockWith {
                 return $testDate
            }

            It "Should return null from the set method" {
                Set-TargetResource @testParams | Should BeNullOrEmpty
            }
        }

        Context -Name "BinaryInstallTime outside range" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                BinaryInstallDays    = "sun"
                BinaryInstallTime    = "3:00am to 5:00am"
                Ensure               = "Present"
            }

            $testDate = Get-Date -Day 17 -Month 7 -Year 2016 -Hour 12 -Minute 00 -Second 00

            Mock -CommandName Get-Date -MockWith {
                 return $testDate
            }

            It "Should return null from the set method" {
                Set-TargetResource @testParams | Should BeNullOrEmpty
            }
        }

        Context -Name "BinaryInstallTime incorrectly formatted, too many arguments" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                BinaryInstallDays    = "sun"
                BinaryInstallTime    = "error 3:00am to 5:00am"
                Ensure               = "Present"
            }

            $testDate = Get-Date -Day 17 -Month 7 -Year 2016 -Hour 12 -Minute 00 -Second 00

            Mock -CommandName Get-Date -MockWith {
                 return $testDate
            }

            It "Should throw exception in the set method" {
                { Set-TargetResource @testParams } | Should Throw "Time window incorrectly formatted."
            }
        }

        Context -Name "BinaryInstallTime incorrectly formatted, incorrect start time" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                BinaryInstallDays    = "sun"
                BinaryInstallTime    = "3:00xm to 5:00am"
                Ensure               = "Present"
            }

            $testDate = Get-Date -Day 17 -Month 7 -Year 2016 -Hour 12 -Minute 00 -Second 00

            Mock -CommandName Get-Date -MockWith {
                 return $testDate
            }

            It "Should throw exception in the set method" {
                { Set-TargetResource @testParams } | Should Throw "Error converting start time"
            }
        }

        Context -Name "BinaryInstallTime incorrectly formatted, incorrect end time" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                BinaryInstallDays    = "sun"
                BinaryInstallTime    = "3:00am to 5:00xm"
                Ensure               = "Present"
            }

            $testDate = Get-Date -Day 17 -Month 7 -Year 2016 -Hour 12 -Minute 00 -Second 00

            Mock -CommandName Get-Date -MockWith {
                 return $testDate
            }

            It "Should throw exception in the set method" {
                { Set-TargetResource @testParams } | Should Throw "Error converting end time"
            }
        }

        Context -Name "BinaryInstallTime start time larger than end time" -Fixture {
            $testParams = @{
                SetupFile            = "C:\Install\CUMay2016\ubersrv2013-kb3115029-fullfile-x64-glb.exe"
                ShutdownServices     = $true
                BinaryInstallDays    = "sun"
                BinaryInstallTime    = "3:00pm to 5:00am"
                Ensure               = "Present"
            }

            $testDate = Get-Date -Day 17 -Month 7 -Year 2016 -Hour 12 -Minute 00 -Second 00

            Mock -CommandName Get-Date -MockWith {
                 return $testDate
            }

            It "Should throw exception in the set method" {
                { Set-TargetResource @testParams } | Should Throw "Error: Start time cannot be larger than end time"
            }
        }
    }
}

Invoke-Command -ScriptBlock $Global:SPDscHelper.CleanupScript -NoNewScope


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>
    </parent>

    <groupId>com.codolutions</groupId>
    <artifactId>spring-react-starter-app</artifactId>
    <version>0.0.1</version>
    <packaging>war</packaging>

    <name>spring-react-starter-aoo</name>
    <description>Spring React Starter App</description>

    <properties>
        <java.version>1.8</java.version>
        <jsoup.version>1.7.3</jsoup.version>
        <start-class>com.codolutions.starterapp.Application</start-class>
        <mysql.connector.version>5.1.39</mysql.connector.version>
        <maven.clean.plugin.version>3.0.0</maven.clean.plugin.version>
        <lesscss.maven.plugin.version>1.7.0.1.1</lesscss.maven.plugin.version>
        <frontend.maven.plugin.version>1.2</frontend.maven.plugin.version>
        <node.version>v4.6.0</node.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.connector.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>${jsoup.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>${start-class}</mainClass>
                    <jvmArguments>
                        -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
                    </jvmArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>${maven.clean.plugin.version}</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>src/main/resources/static/js/bower_components</directory>
                        </fileset>
                        <fileset>
                            <directory>node</directory>
                        </fileset>
                        <fileset>
                            <directory>node_modules</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.lesscss</groupId>
                <artifactId>lesscss-maven-plugin</artifactId>
                <version>${lesscss.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <sourceDirectory>${project.basedir}/src/main/resources/static/less</sourceDirectory>
                    <outputDirectory>${project.build.directory}/classes/static/css</outputDirectory>
                    <compress>true</compress>
                    <includes>
                        <include>*.less</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>${frontend.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>

                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>bower install</id>
                        <goals>
                            <goal>bower</goal>
                        </goals>
                        <phase>generate-resources</phase>

                        <configuration>
                            <arguments>--allow-root install</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>grunt build</id>
                        <goals>
                            <goal>grunt</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                </executions>
                <configuration>
                    <nodeVersion>${node.version}</nodeVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
in Crous & Braun, CBS Diversity Ser. (Utrecht) 1: 147 (2003)

#### Original name
Cercospora curatellae Syd.

### Remarks
null


text:
using System;
using System.Reflection;
using System.Xml;
using Cuemon.Collections.Generic;
using Cuemon.Reflection;
using Cuemon.Runtime.Serialization;
using Cuemon.Xml.Serialization;
using Cuemon.Xml.Serialization.Formatters;

namespace Cuemon.Xml
{
/// <summary>
    /// Extension methods for the <see cref="XmlWriter"/> class tailored to adhere the decorator pattern.
    /// </summary>
    /// <seealso cref="IDecorator{T}"/>
    /// <seealso cref="Decorator{T}"/>
    public static class XmlWriterDecoratorExtensions
    {
        /// <summary>
        /// Serializes the specified <paramref name="value"/> into an XML format of the enclosed <see cref="XmlWriter"/> of the specified <paramref name="decorator"/>.
        /// </summary>
        /// <typeparam name="T">The type of the object to serialize.</typeparam>
        /// <param name="decorator">The <see cref="T:IDecorator{XmlWriter}" /> to extend.</param>
        /// <param name="value">The object to serialize.</param>
        /// <param name="setup">The <see cref="XmlFormatterOptions"/> which may be configured.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="decorator"/> cannot be null.
        /// </exception>
        public static void WriteObject<T>(this IDecorator<XmlWriter> decorator, T value, Action<XmlFormatterOptions> setup = null)
        {
            WriteObject(decorator, value, typeof(T), setup);
        }

        /// <summary>
        /// Serializes the specified <paramref name="value"/> into an XML format of the enclosed <see cref="XmlWriter"/> of the specified <paramref name="decorator"/>.
        /// </summary>
        /// <param name="decorator">The <see cref="T:IDecorator{XmlWriter}" /> to extend.</param>
        /// <param name="value">The object to serialize.</param>
        /// <param name="objectType">The type of the object to serialize.</param>
        /// <param name="setup">The <see cref="XmlFormatterOptions"/> which may be configured.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="decorator"/> cannot be null.
        /// </exception>
        public static void WriteObject(this IDecorator<XmlWriter> decorator, object value, Type objectType, Action<XmlFormatterOptions> setup = null)
        {
            Validator.ThrowIfNull(decorator);
            var formatter = new XmlFormatter(setup);
            formatter.SerializeToWriter(decorator.Inner, value, objectType);
        }

        /// <summary>
        /// Writes the specified start tag and associates it with the given <paramref name="elementName"/> of the enclosed <see cref="XmlWriter"/> of the specified <paramref name="decorator"/>.
        /// </summary>
        /// <param name="decorator">The <see cref="T:IDecorator{XmlWriter}" /> to extend.</param>
        /// <param name="elementName">The fully qualified name of the element.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="decorator"/> cannot be null.
        /// </exception>
        public static void WriteStartElement(this IDecorator<XmlWriter> decorator, XmlQualifiedEntity elementName)
        {
            Validator.ThrowIfNull(decorator);
            decorator.Inner.WriteStartElement(elementName.Prefix, elementName.LocalName, elementName.Namespace);
        }

        /// <summary>
        /// Writes the specified <paramref name="value"/> with the delegate <paramref name="nodeWriter"/> to the enclosed <see cref="XmlWriter"/> of the specified <paramref name="decorator"/>.
        /// If <paramref name="elementName"/> is not null, then the delegate <paramref name="nodeWriter"/> is called from within an encapsulating Start- and End-element.
        /// </summary>
        /// <typeparam name="T">The type of the object to serialize.</typeparam>
        /// <param name="decorator">The <see cref="T:IDecorator{XmlWriter}" /> to extend.</param>
        /// <param name="value">The object to serialize.</param>
        /// <param name="elementName">The optional fully qualified name of the element.</param>
        /// <param name="nodeWriter">The delegate node writer.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="decorator"/> cannot be null.
        /// </exception>
        public static void WriteEncapsulatingElementIfNotNull<T>(this IDecorator<XmlWriter> decorator, T value, XmlQualifiedEntity elementName, Action<XmlWriter, T> nodeWriter)
        {
            Validator.ThrowIfNull(decorator);
            var writer = decorator.Inner;
            if (elementName == null)
            {
                nodeWriter(writer, value);
                return;
            }
            WriteStartElement(decorator, elementName);
            nodeWriter(writer, value);
            writer.WriteEndElement();
        }

        /// <summary>
        /// Writes the XML root element to the enclosed <see cref="XmlWriter"/> of the specified <paramref name="decorator"/>.
        /// </summary>
        /// <typeparam name="T">The type of the object to serialize.</typeparam>
        /// <param name="decorator">The <see cref="T:IDecorator{XmlWriter}" /> to extend.</param>
        /// <param name="value">The object to serialize.</param>
        /// <param name="treeWriter">The delegate used to write the XML hierarchy.</param>
        /// <param name="rootEntity">The optional <seealso cref="XmlQualifiedEntity"/> that will provide the name of the root element.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="decorator"/> cannot be null.
        /// </exception>
        public static void WriteXmlRootElement<T>(this IDecorator<XmlWriter> decorator, T value, Action<XmlWriter, T, XmlQualifiedEntity> treeWriter, XmlQualifiedEntity rootEntity = null)
        {
            Validator.ThrowIfNull(decorator);
            WriteXmlRootElementCore(decorator.Inner, value, (w, o) => treeWriter(w, value, rootEntity), null, rootEntity);
        }

        internal static void WriteXmlRootElement(this IDecorator<XmlWriter> decorator, object value, Action<XmlWriter, IHierarchy<object>> treeWriter, XmlQualifiedEntity rootEntity = null)
        {
            WriteXmlRootElementCore(decorator.Inner, value, null, treeWriter, rootEntity);
        }

        private static void WriteXmlRootElementCore(XmlWriter writer, object value, Action<XmlWriter, object> treeWriterPublic, Action<XmlWriter, IHierarchy<object>> treeWriterInternal, XmlQualifiedEntity rootEntity = null)
        {
            Validator.ThrowIfNull(writer);
            if (value == null) { return; }
            try
            {
                IHierarchy<object> nodes;
                XmlQualifiedEntity rootElement;
                if (treeWriterInternal == null)
                {
                    nodes = new Hierarchy<object>().Add(value);
                    rootElement = Decorator.Enclose(nodes).GetXmlQualifiedEntity(rootEntity);
                    writer.WriteStartElement(rootElement.Prefix, rootElement.LocalName, rootElement.Namespace);
                    treeWriterPublic?.Invoke(writer, value);
                }
                else
                {
                    nodes = new HierarchySerializer(value).Nodes;
                    rootElement = Decorator.Enclose(nodes).GetXmlQualifiedEntity(rootEntity);
                    writer.WriteStartElement(rootElement.Prefix, rootElement.LocalName, rootElement.Namespace);
                    treeWriterInternal(writer, nodes);
                }
            }
            catch (Exception ex)
            {
                var innerException = ex;
                if (innerException is OutOfMemoryException) { throw; }
                if (innerException is TargetInvocationException) { innerException = innerException.InnerException; }
                throw ExceptionInsights.Embed(new InvalidOperationException("There is an error in the XML document.", innerException), MethodBase.GetCurrentMethod(), Arguments.ToArray(writer, value));
            }
            writer.WriteEndElement();
            writer.Flush();
        }
    }
}