public StageDocument Load(ProjectDocument project, StageLinkInfo linkInfo)
 {
     var reader = _core.Reader.GetStageReader(linkInfo.StagePath);
     var stage = reader.Load(linkInfo.StagePath);
     var document = new StageDocument(project, stage, linkInfo);
     return document;
 }
		public void SetUp()
		{
            doc = new ProjectDocument();
            project = new ProjectModel(doc);
            doc.CreateNewProject();
            xmlfile = Path.ChangeExtension(Path.GetTempFileName(), ".nunit");
		}
        public void SetUp()
        {
            doc = new ProjectDocument(xmlfile);
            project = new ProjectModel(doc);

            doc.ProjectChanged += OnProjectChange;
            gotChangeNotice = false;
        }
Пример #4
0
 public ProjectDocument Load(string filePath)
 {
     var project = _projectReader.Load(filePath);
     var structure = new ProjectFileStructure(project);
     var projectDocument = new ProjectDocument(structure, project);
     LoadIncludes(projectDocument, project);
     return projectDocument;
 }
        public void SetUp()
        {
            doc = new ProjectDocument();
            doc.CreateNewProject();
            doc.ProjectChanged += new ActionDelegate(OnProjectChange);

            gotChangeNotice = false;
        }
 public ProjectDocument Load(string filePath)
 {
     _core.Load(filePath);
     var project = _core.Reader.GetProjectReader().Load();
     var structure = new ProjectFileStructure(project);
     var projectDocument = new ProjectDocument(structure, project, _stageFactory);
     return projectDocument;
 }
 public void Initialize()
 {
     IProjectDocument doc = new ProjectDocument();
     doc.LoadXml(NUnitProjectXml.EmptyConfigs);
     model = new ProjectModel(doc);
     dlg = Substitute.For<IRenameConfigurationDialog>();
     presenter = new RenameConfigurationPresenter(model, dlg, "Debug");
 }
Пример #8
0
        public ProjectDocument CreateNew(string directory)
        {
            var project = new Project()
            {
                GameFile = FilePath.FromRelative("game.xml", directory)
            };

            var p = new ProjectDocument(new ProjectFileStructure(project), project);
            return p;
        }
Пример #9
0
        public void Initialize()
        {
            ProjectDocument doc = new ProjectDocument();
            doc.LoadXml(NUnitProjectXml.NormalProject);
            model = new ProjectModel(doc);

            view = Substitute.For<IConfigurationEditorDialog>();

            editor = new ConfigurationEditor(model, view);
        }
        public void SetUp()
        {
            IProjectDocument doc = new ProjectDocument();
            doc.LoadXml(NUnitProjectXml.NormalProject);
            model = new ProjectModel(doc);

            dlg = Substitute.For<IAddConfigurationDialog>();

            presenter = new AddConfigurationPresenter(model, dlg);
        }
Пример #11
0
        /// <summary>
        /// 获取生成器
        /// </summary>
        /// <param name="control">控件对象</param>
        /// <returns>返回控件对应的生成器</returns>
        public static ControlBuildBase GetBuilder(this ControlHost controlHost, bool isPreview, ScreenDefinition screenDef, CompileBase compile, ProjectDocument doc, Dictionary <int, Tuple <int, string> > permissionData, HtmlTextWriter htmlWriter)
        {
            //图表控件名字为空自动生成一个默认名字
            var controlName = controlHost.Content.GetType().Name;

            if (controlName == "ChartPane" || controlName == "DropDownButton")
            {
                if (string.IsNullOrEmpty(controlHost.Name))
                {
                    controlHost.Name = controlName + ctlNumber++;
                }
            }

            if (!isPreview && doc != null && !string.IsNullOrEmpty(controlHost.Name))
            {
                controlHost.Name = doc.Name + "_" + controlHost.Name;
            }
            if (controlHost.Content != null)
            {
                var    assembly = Assembly.GetAssembly(typeof(ControlExtend));
                string typeName = string.Format("Wilmar.Build.Core.Dojo.Default.Builders.{0}Build", controlHost.Content.GetType().Name);
                if (assembly.GetType(typeName) == null)
                {
                    throw new Exception(string.Format("类型【{0}】没对应的生成器。", typeName));
                }
                ControlBuildBase builder = Activator.CreateInstance(assembly.GetType(typeName), isPreview, controlHost, screenDef, compile, doc, permissionData, htmlWriter) as ControlBuildBase;
                return(builder);
            }
            else
            {
                return(null);
            }
        }
Пример #12
0
        /// <summary>
        /// 生成HTML
        /// </summary>
        /// <param name="name">屏幕名称</param>
        /// <param name="controlHost">控件基类</param>
        /// <param name="compile">编译基类</param>
        /// <param name="screenDef">屏幕定义</param>
        /// <param name="doc">项目文档</param>
        private void BuildHtml(ControlHost controlHost, CompileBase compile, ScreenDefinition screenDef, ProjectDocument doc)
        {
            using (var writer = new StringWriter())
            {
                var ionicCompile = compile as IonicCompile;
                Dictionary <int, Tuple <int, string> > itemPermissionData = new Dictionary <int, Tuple <int, string> >();

                var xmlWriter = new HtmlTextWriter(writer);
                var builder   = controlHost.GetBuilder(false, screenDef, compile, doc, itemPermissionData, xmlWriter);
                builder.Build();

                //生成文件全路径
                string fileName   = doc.Name;
                string outputPath = ionicCompile.OutputPath + "\\" + fileName;
                if (!Directory.Exists(outputPath))
                {
                    Directory.CreateDirectory(outputPath);
                }
                var file = Path.Combine(outputPath, fileName + ".html");
                if (File.Exists(file))
                {
                    File.Delete(file);
                }
                //创建HTML文件
                File.WriteAllText(file, writer.ToString(), System.Text.UTF8Encoding.UTF8);

                //启动屏幕名字暂时固定
                //projets/pages中启动屏幕不生成TS文件,TS文件在外部生成
                if (fileName.ToLower() != "startuppage")
                {
                    //生成JS
                    this.BuildJs(compile, screenDef, doc);
                    //生成CSS
                    this.BuildCss(compile, screenDef, doc);
                }
            }
        }
Пример #13
0
        /// <summary>
        /// 生成HTML
        /// </summary>
        /// <param name="name">屏幕名称</param>
        /// <param name="controlHost">控件基类</param>
        /// <param name="compile">编译基类</param>
        /// <param name="screenDef">屏幕定义</param>
        /// <param name="doc">项目文档</param>
        private void BuildHtml(string name, ControlHost controlHost, CompileBase compile, ScreenDefinition screenDef, ProjectDocument doc)
        {
            using (var writer = new StringWriter())
            {
                var dojoCompile = compile as DojoCompile;

                #region 写入权限操作
                //序号,权限ID,权限作用
                Dictionary <int, Tuple <int, string> > itemPermissionData = new Dictionary <int, Tuple <int, string> >();
                var permissionConfigure = screenDef.PermissionConfigure;
                if (permissionConfigure != null && permissionConfigure.EnableAuth)
                {
                    int    permissionItemId = 1;
                    string identity         = dojoCompile.Project.Identity;
                    var    permissionItems  = screenDef.PermissionConfigure.PermissionItems;
                    foreach (var item in permissionItems)
                    {
                        short purpose = DojoCompile.PermissionScreen;
                        switch (item.Purpose)
                        {
                        case EPermissionPurpose.Operate:
                            purpose = DojoCompile.PermissionOperate;
                            break;

                        case EPermissionPurpose.Visible:
                            purpose = DojoCompile.PermissionVisible;
                            break;

                        case EPermissionPurpose.Custom:
                            purpose = DojoCompile.PermissionCustom;
                            break;
                        }
                        permissionItemId = int.Parse(item.Id);
                        string title        = item.Title;
                        string desc         = doc.Title + " " + item.Description;
                        int    permissionId = dojoCompile.Permission.Write(doc.Id, purpose, item.Id, title, desc);
                        itemPermissionData.Add(permissionItemId, new Tuple <int, string>(permissionId, item.Purpose.ToString().ToLower()));
                    }
                }
                #endregion

                //根据屏幕生成HTML
                var xmlWriter = new HtmlTextWriter(writer);
                xmlWriter.AddAttribute("dojoType", "dojox/mvc/Group");
                xmlWriter.AddAttribute("style", "width:100%;height:100%;position:relative;");
                xmlWriter.AddAttribute("class", "groupDiv");
                xmlWriter.RenderBeginTag("div");

                var builder = controlHost.GetBuilder(false, screenDef, compile, doc, itemPermissionData, xmlWriter);
                builder.Build();

                xmlWriter.RenderEndTag();

                //生成屏幕JS
                BuildScreenJs.BuildJs(controlHost, compile, screenDef, xmlWriter, doc);
                //生成文件全路径
                var file = Path.Combine(((DojoCompile)compile).OutputPath, name + ".html");
                if (File.Exists(file))
                {
                    File.Delete(file);
                }
                //创建HTML文件
                File.WriteAllText(file, writer.ToString(), System.Text.UTF8Encoding.UTF8);

                ControlExtend.ctlNumber = 1;
            }
        }
Пример #14
0
 public ModuleTemplate(IonicCompile ionicCompile, ProjectDocument doc)
 {
     this.Compile  = ionicCompile;
     this.Documnet = doc;
     Initial();
 }
Пример #15
0
        /// <summary>
        /// 生成数据集
        /// </summary>
        /// <param name="ionicCompile"></param>
        /// <param name="screenDef"></param>
        /// <param name="doc"></param>
        /// <returns></returns>
        public static Dictionary <string, MetaDataDataSet> RegisterDataSets(IonicCompile ionicCompile, ScreenDefinition screenDef, ProjectDocument doc)
        {
            Dictionary <string, MetaDataDataSet> DataSetData = new Dictionary <string, MetaDataDataSet>();
            var items = screenDef.Children.Where(a => a.MemberType == EMemberType.DataSet || a.MemberType == EMemberType.Objects).ToList();

            foreach (var item in items)
            {
                if (item.MemberType == EMemberType.DataSet)
                {
                    #region 远程数据集(有实体)
                    DataSet dats       = item as DataSet;
                    var     entityItem = ionicCompile.ProjectItems.Where(a => a.Value.DocumentType == GlobalIds.DocumentType.Entity && a.Key == dats.EntityId).FirstOrDefault();
                    if (entityItem.Value != null)
                    {
                        MetaDataDataSet metaDataSet = BuildMetaDataDataSet(entityItem.Value.Name, item);
                        if (metaDataSet != null)
                        {
                            DataSetData.Add(item.Name, metaDataSet);
                        }
                    }
                    #endregion
                }
                else
                {
                    Objects objs       = item as Objects;
                    var     entityItem = ionicCompile.ProjectItems.Where(a => a.Value.DocumentType == GlobalIds.DocumentType.Entity && a.Key == objs.EntityId).FirstOrDefault();
                    if (entityItem.Value != null)
                    {
                        #region 本地对象(有实体)
                        MetaDataDataSet metaDataSet = BuildMetaDataDataSet(entityItem.Value.Name, item);
                        if (metaDataSet != null)
                        {
                            DataSetData.Add(item.Name, metaDataSet);
                        }
                        #endregion
                    }
                    else
                    {
                        #region 本地对象(无实体)
                        MetaDataDataSet metaDataSet = BuildMetaDataDataSet("", item);
                        if (metaDataSet != null)
                        {
                            DataSetData.Add(item.Name, metaDataSet);
                        }
                        #endregion
                    }
                }
            }
            return(DataSetData);
        }
Пример #16
0
        /// <summary>
        ///     Get property element completions.
        /// </summary>
        /// <param name="projectDocument">
        ///     The <see cref="ProjectDocument"/> for which completions will be offered.
        /// </param>
        /// <param name="replaceRange">
        ///     The range of text to be replaced by the completions.
        /// </param>
        /// <returns>
        ///     A sequence of <see cref="CompletionItem"/>s.
        /// </returns>
        public IEnumerable <CompletionItem> GetCompletionItems(ProjectDocument projectDocument, Range replaceRange)
        {
            if (replaceRange == null)
            {
                throw new ArgumentNullException(nameof(replaceRange));
            }

            LspModels.Range replaceRangeLsp = replaceRange.ToLsp();

            HashSet <string> offeredPropertyNames = new HashSet <string>();

            // Special-case properties

            // Output type
            yield return(new CompletionItem
            {
                Label = "<OutputType>",
                Detail = "Property",
                Kind = CompletionItemKind.Property,
                Documentation = MSBuildSchemaHelp.ForProperty("OutputType"),
                SortText = Priority + "<OutputType>",
                TextEdit = new TextEdit
                {
                    NewText = "<OutputType>${1|Library,Exe|}</OutputType>",
                    Range = replaceRangeLsp
                },
                InsertTextFormat = InsertTextFormat.Snippet
            });

            offeredPropertyNames.Add("OutputType");

            // Target framework
            yield return(new CompletionItem
            {
                Label = "<TargetFramework>",
                Detail = "Property",
                Kind = CompletionItemKind.Property,
                Documentation = MSBuildSchemaHelp.ForProperty("TargetFramework"),
                SortText = Priority + "<TargetFramework>",
                TextEdit = new TextEdit
                {
                    NewText = "<TargetFramework>${1|netstandard1.0,netstandard1.1,netstandard1.2,netstandard1.3,netstandard1.4,netstandard1.5,netstandard1.6,netstandard2.0,netcoreapp1.0,netcoreapp1.1,netcoreapp3.0,net4,net451,net452,net46,net461,net462,net47|}</TargetFramework>",
                    Range = replaceRangeLsp
                },
                InsertTextFormat = InsertTextFormat.Snippet
            });

            offeredPropertyNames.Add("TargetFramework");

            // Well-known (but standard-format) properties.

            foreach (string wellKnownPropertyName in MSBuildSchemaHelp.WellKnownPropertyNames)
            {
                if (!offeredPropertyNames.Add(wellKnownPropertyName))
                {
                    continue;
                }

                var propertyDefaults = MSBuildSchemaHelp.DefaultsForProperty(wellKnownPropertyName);

                yield return(PropertyCompletionItem(wellKnownPropertyName, replaceRangeLsp,
                                                    description: MSBuildSchemaHelp.ForProperty(wellKnownPropertyName),
                                                    defaultValue: propertyDefaults.defaultValue,
                                                    defaultValues: propertyDefaults.defaultValues
                                                    ));
            }

            if (!projectDocument.HasMSBuildProject)
            {
                yield break; // Without a valid MSBuild project (even a cached one will do), we can't inspect existing MSBuild properties.
            }
            if (!projectDocument.Workspace.Configuration.Language.CompletionsFromProject.Contains(CompletionSource.Property))
            {
                yield break;
            }

            int otherPropertyPriority = Priority + 10;

            string[] otherPropertyNames =
                projectDocument.MSBuildProject.Properties
                .Select(property => property.Name)
                .Where(propertyName => !propertyName.StartsWith("_"))     // Ignore private properties.
                .ToArray();
            foreach (string propertyName in otherPropertyNames)
            {
                if (!offeredPropertyNames.Add(propertyName))
                {
                    continue;
                }

                yield return(PropertyCompletionItem(propertyName, replaceRangeLsp, otherPropertyPriority,
                                                    description: $"I don't know anything about the '{propertyName}' property, but it's defined in this project (or a project that it imports); you can override its value by specifying it here."
                                                    ));
            }
        }
        /// <summary>
        ///     Provide completions for the specified location.
        /// </summary>
        /// <param name="location">
        ///     The <see cref="XmlLocation"/> where completions are requested.
        /// </param>
        /// <param name="projectDocument">
        ///     The <see cref="ProjectDocument"/> that contains the <paramref name="location"/>.
        /// </param>
        /// <param name="cancellationToken">
        ///     A <see cref="CancellationToken"/> that can be used to cancel the operation.
        /// </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> that resolves either a <see cref="CompletionList"/>s, or <c>null</c> if no completions are provided.
        /// </returns>
        public override async Task <CompletionList> ProvideCompletions(XmlLocation location, ProjectDocument projectDocument, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            List <CompletionItem> completions = new List <CompletionItem>();

            using (await projectDocument.Lock.ReaderLockAsync())
            {
                XSElement   element;
                XSAttribute replaceAttribute;
                PaddingType needsPadding;
                if (!location.CanCompleteAttribute(out element, out replaceAttribute, out needsPadding))
                {
                    return(null);
                }

                // Must be a valid item element.
                if (!element.IsValid || !element.HasParentPath(WellKnownElementPaths.ItemGroup))
                {
                    return(null);
                }

                Range replaceRange = replaceAttribute?.Range ?? location.Position.ToEmptyRange();

                completions.AddRange(
                    WellKnownItemAttributes.Except(
                        element.AttributeNames
                        )
                    .Select(attributeName => new CompletionItem
                {
                    Label         = attributeName,
                    Detail        = "Attribute",
                    Documentation =
                        MSBuildSchemaHelp.ForItemMetadata(itemType: element.Name, metadataName: attributeName)
                        ??
                        MSBuildSchemaHelp.ForAttribute(element.Name, attributeName),
                    Kind     = CompletionItemKind.Field,
                    SortText = GetItemSortText(attributeName),
                    TextEdit = new TextEdit
                    {
                        NewText = $"{attributeName}=\"$1\"$0".WithPadding(needsPadding),
                        Range   = replaceRange.ToLsp()
                    },
                    InsertTextFormat = InsertTextFormat.Snippet
                })
                    );
            }

            if (completions.Count == 0)
            {
                return(null);
            }

            return(new CompletionList(completions, isIncomplete: false));
        }
Пример #18
0
        /// <summary>
        /// 生成属性
        /// </summary>
        public static Dictionary <string, MetaDataProperty> RegisterPropertys(IonicCompile ionicCompile, ScreenDefinition screenDef, ProjectDocument doc)
        {
            Dictionary <string, MetaDataProperty> PropertyData = new Dictionary <string, MetaDataProperty>();
            var items = screenDef.Children.Where(a => a.MemberType == EMemberType.Property).ToList();

            foreach (var item in items)
            {
                MetaDataProperty propertyMember = GetPropertyContent(item);
                PropertyData.Add(item.Name, propertyMember);
            }
            return(PropertyData);
        }
Пример #19
0
 public static Task <ProjectDocument> SetProjectAsync(this IDurableOrchestrationContext functionContext, ProjectDocument project, bool allowUnsafe = false)
 => functionContext.IsLockedByContainerDocument(project) || allowUnsafe
     ? functionContext.CallActivityWithRetryAsync <ProjectDocument>(nameof(ProjectSetActivity), project)
     : throw new NotSupportedException($"Unable to set project '{project.Id}' without acquired lock");
Пример #20
0
 /// <summary>
 /// 执行生成
 /// </summary>
 /// <param name="compile">编译器></param>
 /// <param name="doc">指定的文档对象,如果是全局生成器则为空</param>
 public virtual void Build(CompileBase compile, ProjectDocument doc)
 {
 }
        protected override void Seed(Models.ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.

            var Region1 = new Region()
            {
                Id = 1, Title = "Region1"
            };
            var Region2 = new Region()
            {
                Id = 2, Title = "Region2"
            };
            var Region3 = new Region()
            {
                Id = 3, Title = "Region3"
            };
            var Region4 = new Region()
            {
                Id = 4, Title = "Region4"
            };
            var Region5 = new Region()
            {
                Id = 5, Title = "Region5"
            };

            var SubRegion1 = new SubRegion()
            {
                Id = 1, Title = "SubRegion1"
            };
            var SubRegion2 = new SubRegion()
            {
                Id = 2, Title = "SubRegion2"
            };
            var SubRegion3 = new SubRegion()
            {
                Id = 3, Title = "SubRegion3"
            };
            var SubRegion4 = new SubRegion()
            {
                Id = 4, Title = "SubRegion4"
            };
            var SubRegion5 = new SubRegion()
            {
                Id = 5, Title = "SubRegion5"
            };

            var SupportingDocument1 = new SupportingDocument()
            {
                Id = 1, Title = "Docx1", FileName = "DOCX1.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0"
            };
            var SupportingDocument2 = new SupportingDocument()
            {
                Id = 2, Title = "Docx2", FileName = "DOCX2.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0"
            };
            var SupportingDocument3 = new SupportingDocument()
            {
                Id = 3, Title = "Docx3", FileName = "DOCX3.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0"
            };
            var SupportingDocument4 = new SupportingDocument()
            {
                Id = 4, Title = "Docx4", FileName = "DOCX4.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0"
            };
            var SupportingDocument5 = new SupportingDocument()
            {
                Id = 5, Title = "Docx5", FileName = "DOCX5.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0"
            };

            var ProjectDocument1 = new ProjectDocument()
            {
                Id = 1, Title = "Docx1", FileName = "DOCX1.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0"
            };
            var ProjectDocument2 = new ProjectDocument()
            {
                Id = 2, Title = "Docx2", FileName = "DOCX2.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0"
            };
            var ProjectDocument3 = new ProjectDocument()
            {
                Id = 3, Title = "Docx3", FileName = "DOCX3.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0"
            };
            var ProjectDocument4 = new ProjectDocument()
            {
                Id = 4, Title = "Docx4", FileName = "DOCX4.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0"
            };
            var ProjectDocument5 = new ProjectDocument()
            {
                Id = 5, Title = "Docx5", FileName = "DOCX5.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0"
            };

            ApplicationDbContext dbContext = new ApplicationDbContext();

            dbContext.Region.AddRange(new List <Region>()
            {
                Region1, Region2, Region3, Region4, Region5
            });
            dbContext.SubRegion.AddRange(new List <SubRegion>()
            {
                SubRegion1, SubRegion2, SubRegion3, SubRegion4, SubRegion5
            });
            dbContext.ProjectDocument.AddRange(new List <ProjectDocument>()
            {
                ProjectDocument1, ProjectDocument2, ProjectDocument3, ProjectDocument4, ProjectDocument5
            });
            dbContext.SuportingDocument.AddRange(new List <SupportingDocument>()
            {
                SupportingDocument1, SupportingDocument2, SupportingDocument3, SupportingDocument4, SupportingDocument5
            });

            dbContext.SaveChanges();
        }
        public void NameIsUnique()
        {
            ProjectDocument anotherProject = new ProjectDocument(xmlfile);

            Assert.AreNotEqual(doc.Name, anotherProject.Name);
        }
Пример #23
0
        public ProjectDocumentVM CreateProjectDocumentVM(ProjectDocument item)
        {
            return new ProjectDocumentVM
            {
                Id = item.Id,
                Title = item.Title,
                Description = item.Description,
                Version = item.Version,
                CreatedDate = item.CreatedDate,
                Filename = item.Filename,
                FilenameOriginal = item.FilenameOriginal,
                FileExt = item.FileExt,
                FilePath = item.FilePath,

                DocType = item.DocType,
            };
        }
Пример #24
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="isPreview">是否预览</param>
 /// <param name="controlHost">控件</param>
 /// <param name="compile">编译器对象</param>
 /// <param name="htmlWriter">htmlWriter</param>
 public ControlBuildBase(bool isPreview, ControlHost controlHost, ScreenDefinition screenDef, CompileBase compile, ProjectDocument doc, Dictionary <int, Tuple <int, string> > permissionData, HtmlTextWriter htmlWriter)
 {
     this.IsPreview        = isPreview;
     this.ControlHost      = controlHost;
     this.ScreenDefinition = screenDef;
     this.Compile          = compile;
     this.ProjectDocument  = doc;
     this.PermissionData   = permissionData;
     this.HtmlWriter       = htmlWriter;
 }
 public ProjectDocumentVM()
 {
     ProjectDocument         = new ProjectDocument();
     ProjectDocumentTypeOpts = ListOpts.ProjectDocumentTypeOpts;
 }
Пример #26
0
        /// <summary>
        ///     Provide completions for the specified location.
        /// </summary>
        /// <param name="location">
        ///     The <see cref="SourceLocation"/> where completions are requested.
        /// </param>
        /// <param name="projectDocument">
        ///     The <see cref="ProjectDocument"/> that contains the <paramref name="location"/>.
        /// </param>
        /// <param name="cancellationToken">
        ///     A <see cref="CancellationToken"/> that can be used to cancel the operation.
        /// </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> that resolves either a <see cref="CompletionList"/>s, or <c>null</c> if no completions are provided.
        /// </returns>
        public override async Task <CompletionList> ProvideCompletions(SourceLocation location, ProjectDocument projectDocument, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            List <CompletionItem> completions = new List <CompletionItem>();

            using (await projectDocument.Lock.ReaderLockAsync())
            {
                Range replaceRange = location.Position.ToEmptyRange();

                completions.AddRange(
                    WellKnownItemAttributes
                    .Select(attributeName => new CompletionItem
                {
                    Label    = attributeName,
                    Detail   = "Attribute",
                    Kind     = CompletionItemKind.Field,
                    SortText = GetItemSortText(attributeName),
                    TextEdit = new TextEdit
                    {
                        NewText = $"{attributeName}=\"$1\"$0".WithPadding(PaddingType.None),
                        Range   = replaceRange.ToLsp()
                    },
                    InsertTextFormat = InsertTextFormat.Snippet
                })
                    );
            }

            if (completions.Count == 0)
            {
                return(null);
            }

            return(new CompletionList(completions, isIncomplete: false));
        }
Пример #27
0
        /// <summary>
        /// 生成Module页面HTML
        /// </summary>
        /// <param name="compile"></param>
        /// <param name="doc"></param>
        private void BuildModuleHtml(CompileBase compile, ScreenDefinition screenDef, ProjectDocument doc)
        {
            if (doc.Name.ToLower() == "startuppage")
            {
                var    ionicCompile    = compile as IonicCompile;
                var    targetDirectory = new System.IO.FileInfo(new Uri(this.GetType().Assembly.CodeBase).AbsolutePath).Directory.FullName;
                string outputPath      = Path.Combine(targetDirectory.Replace("\\Wilmar.Service\\bin\\Extension", ""), @"Wilmar.Mobile\src\projects", ionicCompile.Project.Identity);
                outputPath = HttpUtility.UrlDecode(outputPath);
                if (!Directory.Exists(outputPath))
                {
                    Directory.CreateDirectory(outputPath);
                }

                //Module页面
                var fileModulePage = Path.Combine(outputPath, ionicCompile.Project.Identity + ".module.ts");
                if (File.Exists(fileModulePage))
                {
                    File.Delete(fileModulePage);
                }
                var contentModulePage = new ModuleTemplate(ionicCompile, doc).TransformText();
                File.WriteAllText(fileModulePage, contentModulePage, System.Text.UTF8Encoding.UTF8);

                //生成Mian页面TS
                var fileMainPage = Path.Combine(outputPath, ionicCompile.Project.Identity + ".ts");
                if (File.Exists(fileMainPage))
                {
                    File.Delete(fileMainPage);
                }
                var contentMainPage = new PageMainTemplate(ionicCompile, screenDef, doc).TransformText();
                File.WriteAllText(fileMainPage, contentMainPage, System.Text.UTF8Encoding.UTF8);
                //生成Mian页面CSS
                var fileMainCss = Path.Combine(outputPath, ionicCompile.Project.Identity + ".scss");
                if (File.Exists(fileMainCss))
                {
                    File.Delete(fileMainCss);
                }
                string contentMainCss = string.Empty;
                File.WriteAllText(fileMainCss, contentMainCss, System.Text.UTF8Encoding.UTF8);
            }
        }
Пример #28
0
        /// <summary>
        /// 事件生成
        /// </summary>
        /// <param name="ionicCompile"></param>
        /// <param name="screenDef"></param>
        /// <param name="doc"></param>
        /// <returns></returns>
        public static Dictionary <string, MetaDataMethod> RegisterEvents(IonicCompile ionicCompile, ScreenDefinition screenDef, ProjectDocument doc)
        {
            Dictionary <string, MetaDataMethod> EventData = new Dictionary <string, MetaDataMethod>();
            var items = screenDef.Children.Where(a => a.MemberType == EMemberType.Events).ToList();

            foreach (var item in items)
            {
                foreach (var child in item.Children)
                {
                    MetaDataMethod eventMember = GetEventContent(child);
                    if (eventMember != null)
                    {
                        EventData.Add(child.Name, eventMember);
                    }
                }
            }
            return(EventData);
        }
Пример #29
0
        public void Should_read_default_build_executable()
        {
            var document = new ProjectDocument(ProjectType.CSharp);

            _config.BuildExecutable(document).ShouldEqual(@"C:\Somefolder\MSBuild.exe");
        }
Пример #30
0
        /// <summary>
        /// 生成屏幕参数
        /// </summary>
        /// <param name="ionicCompile"></param>
        /// <param name="screenDef"></param>
        /// <param name="doc"></param>
        /// <returns></returns>
        public static Dictionary <string, MetaDataScreenParam> RegisterScreenParams(IonicCompile ionicCompile, ScreenDefinition screenDef, ProjectDocument doc)
        {
            Dictionary <string, MetaDataScreenParam> ScreenParamData = new Dictionary <string, MetaDataScreenParam>();
            var           items        = screenDef.Children.Where(a => a.MemberType == EMemberType.ScreenParameters).ToList();
            StringBuilder screenParams = new StringBuilder();

            foreach (var item in items)
            {
                string parasStr = GetParameterContent(item);
                if (!string.IsNullOrEmpty(parasStr))
                {
                    parasStr = parasStr.Substring(0, parasStr.Length - 3);
                }
                screenParams.Append(parasStr);
            }
            var ScreenParamMember = new MetaDataScreenParam
            {
                Content = screenParams.ToString()
            };

            ScreenParamData.Add(doc.Name, ScreenParamMember);
            return(ScreenParamData);
        }
Пример #31
0
 private void ProjectOpened(object sender, ProjectOpenedEventArgs e)
 {
     _project = e.Project;
 }
Пример #32
0
        /// <summary>
        /// 生成方法
        /// </summary>
        public static Dictionary <string, MetaDataMethod> RegisterMethods(IonicCompile ionicCompile, ScreenDefinition screenDef, ProjectDocument doc)
        {
            Dictionary <string, MetaDataMethod> MethodData = new Dictionary <string, MetaDataMethod>();
            var items = screenDef.Children.Where(a => a.MemberType == EMemberType.Method).ToList();

            foreach (var item in items)
            {
                MetaDataMethod methodMember = GetMethodContent(item);
                MethodData.Add(item.Name, methodMember);
            }
            return(MethodData);
        }
Пример #33
0
 public void AddIntoProject(ProjectDocument document)
 {
     ActiveProject.Add(document);
     RefreshControls();
 }
Пример #34
0
        /// <summary>
        ///     Provide completions for the specified location.
        /// </summary>
        /// <param name="location">
        ///     The <see cref="XmlLocation"/> where completions are requested.
        /// </param>
        /// <param name="projectDocument">
        ///     The <see cref="ProjectDocument"/> that contains the <paramref name="location"/>.
        /// </param>
        /// <param name="triggerCharacters">
        ///     The character(s), if any, that triggered completion.
        /// </param>
        /// <param name="cancellationToken">
        ///     A <see cref="CancellationToken"/> that can be used to cancel the operation.
        /// </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> that resolves either a <see cref="CompletionList"/>s, or <c>null</c> if no completions are provided.
        /// </returns>
        public override async Task <CompletionList> ProvideCompletions(XmlLocation location, ProjectDocument projectDocument, string triggerCharacters, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            List <CompletionItem> completions = new List <CompletionItem>();

            Log.Verbose("Evaluate completions for {XmlLocation:l}", location);

            using (await projectDocument.Lock.ReaderLockAsync())
            {
                XSElement replaceElement;
                if (!location.CanCompleteElement(out replaceElement, parentPath: WellKnownElementPaths.PropertyGroup))
                {
                    Log.Verbose("Not offering any completions for {XmlLocation:l} (not a direct child of a 'PropertyGroup' element).", location);

                    return(null);
                }

                Range targetRange;

                if (replaceElement != null)
                {
                    targetRange = replaceElement.Range;

                    Log.Verbose("Offering completions to replace element {ElementName} @ {ReplaceRange:l}",
                                replaceElement.Name,
                                targetRange
                                );
                }
                else
                {
                    targetRange = location.Position.ToEmptyRange();

                    Log.Verbose("Offering completions to create element @ {ReplaceRange:l}",
                                targetRange
                                );
                }

                // Replace any characters that were typed to trigger the completion.
                HandleTriggerCharacters(triggerCharacters, projectDocument, ref targetRange);

                completions.AddRange(
                    GetCompletionItems(projectDocument, targetRange)
                    );
            }

            Log.Verbose("Offering {CompletionCount} completion(s) for {XmlLocation:l}", completions.Count, location);

            if (completions.Count == 0)
            {
                return(null);
            }

            return(new CompletionList(completions,
                                      isIncomplete: false // Consider this list to be exhaustive
                                      ));
        }
Пример #35
0
 public void RemoveFromProject(ProjectDocument document)
 {
     document.Project.Remove(document, false);
     RefreshControls();
 }
Пример #36
0
 public static Task <ProjectDocument> DeleteProjectAsync(this IDurableOrchestrationContext orchestrationContext, ProjectDocument project)
 => orchestrationContext.CallActivityWithRetryAsync <ProjectDocument>(nameof(ProjectDeleteActivity), project);
Пример #37
0
        public void CanSaveAndReloadProject()
        {
            doc.LoadXml(NUnitProjectXml.NormalProject);
            doc.Save(xmlfile);
            Assert.IsTrue(File.Exists(xmlfile));

            ProjectDocument doc2 = new ProjectDocument(xmlfile);
            doc2.Load();
            ProjectModel project2 = new ProjectModel(doc2);

            Assert.AreEqual(2, project2.Configs.Count);

            Assert.AreEqual(2, project2.Configs[0].Assemblies.Count);
            Assert.AreEqual("assembly1.dll", project2.Configs[0].Assemblies[0]);
            Assert.AreEqual("assembly2.dll", project2.Configs[0].Assemblies[1]);

            Assert.AreEqual(2, project2.Configs[1].Assemblies.Count);
            Assert.AreEqual("assembly1.dll", project2.Configs[1].Assemblies[0]);
            Assert.AreEqual("assembly2.dll", project2.Configs[1].Assemblies[1]);
        }
Пример #38
0
 public HyperlinkBuild(bool isPreview, ControlHost controlHost, ScreenDefinition screenDef, CompileBase compile, ProjectDocument doc, Dictionary <int, Tuple <int, string> > permissionData, HtmlTextWriter htmlWriter)
     : base(isPreview, controlHost, screenDef, compile, doc, permissionData, htmlWriter)
 {
 }
Пример #39
0
 public void LoadMakesProjectNotDirty()
 {
     project.AddConfig("Debug");
     doc.Save(xmlfile);
     ProjectDocument doc2 = new ProjectDocument(xmlfile);
     doc2.Load();
     Assert.IsFalse(doc2.HasUnsavedChanges);
 }
 public ProjectDocumentVM()
 {
     ProjectDocument = new ProjectDocument();
     ProjectDocumentTypeOpts = ListOpts.ProjectDocumentTypeOpts;
 }
Пример #41
0
    /**
     * Save file for project
     *
     * - For projects, no project needs to be created yet to upload a file, so a ProjectDocument is first created
     * without tagging to a project.
     *
     */
    public ProjectDocument saveProjectFile(Stream inputStream, string file_type, string file_name)
    {
        if (session == null || !session.IsOpen)
        {
            session = hibernate.getSession();
        }

        //validate file size
        if (inputStream.Length > MAX_FILE_SIZE)
            throw new SaveFileException("File size exceeds " + MAX_FILE_SIZE + " bytes.");

        //build save file path by userId
        string relativeFilePath = "Files" + "\\"
                                    + "Project" + "\\"
                                    + file_type + "\\";
        string saveFilePath = HttpRuntime.AppDomainAppPath + relativeFilePath;

        if (!Directory.Exists(saveFilePath))
            Directory.CreateDirectory(saveFilePath);

        saveFilePath += file_name;
        relativeFilePath += file_name;

        //create file stream
        var saveFileStream = File.Create(saveFilePath);
        inputStream.Seek(0, SeekOrigin.Begin);
        inputStream.CopyTo(saveFileStream);
        saveFileStream.Close();

        //create UploadedFile object
        ProjectDocument projectDocument = new ProjectDocument();
        projectDocument.PROJECTFILE_NAME = file_name;
        projectDocument.PROJECTFILE_PATH = relativeFilePath;
        projectDocument.PROJECTFILE_TYPE = file_type;

        session.BeginTransaction();
        session.Save(projectDocument);
        session.Transaction.Commit();

        return projectDocument;
    }
        /// <summary>
        ///     Provide completions for the specified location.
        /// </summary>
        /// <param name="location">
        ///     The <see cref="XmlLocation"/> where completions are requested.
        /// </param>
        /// <param name="projectDocument">
        ///     The <see cref="ProjectDocument"/> that contains the <paramref name="location"/>.
        /// </param>
        /// <param name="triggerCharacters">
        ///     The character(s), if any, that triggered completion.
        /// </param>
        /// <param name="cancellationToken">
        ///     A <see cref="CancellationToken"/> that can be used to cancel the operation.
        /// </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> that resolves either a <see cref="CompletionList"/>s, or <c>null</c> if no completions are provided.
        /// </returns>
        public override async Task <CompletionList> ProvideCompletions(XmlLocation location, ProjectDocument projectDocument, string triggerCharacters, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            if (!projectDocument.Workspace.Configuration.Language.CompletionsFromProject.Contains(CompletionSource.Task))
            {
                Log.Verbose("Not offering task attribute completions for {XmlLocation:l} (task completions not enabled in extension settings).", location);

                return(null);
            }

            if (!projectDocument.HasMSBuildProject)
            {
                Log.Verbose("Not offering task attribute completions for {XmlLocation:l} (underlying MSBuild project is not loaded).", location);

                return(null);
            }

            List <CompletionItem> completions = new List <CompletionItem>();

            Log.Verbose("Evaluate completions for {XmlLocation:l}", location);

            using (await projectDocument.Lock.ReaderLockAsync())
            {
                XSElement   taskElement;
                XSAttribute replaceAttribute;
                PaddingType needsPadding;
                if (!location.CanCompleteAttribute(out taskElement, out replaceAttribute, out needsPadding))
                {
                    Log.Verbose("Not offering any completions for {XmlLocation:l} (not a location an attribute can be created or replaced by completion).", location);

                    return(null);
                }

                if (taskElement.ParentElement?.Name != "Target")
                {
                    Log.Verbose("Not offering any completions for {XmlLocation:l} (attribute is not on an element that's a direct child of a 'Target' element).", location);

                    return(null);
                }

                Dictionary <string, MSBuildTaskMetadata> projectTasks = await GetProjectTasks(projectDocument);

                MSBuildTaskMetadata taskMetadata;
                if (!projectTasks.TryGetValue(taskElement.Name, out taskMetadata))
                {
                    Log.Verbose("Not offering any completions for {XmlLocation:l} (no metadata available for task {TaskName}).", location, taskElement.Name);

                    return(null);
                }

                Range replaceRange = replaceAttribute?.Range ?? location.Position.ToEmptyRange();
                if (replaceAttribute != null)
                {
                    Log.Verbose("Offering completions to replace attribute {AttributeName} @ {ReplaceRange:l}",
                                replaceAttribute.Name,
                                replaceRange
                                );
                }
                else
                {
                    Log.Verbose("Offering completions to create attribute @ {ReplaceRange:l}",
                                replaceRange
                                );
                }

                HashSet <string> existingAttributeNames = new HashSet <string>(
                    taskElement.AttributeNames
                    );
                if (replaceAttribute != null)
                {
                    existingAttributeNames.Remove(replaceAttribute.Name);
                }

                completions.AddRange(
                    GetCompletionItems(projectDocument, taskMetadata, existingAttributeNames, replaceRange, needsPadding)
                    );
            }

            Log.Verbose("Offering {CompletionCount} completion(s) for {XmlLocation:l}", completions.Count, location);

            if (completions.Count == 0)
            {
                return(null);
            }

            return(new CompletionList(completions,
                                      isIncomplete: false // Consider this list to be exhaustive
                                      ));
        }
Пример #43
0
 public void SetProject(ProjectDocument projectDocument)
 {
     _project = projectDocument;
 }
Пример #44
0
        private void LoadIncludes(ProjectDocument projectDocument, Project project)
        {

        }
        /// <summary>
        ///     Provide completions for the specified location.
        /// </summary>
        /// <param name="location">
        ///     The <see cref="XmlLocation"/> where completions are requested.
        /// </param>
        /// <param name="projectDocument">
        ///     The <see cref="ProjectDocument"/> that contains the <paramref name="location"/>.
        /// </param>
        /// <param name="triggerCharacters">
        ///     The character(s), if any, that triggered completion.
        /// </param>
        /// <param name="cancellationToken">
        ///     A <see cref="CancellationToken"/> that can be used to cancel the operation.
        /// </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> that resolves either a <see cref="CompletionList"/>s, or <c>null</c> if no completions are provided.
        /// </returns>
        public override async Task <CompletionList> ProvideCompletions(XmlLocation location, ProjectDocument projectDocument, string triggerCharacters, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            List <CompletionItem> completions = new List <CompletionItem>();

            Log.Verbose("Evaluate completions for {XmlLocation:l}", location);

            using (await projectDocument.Lock.ReaderLockAsync())
            {
                if (!projectDocument.EnableExpressions)
                {
                    return(null);
                }

                ExpressionNode expression;
                Range          expressionRange;
                if (!location.IsExpression(out expression, out expressionRange))
                {
                    Log.Verbose("Not offering any completions for {XmlLocation:l} (not on an expression or a location where an expression can be added).", location);

                    return(null);
                }

                if (expression.Kind != ExpressionKind.ItemGroup)
                {
                    Log.Verbose("Not offering any completions for {XmlLocation:l} (this provider only supports MSBuild ItemGroup expressions or ItemGroupMetadata expressions without metadata names, not {ExpressionKind} expressions).", location, expression.Kind);

                    return(null);
                }

                Log.Verbose("Offering completions to replace ItemGroup expression @ {ReplaceRange:l}",
                            expressionRange
                            );

                completions.AddRange(
                    GetCompletionItems(projectDocument, expressionRange)
                    );
            }

            Log.Verbose("Offering {CompletionCount} completion(s) for {XmlLocation:l}", completions.Count, location);

            if (completions.Count == 0)
            {
                return(null);
            }

            return(new CompletionList(completions,
                                      isIncomplete: false // Consider this list to be exhaustive
                                      ));
        }
        /// <summary>
        ///     Provide completions for the specified location.
        /// </summary>
        /// <param name="location">
        ///     The <see cref="SourceLocation"/> where completions are requested.
        /// </param>
        /// <param name="projectDocument">
        ///     The <see cref="ProjectDocument"/> that contains the <paramref name="location"/>.
        /// </param>
        /// <param name="cancellationToken">
        ///     A <see cref="CancellationToken"/> that can be used to cancel the operation.
        /// </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> that resolves either a <see cref="CompletionList"/>s, or <c>null</c> if no completions are provided.
        /// </returns>
        public override async Task <CompletionList> ProvideCompletions(SourceLocation location, ProjectDocument projectDocument, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            List <CompletionItem> completions = new List <CompletionItem>();

            Log.Verbose("Evaluate completions for {XmlLocation:l}", location);

            using (await projectDocument.Lock.ReaderLockAsync())
            {
                SourceNode replaceElement = null;
                // TODO
                if (replaceElement != null)
                {
                    Log.Verbose("Offering completions to replace element {ElementName} @ {ReplaceRange:l}",
                                replaceElement.Name,
                                replaceElement.Range
                                );

                    completions.AddRange(
                        GetCompletionItems(replaceElement.Range)
                        );
                }
                else
                {
                    Log.Verbose("Offering completions to insert element @ {InsertPosition:l}",
                                location.Position
                                );

                    completions.AddRange(
                        GetCompletionItems(
                            replaceRange: location.Position.ToEmptyRange()
                            )
                        );
                }
            }

            Log.Verbose("Offering {CompletionCount} completion(s) for {XmlLocation:l}", completions.Count, location);

            if (completions.Count == 0)
            {
                return(null);
            }

            return(new CompletionList(completions,
                                      isIncomplete: false // Consider this list to be exhaustive
                                      ));
        }
Пример #47
0
        internal static async Task <IDictionary <string, TCommandResult> > SendProviderCommandAsync <TCommand, TCommandResult>(this IDurableOrchestrationContext functionContext, TCommand command, ProjectDocument project, bool failFast = false)
            where TCommand : IProviderCommand
            where TCommandResult : ICommandResult
        {
            if (command is null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            if (project is null && command is IProviderCommand <Model.Data.Project> )
            {
                throw new InvalidOperationException("Must pass original ProjectDocument (internal) for ProviderCommands with a payload of type Project (external).");
            }

            if (project is null && !string.IsNullOrEmpty(command.ProjectId))
            {
                project = await functionContext
                          .GetProjectAsync(command.ProjectId, allowUnsafe : true)
                          .ConfigureAwait(true);
            }

            var providerBatches = await functionContext
                                  .CallActivityWithRetryAsync <IEnumerable <IEnumerable <ProviderDocument> > >(nameof(CommandProviderActivity), project)
                                  .ConfigureAwait(true);

            var commandResults = Enumerable.Empty <KeyValuePair <string, TCommandResult> >();

            foreach (var providerBatch in providerBatches)
            {
                foreach (var commandResult in commandResults.Where(cr => cr.Value is ICommandResult <ProviderOutput>))
                {
                    var commandResultOutput = commandResult.Value as ICommandResult <ProviderOutput>;

                    command.Results.TryAdd(commandResult.Key, commandResultOutput?.Result?.Properties ?? new Dictionary <string, string>());
                }

                var providerTasks = providerBatch.Select(async provider =>
                {
                    var providerResult = await functionContext
                                         .SendProviderCommandAsync <TCommand, TCommandResult>(command, provider)
                                         .ConfigureAwait(true);

                    return(new KeyValuePair <string, TCommandResult>(provider.Id, providerResult));
                });

                commandResults = commandResults.Concat(await Task
                                                       .WhenAll(providerTasks)
                                                       .ConfigureAwait(true));

                if (failFast && commandResults.Any(cr => cr.Value.Errors.Any()))
                {
                    break;
                }
            }

            return(new Dictionary <string, TCommandResult>(commandResults));
        }
Пример #48
0
 public void NameIsUnique()
 {
     ProjectDocument anotherProject = new ProjectDocument(xmlfile);
     Assert.AreNotEqual(doc.Name, anotherProject.Name);
 }
        /// <summary>
        ///     Provide completions for the specified location.
        /// </summary>
        /// <param name="location">
        ///     The <see cref="XmlLocation"/> where completions are requested.
        /// </param>
        /// <param name="projectDocument">
        ///     The <see cref="ProjectDocument"/> that contains the <paramref name="location"/>.
        /// </param>
        /// <param name="triggerCharacters">
        ///     The character(s), if any, that triggered completion.
        /// </param>
        /// <param name="cancellationToken">
        ///     A <see cref="CancellationToken"/> that can be used to cancel the operation.
        /// </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> that resolves either a <see cref="CompletionList"/>s, or <c>null</c> if no completions are provided.
        /// </returns>
        public override async Task <CompletionList> ProvideCompletions(XmlLocation location, ProjectDocument projectDocument, string triggerCharacters, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            bool isIncomplete = false;
            List <CompletionItem> completions = new List <CompletionItem>();

            Log.Verbose("Evaluate completions for {XmlLocation:l}", location);

            using (await projectDocument.Lock.ReaderLockAsync())
            {
                if (location.CanCompleteAttributeValue(out XSAttribute attribute, WellKnownElementPaths.Item, "Include", "Version") && SupportedElementNames.Contains(attribute.Element.Name))
                {
                    Log.Verbose("Offering completions for value of attribute {AttributeName} of {ElementName} element @ {Position:l}",
                                attribute.Name,
                                attribute.Element.Name,
                                location.Position
                                );

                    List <CompletionItem> packageCompletions = await HandlePackageReferenceAttributeCompletion(projectDocument, attribute, cancellationToken);

                    if (packageCompletions != null)
                    {
                        isIncomplete |= packageCompletions.Count > 10; // Default page size.
                        completions.AddRange(packageCompletions);
                    }
                }