text:
package com.landicorp.android.wofupay.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.landicorp.android.wofupay.R;
import com.landicorp.android.wofupay.adapter.SelectPassengerAdapter;
import com.landicorp.android.wofupay.bean.Passenger;
import com.landicorp.android.wofupay.bean.SelectPassenger;
import com.landicorp.android.wofupay.utils.JLog;
import com.landicorp.android.wofupay.utils.PayContacts;
import com.landicorp.android.wofupay.volley.RxVolleyHelper;
import com.yanzhenjie.fragment.NoFragment;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/3/24.
 */

public class SelectPassengerFragment extends NoFragment implements View.OnClickListener {

    private View mInflate;
    private String mParam1;
    private String mParam2;
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    private ListView mListview;
    private boolean regrist;
    private int idNum;
    private String pidname;
    private List<Passenger> listpassenger = new ArrayList<Passenger>();
    private Button mBt_back;
    private Button mBt_ok;
    private ImageView mIv_add;
    private SelectPassengerAdapter mAdapter;

    public SelectPassengerFragment() {
    }

    public static SelectPassengerFragment newInstance(String param1, String param2) {
        SelectPassengerFragment fragment = new SelectPassengerFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1); //传过来的电话号码
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }
    @Override
    public View onCreateView(LayoutInflater inflater,  ViewGroup container,  Bundle savedInstanceState) {
        mInflate = inflater.inflate(R.layout.fragment_select_passenger, null);
        initView();
        initListener();
        return mInflate;
    }

    private void initListener() {
        mBt_back.setOnClickListener(this);
        mBt_ok.setOnClickListener(this);
        mIv_add.setOnClickListener(this);
    }

    @Override
    public void onResume() {
        getPassenger();
        super.onResume();
    }

    private void getPassenger() {
        RxVolleyHelper helper = new RxVolleyHelper(PayContacts.base_url + "TrainTickets/TrainTickets.ashx");
        final HashMap<String, String> params = new HashMap<>();
        params.put("action", "GetContactsList");
        params.put("Phone", mParam1);
        helper.postParams(params).subscribe(new Subscriber<String>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable throwable) {
                Toast.makeText(getContext(),"获取联系人失败",Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onNext(String s) {
                SelectPassenger passenger = new Gson().fromJson(s, SelectPassenger.class);

                if (passenger.code.equals("000")){
                    List<SelectPassenger.SelectedPassenger> list = passenger.Data;
                    regrist = false;
                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).PId == 0){
                            idNum = list.get(i).Id;
                            pidname = list.get(i).UserName;
                        }
                    }
                    //设置adapter
                    mAdapter = new SelectPassengerAdapter(getContext(), list,listpassenger);
                    mListview.setAdapter(mAdapter);
                    JLog.d("--------------","联系人"+list.toString());
                }
            }
        });
    }

    private void initView() {
        mListview = (ListView) mInflate.findViewById(R.id.select_list);
        mBt_back = (Button) mInflate.findViewById(R.id.btn_select_back);
        mBt_ok = (Button) mInflate.findViewById(R.id.btn_select_ok);
        mIv_add = (ImageView) mInflate.findViewById(R.id.iv_select_addpassenger);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_select_back:
                //返回前一个火车票界面
                finish();
                break;
            case R.id.btn_select_ok:
                //ok按钮
                List<Passenger> list = mAdapter.getList();
                if (list.size()>5){
                    Toast.makeText(getContext(),"最多添加5个乘车人",Toast.LENGTH_SHORT).show();
                }else {
                    //返回前一个界面 ,并把数据传递过去
                    Bundle bundle = new Bundle();
                    JLog.d("------------",list.toString());
                    bundle.putSerializable("passenger", (Serializable) list);
                    bundle.putString("pidname",pidname);
                    setResult(RESULT_CANCELED,bundle);
                    finish();
                }
                break;
            case R.id.iv_select_addpassenger:
                //进入编辑联系人界面
                startFragment(EditPassenegrFragment.newInstance(idNum+"",pidname+"",mParam1,regrist));

                break;
            default:
                break;
        }
    }
}


text:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using System.IO;
using System.Text;

namespace Cuemon.Data
{
    ///
    /// The DataManager is an abstract class in the <see cref="Data"/> namespace that can be used to implement execute commands of different database providers.
    ///
    public abstract class DataManager
    {
        #region Constructors

        #endregion

        #region Properties
        ///
        /// Gets the string used to open the connection.
        ///
        /// <value>The connection string used to establish the initial connection. The exact contents of the connection string depend on the specific data source for this connection.</value>
        public abstract string ConnectionString { get; }

        ///
        /// Gets or sets the default connection string.
        ///
        /// <value>The default connection string.</value>
        public static string DefaultConnectionString { get; set; }
        #endregion

        #region Methods
        ///
        /// Parses and returns a <see cref="Type"/> equivalent of <paramref name="dbType"/>.
        ///
        /// <param name="dbType">The <see cref="DbType"/> to parse.</param>
        /// <returns>A <see cref="Type"/> equivalent of <paramref name="dbType"/>.</returns>
        public static Type ParseDbType(DbType dbType)
        {
            switch (dbType)
            {
                case DbType.Byte:
                case DbType.SByte:
                    return typeof(byte);
                case DbType.Binary:
                    return typeof(byte[]);
                case DbType.Boolean:
                    return typeof(bool);
                case DbType.Currency:
                case DbType.Double:
                    return typeof(double);
                case DbType.Date:
                case DbType.DateTime:
                case DbType.Time:
                case DbType.DateTimeOffset:
                case DbType.DateTime2:
                    return typeof(DateTime);
                case DbType.Guid:
                    return typeof(Guid);
                case DbType.Int64:
                    return typeof(long);
                case DbType.Int32:
                    return typeof(int);
                case DbType.Int16:
                    return typeof(short);
                case DbType.Object:
                    return typeof(object);
                case DbType.AnsiString:
                case DbType.AnsiStringFixedLength:
                case DbType.StringFixedLength:
                case DbType.String:
                    return typeof(string);
                case DbType.Single:
                    return typeof(float);
                case DbType.UInt64:
                    return typeof(ulong);
                case DbType.UInt32:
                    return typeof(uint);
                case DbType.UInt16:
                    return typeof(ushort);
                case DbType.Decimal:
                case DbType.VarNumeric:
                    return typeof(decimal);
                case DbType.Xml:
                    return typeof(string);
            }
            throw new ArgumentOutOfRangeException(nameof(dbType), string.Format(CultureInfo.InvariantCulture, "Type, '{0}', is unsupported.", dbType));
        }

        ///
        /// Creates and returns a <see cref="KeyValuePair{TKey,TValue}"/> sequence of column names and values resolved from the specified <paramref name="reader"/>.
        ///
        /// <param name="reader">The reader to resolve column names and values from.</param>
        /// <returns>A <see cref="KeyValuePair{TKey,TValue}"/> sequence of column names and values resolved from the specified <paramref name="reader"/>.</returns>
        public static IEnumerable<KeyValuePair<string, object>> GetReaderColumns(DbDataReader reader)
        {
            if (reader == null) { throw new ArgumentNullException(nameof(reader)); }
            if (reader.IsClosed) { throw new ArgumentException("Reader is closed.", nameof(reader)); }
            return GetReaderColumnsIterator(reader);
        }

        private static IEnumerable<KeyValuePair<string, object>> GetReaderColumnsIterator(DbDataReader reader)
        {
            for (var f = 0; f < reader.FieldCount; f++)
            {
                yield return new KeyValuePair<string, object>(reader.GetName(f), reader.GetValue(f));
            }
        }

        ///
        /// Converts the given <see cref="DbDataReader"/> compatible object to a stream.
        /// Note: DbDataReader must return only one field (for instance, a XML field), otherwise an exception is thrown!
        ///
        /// <param name="value">The <see cref="DbDataReader"/> to build a stream from.</param>
        /// <returns>A <see cref="Stream"/> object.</returns>
        public static Stream ReaderToStream(DbDataReader value)
        {
            if (value == null) { throw new ArgumentNullException(nameof(value)); }
            Stream stream;
            Stream tempStream = null;
            try
            {
                if (value.FieldCount > 1)
                {
                    throw new InvalidDataException(string.Format(CultureInfo.InvariantCulture,
                        "The executed command statement appears to contain invalid fields. Expected field count is 1. Actually field count was {0}.",
                        value.FieldCount));
                }

                tempStream = new MemoryStream();
                while (value.Read())
                {
                    var bytes = Convertible.GetBytes(value.GetString(0));
                    tempStream.Write(bytes, 0, bytes.Length);
                }
                tempStream.Position = 0;
                stream = tempStream;
                tempStream = null;
            }
            finally
            {
                tempStream?.Dispose();
            }
            return stream;
        }

        ///
        /// Converts the given <see cref="DbDataReader"/> compatible object to a string.
        /// Note: DbDataReader must return only one field, otherwise an exception is thrown!
        ///
        /// <param name="value">The <see cref="DbDataReader"/> to build a string from.</param>
        /// <returns>A <see cref="string"/> object.</returns>
        public static string ReaderToString(DbDataReader value)
        {
            if (value == null) { throw new ArgumentNullException(nameof(value)); }
            if (value.FieldCount > 1)
            {
                throw new InvalidDataException(string.Format(CultureInfo.InvariantCulture,
                    "The executed command statement appears to contain invalid fields. Expected field count is 1. Actually field count was {0}.",
                    value.FieldCount));
            }
            var stringBuilder = new StringBuilder();
            while (value.Read())
            {
                stringBuilder.Append(value.GetString(0));
            }
            return stringBuilder.ToString();
        }

        ///
        /// Creates a new object that is a copy of the current instance.
        ///
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public abstract DataManager Clone();

        ///
        /// Executes the command statement and returns the number of rows affected.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>
        /// A <see cref="int"/> value.
        /// </returns>
        public int Execute(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteCore(dataCommand, parameters, dbCommand =>
            {
                try
                {
                    return dbCommand.ExecuteNonQuery();
                }
                finally
                {
                    if (dbCommand.Connection.State != ConnectionState.Closed) { dbCommand.Connection.Close(); }
                }
            });
        }

        ///
        /// Executes the command statement and returns <c>true</c> if one or more records exists; otherwise <c>false</c>.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>
        /// A <see cref="bool"/> value.
        /// </returns>
        public bool ExecuteExists(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            using (var reader = ExecuteReader(dataCommand, parameters))
            {
                return reader.Read();
            }
        }

        ///
        /// Executes the command statement and returns an identity value as int.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns><see cref="int"/></returns>
        public abstract int ExecuteIdentityInt32(IDataCommand dataCommand, params IDbDataParameter[] parameters);

        ///
        /// Executes the command statement and returns an identity value as long.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns><see cref="long"/></returns>
        public abstract long ExecuteIdentityInt64(IDataCommand dataCommand, params IDbDataParameter[] parameters);

        ///
        /// Executes the command statement and returns an identity value as decimal.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns><see cref="decimal"/></returns>
        public abstract decimal ExecuteIdentityDecimal(IDataCommand dataCommand, params IDbDataParameter[] parameters);

        ///
        /// Executes the command statement and returns an object supporting the DbDataReader interface.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>
        /// An object supporting the <see cref="DbDataReader"/> interface.
        /// </returns>
        public DbDataReader ExecuteReader(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteCore(dataCommand, parameters, dbCommand => dbCommand.ExecuteReader(CommandBehavior.CloseConnection));
        }

        ///
        /// Executes the command statement and returns a string object with the retrieved XML.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>
        /// An <see cref="string"/> object.
        /// </returns>
        public virtual string ExecuteXmlString(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            using (var reader = ExecuteReader(dataCommand, parameters))
            {
                return ReaderToString(reader);
            }
        }

        ///
        /// Executes the command statement, and returns the value from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand"/>.</returns>
        public object ExecuteScalar(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteCore(dataCommand, parameters, dbCommand =>
            {
                try
                {
                    return dbCommand.ExecuteScalar();
                }
                finally
                {
                    if (dbCommand.Connection.State != ConnectionState.Closed) { dbCommand.Connection.Close(); }
                }
            });
        }

        ///
        /// Executes the command statement, and returns the value as the specified <paramref name="returnType"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="returnType">The type to return the first column value as.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand"/> as the specified <paramref name="returnType"/>.</returns>
        /// <remarks>This method uses <see cref="CultureInfo.InvariantCulture"/> when casting the first column of the first row in the result from <paramref name="dataCommand"/>.</remarks>
        public object ExecuteScalarAsType(IDataCommand dataCommand, Type returnType, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAsType(dataCommand, returnType, CultureInfo.InvariantCulture, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as the specified <paramref name="returnType"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="returnType">The type to return the first column value as.</param>
        /// <param name="provider">An object that supplies culture-specific formatting information.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand"/> as the specified <paramref name="returnType"/>.</returns>
        public object ExecuteScalarAsType(IDataCommand dataCommand, Type returnType, IFormatProvider provider, params IDbDataParameter[] parameters)
        {
            return Decorator.Enclose(ExecuteScalar(dataCommand, parameters)).ChangeType(returnType, o => o.FormatProvider = provider);
        }

        ///
        /// Executes the command statement, and returns the value as <typeparamref name="TResult" /> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <typeparam name="TResult">The type of the return value.</typeparam>
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <typeparamref name="TResult"/>.</returns>
        /// <remarks>This method uses <see cref="CultureInfo.InvariantCulture"/> when casting the first column of the first row in the result from <paramref name="dataCommand"/>.</remarks>
        public TResult ExecuteScalarAs<TResult>(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return (TResult)ExecuteScalarAsType(dataCommand, typeof(TResult), parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <typeparamref name="TResult" /> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <typeparam name="TResult">The type of the return value.</typeparam>
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="provider">An object that supplies culture-specific formatting information.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <typeparamref name="TResult"/>.</returns>
        public TResult ExecuteScalarAs<TResult>(IDataCommand dataCommand, IFormatProvider provider, params IDbDataParameter[] parameters)
        {
            return (TResult)ExecuteScalarAsType(dataCommand, typeof(TResult), provider, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="bool"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="bool"/>.</returns>
        public bool ExecuteScalarAsBoolean(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<bool>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="DateTime"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="DateTime"/>.</returns>
        public DateTime ExecuteScalarAsDateTime(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<DateTime>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="short"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="short"/>.</returns>
        public short ExecuteScalarAsInt16(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<short>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="int"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="int"/>.</returns>
        public int ExecuteScalarAsInt32(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<int>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="long"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="long"/>.</returns>
        public long ExecuteScalarAsInt64(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<long>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="byte"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="byte"/>.</returns>
        public byte ExecuteScalarAsByte(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<byte>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="sbyte"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="sbyte"/>.</returns>
        public sbyte ExecuteScalarAsSByte(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<sbyte>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="decimal"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="decimal"/>.</returns>
        public decimal ExecuteScalarAsDecimal(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<decimal>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="double"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="double"/>.</returns>
        public double ExecuteScalarAsDouble(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<double>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="ushort"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="ushort"/>.</returns>
        public ushort ExecuteScalarAsUInt16(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<ushort>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="uint"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="uint"/>.</returns>
        public uint ExecuteScalarAsUInt32(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<uint>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="ulong"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="ulong"/>.</returns>
        public ulong ExecuteScalarAsUInt64(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<ulong>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="string"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="string"/>.</returns>
        public string ExecuteScalarAsString(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<string>(dataCommand, parameters);
        }

        ///
        /// Executes the command statement, and returns the value as <see cref="Guid"/> from the first column of the first row in the result set.
        /// Additional columns or rows are ignored.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>The first column of the first row in the result from <paramref name="dataCommand" /> as <see cref="Guid"/>.</returns>
        public Guid ExecuteScalarAsGuid(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            return ExecuteScalarAs<Guid>(dataCommand, parameters);
        }

        ///
        /// Core method for executing methods on the <see cref="DbCommand"/> object resolved from the virtual <see cref="ExecuteCommandCore"/> method.
        ///
        /// <typeparam name="T">The type to return.</typeparam>
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <param name="commandInvoker">The function delegate that will invoke a method on the resolved <see cref="DbCommand"/> from the virtual <see cref="ExecuteCommandCore"/> method.</param>
        /// <returns>A value of <typeparamref name="T"/> that is equal to the invoked method of the <see cref="DbCommand"/> object.</returns>
        protected virtual T ExecuteCore<T>(IDataCommand dataCommand, IDbDataParameter[] parameters, Func<DbCommand, T> commandInvoker)
        {
            return InvokeCommandCore(dataCommand, parameters, commandInvoker);
        }

        private T InvokeCommandCore<T>(IDataCommand dataCommand, IDbDataParameter[] parameters, Func<DbCommand, T> sqlInvoker)
        {
            T result;
            DbCommand command = null;
            try
            {
                using (command = ExecuteCommandCore(dataCommand, parameters))
                {
                    result = sqlInvoker(command);
                }
            }
            finally
            {
                command?.Parameters.Clear();
            }
            return result;
        }

        ///
        /// Core method for executing all commands.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>System.Data.Common.DbCommand</returns>
        protected virtual DbCommand ExecuteCommandCore(IDataCommand dataCommand, params IDbDataParameter[] parameters)
        {
            if (dataCommand == null) throw new ArgumentNullException(nameof(dataCommand));
            DbCommand command = null;
            try
            {
                command = GetCommandCore(dataCommand, parameters);
                command.CommandTimeout = (int)dataCommand.Timeout.TotalSeconds;
                OpenConnection(command);
            }
            catch (Exception)
            {
                command?.Parameters.Clear();
                throw;
            }
            return command;
        }

        private static void OpenConnection(DbCommand command)
        {
            Validator.ThrowIfNull(command);
            Validator.ThrowIfNull(command.Connection, nameof(command), $"The connection of the {nameof(command)} was not set.");
            if (command.Connection.State != ConnectionState.Open) { command.Connection.Open(); }
        }

        ///
        /// Gets the command object to be used by all execute related methods.
        ///
        /// <param name="dataCommand">The data command to execute.</param>
        /// <param name="parameters">The parameters to use in the command.</param>
        /// <returns>An instance of a <see cref="DbCommand"/> implementation.</returns>
        protected abstract DbCommand GetCommandCore(IDataCommand dataCommand, params IDbDataParameter[] parameters);
        #endregion
    }
}

redpajama_set_name: RedPajamaGithub


text:
layout: post
title:  "Showroomprive.com - Landing page"
date: 2015-01-06
excerpt: "Landing Page for a fashion private sales site"
project: true
tag:
- landing page
- fashion
- Showroomprive
- Portugal
comments: true
---

![Uzo]({{ site.url }}/assets/img/projects/showroom/login.jpg){: .login-img }

 Landing page made for one of main fashion private sales site.

## Preview

{% capture images %}
	{{ site.url }}/assets/img/projects/showroom/screen-0.jpg
	{{ site.url }}/assets/img/projects/showroom/screen-1.jpg
	{{ site.url }}/assets/img/projects/showroom/screen-2.jpg
{% endcapture %}
{% include gallery images=images caption="Screenshots of Showroomprive Landing Page" cols=3 %}

You can find the landing page [here](http://outletmoda.pt/)


text:
using System.Collections.Generic;

namespace ClassExercise
{
    class Exercise
    {
        public string Topic { get; set; }

        public string CourseName { get; set; }

        public string JudgeContestLink { get; set; }

        public List<string> Problems { get; set; }
    }
}


text:
@implementation Status

+ (NSDictionary *)andy_objectClassInArray
{
    return @{@"pic_urls" : [PicUrls class]};
    //return @{@"pic_urls" : @"PicUrls"};
}

@end


text:
package org.apache.uima.pear.tools;

import java.io.File;
import java.net.URL;
import java.util.prefs.Preferences;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;

import org.apache.uima.pear.util.FileUtil;

/**
 * The PackageSelectorGUI class provides simple Swing-based file dialog windows for
 * selecting root directories of installed PEAR packages, as well as PEAR package files, which
 * contain components that need to be installed.
 *
 */

public class PackageSelectorGUI implements InstallationController.PackageSelector {
  /**
   * The PackageDirFilter class allows filtering directories.
   */
  public static class PackageDirFilter extends FileFilter {
    /**
     * Determines whether a given File object is accepted by this filter.
     *
     * @param file
     *          The given File object.
     * @return true, if the given File object is accepted,
     *         fase otherwise.
     */
    @Override
    public boolean accept(File file) {
      // accept only directories
      return file.isDirectory();
    }

    /**
     * @return The description of this filter.
     */
    @Override
    public String getDescription() {
      return "Root directories of installed PEAR packages";
    }
  }

  /**
   * The PackageFileFilter class allows filtering PEAR package files.
   */
  public static class PackageFileFilter extends FileFilter {
    // valid file extensions
    private static final String TEAR_EXT = ".tear";

    private static final String PEAR_EXT = ".pear";

    /**
     * Determines whether a given File object is accepted by this filter.
     *
     * @param file
     *          The given File object.
     * @return true, if the given File object is accepted,
     *         fase otherwise.
     */
    @Override
    public boolean accept(File file) {
      if (file.isDirectory()) // show all directories
        return true;
      // show PEAR files
      String ext = FileUtil.getFileNameExtension(file.getName()).toLowerCase();
      return ext.equals(TEAR_EXT) || ext.equals(PEAR_EXT);
    }

    /**
     * @return The description of this filter.
     */
    @Override
    public String getDescription() {
      return "PEAR package files";
    }
  }

  // persistent user preferences keys
  private static final String LAST_PACKAGE_DIR_KEY = "last_package_dir";

  private static final String LAST_PACKAGE_FILE_KEY = "last_package_file";

  // attributes
  private JFrame _dialogFrame = null;

  /**
   * Default constructor.
   */
  public PackageSelectorGUI() {
    _dialogFrame = new JFrame();
    _dialogFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  }

  /**
   * Opens dialog window to select root directory of desired installed component package.
   *
   * @param componentId
   *          The given component ID.
   * @return Selected package root directory or null, if the selection cancelled.
   */
  @Override
  public synchronized File selectPackageDirectory(String componentId) {
    // get last package dir path
    Preferences userPrefs = Preferences.userNodeForPackage(getClass());
    String lastDirPath = (userPrefs != null) ? userPrefs.get(LAST_PACKAGE_DIR_KEY, "./") : "./";
    File lastDir = new File(lastDirPath);
    // create JFileChooser
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.addChoosableFileFilter(new PackageDirFilter());
    fileChooser.setCurrentDirectory(lastDir);
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fileChooser.setDialogTitle("Select " + componentId + " root directory");
    // show information dialog
    String message = "Select the root directory of installed\n" + "\n" + componentId + "\n"
            + "\ncomponent using the following file dialog,\n"
            + "or press 'Cancel' in the file dialog, if this\n"
            + "component is not installed in your file system.";
    JOptionPane.showMessageDialog(_dialogFrame, message);
    // open dialog window
    File selectedDir = null;
    int result = fileChooser.showDialog(_dialogFrame, "Select");
    if (result == JFileChooser.APPROVE_OPTION) {
      // set 'selected dir'
      selectedDir = fileChooser.getSelectedFile();
      if (selectedDir != null) {
        // set 'last dir' in user prefs
        lastDir = selectedDir.getParentFile();
        userPrefs.put(LAST_PACKAGE_DIR_KEY, lastDir.getAbsolutePath());
      }
    }
    return selectedDir;
  }

  /**
   * Opens dialog window to select desired PEAR package file for a given component.
   *
   * @param componentId
   *          The given component ID.
   * @return Selected PEAR package file for the given component, or null, if the
   *         selection cancelled.
   */
  @Override
  public synchronized File selectPackageFile(String componentId) {
    // get last package file path
    Preferences userPrefs = Preferences.userNodeForPackage(getClass());
    String lastFilePath = (userPrefs != null) ? userPrefs.get(LAST_PACKAGE_FILE_KEY, "") : "";
    File lastFile = lastFilePath.length() > 0 ? new File(lastFilePath) : null;
    File lastDir = lastFile != null ? lastFile.getParentFile() : new File(".");
    // create JFileChooser
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.addChoosableFileFilter(new PackageFileFilter());
    fileChooser.setCurrentDirectory(lastDir);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setDialogTitle("Select " + componentId + " PEAR file");
    // show information dialog
    String message = "Select the PEAR file of the\n" + "\n" + componentId + "\n"
            + "\ncomponent using the following file dialog.";
    JOptionPane.showMessageDialog(_dialogFrame, message);
    // open dialog window
    File selectedFile = null;
    int result = fileChooser.showDialog(_dialogFrame, "Select");
    if (result == JFileChooser.APPROVE_OPTION) {
      // set 'selected file'
      selectedFile = fileChooser.getSelectedFile();
      if (selectedFile != null) {
        // set 'last file' in user prefs
        userPrefs.put(LAST_PACKAGE_FILE_KEY, selectedFile.getAbsolutePath());
      }
    }
    return selectedFile;
  }

  /**
   * This method is not implemented. It always returns null.
   *
   * @param componentId
   *          The given component ID.
   * @return The PEAR package URL for the given component or null, if no URL is
   *         entered.
   */
  @Override
  public URL selectPackageUrl(String componentId) {
    return null;
  }
}


text:
Mustacci is a simple, biased continuous integration server.

## How does it work?

Mustacci has many small parts. Here is the general gist of it:

1. The listener is a small Sinatra app that receives push notification from Github.
2. The listener sends the payload via ZeroMQ to the worker.
3. The worker stores the payload and starts the runner.
4. The runner runs your tests.
5. Meanwhile, all output is streamed to your browser.
6. You get to write a script that will notify you in the way you see fit.

It's not finished yet. Feel free to help us out, by contacting us.

## Why Mustacci?

We were fed up with Jenkins and we couldn't wait for Travis Pro. We're not
trying to compete with Travis, we believe it's an awesome service, run by
awesome people, and getting more awesome everyday. But we wanted something
quick and local, so we rolled our own. Also: hacking on a CI server is a lot of
fun! It turned out it wasn't as simple as we thought, but definitely fun.

## Requirements

* Ruby 1.9.3
* ZeroMQ
* CouchDB

## Installation

Install the gem:

``` shell
gem install mustacci
```

And run the installer to generate the configuration files. You'll have to give
it a directory where to put the configuration files, e.g.:

``` shell
mustacci install ~/Mustacci
```

You'll get these files:

* `mustacci.rb`, where you do all of your configurations.
* `Gemfile`, where you can add dependencies via [Bundler](http://gembundler.com/)
* `Procfile`, where you can specify the processes to run, using [Foreman](http://ddollar.github.com/foreman/)

Have a look through those file and configure as needed/wanted.

When you've configured it to your liking, setup the database:

``` shell
mustacci setup
```

Then you can start Mustacci:

``` shell
foreman start
```

## The build process

You are responsible for keeping a script that does your build inside your
repository. You need to create an executable file called `.mustacci` in the
root of your repository. This file needs to do pretty much everything on its
own: install dependencies, create and migrate the database, etc.

The `.mustacci` file must be executable and don't forget the hashbang at the top.

For example:

``` shell
#!/usr/bin/env bash
set -e
export RAILS_ENV=test
gem install bundler
bundle install
rake db:create
rake db:migrate
rspec -fp
```

If no `.mustacci` is found, it will try to run `rake`. No guarantees though.

## Development

After cloning, run `bundle install`, then install the application with the
`--development` option:

``` shell
bundle exec mustacci install dev --development
```

There is a dummy github payload you can use to test the github listener:

``` shell
curl -d "payload=`cat test/payload.json`" http://localhost:8081/github
```


text:
'use strict';

var grunt = require('grunt');

/*
  ======== A Handy Little Nodeunit Reference ========
  https://github.com/caolan/nodeunit

  Test methods:
    test.expect(numAssertions)
    test.done()
  Test assertions:
    test.ok(value, [message])
    test.equal(actual, expected, [message])
    test.notEqual(actual, expected, [message])
    test.deepEqual(actual, expected, [message])
    test.notDeepEqual(actual, expected, [message])
    test.strictEqual(actual, expected, [message])
    test.notStrictEqual(actual, expected, [message])
    test.throws(block, [error], [message])
    test.doesNotThrow(block, [error], [message])
    test.ifError(value)
*/

exports.encrypt = {
  encrypt: function(test) {
    var actual = grunt.file.read('test/tmp/encrypted.encrypted');
    var expected = grunt.file.read('test/expected/123');
    test.equal(actual, expected, 'should describe what the default behavior is.');

    test.done();
  },
  decrypt: function(test) {
    var actual = grunt.file.read('test/tmp/decrypted');
    var expected = grunt.file.read('test/fixtures/123');
    test.equal(actual, expected, 'should describe what the default behavior is.');

    test.done();
  }
};


text:
require "rubygems"
require "amqp"

require './lib/raq/runner'

runner = Raq::Runner.new(ARGV)

EventMachine.run do
  connection = AMQP.connect(runner.connection_options)

  puts "Connected to AMQP broker. Running #{AMQP::VERSION} version of the gem..."

  channel  = AMQP::Channel.new(connection)
  queue    = channel.queue(runner.options[:queue], durable: true, auto_delete: false)
  exchange = channel.direct("")

  puts "publshing #{runner.command} to #{queue.name}"
  exchange.publish runner.command, routing_key: queue.name, persistent: true, type: runner.options[:type]

  EventMachine.add_timer(1) { connection.close { EventMachine.stop } }
end


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PKStudio.ItemWrappers;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace PKStudio.Helpers
{
    public class VerificationHelper : ILoggable, IDisposable
    {
        private int ComponentsChecked = 0;

        private BackgroundWorker m_worker = null;

        public VerificationHelper()
        {
            this.m_worker = new BackgroundWorker();
            this.m_worker.DoWork += new DoWorkEventHandler(m_worker_DoWork);
        }

        void m_worker_DoWork(object sender, DoWorkEventArgs e)
        {
            this.OnLogStarted();
            this.OnMessage("Running Verification...\r\n\r\n");
            VerifyGUID();
            VerifyComponents();
            VerifyStubs();
            this.OnMessage("Verification Complete -- " + mEWList.ErrorsCount + " error(s), " + mEWList.WarningsCount + " warning(s)\r\n");
            this.OnLogFinished(mEWList);
        }

        public void Verify()
        {
            mEWList.ClearAll();
            m_worker.RunWorkerAsync();
        }

        private void VerifyGUID()
        {
            this.OnMessage("Running GUIDs Verification...\r\n");
            List<ComponentWrapper> CheckList = new List<ComponentWrapper>();

            LibraryWrapper[] LWS = PK.Wrapper.GetLibraries();
            foreach (LibraryWrapper LW in LWS)
            {
                CheckList.Add(ComponentWrapper.GetComponentWrapper(LW));
            }

            FeatureWrapper[] FWS = PK.Wrapper.GetFeatures();
            foreach (FeatureWrapper FW in FWS)
            {
                CheckList.Add(ComponentWrapper.GetComponentWrapper(FW));
            }

            AssemblyWrapper[] AWS = PK.Wrapper.GetAssembies();
            foreach (AssemblyWrapper AW in AWS)
            {
                CheckList.Add(ComponentWrapper.GetComponentWrapper(AW));
            }

            ProcessorWrapper[] PWS = PK.Wrapper.GetProcessors();
            foreach (ProcessorWrapper PW in PWS)
            {
                CheckList.Add(ComponentWrapper.GetComponentWrapper(PW));
            }

            BuildToolWrapper_[] BTWS = PK.Wrapper.GetBuildTools();
            foreach (BuildToolWrapper_ BTW in BTWS)
            {
                CheckList.Add(ComponentWrapper.GetComponentWrapper(BTW));
            }

            ISAWrapper[] IWS = PK.Wrapper.GetISAs();
            foreach (ISAWrapper IW in IWS)
            {
                CheckList.Add(ComponentWrapper.GetComponentWrapper(IW));
            }

            //   case ComponentTypeWrapper.BuildParameter:

            LibraryCategoryWrapper[] LCWS = PK.Wrapper.GetLibraryCategories();
            foreach (LibraryCategoryWrapper LCW in LCWS)
            {
                CheckList.Add(ComponentWrapper.GetComponentWrapper(LCW));
            }

            if (PK.Wrapper.Solution != null)
            {
                CheckList.Add(ComponentWrapper.GetComponentWrapper(PK.Wrapper.Solution));

                foreach (ProjectWrapper PW in PK.Wrapper.Solution.Projects)
                {
                    CheckList.Add(ComponentWrapper.GetComponentWrapper(PW));
                }
            }

            foreach (ComponentWrapper w1 in CheckList)
            {
                foreach (ComponentWrapper w2 in CheckList)
                {
                    if (w1 != w2)
                    {
                        if (string.Compare(w1.Guid, w2.Guid, true) == 0)
                        {
                            WEMessage message = new WEMessage();
                            message.Message = GetStringByComponentType(w1.ComponentType) + " \"" + w1.Name + "\" have same GUID as " + GetStringByComponentType(w2.ComponentType) + " \"" + w2.Name + "\"";
                            this.OnWarning(message);
                        }
                    }
                }
            }

            this.OnMessage("Verified " + CheckList.Count + " object(s).\r\n\r\n");
        }

        private void VerifyComponents()
        {
            this.OnMessage("Running Components Verification...\r\n");

            ComponentsChecked = 0;

            FeatureWrapper[] FWS = PK.Wrapper.GetFeatures();
            foreach (FeatureWrapper FW in FWS)
            {
                ComponentWrapper OwnerComponent = ComponentWrapper.GetComponentWrapper(FW);
                string text = "Feature \"" + FW.Name + "\" Assemblies: ";
                foreach (ComponentWrapper item in FW.Assemblies)
                {
                    CheckComponent(OwnerComponent, text, item);
                }
                text = "Feature \"" + FW.Name + "\" Component Dependencies: ";
                foreach (ComponentWrapper item in FW.ComponentDependencies)
                {
                    CheckComponent(OwnerComponent, text, item);
                }
                text = "Feature \"" + FW.Name + "\" Feature Dependencies: ";
                foreach (ComponentWrapper item in FW.FeatureDependencies)
                {
                    CheckComponent(OwnerComponent, text, item);
                }
            }

            LibraryWrapper[] LWS = PK.Wrapper.GetLibraries();
            foreach (LibraryWrapper LW in LWS)
            {
                ComponentWrapper OwnerComponent = ComponentWrapper.GetComponentWrapper(LW);
                string text = "Library \"" + LW.Name + "\" Dependencies: ";
                foreach (ComponentWrapper item in LW.Dependencies)
                {
                    CheckComponent(OwnerComponent, text, item);
                }
                if (LW.ISASpecific != null)
                {
                    text = "Library \"" + LW.Name + "\" ISASpecific: ";
                    CheckComponent(OwnerComponent, text, LW.ISASpecific);
                }

                if (LW.LibraryCategory != null)
                {
                    text = "Library \"" + LW.Name + "\" LibraryCategory: ";
                    CheckComponent(OwnerComponent, text, LW.LibraryCategory);
                }

                if (LW.ProcessorSpecific != null)
                {
                    text = "Library \"" + LW.Name + "\" ProcessorSpecific: ";
                    CheckComponent(OwnerComponent, text, LW.ProcessorSpecific);
                }
            }

            LibraryCategoryWrapper[] LCWS = PK.Wrapper.GetLibraryCategories();
            foreach (LibraryCategoryWrapper LCW in LCWS)
            {
                ComponentWrapper OwnerComponent = ComponentWrapper.GetComponentWrapper(LCW);
                string text = "Library Category \"" + LCW.Name + "\" FeatureAssociations: ";
                foreach (ComponentWrapper item in LCW.FeatureAssociations)
                {
                    CheckComponent(OwnerComponent, text, item);
                }
                if (LCW.StubLibrary != null)
                {
                    text = "Library Category \"" + LCW.Name + "\" StubLibrary: ";
                    CheckComponent(OwnerComponent, text, LCW.StubLibrary);
                }
            }

            AssemblyWrapper[] AWS = PK.Wrapper.GetAssembies();
            foreach (AssemblyWrapper AW in AWS)
            {
                ComponentWrapper OwnerComponent = ComponentWrapper.GetComponentWrapper(AW);
                string text = "Assembly \"" + AW.Name + "\" References: ";
                foreach (ComponentWrapper item in AW.References)
                {
                    CheckComponent(OwnerComponent, text, item);
                }
            }

            ProcessorWrapper[] PWS = PK.Wrapper.GetProcessors();
            foreach (ProcessorWrapper PW in PWS)
            {
                ComponentWrapper OwnerComponent = ComponentWrapper.GetComponentWrapper(PW);
                string text = "Processor \"" + PW.Name + "\" SupportedISAs: ";
                foreach (ComponentWrapper item in PW.SupportedISAs)
                {
                    CheckComponent(OwnerComponent, text, item);
                }
            }

            if (PK.Wrapper.Solution != null)
            {
                ComponentWrapper OwnerComponent = ComponentWrapper.GetComponentWrapper(PK.Wrapper.Solution);
                if (PK.Wrapper.Solution.DefaultISA != null)
                {
                    string text = "Solution \"" + PK.Wrapper.Solution.Name + "\" Default ISA: ";
                    CheckComponent(OwnerComponent, text, PK.Wrapper.Solution.DefaultISA);
                }

                if (PK.Wrapper.Solution.Processor != null)
                {
                    string text = "Solution \"" + PK.Wrapper.Solution.Name + "\" Processor: ";
                    CheckComponent(OwnerComponent, text, PK.Wrapper.Solution.Processor);
                }

                foreach (ProjectWrapper PW in PK.Wrapper.Solution.Projects)
                {
                    string text = "Project \"" + PW.Name + "\" Features: ";
                    foreach (ComponentWrapper item in PW.Features)
                    {
                        CheckComponent(OwnerComponent, text, item);
                    }

                    text = "Project \"" + PW.Name + "\" LibraryCategories: ";
                    foreach (ComponentWrapper item in PW.LibraryCategories)
                    {
                        CheckComponent(OwnerComponent, text, item);
                    }

                    text = "Project \"" + PW.Name + "\" Libraries: ";
                    foreach (ComponentWrapper item in PW.Libraries)
                    {
                        CheckComponent(OwnerComponent, text, item);
                    }
                }
            }

            this.OnMessage("Verified " + ComponentsChecked + " object(s).\r\n\r\n");
        }

        private void VerifyStubs()
        {
            this.OnMessage("Running Stubs Verification...\r\n");

            List<LibraryWrapper> CheckList = new List<LibraryWrapper>();

            LibraryWrapper[] LWS = PK.Wrapper.GetLibraries();
            foreach (LibraryWrapper LW in LWS)
            {
                if (LW.IsStub)
                    CheckList.Add(LW);
            }

            foreach (LibraryWrapper LW in CheckList)
            {
                ComponentMessageObject CMO = new ComponentMessageObject();
                CMO.Component = ComponentWrapper.GetComponentWrapper(LW);

                if (LW.HasLibraryCategory == false)
                {
                    WEMessage message = new WEMessage();
                    message.Message = "Stub " + GetStringByComponentType(ComponentTypeWrapper.Library) + " \"" + LW.Name + "\" has not have library category";
                    message.MessageObject = CMO;
                    this.OnWarning(message);
                }
                else
                {
                    LibraryCategoryWrapper LCW = PK.Wrapper.FindLibraryCategory(LW.LibraryCategory.Guid);
                    if (string.Compare(LCW.StubLibrary.Guid, LW.Guid, true) != 0)
                    {
                        WEMessage message = new WEMessage();
                        message.Message = "Stub " + GetStringByComponentType(ComponentTypeWrapper.Library) + " \"" + LW.Name + "\": " + GetStringByComponentType(ComponentTypeWrapper.LibraryCategory) + " \"" + LCW.Name + "\" has wrong GUID in it's StubLibrary field";
                        message.MessageObject = CMO;
                        this.OnWarning(message);
                    }

                    if (string.Compare(LCW.StubLibrary.Name, LW.Name, true) != 0)
                    {
                        WEMessage message = new WEMessage();
                        message.Message = "Stub " + GetStringByComponentType(ComponentTypeWrapper.Library) + " \"" + LW.Name + "\": " + GetStringByComponentType(ComponentTypeWrapper.LibraryCategory) + " \"" + LCW.Name + "\" has wrong NAME in it's StubLibrary field";
                        message.MessageObject = CMO;
                        this.OnWarning(message);
                    }

                    if (string.Compare(LCW.StubLibrary.ProjectPath, LW.ProjectPath, true) != 0)
                    {
                        WEMessage message = new WEMessage();
                        message.Message = "Stub " + GetStringByComponentType(ComponentTypeWrapper.Library) + " \"" + LW.Name + "\": " + GetStringByComponentType(ComponentTypeWrapper.LibraryCategory) + " \"" + LCW.Name + "\" has wrong ProjectPath in it's StubLibrary field";
                        message.MessageObject = CMO;
                        this.OnWarning(message);
                    }
                }
            }

            LibraryCategoryWrapper[] LCWS = PK.Wrapper.GetLibraryCategories();
            foreach (LibraryCategoryWrapper LCW in LCWS)
            {
                ComponentMessageObject CMO = new ComponentMessageObject();
                CMO.Component = ComponentWrapper.GetComponentWrapper(LCW);

                if (LCW.StubLibrary.Guid == null)
                {
                    WEMessage message = new WEMessage();
                    message.Message = GetStringByComponentType(ComponentTypeWrapper.LibraryCategory) + " \"" + LCW.Name + "\" has not have stub library";
                    message.MessageObject = CMO;
                    this.OnWarning(message);
                }
                else
                {
                    LibraryWrapper LW = PK.Wrapper.FindLibrary(LCW.StubLibrary.Guid);
                    if (LW == null)
                    {
                        WEMessage message = new WEMessage();
                        message.Message = GetStringByComponentType(ComponentTypeWrapper.LibraryCategory) + " \"" + LCW.Name + "\" Stub Library: Can't find library with GUID";
                        message.MessageObject = CMO;
                        this.OnWarning(message);
                    }
                    else
                    {
                        if (string.Compare(LCW.StubLibrary.Name, LW.Name, true) != 0)
                        {
                            WEMessage message = new WEMessage();
                            message.Message = GetStringByComponentType(ComponentTypeWrapper.LibraryCategory) + " \"" + LCW.Name + "\" Stub Library: Name mismatch. Stub component Name is \"" + LCW.StubLibrary.Name + "\" " + GetStringByComponentType(ComponentTypeWrapper.Library) + " Name is \"" + LW.Name + "\"";
                            message.MessageObject = CMO;
                            this.OnWarning(message);
                        }

                        if (string.Compare(LCW.StubLibrary.ProjectPath, LW.ProjectPath, true) != 0)
                        {
                            WEMessage message = new WEMessage();
                            message.Message = GetStringByComponentType(ComponentTypeWrapper.LibraryCategory) + " \"" + LCW.Name + "\" Stub Library: Project Path mismatch. Stub component Project Path is \"" + LCW.StubLibrary.Name + "\" " + GetStringByComponentType(ComponentTypeWrapper.Library) + " Project Path is \"" + LW.Name + "\"";
                            message.MessageObject = CMO;
                            this.OnWarning(message);
                        }
                    }
                }
            }

            this.OnMessage("Verified " + CheckList.Count + " object(s).\r\n\r\n");
        }

        private string GetStringByComponentType(ComponentTypeWrapper type)
        {

            string result = string.Empty;
            switch (type)
            {
                case ComponentTypeWrapper.Library:
                    result = "Library";
                    break;
                case ComponentTypeWrapper.Feature:
                    result = "Feature";
                    break;
                case ComponentTypeWrapper.MFAssembly:
                    result = "MF Assembly";
                    break;
                case ComponentTypeWrapper.MFSolution:
                    result = "MF Solution";
                    break;
                case ComponentTypeWrapper.Processor:
                    result = "Processor";
                    break;
                case ComponentTypeWrapper.OperatingSystem:
                    result = "Operating System";
                    break;
                case ComponentTypeWrapper.BuildTool:
                    result = "Build Tool";
                    break;
                case ComponentTypeWrapper.ISA:
                    result = "ISA";
                    break;
                case ComponentTypeWrapper.BuildParameter:
                    result = "Build Parameter";
                    break;
                case ComponentTypeWrapper.LibraryCategory:
                    result = "Library Category";
                    break;
                case ComponentTypeWrapper.Unknown:
                    result = "Unknown";
                    break;
                default:
                    result = "Unknown";
                    break;
            }
            return result;
        }

        private void CheckComponent(ComponentWrapper OwnerComponent, string text, ComponentWrapper component)
        {
            ComponentMessageObject CMO = new ComponentMessageObject();
            CMO.Component = OwnerComponent;

            ComponentsChecked++;
            switch (component.ComponentType)
            {
                #region Library
                case ComponentTypeWrapper.Library:
                    if (!CheckComponentGUID(component, text, CMO)) return;

                    LibraryWrapper LW = PK.Wrapper.FindLibrary(component.Guid);
                    if (LW == null)
                    {
                        CanTFindComponentsReference(component, text, CMO);
                        return;
                    }
                    CompareComponentName(component, LW.Name, text, CMO);
                    CompareComponentProjectPath(component, LW.ProjectPath, text, CMO);
                    break;
                #endregion
                #region Feature
                case ComponentTypeWrapper.Feature:
                    if (!CheckComponentGUID(component, text, CMO)) return;

                    FeatureWrapper FW = PK.Wrapper.FindFeature(component.Guid);
                    if (FW == null)
                    {
                        CanTFindComponentsReference(component, text, CMO);
                        return;
                    }
                    CompareComponentName(component, FW.Name, text, CMO);
                    CompareComponentProjectPath(component, FW.ProjectPath, text, CMO);
                    break;
                #endregion
                #region Assembly
                case ComponentTypeWrapper.MFAssembly:
                    if (!CheckComponentGUID(component, text, CMO)) return;

                    AssemblyWrapper AW = PK.Wrapper.FindAssembly(component.Guid);
                    if (AW == null)
                    {
                        CanTFindComponentsReference(component, text, CMO);
                        return;
                    }
                    CompareComponentName(component, AW.Name, text, CMO);
                    CompareComponentProjectPath(component, AW.ProjectPath, text, CMO);
                    break;
                #endregion
                case ComponentTypeWrapper.MFSolution:
                    break;
                #region Processors
                case ComponentTypeWrapper.Processor:
                    if (!CheckComponentGUID(component, text, CMO)) return;

                    ProcessorWrapper PW = PK.Wrapper.FindProcessor(component.Guid);
                    if (PW == null)
                    {
                        CanTFindComponentsReference(component, text, CMO);
                        return;
                    }
                    CompareComponentName(component, PW.Name, text, CMO);
                    CompareComponentProjectPath(component, PW.ProjectPath, text, CMO);
                    break;
                #endregion
                case ComponentTypeWrapper.OperatingSystem:
                    break;
                case ComponentTypeWrapper.BuildTool:
                    break;
                #region ISA
                case ComponentTypeWrapper.ISA:
                    if (!CheckComponentGUID(component, text, CMO)) return;

                    ISAWrapper IW = PK.Wrapper.FindISA(component.Guid);
                    if (IW == null)
                    {
                        CanTFindComponentsReference(component, text, CMO);
                        return;
                    }
                    CompareComponentName(component, IW.Name, text, CMO);
                    break;
                #endregion
                case ComponentTypeWrapper.BuildParameter:
                    break;
                #region LibraryCategory
                case ComponentTypeWrapper.LibraryCategory:
                    if (!CheckComponentGUID(component, text, CMO)) return;

                    LibraryCategoryWrapper LCW = PK.Wrapper.FindLibraryCategory(component.Guid);
                    if (LCW == null)
                    {
                        CanTFindComponentsReference(component, text, CMO);
                        return;
                    }

                    CompareComponentName(component, LCW.Name, text, CMO);

                    CompareComponentProjectPath(component, LCW.ProjectPath, text, CMO);
                    break;
                #endregion
                #region Unknown
                case ComponentTypeWrapper.Unknown:
                    WEMessage UMessage = new WEMessage();
                    UMessage.Message = text + "Component with \"Type\": " + GetStringByComponentType(component.ComponentType);
                    UMessage.MessageObject = CMO;
                    this.OnWarning(UMessage);
                    break;
                #endregion
                default:
                    break;
            }
        }

        private void CompareComponentProjectPath(ComponentWrapper component, string ProjectPath, string text, ComponentMessageObject CMO)
        {
            if (component.Name == "COM_PAL")
            {
            }
            if (string.Compare(component.ProjectPath, ProjectPath, true) != 0)
            {
                WEMessage message = new WEMessage();
                message.Message = text + "Project Path mismatch. Component Project Path: \"" + component.ProjectPath + "\" " + GetStringByComponentType(component.ComponentType) + " Project Path:\"" + ProjectPath + "\"";
                message.MessageObject = CMO;
                this.OnWarning(message);
            }
        }

        private void CompareComponentName(ComponentWrapper component, string Name, string text, ComponentMessageObject CMO)
        {
            if (string.Compare(component.Name, Name, StringComparison.Ordinal) != 0)
            {
                WEMessage message = new WEMessage();
                message.Message = text + "Name mismatch. Component Name: \"" + component.Name + "\" " + GetStringByComponentType(component.ComponentType) + " Name:\"" + Name + "\"";
                message.MessageObject = CMO;
                this.OnWarning(message);
            }
        }

        private void CanTFindComponentsReference(ComponentWrapper component, string text, ComponentMessageObject CMO)
        {
            WEMessage message = new WEMessage();
            message.Message = text + "Can't find " + GetStringByComponentType(component.ComponentType) + " with GUID " + component.Guid;
            message.MessageObject = CMO;
            this.OnWarning(message);
        }

        private bool CheckComponentGUID(ComponentWrapper component, string text, ComponentMessageObject CMO)
        {
            if (string.IsNullOrEmpty(component.Guid))
            {
                if (!string.IsNullOrEmpty(component.Name) || !string.IsNullOrEmpty(component.ProjectPath))
                {
                    WEMessage message = new WEMessage();
                    message.Message = text + "GUID missing in " + GetStringByComponentType(component.ComponentType);
                    message.MessageObject = CMO;
                    this.OnWarning(message);
                }
                return false;
            }
            return true;
        }

        #region ILogger

        private ErrorsAndWarningsList mEWList = new ErrorsAndWarningsList();

        public event EventHandler LogStartedEvent;
        protected void OnLogStarted()
        {
            if (LogStartedEvent != null)
            {
                LogStartedEvent(this, EventArgs.Empty);
            }
        }

        public event EventHandler<LogFinishedEventArgs> LogFinishedEvent;
        protected void OnLogFinished(ErrorsAndWarningsList ErrorsAndWarningsList)
        {
            if (LogFinishedEvent != null)
            {
                LogFinishedEvent(this, new LogFinishedEventArgs(ErrorsAndWarningsList));
            }
        }

        public event EventHandler<MessageEventArgs> MessageEvent;
        protected void OnMessage(string message)
        {
            if (MessageEvent != null)
            {
                MessageEvent(this, new MessageEventArgs(message));
            }
        }

        public event EventHandler<WarningEventArgs> WarningEvent;
        protected void OnWarning(WEMessage Warning)
        {
            if (this.mEWList.AddWarning(Warning))
            {
                if (WarningEvent != null)
                {
                    WarningEvent(this, new WarningEventArgs(Warning));
                }
            }
        }

        public event EventHandler<ErrorEventArgs> ErrorEvent;
        protected void OnError(WEMessage Error)
        {
            if (ErrorEvent != null)
            {
                ErrorEvent(this, new ErrorEventArgs(Error));
            }
        }

        public ErrorsAndWarningsList ErrorsAndWarningsList { get { return mEWList; } }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // free managed resources
                if (m_worker != null)
                {
                    m_worker.Dispose();
                    m_worker = null;
                }
            }
        }
        #endregion
    }
}


text:
package com.zhouyuanchao.android.runtracker;

import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zhouyuanchao.android.runtracker.RunDatabaseHelper.RunCursor;

public class RunListFragment extends ListFragment {

	private static final int REQUEST_NEW_RUN = 0;

	private RunCursor mCursor;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setHasOptionsMenu(true);

		// Query the list of runs
		mCursor = RunManager.get(getActivity()).queryRuns();
		// Create an adapter to point at this cursor
		RunCursorAdapter adapter = new RunCursorAdapter(getActivity(), mCursor);
		setListAdapter(adapter);
	}

	@Override
	public void onDestroy() {
		mCursor.close();
		super.onDestroy();
	}

	@Override
	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
		super.onCreateOptionsMenu(menu, inflater);
		inflater.inflate(R.menu.run_list_options, menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		switch (item.getItemId()) {
		case R.id.menu_item_new_run:
			Intent intent = new Intent(getActivity(), RunActivity.class);
			startActivityForResult(intent, REQUEST_NEW_RUN);
			return true;

		default:
			break;
		}

		return super.onOptionsItemSelected(item);
	}

	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (REQUEST_NEW_RUN == requestCode) {
			mCursor.requery();
			((RunCursorAdapter)getListAdapter()).notifyDataSetChanged();
		}
	}

	private static class RunCursorAdapter extends CursorAdapter {

		private RunCursor mRunCursor;

		public RunCursorAdapter(Context context, RunCursor cursor) {
			super(context, cursor, 0);
			mRunCursor = cursor;
		}

		@Override
		public View newView(Context context, Cursor cursor, ViewGroup parent) {
			// Use a layout inflater to get a row view
			LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			return inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
		}

		@Override
		public void bindView(View view, Context context, Cursor cursor) {
			Run run = mRunCursor.getRun();

			TextView startDateTextView = (TextView)view;
			String cellText =
					context.getString(R.string.cell_text, run.getStartDate());
			startDateTextView.setText(cellText);
		}
	}
}


text: Конструктор речных круизов в Telegram


text:
package de.timmyrs.suprdiscordbot.scripts;

import de.timmyrs.suprdiscordbot.Main;
import de.timmyrs.suprdiscordbot.apis.ScriptAPI;

import javax.script.ScriptEngine;
import javax.script.ScriptException;
import java.util.HashMap;
import java.util.function.Consumer;

public class Script
{
	public final HashMap<String, Consumer<Object>> events = new HashMap<>();
	public String name;
	String hash;
	private boolean started = false;

	Script(String name, String hash, String script) throws ScriptException
	{
		this.name = name;
		setScript(hash, script);
	}

	Script setScript(final String hash, final String script) throws ScriptException
	{
		synchronized(events)
		{
			if(started)
			{
				if(events.containsKey("UNLOAD"))
				{
					events.get("UNLOAD").accept(null);
				}
			}
			events.clear();
			final ScriptEngine engine = Main.scriptManager.factory.getEngineByExtension("js");
			engine.put("console", Main.consoleAPI);
			engine.put("discord", Main.discordAPI);
			engine.put("internet", Main.internetAPI);
			engine.put("permission", Main.permissionAPI);
			engine.put("script", new ScriptAPI(this));
			engine.eval(script);
			this.hash = hash;
			started = true;
		}
		return this;
	}

	public void fireEvent(String event, final Object data)
	{
		event = event.toUpperCase();
		synchronized(events)
		{
			if(this.events.containsKey(event))
			{
				final Consumer<Object> function = this.events.get(event);
				new Thread(()->
				{
					function.accept(data);
				}, name + " " + event).start();
			}
		}
	}
}


text:
<?php

App::uses('Controller', 'Controller');

/**
 * Application Controller
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @package		app.Controller
 * @link		http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
 */
class AppController extends Controller {

    public $uses = array('User');

    public $helpers = array('Form' => array('className' => 'Bs3Helpers.Bs3Form'),"MinifyHtml.MinifyHtml");

    public $components = array(
        'Auth' => array(
            'loginRedirect' => array(
                'controller' => 'websites',
                'action' => 'index'
            ),
            'logoutRedirect' => array(
                'controller' => 'checks',
                'action' => 'publicview'
            ),
            'authenticate' => array(
                'Blowfish' => array(
                    'fields' => array('username'=>'email')
                )
            )
        ),
        'Session',
        'Email',
        'Cookie',
//        'Security'
    );

    public function beforeFilter() {

        $this->response->disableCache();

        if (isset($this->request->data['_wysihtml5_mode'])) unset($this->request->data['_wysihtml5_mode']);

        if ($this->Auth->loggedIn()) {
            $this->set('my_displayname', $this->User->getNameById($this->Auth->user('id')));
            $this->set('my_user_id', $this->Auth->user('id'));
        }
    }

    public function hasRights($user, $rights=null) {

        if(is_array($rights)) {
            foreach($rights as $r){
                if (isset($user['Role']['name']) && $user['Role']['name'] === $r) {
                    return true;
                }
            }
        } else {
            if (isset($user['Role']['name']) && $user['Role']['name'] === $rights) {
                return true;
            }
        }
        // Default deny
        return false;
    }
}


text:
namespace Fixtures.AcceptanceTestsHttp
{
    using System;
    using System.Collections.Generic;
    using System.Net.Http;
    using System.Threading;
    using System.Threading.Tasks;
    using Microsoft.Rest;
    using Models;

    /// <summary>
    /// HttpFailure operations.
    /// </summary>
    public partial interface IHttpFailure
    {
        /// <summary>
        /// Get empty error form server
        /// </summary>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        Task<HttpOperationResponse<bool?>> GetEmptyErrorWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Get empty error form server
        /// </summary>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="HttpOperationException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        Task<HttpOperationResponse<bool?>> GetNoModelErrorWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Get empty response from server
        /// </summary>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="HttpOperationException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        Task<HttpOperationResponse<bool?>> GetNoModelEmptyWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
    }
}


text:
<?php

namespace Ftm\PlayerBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * InscriptionRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class InscriptionRepository extends EntityRepository
{
	//inscription exists
	public function exists($pseudo, $server)
	{
		$resultats = $this->_em->createQueryBuilder()
								  ->select('COUNT(a)')
								  ->from($this->_entityName, 'a')
								  ->where('a.pseudo=:pseudo AND a.server=:server')
								  ->setParameter('pseudo', $pseudo)
								  ->setParameter('server', $server)
								  ->getQuery()
								  ->getSingleScalarResult();

		return $resultats>0?true:false;
	}

	public function getNewCount()
	{
		$resultat = $this->_em->createQueryBuilder()
								  ->select('COUNT(a)')
								  ->from($this->_entityName, 'a')
								  ->where('a.premod=0 AND a.mail_valid=1')
								  ->getQuery()
								  ->getSingleScalarResult();

		return $resultat;
	}

	public function getIgnoredCount()
	{
		$resultat = $this->_em->createQueryBuilder()
								  ->select('COUNT(a)')
								  ->from($this->_entityName, 'a')
								  ->where('a.premod=1')
								  ->getQuery()
								  ->getSingleScalarResult();

		return $resultat;
	}
}