Beispiel #1
0
        internal IEnumerable <IProjectItem> ExecuteInternal(IProject project, IProjectItemTemplate itemTemplate, string userSpecifiedFileName)
        {
            List <IProjectItem> itemsToOpen        = (List <IProjectItem>)null;
            TemplateItemHelper  templateItemHelper = new TemplateItemHelper(project, (IList <string>)null, (IServiceProvider)this.designerContext.Services);
            CreationOptions     creationOptions    = CreationOptions.DoNotSelectCreatedItems | CreationOptions.DoNotSetDefaultImportPath;

            if (!this.allowOverwrite)
            {
                creationOptions |= CreationOptions.DoNotAllowOverwrites;
            }
            IEnumerable <IProjectItem> enumerable = templateItemHelper.AddProjectItemsForTemplateItem(itemTemplate, userSpecifiedFileName, this.designerContext.ProjectManager.TargetFolderForProject(project), creationOptions, out itemsToOpen);

            if (enumerable != null)
            {
                foreach (IProjectItem projectItem in enumerable)
                {
                    if (projectItem.DocumentType is AssemblyReferenceDocumentType)
                    {
                        project.AddAssemblyReference(projectItem.DocumentReference.Path, false);
                    }
                }
            }
            if (itemsToOpen != null)
            {
                foreach (IProjectItem projectItem in itemsToOpen)
                {
                    projectItem.OpenView(true);
                }
            }
            return(enumerable);
        }
        partial void SetMarshalMemberBuilder(CreationOptions options)
        {
            if (options.MarshalMemberBuilder != null)
            {
                marshalMemberBuilder = SetRuntime(options.MarshalMemberBuilder);
                return;
            }

            Assembly jie;

            try {
                jie = Assembly.Load(new AssemblyName("Java.Interop.Export"));
            } catch (Exception) {
                return;
            }
            var t = jie.GetType("Java.Interop.MarshalMemberBuilder");

            if (t == null)
            {
                throw new InvalidOperationException("Could not find Java.Interop.MarshalMemberBuilder from Java.Interop.Export.dll!");
            }
            var b = (JniMarshalMemberBuilder)Activator.CreateInstance(t);

            marshalMemberBuilder = SetRuntime(b);
        }
Beispiel #3
0
        private IProjectItem GetUpdatedItem(IProjectItem item, FileInfo fileInfo, CreationOptions creationOptions)
        {
            IDocumentType documentType = this.GetDocumentType(item.DocumentReference.Path);

            if (item.DocumentType == documentType)
            {
                return(null);
            }
            if (item.DocumentType == base.Services.DocumentTypes()[DocumentTypeNamesHelper.Xml] && documentType == base.Services.DocumentTypes()[DocumentTypeNamesHelper.DeepZoom])
            {
                string[] directoryExtensions = DeepZoomHelper.GetDirectoryExtensions(item.DocumentReference.Path);
                for (int i = 0; i < (int)directoryExtensions.Length; i++)
                {
                    string str = directoryExtensions[i];
                    Microsoft.Expression.Framework.Documents.DocumentReference documentReference = DeepZoomHelper.CreateDeepZoomDirectoryReference(item.DocumentReference, str);
                    IProjectItem projectItem = base.FindItem(documentReference);
                    if (projectItem != null)
                    {
                        this.RemoveProjectItem(projectItem, false);
                    }
                }
            }
            this.RemoveProjectItem(item, false);
            DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo()
            {
                TargetPath      = fileInfo.FullName,
                CreationOptions = creationOptions,
                DocumentType    = documentType
            };

            return(base.AddItem(documentCreationInfo));
        }
Beispiel #4
0
        internal async Task CreateAsync(CloudService parent, Uri packageUrl, CreationOptions options = null)
        {
            Contract.Requires(parent != null);
            Contract.Requires(packageUrl != null);
            Contract.Requires(!string.IsNullOrWhiteSpace(Label));
            Contract.Requires(Configuration != null);

            if (options == null)
            {
                options = new CreationOptions();
            }
            var ns      = XmlNamespaces.WindowsAzure;
            var content = new XElement(ns + "CreateDeployment",
                                       new XElement(ns + "Name", Name),
                                       new XElement(ns + "PackageUrl", packageUrl.ToString()),
                                       new XElement(ns + "Label", Label.ToBase64String()),
                                       new XElement(ns + "Configuration", Configuration.ToXml().ToString().ToBase64String()),
                                       new XElement(ns + "StartDeployment", options.StartDeployment),
                                       new XElement(ns + "TreatWarningsAsError", options.TreatWarningsAsError)
                                       );

            HttpResponseMessage response = await GetRestClient(parent).PostAsync(content);

            await parent.Subscription.WaitForOperationCompletionAsync(response);

            Parent = parent;
        }
        private static void AddSubNodes(string[] words, TrieNode node, int position, CreationOptions options, bool leftToRight, ObjectPool <List <int>[]> listsPool)
        {
            if (!node.IsRoot)
            {
                if (node.Path.Length >= options.MaxDepth)
                {
                    return;
                }
                if (node.Selection.Count < options.MinSplit)
                {
                    return;
                }
            }

            var lists = listsPool.Lend();

            foreach (int s in node.Selection.Value)
            {
                var word = words[s];
                if (position < word.Length)
                {
                    lists[leftToRight ? word[position] : word[word.Length - 1 - position]].Add(s);
                }
            }

            node.AddAsSubNodes(lists);
            listsPool.Return(lists);

            foreach (var n in node.SubNodes)
            {
                AddSubNodes(words, n, position + 1, options, leftToRight, listsPool);
            }
        }
Beispiel #6
0
        private Server(CreationOptions creationOptions, Action <LanguageServerOptions> onOptionsFunc)
        {
            BicepDeploymentsInterop.Initialize();
            server = OmniSharp.Extensions.LanguageServer.Server.LanguageServer.PreInit(options =>
            {
                options
                .WithHandler <BicepTextDocumentSyncHandler>()
                .WithHandler <BicepDocumentSymbolHandler>()
                .WithHandler <BicepDefinitionHandler>()
                .WithHandler <BicepDeploymentGraphHandler>()
                .WithHandler <BicepReferencesHandler>()
                .WithHandler <BicepDocumentHighlightHandler>()
                .WithHandler <BicepDocumentFormattingHandler>()
                .WithHandler <BicepRenameHandler>()
                .WithHandler <BicepHoverHandler>()
                .WithHandler <BicepCompletionHandler>()
                .WithHandler <BicepCodeActionHandler>()
                .WithHandler <BicepDidChangeWatchedFilesHandler>()
                .WithHandler <BicepSignatureHelpHandler>()
#pragma warning disable 0612 // disable 'obsolete' warning for proposed LSP feature
                .WithHandler <BicepSemanticTokensHandler>()
#pragma warning restore 0612
                .WithServices(services => RegisterServices(creationOptions, services));

                onOptionsFunc(options);
            });
        }
Beispiel #7
0
        /// <summary>
        /// Create (or open) a new file in the folder.
        /// </summary>
        /// <param name="name">
        /// The name of the file to open or create. The file name must not contain path
        /// separators.
        /// </param>
        /// <param name="access">
        /// The access mode to open the file with.
        /// </param>
        /// <param name="options">
        /// Creation options.
        /// </param>
        /// <returns>A Stream instance to read or write to the file.</returns>
        public Stream CreateFile(string name, FileAccessMode access, CreationOptions options)
        {
            bool   exists = FileExists(name);
            string target = Path.Combine(m_path, name);

            switch (options)
            {
            case CreationOptions.FailIfExists:
                if (exists)
                {
                    throw new InvalidOperationException(String.Format("File '{0}' exists and {1} was specified.", target, options));
                }
                break;

            case CreationOptions.OpenIfExists:
                break;

            case CreationOptions.ReplaceExisting:
                if (exists)
                {
                    File.Delete(target);
                }
                break;
            }
            // Now open the stream
            return(File.Open(target, FileMode.OpenOrCreate, (access == FileAccessMode.Read) ? FileAccess.Read : FileAccess.ReadWrite, FileShare.None));
        }
Beispiel #8
0
 private static void RegisterServices(CreationOptions creationOptions, IServiceCollection services)
 {
     // using type based registration so dependencies can be injected automatically
     // without manually constructing up the graph
     services.AddSingleton <IAzResourceTypeLoader, AzResourceTypeLoader>();
     services.AddSingletonOrInstance <INamespaceProvider, DefaultNamespaceProvider>(creationOptions.NamespaceProvider);
     services.AddSingletonOrInstance <ISnippetsProvider, SnippetsProvider>(creationOptions.SnippetsProvider);
     services.AddSingletonOrInstance <IFileResolver, FileResolver>(creationOptions.FileResolver);
     services.AddSingletonOrInstance <IFeatureProvider, FeatureProvider>(creationOptions.Features);
     services.AddSingleton <EmitterSettings>();
     services.AddSingleton <IModuleRegistryProvider, DefaultModuleRegistryProvider>();
     services.AddSingleton <IContainerRegistryClientFactory, ContainerRegistryClientFactory>();
     services.AddSingleton <ITemplateSpecRepositoryFactory, TemplateSpecRepositoryFactory>();
     services.AddSingleton <IModuleDispatcher, ModuleDispatcher>();
     services.AddSingleton <IFileSystem, FileSystem>();
     services.AddSingleton <IConfigurationManager, ConfigurationManager>();
     services.AddSingleton <ITokenCredentialFactory, TokenCredentialFactory>();
     services.AddSingleton <ITelemetryProvider, TelemetryProvider>();
     services.AddSingleton <IWorkspace, Workspace>();
     services.AddSingleton <ICompilationManager, BicepCompilationManager>();
     services.AddSingleton <ICompilationProvider, BicepCompilationProvider>();
     services.AddSingleton <ISymbolResolver, BicepSymbolResolver>();
     services.AddSingleton <ICompletionProvider, BicepCompletionProvider>();
     services.AddSingletonOrInstance <IModuleRestoreScheduler, ModuleRestoreScheduler>(creationOptions.ModuleRestoreScheduler);
     services.AddSingleton <IAzResourceProvider, AzResourceProvider>();
     services.AddSingleton <ILinterRulesProvider, LinterRulesProvider>();
     services.AddSingleton <IBicepConfigChangeHandler, BicepConfigChangeHandler>();
     services.AddSingleton <IDeploymentCollectionProvider, DeploymentCollectionProvider>();
 }
Beispiel #9
0
        public Server(CreationOptions creationOptions, Action <LanguageServerOptions> onOptionsFunc)
        {
            BicepDeploymentsInterop.Initialize();
            server = OmnisharpLanguageServer.PreInit(options =>
            {
                options
                .WithHandler <BicepTextDocumentSyncHandler>()
                .WithHandler <BicepDocumentSymbolHandler>()
                .WithHandler <BicepDefinitionHandler>()
                .WithHandler <BicepDeploymentGraphHandler>()
                .WithHandler <BicepReferencesHandler>()
                .WithHandler <BicepDocumentHighlightHandler>()
                .WithHandler <BicepDocumentFormattingHandler>()
                .WithHandler <BicepRenameHandler>()
                .WithHandler <BicepHoverHandler>()
                .WithHandler <BicepCompletionHandler>()
                .WithHandler <BicepCodeActionHandler>()
                .WithHandler <BicepDidChangeWatchedFilesHandler>()
                .WithHandler <BicepSignatureHelpHandler>()
                .WithHandler <BicepSemanticTokensHandler>()
                .WithHandler <BicepTelemetryHandler>()
                .WithHandler <BicepBuildCommandHandler>()
                .WithHandler <BicepDeployCommandHandler>()
                .WithHandler <BicepDeploymentScopeRequestHandler>()
                .WithHandler <BicepRegistryCacheRequestHandler>()
                .WithHandler <InsertResourceHandler>()
                .WithServices(services => RegisterServices(creationOptions, services));

                creationOptions.onRegisterServices?.Invoke(options.Services);

                onOptionsFunc(options);
            });
        }
Beispiel #10
0
        partial void SetMarshalMemberBuilder(CreationOptions options)
        {
            if (!options.UseMarshalMemberBuilder)
            {
                return;
            }

            if (options.MarshalMemberBuilder != null)
            {
                marshalMemberBuilder = SetRuntime(options.MarshalMemberBuilder);
                return;
            }

            Assembly jie;

            try {
                jie = Assembly.Load(new AssemblyName("Java.Interop.Export"));
            } catch (Exception e) {
                System.Diagnostics.Debug.WriteLine($"Java.Interop.Export assembly was not loaded: {e}");
                return;
            }
            var t = jie.GetType("Java.Interop.MarshalMemberBuilder");

            if (t == null)
            {
                throw new InvalidOperationException("Could not find Java.Interop.MarshalMemberBuilder from Java.Interop.Export.dll!");
            }
            var b = (JniMarshalMemberBuilder)Activator.CreateInstance(t);

            marshalMemberBuilder = SetRuntime(b);
        }
Beispiel #11
0
        internal async Task CreateAsync(
            CloudService parent,
            Uri packageUrl,
            CreationOptions options = null,
            params ExtensionAssociation[] extensionAssociations)
        {
            Contract.Requires(parent != null);
            Contract.Requires(packageUrl != null);
            Contract.Requires(!string.IsNullOrWhiteSpace(Label));
            Contract.Requires(Configuration != null);

            if (options == null) options = new CreationOptions();
            var ns = XmlNamespaces.WindowsAzure;
            var content = new XElement(ns + "CreateDeployment",
                new XElement(ns + "Name", Name),
                new XElement(ns + "PackageUrl", packageUrl.ToString()),
                new XElement(ns + "Label", Label.ToBase64String()),
                new XElement(ns + "Configuration", Configuration.ToXml().ToString().ToBase64String()),
                new XElement(ns + "StartDeployment", options.StartDeployment),
                new XElement(ns + "TreatWarningsAsError", options.TreatWarningsAsError)
                );

            AddExtensionConfigurationXml(content, extensionAssociations);

            var response = await GetRestClient(parent).PostAsync(content);
            await parent.Subscription.WaitForOperationCompletionAsync(response);
            Parent = parent;
        }
 bool ICustomInterpreterSerialization.GetSerializationInfo(out string assembly, out string typeName, out Dictionary <string, object> properties)
 {
     assembly   = GetType().Assembly.Location;
     typeName   = GetType().FullName;
     properties = CreationOptions.ToDictionary();
     Configuration.WriteToDictionary(properties);
     return(true);
 }
Beispiel #13
0
        /// <inheritdoc />
        public object Clone()
        {
            var result = (HistogramCreationInformation)MemberwiseClone();

            result._warnings        = new System.Collections.ObjectModel.ObservableCollection <string>(_warnings);
            result._errors          = new System.Collections.ObjectModel.ObservableCollection <string>(_errors);
            result._creationOptions = (HistogramCreationOptions)CreationOptions.Clone();
            return(result);
        }
Beispiel #14
0
        private void RefreshDirectory(string directoryPath, bool selectNewlyCreatedItems)
        {
            if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(directoryPath))
            {
                return;
            }
            CreationOptions creationOption = (selectNewlyCreatedItems ? CreationOptions.None : CreationOptions.DoNotSelectCreatedItems);

            foreach (FileInfo fileInfo in (new DirectoryInfo(directoryPath)).EnumerateFiles())
            {
                if ((fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                {
                    continue;
                }
                Microsoft.Expression.Framework.Documents.DocumentReference documentReference = Microsoft.Expression.Framework.Documents.DocumentReference.Create(fileInfo.FullName);
                IProjectItem projectItem = base.FindItem(documentReference);
                if (projectItem != null)
                {
                    IProjectItem updatedItem = this.GetUpdatedItem(projectItem, fileInfo, creationOption);
                    projectItem = (updatedItem != null ? updatedItem : projectItem);
                }
                else
                {
                    IDocumentType        documentType         = this.GetDocumentType(fileInfo.FullName);
                    DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo()
                    {
                        TargetPath      = fileInfo.FullName,
                        CreationOptions = creationOption,
                        DocumentType    = documentType
                    };
                    projectItem = base.CreateProjectItemIfNeeded(documentCreationInfo);
                    if (projectItem == null)
                    {
                        continue;
                    }
                    this.AddProjectItem(projectItem, ProjectItemEventOptions.None);
                }
            }
            foreach (string str in Directory.EnumerateDirectories(directoryPath))
            {
                if (!this.ShouldInitializeFolder(base.FindItem(Microsoft.Expression.Framework.Documents.DocumentReference.Create(str)) as FolderProjectItem))
                {
                    continue;
                }
                this.RefreshDirectory(str, selectNewlyCreatedItems);
            }
            if (directoryPath != base.ProjectRoot.Path)
            {
                Microsoft.Expression.Framework.Documents.DocumentReference documentReference1 = Microsoft.Expression.Framework.Documents.DocumentReference.Create(string.Concat(directoryPath, Path.DirectorySeparatorChar));
                if (base.FindItem(documentReference1) == null)
                {
                    IProjectItem folderProjectItem = new FolderProjectItem(this, documentReference1, base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder], base.Services);
                    base.AddProjectItem(folderProjectItem);
                }
            }
        }
 public PathObject()
 {
     info      = new PathInformation();
     start     = new Point();
     end       = new Point();
     distance  = startAngle = pathLength = 0;
     dimension = new Dimensions();
     options   = CreationOptions.none;
     figureId  = -1;
 }
 bool ICustomInterpreterSerialization.GetSerializationInfo(out string assembly, out string typeName, out Dictionary <string, object> properties)
 {
     assembly   = GetType().Assembly.Location;
     typeName   = GetType().FullName;
     properties = Configuration.ToDictionary();
     foreach (var kv in CreationOptions.ToDictionary())
     {
         properties[kv.Key] = kv.Value;
     }
     return(true);
 }
Beispiel #17
0
 public TeVirtualMidi(string portName, uint maxSysexLength, CreationOptions options, ref Guid manufacturer, ref Guid product)
 {
     instance = VirtualMIDICreatePortEx3(portName, IntPtr.Zero, IntPtr.Zero, maxSysexLength, (uint)options, ref manufacturer, ref product);
     if (instance == IntPtr.Zero)
     {
         int lastError = Marshal.GetLastWin32Error();
         throw TeVirtualMidiException.NewExceptionForReasonCode(lastError);
     }
     readBuffer          = new byte[maxSysexLength];
     readProcessIds      = new ulong[17];
     this.maxSysexLength = maxSysexLength;
 }
        public RegexRetriever(string[] words, CreationOptions options)
        {
            Words = words;

            options.SubStringTrieOptions            = options.SubStringTrieOptions ?? new SubStringTrieMatcher.CreationOptions();
            options.LTRPositionSubStringTrieOptions = options.LTRPositionSubStringTrieOptions ?? new PositionalSubStringTrieMatcher.CreationOptions();
            options.RTLPositionSubStringTrieOptions = options.RTLPositionSubStringTrieOptions ?? new PositionalSubStringTrieMatcher.CreationOptions();

            var logger = options.Logger ?? (s => { });

            T Create <T>(string name, Func <T> supplier)
            {
                logger($"Creating {name}...");
                var watch = Stopwatch.StartNew();

                var res = supplier();

                logger($"\rCreated {name} ({watch.ElapsedTicks * 1.0 / Stopwatch.Frequency:0.#}s)");

                GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
                GC.Collect();

                return(res);
            }

            if (options.UseWordIndex)
            {
                wordIndex = Create(nameof(WordIndex), () => new WordIndex(words));
            }

            if (options.UseLTRPositionSubStringTrie)
            {
                ltrPositionalTrie = Create($"LTR {nameof(PositionalSubStringTrieMatcher)}",
                                           () => new PositionalSubStringTrieMatcher(words, options.LTRPositionSubStringTrieOptions, true));
            }

            if (options.UseRTLPositionSubStringTrie)
            {
                rtlPositionalTrie = Create($"RTL {nameof(PositionalSubStringTrieMatcher)}",
                                           () => new PositionalSubStringTrieMatcher(words, options.RTLPositionSubStringTrieOptions, false));
            }

            if (options.UseSubStringTrie)
            {
                subStringTrie = Create(nameof(SubStringTrieMatcher),
                                       () => new SubStringTrieMatcher(words, options.SubStringTrieOptions));
            }

            if (options.UseLengthMatcher)
            {
                lengthMatcher = Create(nameof(LengthMatcher), () => new LengthMatcher(words));
            }
        }
Beispiel #19
0
 private static void RegisterServices(CreationOptions creationOptions, IServiceCollection services)
 {
     // using type based registration so dependencies can be injected automatically
     // without manually constructing up the graph
     services.AddSingleton <IResourceTypeProvider>(services => creationOptions.ResourceTypeProvider ?? new AzResourceTypeProvider());
     services.AddSingleton <IFileResolver>(services => creationOptions.FileResolver ?? new FileResolver());
     services.AddSingleton <IWorkspace, Workspace>();
     services.AddSingleton <ICompilationManager, BicepCompilationManager>();
     services.AddSingleton <ICompilationProvider, BicepCompilationProvider>();
     services.AddSingleton <ISymbolResolver, BicepSymbolResolver>();
     services.AddSingleton <ICompletionProvider, BicepCompletionProvider>();
 }
        private static TrieNode CreateTree(string[] words, CreationOptions options)
        {
            var rootNode = TrieNode.CreateRoot(new Selection <int>(Enumerable.Range(0, words.Length), words.Length));

            var listsPool = MatcherUtil.CreateListArrayPool(words.GetCharactersDistribution());

            AddSubNodes(words, rootNode, options, listsPool);

            listsPool.Clear();

            return(rootNode);
        }
Beispiel #21
0
        partial void SetValueManager(CreationOptions options)
        {
            var manager = options.ValueManager;

            if (manager == null)
            {
                throw new ArgumentException(
                          "No JniValueManager specified in JniRuntime.CreationOptions.ValueManager.",
                          nameof(options));
            }
            ValueManager = SetRuntime(manager);
        }
Beispiel #22
0
        public static BigInteger CreateBigInteger(uint numberOfDigits, CreationOptions options)
        {
            var result = NumberGenerator.CreateBigInteger(numberOfDigits);

            if (options == CreationOptions.CreateOdd && result.IsEven)
            {
                result--;
            }
            else if (options == CreationOptions.CreateEven && !result.IsEven)
            {
                result++;
            }

            return(result);
        }
Beispiel #23
0
        public Server(CreationOptions creationOptions, Action <LanguageServerOptions> onOptionsFunc)
        {
            BicepDeploymentsInterop.Initialize();
            server = OmnisharpLanguageServer.PreInit(options =>
            {
                options
                .WithHandler <BicepTextDocumentSyncHandler>()
                .WithHandler <BicepDocumentSymbolHandler>()
                .WithHandler <BicepDefinitionHandler>()
                .WithHandler <BicepDeploymentGraphHandler>()
                .WithHandler <BicepReferencesHandler>()
                .WithHandler <BicepDocumentHighlightHandler>()
                .WithHandler <BicepDocumentFormattingHandler>()
                .WithHandler <BicepRenameHandler>()
                .WithHandler <BicepHoverHandler>()
                .WithHandler <BicepCompletionHandler>()
                .WithHandler <BicepCodeActionHandler>()
                .WithHandler <BicepCreateConfigFileHandler>()
                .WithHandler <BicepDidChangeWatchedFilesHandler>()
                .WithHandler <BicepEditLinterRuleCommandHandler>()
                .WithHandler <BicepGetRecommendedConfigLocationHandler>()
                .WithHandler <BicepSignatureHelpHandler>()
                .WithHandler <BicepSemanticTokensHandler>()
                .WithHandler <BicepTelemetryHandler>()
                .WithHandler <BicepBuildCommandHandler>()
                .WithHandler <BicepGenerateParamsCommandHandler>()
                .WithHandler <BicepDeploymentStartCommandHandler>()
                // Base handler - ExecuteTypedResponseCommandHandlerBase is serial. This blocks other commands on the client side.
                // To avoid the above issue, we'll change the RequestProcessType to parallel
                .WithHandler <BicepDeploymentWaitForCompletionCommandHandler>(new JsonRpcHandlerOptions()
                {
                    RequestProcessType = RequestProcessType.Parallel
                })
                .WithHandler <BicepDeploymentScopeRequestHandler>()
                .WithHandler <BicepDeploymentParametersHandler>()
                .WithHandler <BicepForceModulesRestoreCommandHandler>()
                .WithHandler <BicepRegistryCacheRequestHandler>()
                .WithHandler <InsertResourceHandler>()
                .WithServices(services => RegisterServices(creationOptions, services));

                creationOptions.onRegisterServices?.Invoke(options.Services);

                onOptionsFunc(options);
            });
        }
Beispiel #24
0
        private static void RegisterServices(CreationOptions creationOptions, IServiceCollection services)
        {
            var fileResolver = creationOptions.FileResolver ?? new FileResolver();

            // using type based registration so dependencies can be injected automatically
            // without manually constructing up the graph
            services.AddSingleton <IResourceTypeProvider>(services => creationOptions.ResourceTypeProvider ?? AzResourceTypeProvider.CreateWithAzTypes());
            services.AddSingleton <ISnippetsProvider>(services => creationOptions.SnippetsProvider ?? new SnippetsProvider(fileResolver));
            services.AddSingleton <IFileResolver>(services => fileResolver);
            services.AddSingleton <IModuleRegistryProvider, DefaultModuleRegistryProvider>();
            services.AddSingleton <IModuleDispatcher, ModuleDispatcher>();
            services.AddSingleton <ITelemetryProvider, TelemetryProvider>();
            services.AddSingleton <IWorkspace, Workspace>();
            services.AddSingleton <ICompilationManager, BicepCompilationManager>();
            services.AddSingleton <ICompilationProvider, BicepCompilationProvider>();
            services.AddSingleton <ISymbolResolver, BicepSymbolResolver>();
            services.AddSingleton <ICompletionProvider, BicepCompletionProvider>();
            services.AddSingleton <IModuleRestoreScheduler, ModuleRestoreScheduler>();
        }
Beispiel #25
0
 /// <summary>
 /// Create (or open) a new file in the folder.
 /// </summary>
 /// <param name="name">
 /// The name of the file to open or create. The file name must not contain path
 /// separators.
 /// </param>
 /// <param name="access">
 /// The access mode to open the file with.
 /// </param>
 /// <param name="options">
 /// Creation options.
 /// </param>
 /// <returns>A Stream instance to read or write to the file.</returns>
 public Stream CreateFile(string name, FileAccessMode access, CreationOptions options)
 {
     bool exists = FileExists(name);
     string target = Path.Combine(m_path, name);
     switch (options)
     {
         case CreationOptions.FailIfExists:
             if (exists)
                 throw new InvalidOperationException(String.Format("File '{0}' exists and {1} was specified.", target, options));
             break;
         case CreationOptions.OpenIfExists:
             break;
         case CreationOptions.ReplaceExisting:
             if (exists)
                 File.Delete(target);
             break;
     }
     // Now open the stream
     return File.Open(target, FileMode.OpenOrCreate, (access == FileAccessMode.Read) ? FileAccess.Read : FileAccess.ReadWrite, FileShare.None);
 }
        private static TrieNode[] CreatePositionalTrees(string[] words, CreationOptions options, bool leftToRight)
        {
            var maxWordLength = words.Select(w => w.Length).Max();

            var listsPool = MatcherUtil.CreateListArrayPool(words.GetCharactersDistribution());

            var selection = new Selection <int>(Enumerable.Range(0, words.Length), words.Length);
            var rootNodes = new TrieNode[maxWordLength].SetParallel(i =>
            {
                // create root
                var r = TrieNode.CreateRoot(selection);

                // add sub nodes
                AddSubNodes(words, r, i, options, leftToRight, listsPool);

                return(r);
            });

            listsPool.Clear();

            return(rootNodes);
        }
        public IEnumerable <IProjectItem> AddProjectItemsForTemplateItem(IProjectItemTemplate templateItem, string fileName, string targetFolder, CreationOptions creationOptions, out List <IProjectItem> itemsToOpen)
        {
            IEnumerable <TemplateArgument> templateArguments;
            IProjectItemTemplate           projectItemTemplate = templateItem;
            string   str     = fileName;
            string   str1    = targetFolder;
            IProject project = this.project;

            if (this.project.TargetFramework == null)
            {
                templateArguments = Enumerable.Empty <TemplateArgument>();
            }
            else
            {
                TemplateArgument[] templateArgument = new TemplateArgument[] { new TemplateArgument("targetframeworkversion", this.project.TargetFramework.Version.ToString(2)) };
                templateArguments = templateArgument;
            }
            IEnumerable <TemplateArgument> templateArguments1 = templateArguments;
            CreationOptions  creationOption  = creationOptions;
            IServiceProvider serviceProvider = this.serviceProvider;

            return(projectItemTemplate.CreateProjectItems(str, str1, project, templateArguments1, creationOption, out itemsToOpen, serviceProvider));
        }
Beispiel #28
0
 protected override bool CreateProjectItem()
 {
     this.addedProjectItems = null;
     string[] filesToImport = this.GetFilesToImport(base.GetImportFolder());
     if (filesToImport != null && (int)filesToImport.Length > 0 && this.project != null)
     {
         CreationOptions creationOption = (this.selectAddedItems ? CreationOptions.DoNotSelectCreatedItems : CreationOptions.None);
         this.addedProjectItems = this.project.AddItems(
             from file in filesToImport
             select new DocumentCreationInfo()
         {
             SourcePath      = file,
             TargetFolder    = this.targetFolder,
             CreationOptions = creationOption
         });
     }
     this.project = null;
     if (this.addedProjectItems == null)
     {
         return(false);
     }
     return(this.addedProjectItems.CountIsMoreThan <IProjectItem>(0));
 }
 void Create(DbgEvaluationInfo evalInfo, List <DbgDotNetValueNodeProvider> providers, bool addParens, DmdType slotType, DbgDotNetValueNodeInfo nodeInfo, DbgValueNodeEvaluationOptions options, CreationOptions creationOptions) =>
 CreateCore(evalInfo, providers, addParens, slotType, nodeInfo, GetTypeState(nodeInfo), options, creationOptions);
Beispiel #30
0
 public Server(Stream input, Stream output, CreationOptions creationOptions)
     : this(creationOptions, options => options.WithInput(input).WithOutput(output))
 {
 }
Beispiel #31
0
 public Server(PipeReader input, PipeWriter output, CreationOptions creationOptions)
     : this(creationOptions, options => options.WithInput(input).WithOutput(output))
 {
 }
        private static void AddSubNodes(string[] words, TrieNode node, CreationOptions options, ObjectPool <List <int>[]> listsPool)
        {
            if (node.Path.Length >= options.MaxDepth)
            {
                return;
            }
            if (node.Selection.Count < options.MinSplit)
            {
                return;
            }

            var lists       = listsPool.Lend();
            var charCounter = new int[0x10000].Set(i => - 1);

            string stack = node.Path;

            if (node.IsRoot)
            {
                // optimization because we know that: node.Selection == ALL && stack == ""
                for (int s = 0; s < words.Length; s++)
                {
                    var word = words[s];

                    foreach (var c in word)
                    {
                        // so that we don't add a word twice
                        if (charCounter[c] == s)
                        {
                            continue;
                        }
                        charCounter[c] = s;

                        lists[c].Add(s);
                    }
                }
            }
            else
            {
                foreach (int s in node.Selection.Value)
                {
                    var word = words[s];
                    if (word.Length <= stack.Length)
                    {
                        continue;
                    }

                    int offset = 0;
                    while (offset < word.Length)
                    {
                        int index = word.IndexOf(stack, offset, word.Length - offset - 1, StringComparison.Ordinal);
                        if (index == -1)
                        {
                            break;
                        }
                        offset = index + 1;

                        // get next char
                        var c = word[index + stack.Length];

                        // so that we don't add a word twice
                        if (charCounter[c] == s)
                        {
                            continue;
                        }
                        charCounter[c] = s;

                        lists[c].Add(s);
                    }
                }
            }


            node.AddAsSubNodes(lists);
            listsPool.Return(lists);

            if (node.IsRoot)
            {
                node.SubNodes.AsParallel().ForAll(n => AddSubNodes(words, n, options, listsPool));
            }
            else
            {
                foreach (var n in node.SubNodes)
                {
                    AddSubNodes(words, n, options, listsPool);
                }
            }
        }