text:
package com.taobao.android.builder.tasks.transform;

import android.databinding.tool.DataBindingBuilder;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.build.api.transform.QualifiedContent;
import com.android.build.gradle.api.BaseVariantOutput;
import com.android.build.gradle.internal.ApkDataUtils;
import com.android.build.gradle.internal.ExtraModelInfo;
import com.android.build.gradle.internal.LoggerWrapper;
import com.android.build.gradle.internal.TaskManager;
import com.android.build.gradle.internal.aapt.AaptGeneration;
import com.android.build.gradle.internal.api.AppVariantContext;
import com.android.build.gradle.internal.dsl.PackagingOptions;
import com.android.build.gradle.internal.pipeline.TransformTask;
import com.android.build.gradle.internal.process.GradleJavaProcessExecutor;
import com.android.build.gradle.internal.scope.DefaultGradlePackagingScope;
import com.android.build.gradle.internal.scope.PackagingScope;
import com.android.build.gradle.internal.scope.TaskOutputHolder;
import com.android.build.gradle.internal.scope.VariantScope;
import com.android.build.gradle.internal.tasks.databinding.DataBindingMergeArtifactsTransform;
import com.android.build.gradle.internal.transforms.*;
import com.android.build.gradle.options.BooleanOption;
import com.android.build.gradle.options.IntegerOption;
import com.android.build.gradle.options.ProjectOptions;
import com.android.build.gradle.tasks.ir.FastDeployRuntimeExtractorTask;
import com.android.builder.core.AtlasBuilder;
import com.android.builder.core.DefaultDexOptions;
import com.android.builder.core.DexOptions;
import com.android.builder.core.ErrorReporter;
import com.android.builder.dexing.DexMergerTool;
import com.android.builder.dexing.DexingType;
import com.android.builder.utils.FileCache;
import com.android.ide.common.internal.WaitableExecutor;
import com.android.ide.common.process.JavaProcessExecutor;
import com.android.utils.FileUtils;
import com.google.common.collect.ImmutableSet;
import com.taobao.android.builder.AtlasBuildContext;
import com.taobao.android.builder.hook.dex.DexByteCodeConverterHook;
import com.taobao.android.builder.insant.*;
import com.taobao.android.builder.tasks.manager.transform.TransformManager;
import com.taobao.android.builder.tasks.transform.dex.AtlasDexArchiveBuilderTransform;
import com.taobao.android.builder.tasks.transform.dex.AtlasDexMergerTransform;
import com.taobao.android.builder.tasks.transform.dex.AtlasMultiDexListTransform;
import com.taobao.android.builder.tools.ReflectUtils;
import com.taobao.android.builder.tools.multidex.FastMultiDexer;
import groovy.transform.PackageScope;
import org.gradle.api.Action;
import org.gradle.api.Task;
import org.gradle.api.internal.tasks.DefaultTaskOutputs;
import org.gradle.api.logging.LogLevel;
import org.gradle.api.logging.Logging;
import org.gradle.api.specs.AndSpec;
import org.gradle.api.specs.Spec;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Supplier;

import static com.google.common.base.Verify.verifyNotNull;

/**
 * @author lilong
 * @create 2017-12-08 上午9:02
 */

public class TransformReplacer {

    private AppVariantContext variantContext;

    public TransformReplacer(AppVariantContext variantContext) {
        this.variantContext = variantContext;
    }

    public void replaceDexArchiveBuilderTransform(BaseVariantOutput vod) {
        List<TransformTask> list = TransformManager.findTransformTaskByTransformType(variantContext,
                DexArchiveBuilderTransform.class);

        DefaultDexOptions dexOptions = variantContext.getAppExtension().getDexOptions();

        boolean minified = variantContext.getScope().getCodeShrinker() != null;

        ProjectOptions projectOptions = variantContext.getScope().getGlobalScope().getProjectOptions();

        FileCache userLevelCache = getUserDexCache(minified, dexOptions.getPreDexLibraries());
        for (TransformTask transformTask : list) {
            AtlasDexArchiveBuilderTransform atlasDexArchiveBuilderTransform = new AtlasDexArchiveBuilderTransform(variantContext, vod,
                    dexOptions,
                    variantContext.getScope().getGlobalScope().getAndroidBuilder().getErrorReporter(),
                    userLevelCache,
                    variantContext.getScope().getMinSdkVersion().getFeatureLevel(),
                    variantContext.getScope().getDexer(),
                    projectOptions.get(BooleanOption.ENABLE_GRADLE_WORKERS),
                    projectOptions.get(IntegerOption.DEXING_READ_BUFFER_SIZE),
                    projectOptions.get(IntegerOption.DEXING_WRITE_BUFFER_SIZE),
                    variantContext.getScope().getVariantConfiguration().getBuildType().isDebuggable());
            atlasDexArchiveBuilderTransform.setTransformTask(transformTask);
            ReflectUtils.updateField(transformTask, "transform", atlasDexArchiveBuilderTransform);
            if (variantContext.getScope().getInstantRunBuildContext().isInInstantRunMode() && variantContext.getVariantConfiguration().getMinSdkVersion().getApiLevel() < 21) {
                transformTask.doLast(task -> {
                    task.getLogger().info("generate maindexList......");
                    generateMainDexList(variantContext.getScope());

                });
            }

        }

    }

    private void generateMainDexList(VariantScope variantScope) {
        File mainDexListFile = variantScope.getMainDexListFile();
        Collection<File> inputs = AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).getAllMainDexJars();
        inputs.addAll(AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).getInputDirs());
        FastMultiDexer fastMultiDexer = new FastMultiDexer(variantContext);
        Collection<File> files = null;
        try {
            files = fastMultiDexer.repackageJarList(inputs, mainDexListFile, variantScope.getVariantData().getName().toLowerCase().endsWith("release"));
        } catch (IOException e) {
            e.printStackTrace();
        }

        if (files != null && files.size() > 0) {
            AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).addAllMainDexJars(files);

        }
    }

    public void replaceDataBindingMergeArtifactsTransform() {
        List<TransformTask> list = TransformManager.findTransformTaskByTransformType(variantContext,
                DataBindingMergeArtifactsTransform.class);
        for (TransformTask transformTask : list) {
            File outFolder =
                    new File(
                            variantContext.getScope().getBuildFolderForDataBindingCompiler(),
                            DataBindingBuilder.ARTIFACT_FILES_DIR_FROM_LIBS);
            AtlasDataBindingMergeArtifactsTransform dataBindingMergeArtifactsTransform = new AtlasDataBindingMergeArtifactsTransform(variantContext, Logging.getLogger(AtlasDataBindingMergeArtifactsTransform.class), outFolder);
            ReflectUtils.updateField(transformTask, "transform", dataBindingMergeArtifactsTransform);
        }

    }

    @Nullable
    private FileCache getUserDexCache(boolean isMinifiedEnabled, boolean preDexLibraries) {
//        if (!preDexLibraries || isMinifiedEnabled) {
//            return null;
//        }
        return getUserIntermediatesCache();
    }

    @Nullable
    private FileCache getUserIntermediatesCache() {
        if (variantContext.getScope().getGlobalScope()
                .getProjectOptions()
                .get(BooleanOption.ENABLE_INTERMEDIATE_ARTIFACTS_CACHE)) {
            return variantContext.getScope().getGlobalScope().getBuildCache();
        } else {
            return null;
        }
    }

    public void replaceDexExternalLibMerge(BaseVariantOutput vod) {
        List<TransformTask> list = TransformManager.findTransformTaskByTransformType(variantContext,
                ExternalLibsMergerTransform.class);
        for (TransformTask transformTask : list) {
            transformTask.setEnabled(false);

        }
    }

    public void replaceDexMerge(BaseVariantOutput vod) {
        List<TransformTask> list = TransformManager.findTransformTaskByTransformType(variantContext,
                DexMergerTransform.class);
        DexingType dexingType = variantContext.getScope().getDexingType();
        if (variantContext.getScope().getInstantRunBuildContext().isInInstantRunMode() && variantContext.getVariantConfiguration().getMinSdkVersion().getApiLevel() < 21) {
            dexingType = DexingType.LEGACY_MULTIDEX;
        }
        DexMergerTool dexMergerTool = variantContext.getScope().getDexMerger();
        int sdkVerision = variantContext.getScope().getMinSdkVersion().getFeatureLevel();
        boolean debug = variantContext.getScope().getVariantConfiguration().getBuildType().isDebuggable();
        ErrorReporter errorReporter = variantContext.getScope().getGlobalScope().getAndroidBuilder().getErrorReporter();
        for (TransformTask transformTask : list) {
            AtlasDexMergerTransform dexMergerTransform = new AtlasDexMergerTransform(
                    variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod))
                    , dexingType,
                    dexingType == DexingType.LEGACY_MULTIDEX
                            ? variantContext.getProject().files(variantContext.getScope().getMainDexListFile())
                            : null,
                    errorReporter, dexMergerTool, sdkVerision, debug);
            ReflectUtils.updateField(transformTask, "transform", dexMergerTransform);

        }
    }

    public void replaceMultiDexListTransform() {
        List<TransformTask> list = null;
        FastMultiDexer fastMultiDexer = new FastMultiDexer(variantContext);
        if (usingIncrementalDexing(variantContext.getScope())) {
            list = TransformManager.findTransformTaskByTransformType(variantContext,
                    MainDexListTransform.class);
        } else {
            list = TransformManager.findTransformTaskByTransformType(variantContext,
                    MultiDexTransform.class);
        }
        if (list.size() > 0 && fastMultiDexer.isFastMultiDexEnabled()) {
            com.android.build.gradle.internal.dsl.DexOptions dexOptions = variantContext.getScope().getGlobalScope().getExtension().getDexOptions();
            AtlasMultiDexListTransform atlasMultiDexListTransform = new AtlasMultiDexListTransform(variantContext.getScope(), dexOptions);
            for (TransformTask transformTask : list) {
                ReflectUtils.updateField(transformTask, "transform", atlasMultiDexListTransform);
                transformTask.doFirst(task -> AtlasBuildContext.androidBuilderMap.get(task.getProject()).multiDexer = (AtlasBuilder.MultiDexer) fastMultiDexer);
                transformTask.doLast(task -> AtlasBuildContext.androidBuilderMap.get(task.getProject()).multiDexer = null);
            }
        }
    }

    private boolean usingIncrementalDexing(@NonNull VariantScope variantScope) {
        if (!variantScope.getGlobalScope().getProjectOptions().get(BooleanOption.ENABLE_DEX_ARCHIVE)) {
            return false;
        }
        if (variantScope.getVariantConfiguration().getBuildType().isDebuggable()) {
            return true;
        }

        // In release builds only D8 can be used. See b/37140568 for details.
        return variantScope.getGlobalScope().getProjectOptions().get(BooleanOption.ENABLE_D8);
    }

    public void replaceProguardTransform() {

        List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(
                variantContext, ProGuardTransform.class);
        List<TransformTask> nextTransformTasks = TransformManager.findTransformTaskByTransformType(
                variantContext, DexArchiveBuilderTransform.class);

        for (TransformTask transformTask : baseTransforms) {
            AtlasProguardTransform newTransform = new AtlasProguardTransform(variantContext);
            newTransform.oldTransform = (ProGuardTransform) transformTask.getTransform();
            for (TransformTask nextTransformTask : nextTransformTasks) {
                if (nextTransformTask.getVariantName().equals(transformTask.getVariantName())) {
                    newTransform.nextTransformTask = nextTransformTask;
                }
            }
            ReflectUtils.updateField(transformTask, "transform",
                    newTransform);

//
        }
    }

    public void replaceDexTransform(AppVariantContext appVariantContext, BaseVariantOutput vod) {
        List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(
                variantContext, DexTransform.class);

        DefaultDexOptions dexOptions = appVariantContext.getAppExtension().getDexOptions();
        DexingType dexingType = appVariantContext.getScope().getDexingType();
        DexByteCodeConverterHook dexByteCodeConverterHook = new DexByteCodeConverterHook(variantContext
                , variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod))
                , LoggerWrapper.getLogger(DexByteCodeConverterHook.class)
                , appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getTargetInfo()
                , new GradleJavaProcessExecutor(appVariantContext.getProject())
                , appVariantContext.getProject().getLogger().isEnabled(LogLevel.INFO)
                , new ExtraModelInfo(appVariantContext.getScope().getGlobalScope().getProjectOptions(), appVariantContext.getProject().getLogger()));

        for (TransformTask transformTask : baseTransforms) {
            DexTransform newTransform = new DexTransform(dexOptions
                    , dexingType
                    , false
                    , appVariantContext.getProject().files(variantContext.getScope().getMainDexListFile())
                    , verifyNotNull(appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getTargetInfo(), "Target Info not set.")
                    , dexByteCodeConverterHook
                    , appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getErrorReporter()
                    , variantContext.getScope().getMinSdkVersion().getFeatureLevel());
            ReflectUtils.updateField(transformTask, "transform",
                    newTransform);
        }

    }

    public void replaceMergeJavaResourcesTransform(AppVariantContext appVariantContext, BaseVariantOutput vod) {
        List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(
                variantContext, MergeJavaResourcesTransform.class);
        for (TransformTask transformTask : baseTransforms) {
            MergeJavaResourcesTransform transform = (MergeJavaResourcesTransform) transformTask.getTransform();
            PackagingOptions packagingOptions = (PackagingOptions) ReflectUtils.getField(transform, "packagingOptions");
            packagingOptions.exclude("**.aidl");
            packagingOptions.exclude("**.cfg");
            Set<? super QualifiedContent.Scope> mergeScopes = (Set<? super QualifiedContent.Scope>) ReflectUtils.getField(transform, "mergeScopes");
            Set<QualifiedContent.ContentType> mergedType = (Set<QualifiedContent.ContentType>) ReflectUtils.getField(transform, "mergedType");
            String name = (String) ReflectUtils.getField(transform, "name");
            AtlasMergeJavaResourcesTransform atlasMergeJavaResourcesTransform = new AtlasMergeJavaResourcesTransform(appVariantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)), packagingOptions, mergeScopes, mergedType.iterator().next(), name, appVariantContext.getScope());
            ReflectUtils.updateField(transformTask, "transform",
                    atlasMergeJavaResourcesTransform);
        }

    }

    public void replaceFixStackFramesTransform(BaseVariantOutput vod) {
        List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(
                variantContext, FixStackFramesTransform.class);
        for (TransformTask transformTask : baseTransforms) {
            FixStackFramesTransform transform = (FixStackFramesTransform) transformTask.getTransform();

            AtlasFixStackFramesTransform atlasFixStackFramesTransform = new AtlasFixStackFramesTransform(variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)), (Supplier<List<File>>) ReflectUtils.getField(transform, "androidJarClasspath"), (List<Path>) ReflectUtils.getField(transform, "compilationBootclasspath"), (FileCache) ReflectUtils.getField(transform, "userCache"));
            atlasFixStackFramesTransform.oldTransform = transform;
            ReflectUtils.updateField(transformTask, "transform",
                    atlasFixStackFramesTransform);
        }
    }

    public void replaceDesugarTransform(BaseVariantOutput vod) {
        List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(
                variantContext, DesugarTransform.class);
        for (TransformTask transformTask : baseTransforms) {
            DesugarTransform transform = (DesugarTransform) transformTask.getTransform();
            AtlasDesugarTransform atlasDesugarTransform = new AtlasDesugarTransform(
                    variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)),
                    (Supplier<List<File>>) ReflectUtils.getField(transform, "androidJarClasspath"),
                    (List) ReflectUtils.getField(transform, "compilationBootclasspath"),
                    variantContext.getScope().getGlobalScope().getBuildCache(),
                    (int) ReflectUtils.getField(transform, "minSdk"),
                    (JavaProcessExecutor) ReflectUtils.getField(transform, "executor"),
                    (boolean) ReflectUtils.getField(transform, "verbose"),
                    (boolean) ReflectUtils.getField(transform, "enableGradleWorkers"),
                    (Path) ReflectUtils.getField(transform, "tmpDir"));
            atlasDesugarTransform.oldTransform = transform;
            ReflectUtils.updateField(transformTask, "transform",
                    atlasDesugarTransform);
        }
    }

    public void replaceShrinkResourcesTransform() {
        File shrinkerOutput =
                FileUtils.join(
                        variantContext.getScope().getGlobalScope().getIntermediatesDir(),
                        "res_stripped",
                        variantContext.getScope().getVariantConfiguration().getDirName());
        List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(
                variantContext, ShrinkResourcesTransform.class);
        for (TransformTask transform : baseTransforms) {
            ShrinkResourcesTransform oldTransform = (ShrinkResourcesTransform) transform.getTransform();
            ResourcesShrinker resourcesShrinker = new ResourcesShrinker(oldTransform, variantContext.getVariantData(),
                    variantContext.getScope().getOutput(TaskOutputHolder.TaskOutputType.PROCESSED_RES),
                    shrinkerOutput,
                    AaptGeneration.fromProjectOptions(variantContext.getScope().getGlobalScope().getProjectOptions()),
                    variantContext.getScope().getOutput(TaskOutputHolder.TaskOutputType.SPLIT_LIST),
                    variantContext.getProject().getLogger(),
                    variantContext);
            ReflectUtils.updateField(transform, "transform",
                    resourcesShrinker);

        }

    }

    public void disableCache() {
        List<TransformTask> list = null;
        if (usingIncrementalDexing(variantContext.getScope())) {
            list = TransformManager.findTransformTaskByTransformType(variantContext,
                    MainDexListTransform.class);
        } else {
            list = TransformManager.findTransformTaskByTransformType(variantContext,
                    MultiDexTransform.class);
        }
        if (list != null) {
            for (TransformTask transformTask : list) {
                List<Object> list1 = (List<Object>) ReflectUtils.getField(DefaultTaskOutputs.class, transformTask.getOutputs(), "cacheIfSpecs");
                list1.clear();
                ReflectUtils.updateField(transformTask.getOutputs(), "upToDateSpec", AndSpec.empty());

            }
        }

        list = TransformManager.findTransformTaskByTransformType(variantContext,
                AtlasProguardTransform.class);
        if (list != null) {
            for (TransformTask transformTask : list) {
                List<Object> list1 = (List<Object>) ReflectUtils.getField(DefaultTaskOutputs.class, transformTask.getOutputs(), "cacheIfSpecs");
                list1.clear();
                ReflectUtils.updateField(transformTask.getOutputs(), "upToDateSpec", AndSpec.empty());

            }
        }

        list = TransformManager.findTransformTaskByTransformType(variantContext,
                DexTransform.class);
        if (list != null) {
            for (TransformTask transformTask : list) {
                List<Object> list1 = (List<Object>) ReflectUtils.getField(DefaultTaskOutputs.class, transformTask.getOutputs(), "cacheIfSpecs");
                list1.clear();
                ReflectUtils.updateField(transformTask.getOutputs(), "upToDateSpec", AndSpec.empty());

            }
        }

        list = TransformManager.findTransformTaskByTransformType(variantContext,
                AtlasMultiDexListTransform.class);
        if (list != null) {
            for (TransformTask transformTask : list) {
                List<Object> list1 = (List<Object>) ReflectUtils.getField(DefaultTaskOutputs.class, transformTask.getOutputs(), "cacheIfSpecs");
                list1.clear();
                ReflectUtils.updateField(transformTask.getOutputs(), "upToDateSpec", AndSpec.empty());

            }
        }

    }

    public void repalaceSomeInstantTransform(BaseVariantOutput vod) {

        variantContext.getProject().getTasks().withType(FastDeployRuntimeExtractorTask.class).forEach(fastDeployRuntimeExtractorTask -> fastDeployRuntimeExtractorTask.setEnabled(false));
        List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(
                variantContext, InstantRunDependenciesApkBuilder.class);
        if (baseTransforms != null && baseTransforms.size() > 0) {
            for (TransformTask transformTask : baseTransforms) {
                transformTask.setEnabled(false);
            }
        }

        List<TransformTask> transforms = TransformManager.findTransformTaskByTransformType(
                variantContext, InstantRunTransform.class);
        if (transforms != null && transforms.size() > 0) {
            for (TransformTask transformTask : transforms) {
                TaobaoInstantRunTransform taobaoInstantRunTransform = new TaobaoInstantRunTransform(variantContext, variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)), WaitableExecutor.useGlobalSharedThreadPool(),
                        variantContext.getScope());
                ReflectUtils.updateField(transformTask, "transform", taobaoInstantRunTransform);
            }
        }

        List<TransformTask> verifytransforms = TransformManager.findTransformTaskByTransformType(
                variantContext, InstantRunVerifierTransform.class);
        if (verifytransforms != null && verifytransforms.size() > 0) {
            for (TransformTask transformTask : verifytransforms) {
                transformTask.setEnabled(false);
            }
        }

        List<TransformTask> transforms1 = TransformManager.findTransformTaskByTransformType(
                variantContext, ExtractJarsTransform.class);
        if (transforms1 != null && transforms1.size() > 0) {
            for (TransformTask transformTask : transforms1) {
                TaobaoExtractJarsTransform taobaoExtractJarsTransform = new TaobaoExtractJarsTransform(variantContext, variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)), ImmutableSet.of(QualifiedContent.DefaultContentType.CLASSES),
                        ImmutableSet.of(QualifiedContent.Scope.SUB_PROJECTS));
                ReflectUtils.updateField(transformTask, "transform", taobaoExtractJarsTransform);
            }
        }

        List<TransformTask> transforms2 = TransformManager.findTransformTaskByTransformType(
                variantContext, InstantRunDex.class);
        if (transforms2 != null && transforms2.size() > 0) {
            for (TransformTask transformTask : transforms2) {
                TaobaoInstantRunDex taobaoInstantRunDex = new TaobaoInstantRunDex(variantContext,
                        variantContext.getScope(),
                        variantContext.getScope().getGlobalScope().getAndroidBuilder().getDexByteCodeConverter(),
                        (DexOptions) ReflectUtils.getField(transformTask.getTransform(), "dexOptions"),
                        variantContext.getProject().getLogger(),
                        (Integer) ReflectUtils.getField(transformTask.getTransform(), "minSdkForDx"),
                vod);
                ReflectUtils.updateField(transformTask, "transform", taobaoInstantRunDex);
            }
        }

        List<TransformTask> transformTaskList = TransformManager.findTransformTaskByTransformType(
                variantContext, InstantRunSliceSplitApkBuilder.class);
        if (transformTaskList != null && transformTaskList.size() > 0) {
            for (TransformTask transformTask : transformTaskList) {
                transformTask.setEnabled(false);
            }
        }

        List<TransformTask> transformTaskList1 = TransformManager.findTransformTaskByTransformType(
                variantContext, InstantRunSlicer.class);
        if (transformTaskList1 != null && transformTaskList1.size() > 0) {
            for (TransformTask transformTask : transformTaskList1) {
                transformTask.setEnabled(false);
//                TaobaoInstantRunSlicer taobaoInstantRunSlicer = new TaobaoInstantRunSlicer(variantContext.getProject().getLogger(),variantContext.getScope());
//                ReflectUtils.updateField(transformTask,"transform",taobaoInstantRunSlicer);
            }
        }

    }
}


text:
<?php

namespace BingAds\v10\CampaignManagement;

/**
 * Gets the ad extensions from the account's ad extension library.
 *
 * @link http://msdn.microsoft.com/en-us/library/dn277509(v=msads.100).aspx GetAdExtensionIdsByAccountId Request Object
 *
 * @uses AdExtensionsTypeFilter
 * @uses AssociationType
 * @used-by BingAdsCampaignManagementService::GetAdExtensionIdsByAccountId
 */
final class GetAdExtensionIdsByAccountIdRequest
{
    public $AccountId;
    public $AdExtensionType;
    public $AssociationType;
}

redpajama_set_name: RedPajamaGithub


text:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"
    tools:context="com.evgenii.aescrypto.DrawingActivity" >

    <ImageView
        android:id="@+id/imageViewDrawing"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerHorizontal="true"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/drawing_description" />

</RelativeLayout>


text:
from u2flib_server.attestation.matchers import DEFAULT_MATCHERS
from u2flib_server.attestation.resolvers import create_resolver

__all__ = ['Attestation', 'MetadataProvider']

class Attestation(object):
    def __init__(self, trusted, vendor_info=None, device_info=None):
        self._trusted = trusted
        self._vendor_info = vendor_info
        self._device_info = device_info

    @property
    def trusted(self):
        return self._trusted

    @property
    def vendor_info(self):
        return self._vendor_info

    @property
    def device_info(self):
        return self._device_info

UNKNOWN_ATTESTATION = Attestation(False)

class MetadataProvider(object):

    def __init__(self, resolver=None, matchers=DEFAULT_MATCHERS):
        if resolver is None:
            resolver = create_resolver()
        self._resolver = resolver
        self._matchers = {}

        for matcher in matchers:
            self.add_matcher(matcher)

    def add_matcher(self, matcher):
        self._matchers[matcher.selector_type] = matcher

    def get_attestation(self, cert):
        metadata = self._resolver.resolve(cert)
        if metadata is None:
            return UNKNOWN_ATTESTATION
        vendor_info = metadata.vendorInfo
        device_info = self._lookup_device(metadata, cert)
        return Attestation(True, vendor_info, device_info)

    def _lookup_device(self, metadata, cert):
        for device in metadata.devices:
            selectors = device.selectors
            if selectors is None:
                return device
            for selector in selectors:
                matcher = self._matchers.get(selector.type)
                if matcher and matcher.matches(cert, selector.parameters):
                    return device
        return None


text:
package org.kie.workbench.common.screens.library.client.screens.organizationalunit.contributors.widget;

import org.ext.uberfire.social.activities.model.SocialUser;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.*;

@RunWith(MockitoJUnitRunner.class)
public class ContributorsManagementListItemPresenterTest {

    @Mock
    private ContributorsManagementListItemPresenter.View view;

    private ContributorsManagementListItemPresenter presenter;

    @Before
    public void setup() {
        presenter = new ContributorsManagementListItemPresenter(view);
    }

    @Test
    public void setupUserWithNameTest() {
        presenter.setup(new SocialUser("user",
                                       "John Admin",
                                       null,
                                       null,
                                       null));

        verify(view).init(presenter);
        verify(view).setUserName("John Admin");
        verify(view,
               never()).setSelected(anyBoolean());
    }

    @Test
    public void setupSelectedUserWithoutNameTest() {
        presenter.setup(new SocialUser("user"),
                        true);

        verify(view).init(presenter);
        verify(view).setUserName("user");
        verify(view).setSelected(true);
    }
}


text:
package com.blackducksoftware.tools.commonframework.standard.protex.report.template;

import com.blackducksoftware.tools.commonframework.standard.protex.report.model.TemplatePojo;

// TODO: Auto-generated Javadoc
/**
 * Bad pojo that has unmapped methods.
 *
 * @author akamen
 */
public class BadTestPojo implements TemplatePojo {

    /** The un mapped value. */
    private String unMappedValue = "";

    /**
     * Gets the un mapped value.
     *
     * @return the un mapped value
     */
    public String getUnMappedValue() {
	return unMappedValue;
    }

    /**
     * Sets the un mapped value.
     *
     * @param unMappedValue
     *            the new un mapped value
     */
    public void setUnMappedValue(String unMappedValue) {
	this.unMappedValue = unMappedValue;
    }

}


text:
<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Sitename
    |--------------------------------------------------------------------------
    |
    | Set the sites name
    |
    */
    'sitename' => 'Diablo 3 Database',

    /*
    |--------------------------------------------------------------------------
    | Registration Enabled
    |--------------------------------------------------------------------------
    |
    | Set this to false if you do not currently wish to allow new users to register.
    | You will still be able to register them by hand if you are an administrator.
    |
    */
    'registration_enabled' => true,

    'battlenet' => [

        /* Region: Valid Options: eu, us, kr, tw */
        'region' => 'eu',

        /* Locale:
         *  Valid Options
         *      Region EU: en_GB, de_DE, es_ES, fr_FR, it_IT, pl_PL, pt_PT, ru_RU */
        'locale' => 'en_GB',

        /* If you don't have an API key register for one here: https://dev.battle.net/ */
        'api_key' => 'INSERT_KEY_HERE',
    ],

    /* If you wish to set up cron to automatically update characters, enter the time frequencies below */
    'schedule' => [

        // Valid options: 'hourly', 'daily', 'weekly', 'monthly', 'yearly'
        //                'everyFiveMinutes', 'everyTenMinutes', 'everyThirtyMinutes'

        'members' => 'daily',

        'characters' => 'hourly',
    ]
];


text:
package com.google.ads.googleads.v11.services.stub;

import static com.google.ads.googleads.v11.services.BatchJobServiceClient.ListBatchJobResultsPagedResponse;

import com.google.ads.googleads.v11.resources.BatchJob;
import com.google.ads.googleads.v11.services.AddBatchJobOperationsRequest;
import com.google.ads.googleads.v11.services.AddBatchJobOperationsResponse;
import com.google.ads.googleads.v11.services.ListBatchJobResultsRequest;
import com.google.ads.googleads.v11.services.ListBatchJobResultsResponse;
import com.google.ads.googleads.v11.services.MutateBatchJobRequest;
import com.google.ads.googleads.v11.services.MutateBatchJobResponse;
import com.google.ads.googleads.v11.services.RunBatchJobRequest;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.common.collect.ImmutableMap;
import com.google.longrunning.Operation;
import com.google.longrunning.stub.GrpcOperationsStub;
import com.google.protobuf.Empty;
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
 * gRPC stub implementation for the BatchJobService service API.
 *
 * <p>This class is for advanced usage and reflects the underlying API directly.
 */
@Generated("by gapic-generator-java")
public class GrpcBatchJobServiceStub extends BatchJobServiceStub {
  private static final MethodDescriptor<MutateBatchJobRequest, MutateBatchJobResponse>
      mutateBatchJobMethodDescriptor =
          MethodDescriptor.<MutateBatchJobRequest, MutateBatchJobResponse>newBuilder()
              .setType(MethodDescriptor.MethodType.UNARY)
              .setFullMethodName("google.ads.googleads.v11.services.BatchJobService/MutateBatchJob")
              .setRequestMarshaller(
                  ProtoUtils.marshaller(MutateBatchJobRequest.getDefaultInstance()))
              .setResponseMarshaller(
                  ProtoUtils.marshaller(MutateBatchJobResponse.getDefaultInstance()))
              .build();

  private static final MethodDescriptor<ListBatchJobResultsRequest, ListBatchJobResultsResponse>
      listBatchJobResultsMethodDescriptor =
          MethodDescriptor.<ListBatchJobResultsRequest, ListBatchJobResultsResponse>newBuilder()
              .setType(MethodDescriptor.MethodType.UNARY)
              .setFullMethodName(
                  "google.ads.googleads.v11.services.BatchJobService/ListBatchJobResults")
              .setRequestMarshaller(
                  ProtoUtils.marshaller(ListBatchJobResultsRequest.getDefaultInstance()))
              .setResponseMarshaller(
                  ProtoUtils.marshaller(ListBatchJobResultsResponse.getDefaultInstance()))
              .build();

  private static final MethodDescriptor<RunBatchJobRequest, Operation> runBatchJobMethodDescriptor =
      MethodDescriptor.<RunBatchJobRequest, Operation>newBuilder()
          .setType(MethodDescriptor.MethodType.UNARY)
          .setFullMethodName("google.ads.googleads.v11.services.BatchJobService/RunBatchJob")
          .setRequestMarshaller(ProtoUtils.marshaller(RunBatchJobRequest.getDefaultInstance()))
          .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
          .build();

  private static final MethodDescriptor<AddBatchJobOperationsRequest, AddBatchJobOperationsResponse>
      addBatchJobOperationsMethodDescriptor =
          MethodDescriptor.<AddBatchJobOperationsRequest, AddBatchJobOperationsResponse>newBuilder()
              .setType(MethodDescriptor.MethodType.UNARY)
              .setFullMethodName(
                  "google.ads.googleads.v11.services.BatchJobService/AddBatchJobOperations")
              .setRequestMarshaller(
                  ProtoUtils.marshaller(AddBatchJobOperationsRequest.getDefaultInstance()))
              .setResponseMarshaller(
                  ProtoUtils.marshaller(AddBatchJobOperationsResponse.getDefaultInstance()))
              .build();

  private final UnaryCallable<MutateBatchJobRequest, MutateBatchJobResponse> mutateBatchJobCallable;
  private final UnaryCallable<ListBatchJobResultsRequest, ListBatchJobResultsResponse>
      listBatchJobResultsCallable;
  private final UnaryCallable<ListBatchJobResultsRequest, ListBatchJobResultsPagedResponse>
      listBatchJobResultsPagedCallable;
  private final UnaryCallable<RunBatchJobRequest, Operation> runBatchJobCallable;
  private final OperationCallable<RunBatchJobRequest, Empty, BatchJob.BatchJobMetadata>
      runBatchJobOperationCallable;
  private final UnaryCallable<AddBatchJobOperationsRequest, AddBatchJobOperationsResponse>
      addBatchJobOperationsCallable;

  private final BackgroundResource backgroundResources;
  private final GrpcOperationsStub operationsStub;
  private final GrpcStubCallableFactory callableFactory;

  public static final GrpcBatchJobServiceStub create(BatchJobServiceStubSettings settings)
      throws IOException {
    return new GrpcBatchJobServiceStub(settings, ClientContext.create(settings));
  }

  public static final GrpcBatchJobServiceStub create(ClientContext clientContext)
      throws IOException {
    return new GrpcBatchJobServiceStub(
        BatchJobServiceStubSettings.newBuilder().build(), clientContext);
  }

  public static final GrpcBatchJobServiceStub create(
      ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
    return new GrpcBatchJobServiceStub(
        BatchJobServiceStubSettings.newBuilder().build(), clientContext, callableFactory);
  }

  /**
   * Constructs an instance of GrpcBatchJobServiceStub, using the given settings. This is protected
   * so that it is easy to make a subclass, but otherwise, the static factory methods should be
   * preferred.
   */
  protected GrpcBatchJobServiceStub(
      BatchJobServiceStubSettings settings, ClientContext clientContext) throws IOException {
    this(settings, clientContext, new GrpcBatchJobServiceCallableFactory());
  }

  /**
   * Constructs an instance of GrpcBatchJobServiceStub, using the given settings. This is protected
   * so that it is easy to make a subclass, but otherwise, the static factory methods should be
   * preferred.
   */
  protected GrpcBatchJobServiceStub(
      BatchJobServiceStubSettings settings,
      ClientContext clientContext,
      GrpcStubCallableFactory callableFactory)
      throws IOException {
    this.callableFactory = callableFactory;
    this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);

    GrpcCallSettings<MutateBatchJobRequest, MutateBatchJobResponse>
        mutateBatchJobTransportSettings =
            GrpcCallSettings.<MutateBatchJobRequest, MutateBatchJobResponse>newBuilder()
                .setMethodDescriptor(mutateBatchJobMethodDescriptor)
                .setParamsExtractor(
                    request -> {
                      ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
                      params.put("customer_id", String.valueOf(request.getCustomerId()));
                      return params.build();
                    })
                .build();
    GrpcCallSettings<ListBatchJobResultsRequest, ListBatchJobResultsResponse>
        listBatchJobResultsTransportSettings =
            GrpcCallSettings.<ListBatchJobResultsRequest, ListBatchJobResultsResponse>newBuilder()
                .setMethodDescriptor(listBatchJobResultsMethodDescriptor)
                .setParamsExtractor(
                    request -> {
                      ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
                      params.put("resource_name", String.valueOf(request.getResourceName()));
                      return params.build();
                    })
                .build();
    GrpcCallSettings<RunBatchJobRequest, Operation> runBatchJobTransportSettings =
        GrpcCallSettings.<RunBatchJobRequest, Operation>newBuilder()
            .setMethodDescriptor(runBatchJobMethodDescriptor)
            .setParamsExtractor(
                request -> {
                  ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
                  params.put("resource_name", String.valueOf(request.getResourceName()));
                  return params.build();
                })
            .build();
    GrpcCallSettings<AddBatchJobOperationsRequest, AddBatchJobOperationsResponse>
        addBatchJobOperationsTransportSettings =
            GrpcCallSettings
                .<AddBatchJobOperationsRequest, AddBatchJobOperationsResponse>newBuilder()
                .setMethodDescriptor(addBatchJobOperationsMethodDescriptor)
                .setParamsExtractor(
                    request -> {
                      ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
                      params.put("resource_name", String.valueOf(request.getResourceName()));
                      return params.build();
                    })
                .build();

    this.mutateBatchJobCallable =
        callableFactory.createUnaryCallable(
            mutateBatchJobTransportSettings, settings.mutateBatchJobSettings(), clientContext);
    this.listBatchJobResultsCallable =
        callableFactory.createUnaryCallable(
            listBatchJobResultsTransportSettings,
            settings.listBatchJobResultsSettings(),
            clientContext);
    this.listBatchJobResultsPagedCallable =
        callableFactory.createPagedCallable(
            listBatchJobResultsTransportSettings,
            settings.listBatchJobResultsSettings(),
            clientContext);
    this.runBatchJobCallable =
        callableFactory.createUnaryCallable(
            runBatchJobTransportSettings, settings.runBatchJobSettings(), clientContext);
    this.runBatchJobOperationCallable =
        callableFactory.createOperationCallable(
            runBatchJobTransportSettings,
            settings.runBatchJobOperationSettings(),
            clientContext,
            operationsStub);
    this.addBatchJobOperationsCallable =
        callableFactory.createUnaryCallable(
            addBatchJobOperationsTransportSettings,
            settings.addBatchJobOperationsSettings(),
            clientContext);

    this.backgroundResources =
        new BackgroundResourceAggregation(clientContext.getBackgroundResources());
  }

  public GrpcOperationsStub getOperationsStub() {
    return operationsStub;
  }

  @Override
  public UnaryCallable<MutateBatchJobRequest, MutateBatchJobResponse> mutateBatchJobCallable() {
    return mutateBatchJobCallable;
  }

  @Override
  public UnaryCallable<ListBatchJobResultsRequest, ListBatchJobResultsResponse>
      listBatchJobResultsCallable() {
    return listBatchJobResultsCallable;
  }

  @Override
  public UnaryCallable<ListBatchJobResultsRequest, ListBatchJobResultsPagedResponse>
      listBatchJobResultsPagedCallable() {
    return listBatchJobResultsPagedCallable;
  }

  @Override
  public UnaryCallable<RunBatchJobRequest, Operation> runBatchJobCallable() {
    return runBatchJobCallable;
  }

  @Override
  public OperationCallable<RunBatchJobRequest, Empty, BatchJob.BatchJobMetadata>
      runBatchJobOperationCallable() {
    return runBatchJobOperationCallable;
  }

  @Override
  public UnaryCallable<AddBatchJobOperationsRequest, AddBatchJobOperationsResponse>
      addBatchJobOperationsCallable() {
    return addBatchJobOperationsCallable;
  }

  @Override
  public final void close() {
    try {
      backgroundResources.close();
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new IllegalStateException("Failed to close resource", e);
    }
  }

  @Override
  public void shutdown() {
    backgroundResources.shutdown();
  }

  @Override
  public boolean isShutdown() {
    return backgroundResources.isShutdown();
  }

  @Override
  public boolean isTerminated() {
    return backgroundResources.isTerminated();
  }

  @Override
  public void shutdownNow() {
    backgroundResources.shutdownNow();
  }

  @Override
  public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
    return backgroundResources.awaitTermination(duration, unit);
  }
}


text:
// Sanity check integration test for nt_info
// Spec file: specs/windows/nt_info.table

#include <osquery/tests/integration/tables/helper.h>

namespace osquery {

class nt_info : public IntegrationTableTest {};

TEST_F(NTdomains, test_sanity) {
  QueryData data = execute_query("select * from nt_info");

  ASSERT_EQ(data.size(), 1ul);

  ValidatatioMap row_map = {
      {"name", NonEmptyString},
      {"client_site_name", NonEmptyString},
      {"dc_site_name", NonEmptyString},
      {"dns_forest_name", NonEmptyString},
      {"domain_controller_address", NonEmptyString},
      {"domain_controller_name", NonEmptyString},
      {"domain_name", NonEmptyString},
      {"status", NonEmptyString},
  };
  validate_rows(data, row_map);
}

} // namespace osquery


text:
package com.group6.babytime.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.group6.babytime.R;
import com.group6.babytime.ablumactivity.AlbumInfoActivity;
import com.group6.babytime.entity.Album;
import com.group6.babytime.utils.CommontAdapter;
import com.group6.babytime.utils.NetUtil;
import com.group6.babytime.utils.ViewHolder;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by Administrator on 2016/10/21.
 */
public class FragmentPage1 extends Fragment {

    //相册名称
    String albumName;
    int orderFlag = 0;
    int pageNo = 1;
    int pageSize = 5;
    CommontAdapter<Album> albumsAdapter;

    List<Album> albums = new ArrayList<Album>();//存放的相册信息
    @InjectView(R.id.lv_liebiao_xianshi)
    ListView lvLiebiaoXianshi;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.lv_liebiao_xiangqing, null);
        ButterKnife.inject(this, view);
        initView();
        initData();
        initEvent();
        return view;

    }

    public void initView() {

    }

    public void initData() {
        getData();//获取网络数据,显示在listview上

    }

    public void getData() {
        //xutils获取网络数据
        //访问网络的url
        String url = NetUtil.url + "QueryAlbumServlet";

        RequestParams requestParams = new RequestParams(url);

        //设置传给服务器的参数

        requestParams.addQueryStringParameter("albumName", albumName);
        requestParams.addQueryStringParameter("orderFlag", orderFlag + "");//排序标记
        requestParams.addQueryStringParameter("pageNo", pageNo + "");
        requestParams.addQueryStringParameter("pageSize", pageSize + "");
        Log.i("albumFragment", "onSuccess: " + "==============");

        x.http().get(requestParams, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {

                //json转换成List<Album>
                Gson gson = new Gson();
                Type type = new TypeToken<List<Album>>() {
                }.getType();

                List<Album> newalbums = new ArrayList<Album>();
                newalbums = gson.fromJson(result, type);//解析成List<Album
                //products=gson.fromJson(result,type);//解析成List<Album>

                //清空原来的数据
                albums.clear();
                albums.addAll(newalbums);

                //设置ListView的adapter
                if (albumsAdapter == null) {
                    albumsAdapter = new CommontAdapter<Album>(getActivity(), albums, R.layout.photo_list_item) {
                        @Override
                        public void convert(ViewHolder viewHolder, Album album, int position) {
                            //取出控件,赋值
                            TextView tv = viewHolder.getViewById(R.id.photo_item_name_tv1);
                            tv.setText(album.getAlbumName());
                            TextView tvNumber = viewHolder.getViewById(R.id.photo_item_number_tv2);
                            tvNumber.setText(album.getPhotoNumber() + "");
                            //其他控件的赋值

                        }
                    };
                    lvLiebiaoXianshi.setAdapter(albumsAdapter);

                } else {
                    //有数据源更新的话,直接更新界面
                    albumsAdapter.notifyDataSetChanged();
                }

            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {

            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });
    }

    public void initEvent() {
        //lvLiebiaoXianshi的item的点击事件
        lvLiebiaoXianshi.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
                //跳转到相册的详情页面
                Intent intent = new Intent(getActivity(), AlbumInfoActivity.class);
                //获取相册信息
                intent.putExtra("albumInfo", albums.get(position));
                startActivity(intent);
            }
        });
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.reset(this);
    }
}


text:
######################################################################
# PUBLIC DEFINITIONS
######################################################################

# supported XML interfaces

XMLIF_MINIDOM     = "XMLIF_MINIDOM"
XMLIF_4DOM        = "XMLIF_4DOM"
XMLIF_ELEMENTTREE = "XMLIF_ELEMENTTREE"

# namespace definitions

XINC_NAMESPACE  = "http://www.w3.org/2001/XInclude"

# definition of genxmlif path

import os
GENXMLIF_DIR = os.path.dirname(__file__)

########################################
# central function to choose the XML interface to be used
#

def chooseXmlIf (xmlIf, verbose=0, useCaching=1, processXInclude=1):
    if xmlIf == XMLIF_MINIDOM:
        import xmlifMinidom
        return xmlifMinidom.XmlInterfaceMinidom(verbose, useCaching, processXInclude)

    elif xmlIf == XMLIF_4DOM:
        import xmlif4Dom
        return xmlif4Dom.XmlInterface4Dom(verbose, useCaching, processXInclude)

    elif xmlIf == XMLIF_ELEMENTTREE:
        import xmlifElementTree
        return xmlifElementTree.XmlInterfaceElementTree(verbose, useCaching, processXInclude)

    else:
        raise AttributeError, "Unknown XML interface: %s" %(xmlIf)

########################################
# define own exception for GenXmlIf errors
# The following errors/exceptions are mapped to a GenxmlIf exception:
# - Expat errors
# - XInclude errors
#
class GenXmlIfError (StandardError):
    pass


text:
<?xml version="1.0"?>
<Schedule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <PubDate>2017-02-12T00:00:00+00:00</PubDate>
  <Shows>
    <Show>
      <ID>140829</ID>
      <dtAccounting>2017-02-12T00:00:00</dtAccounting>
      <dttmShowStart>2017-02-12T11:00:00</dttmShowStart>
      <dttmShowStartUTC>2017-02-12T09:00:00Z</dttmShowStartUTC>
      <dttmShowEnd>2017-02-12T12:54:00</dttmShowEnd>
      <dttmShowEndUTC>2017-02-12T10:54:00Z</dttmShowEndUTC>
      <ShowSalesStartTime>2000-01-01T00:00:00</ShowSalesStartTime>
      <ShowSalesStartTimeUTC>2000-01-01T00:00:00Z</ShowSalesStartTimeUTC>
      <ShowSalesEndTime>2017-02-12T10:15:00</ShowSalesEndTime>
      <ShowSalesEndTimeUTC>2017-02-12T08:15:00Z</ShowSalesEndTimeUTC>
      <ShowReservationStartTime>0001-01-01T00:00:00</ShowReservationStartTime>
      <ShowReservationStartTimeUTC>0001-01-01T00:00:00</ShowReservationStartTimeUTC>
      <ShowReservationEndTime>0001-01-01T00:00:00</ShowReservationEndTime>
      <ShowReservationEndTimeUTC>0001-01-01T00:00:00</ShowReservationEndTimeUTC>
      <EventID>2897</EventID>
      <Title>Lego Batman movie</Title>
      <OriginalTitle>Lego Batman movie</OriginalTitle>
      <ProductionYear>2017</ProductionYear>
      <LengthInMinutes>104</LengthInMinutes>
      <dtLocalRelease>2017-02-10T00:00:00</dtLocalRelease>
      <Rating>Family film</Rating>
      <RatingLabel>Family film</RatingLabel>
      <RatingImageUrl>https://mcswebsites.blob.core.windows.net/apollokino-ee/images/rating_large_Family film.png</RatingImageUrl>
      <EventType>Movie</EventType>
      <Genres>Comedy, Action, Animation</Genres>
      <TheatreID>1038</TheatreID>
      <TheatreAuditriumID>1206</TheatreAuditriumID>
      <Theatre>Apollo Kino Solaris</Theatre>
      <TheatreAuditorium>Telia Screen 2</TheatreAuditorium>
      <TheatreAndAuditorium>Apollo Kino Solaris, Telia Screen 2</TheatreAndAuditorium>
      <PresentationMethodAndLanguage>in Estonian</PresentationMethodAndLanguage>
      <PresentationMethod />
      <EventSeries />
      <ShowURL>http://apollokino.ee/eng/Websales/Show/140829/</ShowURL>
      <EventURL>http://apollokino.ee/eng/Event/2897/</EventURL>
      <Images>
        <EventMicroImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6101/portrait_micro/Lego-Batman_B1_EE_Preview.jpg</EventMicroImagePortrait>
        <EventSmallImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6101/portrait_small/Lego-Batman_B1_EE_Preview.jpg</EventSmallImagePortrait>
        <EventMediumImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6101/portrait_medium/Lego-Batman_B1_EE_Preview.jpg</EventMediumImagePortrait>
        <EventLargeImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6101/portrait_large/Lego-Batman_B1_EE_Preview.jpg</EventLargeImagePortrait>
        <EventSmallImageLandscape>http://mcswebsites.blob.core.windows.net/1013/Event_6101/landscape_small/LegoBatman_ApolloKino_MoviePageHeader.jpg</EventSmallImageLandscape>
        <EventLargeImageLandscape>http://mcswebsites.blob.core.windows.net/1013/Event_6101/landscape_large/LegoBatman_ApolloKino_MoviePageHeader.jpg</EventLargeImageLandscape>
      </Images>
      <ContentDescriptors />
    </Show>
    <Show>
      <ID>140599</ID>
      <dtAccounting>2017-02-12T00:00:00</dtAccounting>
      <dttmShowStart>2017-02-12T11:00:00</dttmShowStart>
      <dttmShowStartUTC>2017-02-12T09:00:00Z</dttmShowStartUTC>
      <dttmShowEnd>2017-02-12T12:39:00</dttmShowEnd>
      <dttmShowEndUTC>2017-02-12T10:39:00Z</dttmShowEndUTC>
      <ShowSalesStartTime>2000-01-01T00:00:00</ShowSalesStartTime>
      <ShowSalesStartTimeUTC>2000-01-01T00:00:00Z</ShowSalesStartTimeUTC>
      <ShowSalesEndTime>2017-02-12T10:15:00</ShowSalesEndTime>
      <ShowSalesEndTimeUTC>2017-02-12T08:15:00Z</ShowSalesEndTimeUTC>
      <ShowReservationStartTime>0001-01-01T00:00:00</ShowReservationStartTime>
      <ShowReservationStartTimeUTC>0001-01-01T00:00:00</ShowReservationStartTimeUTC>
      <ShowReservationEndTime>0001-01-01T00:00:00</ShowReservationEndTime>
      <ShowReservationEndTimeUTC>0001-01-01T00:00:00</ShowReservationEndTimeUTC>
      <EventID>3041</EventID>
      <Title>Ballerina</Title>
      <OriginalTitle>Ballerina</OriginalTitle>
      <ProductionYear>2016</ProductionYear>
      <LengthInMinutes>89</LengthInMinutes>
      <dtLocalRelease>2017-01-20T00:00:00</dtLocalRelease>
      <Rating>Family film</Rating>
      <RatingLabel>Family film</RatingLabel>
      <RatingImageUrl>https://mcswebsites.blob.core.windows.net/apollokino-ee/images/rating_large_Family film.png</RatingImageUrl>
      <EventType>Movie</EventType>
      <Genres>Animation, Family</Genres>
      <TheatreID>1040</TheatreID>
      <TheatreAuditriumID>1215</TheatreAuditriumID>
      <Theatre>Apollo Kino Mustamäe</Theatre>
      <TheatreAuditorium>Telia Screen 2</TheatreAuditorium>
      <TheatreAndAuditorium>Apollo Kino Mustamäe, Telia Screen 2</TheatreAndAuditorium>
      <PresentationMethodAndLanguage>in Estonian</PresentationMethodAndLanguage>
      <PresentationMethod />
      <EventSeries />
      <ShowURL>http://apollokino.ee/eng/Websales/Show/140599/</ShowURL>
      <EventURL>http://apollokino.ee/eng/Event/3041/</EventURL>
      <Images>
        <EventMicroImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6263/portrait_micro/Ballerina_B1_EE_new.jpg</EventMicroImagePortrait>
        <EventSmallImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6263/portrait_small/Ballerina_B1_EE_new.jpg</EventSmallImagePortrait>
        <EventMediumImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6263/portrait_medium/Ballerina_B1_EE_new.jpg</EventMediumImagePortrait>
        <EventLargeImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6263/portrait_large/Ballerina_B1_EE_new.jpg</EventLargeImagePortrait>
        <EventSmallImageLandscape>http://mcswebsites.blob.core.windows.net/1013/Event_6263/landscape_small/Ballerina_ApolloKino_MoviePageHeader.jpg</EventSmallImageLandscape>
        <EventLargeImageLandscape>http://mcswebsites.blob.core.windows.net/1013/Event_6263/landscape_large/Ballerina_ApolloKino_MoviePageHeader.jpg</EventLargeImageLandscape>
      </Images>
      <ContentDescriptors />
    </Show>
    <Show>
      <ID>140860</ID>
      <dtAccounting>2017-02-12T00:00:00</dtAccounting>
      <dttmShowStart>2017-02-12T11:10:00</dttmShowStart>
      <dttmShowStartUTC>2017-02-12T09:10:00Z</dttmShowStartUTC>
      <dttmShowEnd>2017-02-12T13:15:00</dttmShowEnd>
      <dttmShowEndUTC>2017-02-12T11:15:00Z</dttmShowEndUTC>
      <ShowSalesStartTime>2000-01-01T00:00:00</ShowSalesStartTime>
      <ShowSalesStartTimeUTC>2000-01-01T00:00:00Z</ShowSalesStartTimeUTC>
      <ShowSalesEndTime>2017-02-12T10:25:00</ShowSalesEndTime>
      <ShowSalesEndTimeUTC>2017-02-12T08:25:00Z</ShowSalesEndTimeUTC>
      <ShowReservationStartTime>0001-01-01T00:00:00</ShowReservationStartTime>
      <ShowReservationStartTimeUTC>0001-01-01T00:00:00</ShowReservationStartTimeUTC>
      <ShowReservationEndTime>0001-01-01T00:00:00</ShowReservationEndTime>
      <ShowReservationEndTimeUTC>0001-01-01T00:00:00</ShowReservationEndTimeUTC>
      <EventID>3110</EventID>
      <Title>November</Title>
      <OriginalTitle>November</OriginalTitle>
      <ProductionYear>2016</ProductionYear>
      <LengthInMinutes>115</LengthInMinutes>
      <dtLocalRelease>2017-02-03T00:00:00</dtLocalRelease>
      <Rating>Under 12 Not Recommended</Rating>
      <RatingLabel>Under 12 Not Recommended</RatingLabel>
      <RatingImageUrl>https://mcswebsites.blob.core.windows.net/apollokino-ee/images/rating_large_Under 12 Not Recommended.png</RatingImageUrl>
      <EventType>Movie</EventType>
      <Genres>Fantasy</Genres>
      <TheatreID>1038</TheatreID>
      <TheatreAuditriumID>1207</TheatreAuditriumID>
      <Theatre>Apollo Kino Solaris</Theatre>
      <TheatreAuditorium>Screen 3</TheatreAuditorium>
      <TheatreAndAuditorium>Apollo Kino Solaris, Screen 3</TheatreAndAuditorium>
      <PresentationMethodAndLanguage>in Estonian</PresentationMethodAndLanguage>
      <PresentationMethod />
      <EventSeries />
      <ShowURL>http://apollokino.ee/eng/Websales/Show/140860/</ShowURL>
      <EventURL>http://apollokino.ee/eng/Event/3110/</EventURL>
      <Images>
        <EventMicroImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6339/portrait_micro/November%20768x1097.jpg</EventMicroImagePortrait>
        <EventSmallImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6339/portrait_small/November%20768x1097.jpg</EventSmallImagePortrait>
        <EventMediumImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6339/portrait_medium/November%20768x1097.jpg</EventMediumImagePortrait>
        <EventLargeImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6339/portrait_large/November%20768x1097.jpg</EventLargeImagePortrait>
        <EventSmallImageLandscape>http://mcswebsites.blob.core.windows.net/1013/Event_6339/landscape_small/APK_WEB_HEADER_TEMPLATE_NEW-1.jpg</EventSmallImageLandscape>
      </Images>
      <ContentDescriptors />
    </Show>
    <Show>
      <ID>140807</ID>
      <dtAccounting>2017-02-12T00:00:00</dtAccounting>
      <dttmShowStart>2017-02-12T11:30:00</dttmShowStart>
      <dttmShowStartUTC>2017-02-12T09:30:00Z</dttmShowStartUTC>
      <dttmShowEnd>2017-02-12T13:09:00</dttmShowEnd>
      <dttmShowEndUTC>2017-02-12T11:09:00Z</dttmShowEndUTC>
      <ShowSalesStartTime>2000-01-01T00:00:00</ShowSalesStartTime>
      <ShowSalesStartTimeUTC>2000-01-01T00:00:00Z</ShowSalesStartTimeUTC>
      <ShowSalesEndTime>2017-02-12T10:45:00</ShowSalesEndTime>
      <ShowSalesEndTimeUTC>2017-02-12T08:45:00Z</ShowSalesEndTimeUTC>
      <ShowReservationStartTime>0001-01-01T00:00:00</ShowReservationStartTime>
      <ShowReservationStartTimeUTC>0001-01-01T00:00:00</ShowReservationStartTimeUTC>
      <ShowReservationEndTime>0001-01-01T00:00:00</ShowReservationEndTime>
      <ShowReservationEndTimeUTC>0001-01-01T00:00:00</ShowReservationEndTimeUTC>
      <EventID>3041</EventID>
      <Title>Ballerina</Title>
      <OriginalTitle>Ballerina</OriginalTitle>
      <ProductionYear>2016</ProductionYear>
      <LengthInMinutes>89</LengthInMinutes>
      <dtLocalRelease>2017-01-20T00:00:00</dtLocalRelease>
      <Rating>Family film</Rating>
      <RatingLabel>Family film</RatingLabel>
      <RatingImageUrl>https://mcswebsites.blob.core.windows.net/apollokino-ee/images/rating_large_Family film.png</RatingImageUrl>
      <EventType>Movie</EventType>
      <Genres>Animation, Family</Genres>
      <TheatreID>1038</TheatreID>
      <TheatreAuditriumID>1203</TheatreAuditriumID>
      <Theatre>Apollo Kino Solaris</Theatre>
      <TheatreAuditorium>Screen 4</TheatreAuditorium>
      <TheatreAndAuditorium>Apollo Kino Solaris, Screen 4</TheatreAndAuditorium>
      <PresentationMethodAndLanguage>in Estonian</PresentationMethodAndLanguage>
      <PresentationMethod />
      <EventSeries />
      <ShowURL>http://apollokino.ee/eng/Websales/Show/140807/</ShowURL>
      <EventURL>http://apollokino.ee/eng/Event/3041/</EventURL>
      <Images>
        <EventMicroImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6263/portrait_micro/Ballerina_B1_EE_new.jpg</EventMicroImagePortrait>
        <EventSmallImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6263/portrait_small/Ballerina_B1_EE_new.jpg</EventSmallImagePortrait>
        <EventMediumImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6263/portrait_medium/Ballerina_B1_EE_new.jpg</EventMediumImagePortrait>
        <EventLargeImagePortrait>http://mcswebsites.blob.core.windows.net/1013/Event_6263/portrait_large/Ballerina_B1_EE_new.jpg</EventLargeImagePortrait>
        <EventSmallImageLandscape>http://mcswebsites.blob.core.windows.net/1013/Event_6263/landscape_small/Ballerina_ApolloKino_MoviePageHeader.jpg</EventSmallImageLandscape>
        <EventLargeImageLandscape>http://mcswebsites.blob.core.windows.net/1013/Event_6263/landscape_large/Ballerina_ApolloKino_MoviePageHeader.jpg</EventLargeImageLandscape>
      </Images>
      <ContentDescriptors />
    </Show>
  </Shows>
</Schedule>


text:
namespace Framework.Cli
{
    using Framework.Cli.Command;
    using Framework.Cli.Config;
    using Microsoft.Extensions.CommandLineUtils;
    using System;
    using System.CodeDom;
    using System.CodeDom.Compiler;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Globalization;
    using System.IO;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading.Tasks;

    internal static class UtilCliInternal
    {
        /// <summary>
        /// Returns CommandOption flag.
        /// </summary>
        public static bool OptionGet(this CommandOption option)
        {
            return option?.Value() == "on" == true;
        }

        /// <summary>
        /// Sets CommandOption flag.
        /// </summary>
        public static void OptionSet(ref CommandOption option, bool value)
        {
            if (option == null)
            {
                option = new CommandOption("--null", CommandOptionType.NoValue); // For example if command calls command and options is not registered.
            }
            option.Values.Clear();
            if (value)
            {
                option.Values.Add("on");
            }
            UtilFramework.Assert(OptionGet(option) == value);
        }

        /// <summary>
        /// Run dotnet command.
        /// </summary>
        internal static void DotNet(string workingDirectory, string arguments, bool isWait = true)
        {
            Start(workingDirectory, "dotnet", arguments, isWait: isWait);
        }

        /// <summary>
        /// Run npm command.
        /// </summary>
        internal static void Npm(string workingDirectory, string arguments, bool isWait = true, bool isRedirectStdErr = false)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                UtilCliInternal.Start(workingDirectory, "cmd", "/c npm.cmd " + arguments, isWait: isWait, isRedirectStdErr: isRedirectStdErr);
            }
            else
            {
                UtilCliInternal.Start(workingDirectory, "npm", arguments, isWait: isWait, isRedirectStdErr: isRedirectStdErr);
            }
        }

        /// <summary>
        /// Start script.
        /// </summary>
        /// <param name="isRedirectStdErr">If true, do not write to stderr. Use this flag if shell command is known to write info (mistakenly) to stderr.</param>
        internal static void Start(string workingDirectory, string fileName, string arguments, bool isWait = true, bool isRedirectStdErr = false)
        {
            string time = UtilFramework.DateTimeToString(DateTime.Now);
            UtilCliInternal.ConsoleWriteLinePassword(string.Format("### {4} Process Begin (FileName={1}; Arguments={2}; IsWait={3}; WorkingDirectory={0};)", workingDirectory, fileName, arguments, isWait, time), ConsoleColor.Green);

            ProcessStartInfo info = new ProcessStartInfo
            {
                WorkingDirectory = workingDirectory,
                FileName = fileName,
                Arguments = arguments
            };
            if (isRedirectStdErr)
            {
                info.RedirectStandardError = true; // Do not write to stderr.
            }
            // info.UseShellExecute = true;

            using (var process = Process.Start(info))
            {
                if (isWait)
                {
                    if (isRedirectStdErr)
                    {
                        // process.WaitForExit(); // Can hang. For example Angular 9.1.1 build:ssr (May be when std buffer is full)
                        string errorText = process.StandardError.ReadToEnd(); // Waits for process to exit.
                        process.WaitForExit(); // Used for Ubuntu. Otherwise HasExited is not (yet) true.
                        UtilFramework.Assert(process.HasExited);
                        if (!string.IsNullOrEmpty(errorText))
                        {
                            UtilCliInternal.ConsoleWriteLinePassword(string.Format("### {4} Process StdErr (FileName={1}; Arguments={2}; IsWait={3}; WorkingDirectory={0};)", workingDirectory, fileName, arguments, isWait, time), ConsoleColor.DarkGreen); // Write stderr to stdout.
                            UtilCliInternal.ConsoleWriteLinePassword(errorText, ConsoleColor.DarkGreen); // Log DarkGreen because it is not treated like an stderr output.
                        }
                    }
                    else
                    {
                        process.WaitForExit();
                        UtilFramework.Assert(process.HasExited);
                    }
                    if (process.ExitCode != 0)
                    {
                        throw new Exception("Script failed!");
                    }
                }
            }

            UtilCliInternal.ConsoleWriteLinePassword(string.Format("### {4} Process End (FileName={1}; Arguments={2}; IsWait={3}; WorkingDirectory={0};)", workingDirectory, fileName, arguments, isWait, time), ConsoleColor.DarkGreen);
        }

        /// <summary>
        /// Returns stdout of command.
        /// </summary>
        internal static string StartStdout(string workingDirectory, string fileName, string arguments)
        {
            ProcessStartInfo info = new ProcessStartInfo
            {
                WorkingDirectory = workingDirectory,
                FileName = fileName,
                Arguments = arguments,
                RedirectStandardOutput = true // Do not write to stdout.
            };
            var process = Process.Start(info);
            process.WaitForExit();
            string result = process.StandardOutput.ReadToEnd();
            if (process.ExitCode != 0)
            {
                throw new Exception("Script failed!");
            }

            return result;
        }

        internal static void OpenWebBrowser(string url)
        {
            Start(null, "cmd", $"/c start {url}", isWait: false);
        }

        internal static void FolderNameDelete(string folderName)
        {
            if (Directory.Exists(folderName))
            {
                foreach (FileInfo fileInfo in new DirectoryInfo(folderName).GetFiles("*.*", SearchOption.AllDirectories))
                {
                    fileInfo.Attributes = FileAttributes.Normal; // See also: https://stackoverflow.com/questions/1701457/directory-delete-doesnt-work-access-denied-error-but-under-windows-explorer-it/30673648
                }
                Directory.Delete(folderName, true);
            }
        }

        /// <summary>
        /// Adjustment for: If sequence of arguments is passed different than defined in CommandLineApplication values are wrong.
        /// </summary>
        /// <param name="commandBase"></param>
        /// <param name="commandArgument"></param>
        /// <returns></returns>
        private static CommandArgument ArgumentValue(CommandBase command, CommandArgument commandArgument)
        {
            CommandArgument result = null;
            foreach (CommandArgument item in command.Configuration.Arguments)
            {
                string name = item.Value;
                if (name?.IndexOf("=") != -1)
                {
                    name = name?.Substring(0, name.IndexOf("="));
                }
                if (name?.ToLower() == commandArgument.Name.ToLower())
                {
                    result = item;
                    break;
                }
            }
            return result;
        }

        /// <summary>
        /// Returns true, if argument is used in command line.
        /// </summary>
        internal static bool ArgumentValueIsDelete(CommandBase command, CommandArgument commandArgument)
        {
            commandArgument = ArgumentValue(command, commandArgument); // Sequence of passed arguments might be wrong.

            bool result = commandArgument != null && commandArgument.Value != null;
            return result;
        }

        /// <summary>
        /// Returns true, if value has been set. (Use Argument=null to set a value to null).
        /// </summary>
        /// <param name="value">Returns value.</param>
        internal static bool ArgumentValue(CommandBase command, CommandArgument commandArgument, out string value)
        {
            string name = commandArgument.Name;
            commandArgument = ArgumentValue(command, commandArgument); // Sequence of passed arguments might be wrong.

            bool isValue = false;
            string result = commandArgument.Value;
            UtilFramework.Assert(name.ToLower() == result.Substring(0, name.Length).ToLower());
            if (result.ToUpper().StartsWith(name.ToUpper()))
            {
                result = result.Substring(name.Length);
            }
            if (result.StartsWith("="))
            {
                result = result.Substring(1);
            }
            result = UtilFramework.StringNull(result);
            if (result != null)
            {
                isValue = true;
            }
            if (result?.ToLower() == "null") // User sets value to null.
            {
                result = null;
            }
            value = result;
            return isValue;
        }

        /// <summary>
        /// Copy folder.
        /// </summary>
        /// <param name="searchPattern">For example: "*.*"</param>
        /// <param name="isAllDirectory">If true, includes subdirectories.</param>
        internal static void FolderCopy(string folderNameSource, string folderNameDest, string searchPattern = "*.*", bool isAllDirectory = true)
        {
            var source = new DirectoryInfo(folderNameSource);
            var dest = new DirectoryInfo(folderNameDest);

            SearchOption searchOption = SearchOption.TopDirectoryOnly;
            foreach (FileInfo file in source.GetFiles(searchPattern, searchOption))
            {
                string fileNameSource = file.FullName;
                string fileNameDest = Path.Combine(dest.FullName, file.FullName.Substring(source.FullName.Length));
                FileCopy(fileNameSource, fileNameDest);
            }

            if (isAllDirectory)
            {
                foreach (var folderName in source.GetDirectories())
                {
                    if (folderName.Name == "node_modules")
                    {
                        // Skip folder node_modules/
                        continue;
                    }
                    FolderCopy(folderNameSource + folderName.Name + "/", folderNameDest + folderName.Name + "/");
                }
            }
        }

        /// <summary>
        /// Returns list of files in folder.
        /// </summary>
        private static void FileNameList(string folderName, string searchPattern, bool isAllDirectory, List<string> result)
        {
            var directoryInfo = new DirectoryInfo(folderName);
            SearchOption searchOption = SearchOption.TopDirectoryOnly;
            foreach (FileInfo file in directoryInfo.GetFiles(searchPattern, searchOption))
            {
                string fileName = file.FullName;
                result.Add(fileName);
            }

            if (isAllDirectory)
            {
                foreach (var folderNameSub in directoryInfo.GetDirectories())
                {
                    if (folderNameSub.Name == "node_modules")
                    {
                        // Skip folder node_modules/
                        continue;
                    }
                    FileNameList(folderNameSub.FullName, searchPattern, isAllDirectory, result);
                }
            }
        }

        /// <summary>
        /// Returns list of files in folder.
        /// </summary>
        /// <param name="folderName"></param>
        /// <param name="searchPattern">For example: "*.*"</param>
        /// <param name="isAllDirectory">If true, includes subdirectories.</param>
        internal static List<string> FileNameList(string folderName, string searchPattern = "*.*", bool isAllDirectory = true)
        {
            var result = new List<string>();
            FileNameList(folderName, searchPattern, isAllDirectory, result);
            return result;
        }

        /// <summary>
        /// Create folder if it does not yet exist.
        /// </summary>
        internal static void FolderCreate(string fileName)
        {
            string folderName = new FileInfo(fileName).DirectoryName;
            if (!Directory.Exists(folderName))
            {
                Directory.CreateDirectory(folderName);
            }
        }

        internal static void FileCopy(string fileNameSource, string fileNameDest)
        {
            FolderCreate(fileNameDest);
            File.Copy(fileNameSource, fileNameDest, true);

            // chmod+x for ./cli.sh file for Linux.
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                if (Path.GetExtension(fileNameSource) == ".sh")
                {
                    // Console.WriteLine("chmode +x " + fileNameDest);
                    Process.Start(new ProcessStartInfo
                    {
                        FileName = "/bin/bash",
                        Arguments = "-c \"chmod +x " + fileNameDest,
                    }).WaitForExit();
                }
            }
        }

        internal static void FolderDelete(string folderName)
        {
            var count = 0;
            do
            {
                if (count > 0)
                {
                    Task.Delay(1000).Wait(); // Wait for next attempt.
                }
                if (UtilCliInternal.FolderNameExist(folderName))
                {
                    foreach (FileInfo fileInfo in new DirectoryInfo(folderName).GetFiles("*.*", SearchOption.AllDirectories))
                    {
                        fileInfo.Attributes = FileAttributes.Normal; // See also: https://stackoverflow.com/questions/1701457/directory-delete-doesnt-work-access-denied-error-but-under-windows-explorer-it/30673648
                    }
                    try
                    {
                        Directory.Delete(folderName, true);
                    }
                    catch (IOException)
                    {
                        // Silent exception.
                        Console.WriteLine(string.Format("Can not delete folder! ({0})", folderName));
                        UtilFramework.NodeClose();
                    }
                }
                count += 1;
            } while (UtilCliInternal.FolderNameExist(folderName) && count <= 3);
            UtilFramework.Assert(!UtilCliInternal.FolderNameExist(folderName), string.Format("Can not delete folder! Make sure it is not locked by another program. For example by a running server.ts or node.exe. ({0}", folderName));
        }

        internal static bool FolderNameExist(string folderName)
        {
            return Directory.Exists(folderName);
        }

        /// <summary>
        /// Returns git commit sha.
        /// </summary>
        internal static string GitCommit()
        {
            string result = "Commit";
            try
            {
                result = UtilCliInternal.StartStdout(UtilFramework.FolderName, "git", "rev-parse --short HEAD");
                result = result.Replace("\n", "");
            }
            catch
            {
                // Silent exception
            }
            return result;
        }

        /// <summary>
        /// Tag version build.
        /// </summary>
        internal static void VersionBuild(Action build)
        {
            // Read UtilFramework.cs
            string fileNameServer = UtilFramework.FolderName + "Framework/Framework/UtilFramework.cs";
            string textServer = UtilFramework.FileLoad(fileNameServer);
            // string fileNameClient = UtilFramework.FolderName + "Framework/Framework.Angular/application/src/app/data.service.ts"; // TODO Tag all Angular sites.
            // string textClient = UtilFramework.FileLoad(fileNameClient);

            string versionBuild = string.Format("Build (WorkplaceX={3}; Commit={0}; Pc={1}; Time={2} (UTC);)", UtilCliInternal.GitCommit(), System.Environment.MachineName, UtilFramework.DateTimeToString(DateTime.Now.ToUniversalTime()), UtilFramework.Version);

            string findServer = "/* VersionBuild */"; // See also: method CommandBuild.Execute(); and method CommandStart.Execute();
            string replaceServer = string.Format("                return \"{0}\"; /* VersionBuild */", versionBuild);
            // string findClient = "/* VersionBuild */"; // See also: file data.service.ts
            // string replaceClient = string.Format("  public VersionBuild: string = \"{0}\"; /* VersionBuild */", versionBuild);

            // Write UtilFramework.cs
            string textNewServer = UtilFramework.ReplaceLine(textServer, findServer, replaceServer);
            File.WriteAllText(fileNameServer, textNewServer);
            // string textNewClient = UtilFramework.ReplaceLine(textClient, findClient, replaceClient);
            // File.WriteAllText(fileNameClient, textNewClient);

            try
            {
                build();
            }
            finally
            {
                File.WriteAllText(fileNameServer, textServer); // Back to original text.
                // File.WriteAllText(fileNameClient, textClient); // Back to original text.
            }
        }

        /// <summary>
        /// Returns password (ConnectionString or GitUrl) without sensitive data.
        /// </summary>
        /// <param name="password">For example ConnectionString or GitUrl.</param>
        private static string ConsoleWriteLinePasswordHide(string password)
        {
            return "[Password]"; // Remove password from ConnectionString or GitUrl.
        }

        /// <summary>
        /// Returns text without password. It replaces password with PasswordHide.
        /// </summary>
        private static string ConsoleWriteLinePasswordHide(string text, string password)
        {
            if (text != null && password?.Length > 0)
            {
                while (text.ToLower().IndexOf(password.ToLower()) >= 0)
                {
                    int indexStart = text.ToLower().IndexOf(password.ToLower());
                    int length = password.Length;
                    string passwordHide = ConsoleWriteLinePasswordHide(password);
                    text = text.Substring(0, indexStart) + passwordHide + text.Substring(indexStart + length);
                }
            }
            return text;
        }

        /// <summary>
        /// Write text which might contain sensitive data (ConnectionString and GitUrl) with this method to console.
        /// </summary>
        internal static void ConsoleWriteLinePassword(object value, ConsoleColor? color = null)
        {
            string text = string.Format("{0}", value);
            var configCli = ConfigCli.Load();
            var environment = configCli.EnvironmentGet();
            text = ConsoleWriteLinePasswordHide(text, environment.ConnectionStringFramework);
            text = ConsoleWriteLinePasswordHide(text, environment.ConnectionStringApplication);
            text = ConsoleWriteLinePasswordHide(text, environment.DeployAzureGitUrl);
            foreach (var item in configCli.ExternalGitList)
            {
                text = ConsoleWriteLinePasswordHide(text, item.ExternalGit);
            }

            text = text.Replace("{", "{{").Replace("}", "}}"); // Console.Write("{", ConsoleColor.Green); throws exception "Input string was not in a correct format". // TODO Bug report

            Console.WriteLine(text, color);
        }

        /// <summary>
        /// Write to console in color.
        /// </summary>
        internal static void ConsoleWriteLineColor(object value, ConsoleColor? color, bool isLine = true)
        {
            if (color == null)
            {
                if (isLine)
                {
                    Console.WriteLine(value);
                }
                else
                {
                    Console.Write(value);
                }
            }
            else
            {
                Console.ForegroundColor = color.Value;
                if (isLine)
                {
                    Console.WriteLine(value);
                }
                else
                {
                    Console.Write(value);
                }
                Console.ResetColor();

                // ConsoleColor foregroundColor = Console.ForegroundColor;
                // Console.ForegroundColor = color.Value;
                // try
                // {
                //     Console.WriteLine(value);
                // }
                // finally
                // {
                //     Console.ForegroundColor = foregroundColor;
                // }
            }
        }

        /// <summary>
        /// Wait for user interaction.
        /// </summary>
        internal static bool ConsoleReadYesNo(string text)
        {
            string consoleReadLine;
            do
            {
                Console.Write(text + " [y/n] ");
                consoleReadLine = Console.ReadLine().ToUpper();
            } while (!(consoleReadLine == "Y" || consoleReadLine == "N"));
            return consoleReadLine == "Y";
        }

        /// <summary>
        /// Write to stderr.
        /// </summary>
        internal static void ConsoleWriteLineError(object value)
        {
            using TextWriter textWriter = Console.Error;
            textWriter.WriteLine(value);
        }

        /// <summary>
        /// Returns text escaped as CSharp code. Handles special characters.
        /// </summary>
        public static string EscapeCSharpString(string text)
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("\"");
            var textList = UtilFramework.SplitChunk(text); // Because of line break after 80 characters!
            using (var writer = new StringWriter(CultureInfo.InvariantCulture))
            {
                using var provider = CodeDomProvider.CreateProvider("CSharp");
                foreach (var item in textList)
                {
                    provider.GenerateCodeFromExpression(new CodePrimitiveExpression(item), writer, null); // Does a line break after 80 characters by default!
                    string textCSharp = writer.ToString();
                    UtilFramework.Assert(textCSharp.StartsWith("\""));
                    UtilFramework.Assert(textCSharp.EndsWith("\""));
                    textCSharp = textCSharp[1..^1]; // Remove quotation marks.
                    stringBuilder.Append(textCSharp);
                    writer.GetStringBuilder().Clear(); // Reset writer for next chunk.
                }
            }
            stringBuilder.Append("\"");
            string result = stringBuilder.ToString();
            return result;
        }

        /// <summary>
        /// Create new text file.
        /// </summary>
        public static void FileCreate(string fileName, string text = null)
        {
            FolderCreate(fileName);
            File.WriteAllText(fileName, text);
        }

        /// <summary>
        /// Rename file.
        /// </summary>
        public static void FileRename(string fileNameSource, string fileNameDest)
        {
            if (fileNameSource != fileNameDest)
            {
                FileCopy(fileNameSource, fileNameDest);
                File.Delete(fileNameSource);
            }
        }
    }
}


text:
@media (max-width:1024px){
.countDown .rotate {
width:150px;
height:150px;
margin:0 40px;
}
}
@media (max-width:768px){
.countDown .days, .countDown .hours, .countDown .minutes, .countDown .seconds {
  font-size: 54px;
  margin: 0 36px;
  padding: 10px 0;
}
.countDown .rotate {
  width:120px;
height:120px;
margin:0 30px;
}
.services .service .ser {
    padding-top: 20px;
}
.services .service .square {
margin-bottom:10px;
}
.carousel-caption {
    bottom: inherit;
    left: 10%;
    padding-bottom: 0;
    right: 10%;
    top: 10%;
}.carousel-caption img {    max-width: 100%;    height: auto;}
}
@media (min-width:480px) and (max-width:767px){
.countDown .rotate {    width: 95px;    height: 95px;    margin: 2% 20px;    float: none;    display: inline-block;}.countDown .days, .countDown .hours, .countDown .minutes, .countDown .seconds {    font-size: 48px;    margin: 0 35px;    padding: 0;}
.address {
    margin-top: -10px;
}.carousel-caption {    top: 15%;}
}
@media (max-width:480px){.carousel-caption img {    max-width: 100%;    height: auto;}
header .social-icons {
padding:5px 0 !important;;
}
header .social-icons li {
    font-size: 14px;
	margin: 0 5px 0 0;
}
header .social-icons .icon {
    background-color: #fff;
    border-top-right-radius: 15px;
    border-bottom-left-radius: 15px;
    height: 25px;
    width: 25px;
    padding: 5px 4px;
    color: #eb5054;
}

.countDown .rotate {    width: 55px;    height: 55px;    margin: 0 10px;    float: none;    display: inline-block;}
.carousel-caption h1 {
  font-size: 30px;
}
.newsletter .form-group {
  left: 0%;
  width: 100% !important;
}
.newsletter .form-control {
  width: 100%;
}
.newsletter .btn{
width:100%;
}
.countDown .days,
.countDown .hours,
.countDown .minutes,
.countDown .seconds {
    font-size: 30px;
    padding: 0;
    margin: 0;
}
.countDown .text {
  font-size:10px;
  margin-top:-5px;
}
.address{
margin-top:0 !important;
}
.countDown {
margin: 10px auto;
}
.address {
    margin-top: -110px;
}
.services .service .square {
    margin: 0 auto;
}
.ser h4{
text-align:center;
}
header .social-icons ul {
    padding: 0 5px;
}
header .social-icons ul li {
    margin: 0 2px;
}
.form-group {
    margin-bottom: 0;
}
.logo_class img {
    width: 150px;
    height: 90px;
}
.c_social .social li a i {
    font-size: 25px;
}
.carousel-caption {
  left: 5%;
  right: 5%;
  top: 5%;
  text-align:center;
}
.footer_social{
	text-align:center;
}
.c_social .social li {
    margin: 0 -1px 0px -2px !important;
	padding: 10px 0 !important;
}
.space {
    padding: 50px 0;
}
.sub_btn {
    display: inline-block;
}
.c_get_detail {
	min-height: auto;
}
.c_get {
    min-height: auto;
}
footer{
	padding:10px 0;
}
.footer_copy {
    font-size: 14px;
}
}
@media (max-width: 1024px){
.countDown .circle {
    margin: 0 4% 0 5% !important;
}
.countDown .circle .days,
 .countDown .circle .hours,
 .countDown .circle .minutes,
 .countDown .circle .seconds {
    font-size: 66px; margin: 20px auto !important;
}
}
@media (max-width: 768px){
.countDown .circle {
    margin: 0 2% !important;
	width: 150px !important;
    height: 150px !important;
}
.countDown .circle .days, .countDown .circle .hours, .countDown .circle .minutes, .countDown .circle .seconds{
 margin: 5px auto !important;
}
}
@media (max-width: 767px){
.countDown .circle {
    margin: 0 10px 0 20px !important;
    width: 120px !important;
    height: 120px !important;
}
.countDown .circle .days,
.countDown .circle .hours,
.countDown .circle .minutes,
.countDown .circle .seconds {
    font-size: 48px;
    margin: 5px auto !important;
}
}
@media (max-width: 480px){
.countDown .circle {
    margin: 0px 3px 0 10px !important;
    width: 65px !important;
    height: 65px !important;
}
.countDown .circle .days,
.countDown .circle .hours,
.countDown .circle .minutes,
.countDown .circle .seconds {
font-size: 42px;
}
}
@media (max-width: 320px){
.countDown .circle {
    margin: 0px 3px 0 2px !important;
    width: 60px !important;
    height: 60px !important;
}
.countDown .circle .days,
.countDown .circle .hours,
.countDown .circle .minutes,
.countDown .circle .seconds {
font-size: 36px;
}.countDown .rotate {    width: 48px;    height: 48px;    margin: 20px 10px ;}.countDown .rotate .days,.countDown .rotate .hours,.countDown .rotate .minutes,.countDown .rotate .seconds {font-size: 24px;}.countDown .text {  font-size:10px;  margin-top:-5px;}
}


text: ..amasing tabular


text:
module Chandler
  module Refinements
    # Monkey patch String to provide basic ANSI color support.
    #
    # "hello".color? # => false
    # "hello".blue # => "\e[0;34;49mhello\e[0m"
    # "hello".blue.color? # => true
    # "hello".blue.strip_color # "hello"
    #
    module Color
      ANSI_CODES = {
        :red   => 31,
        :green => 32,
        :blue  => 34,
        :gray  => 90,
        :grey  => 90
      }.freeze

      refine String do
        # Returns `true` if this String contains ANSI color sequences.
        def color?
          self != strip_color
        end

        # Returns a new String with ANSI color sequences removed.
        def strip_color
          gsub(/\e\[[0-9;]*m/, "")
        end

        # Define red, green, blue, etc. methods that return a copy of the
        # String that is wrapped in the corresponding ANSI color escape
        # sequence.
        ANSI_CODES.each do |name, code|
          define_method(name) do
            "\e[0;#{code};49m#{self}\e[0m"
          end
        end
      end
    end
  end
end