public static void CopyToNewLayer(Collection <FeatureLayer> selectedFeaturesLayers)
        {
            Collection <FeatureLayer> existLayers = new Collection <FeatureLayer>();

            foreach (var item in GisEditor.ActiveMap.GetFeatureLayers().OfType <InMemoryFeatureLayer>())
            {
                existLayers.Add(item);
            }

            GetLayersParameters parameters = new GetLayersParameters();

            parameters.LayerUris.Add(new Uri("mem:Newlayer"));
            InMemoryFeatureLayerPlugin plugin = GisEditor.LayerManager.GetActiveLayerPlugins <InMemoryFeatureLayerPlugin>().FirstOrDefault();
            InMemoryFeatureLayer       inMemoryFeatureLayer = null;

            if (plugin != null)
            {
                inMemoryFeatureLayer      = plugin.GetLayers(parameters).OfType <InMemoryFeatureLayer>().FirstOrDefault();
                inMemoryFeatureLayer.Name = "New layer";
                existLayers.Insert(0, inMemoryFeatureLayer);
            }
            if (selectedFeaturesLayers.Count > 1)
            {
                AddFeaturesToSelectedLayer(selectedFeaturesLayers, existLayers);
                GisEditor.ActiveMap.Refresh(GisEditor.ActiveMap.ActiveOverlay);
                RefreshArgs refreshArgs = new RefreshArgs(GisEditor.ActiveMap, RefreshArgsDescription.AddLayerGroupCommandDescription);
                GisEditor.UIManager.BeginRefreshPlugins(refreshArgs);
                LayerOverlay overlay = GisEditor.ActiveMap.ActiveOverlay as LayerOverlay;
                if (overlay != null)
                {
                    overlay.Invalidate();
                }
            }
            else if (selectedFeaturesLayers.Count == 1)
            {
                AddFeatureToInMemoryFeatureLayer(null, selectedFeaturesLayers[0]);
            }
        }
        private static void AddFeatureToInMemoryFeatureLayer(InMemoryFeatureLayer inMemoryFeatureLayer, FeatureLayer sourceLayer)
        {
            if (inMemoryFeatureLayer == null)
            {
                string name         = "ExportResults";
                string existingName = string.Empty;
                InMemoryFeatureLayer existingLayer = GisEditor.ActiveMap.Overlays.OfType <LayerOverlay>()
                                                     .SelectMany(o => o.Layers).OfType <InMemoryFeatureLayer>()
                                                     .FirstOrDefault(l => l.Name.Equals(name, System.StringComparison.Ordinal));
                if (existingLayer != null)
                {
                    existingName = existingLayer.Name;
                }

                int index = 0;
                while (name.Equals(existingName))
                {
                    index++;
                    name          = "ExportResults" + index;
                    existingLayer = GisEditor.ActiveMap.Overlays.OfType <LayerOverlay>()
                                    .SelectMany(o => o.Layers).OfType <InMemoryFeatureLayer>()
                                    .FirstOrDefault(l => l.Name.Equals(name, System.StringComparison.Ordinal));
                    existingName = existingLayer != null ? existingLayer.Name : string.Empty;
                }

                GetLayersParameters parameters = new GetLayersParameters();
                parameters.LayerUris.Add(new Uri("mem:" + name));
                InMemoryFeatureLayerPlugin plugin = GisEditor.LayerManager.GetActiveLayerPlugins <InMemoryFeatureLayerPlugin>().FirstOrDefault();
                if (plugin != null)
                {
                    inMemoryFeatureLayer = plugin.GetLayers(parameters).OfType <InMemoryFeatureLayer>().FirstOrDefault();
                }
                GisEditor.ActiveMap.AddLayerToActiveOverlay(inMemoryFeatureLayer, TargetLayerOverlayType.Dynamic);
            }

            //if (sourceLayer != null)
            //{
            //    foreach (var item in sourceLayer.FeatureSource.LinkExpressions)
            //    {
            //        inMemoryFeatureLayer.FeatureSource.LinkExpressions.Add(item);
            //    }
            //    foreach (var item in sourceLayer.FeatureSource.LinkSources)
            //    {
            //        inMemoryFeatureLayer.FeatureSource.LinkSources.Add(item);
            //    }
            //}

            Collection <Feature> features = GisEditor.SelectionManager.GetSelectedFeatures();

            AddFeaturesToInMemoryFeatureLayer(inMemoryFeatureLayer, features);

            GisEditor.ActiveMap.Refresh(GisEditor.ActiveMap.ActiveOverlay);
            RefreshArgs refreshArgs = new RefreshArgs(GisEditor.ActiveMap, RefreshArgsDescription.AddLayerGroupCommandDescription);

            GisEditor.UIManager.BeginRefreshPlugins(refreshArgs);
            LayerOverlay overlay = GisEditor.ActiveMap.ActiveOverlay as LayerOverlay;

            if (overlay != null)
            {
                overlay.Invalidate();
            }
        }