Пример #1
0
        protected static Microsoft.SharePoint.Client.ListItemCollection GetListItems(ClientContext context, Microsoft.SharePoint.Client.List list, CamlQuery query)
        {
            Microsoft.SharePoint.Client.ListItemCollection coll = null;

            coll = list.GetItems(query);

            context.Load(coll);
            context.ExecuteQuery();

            return coll;
        }
        private static bool UpgradeCSharpConfiguration(EnvDTE.Project dteProject,
            Microsoft.Build.Evaluation.Project project, OldConfiguration cfg)
        {
            ProjectPropertyGroupElement propertyGroup = project.Xml.PropertyGroups.FirstOrDefault(g => g.Label.Equals("IceBuilder"));
            if (propertyGroup == null)
            {
                propertyGroup = project.Xml.AddPropertyGroup();
                propertyGroup.Label = "IceBuilder";
            }

            if (!String.IsNullOrEmpty(cfg.OutputDir))
            {
                propertyGroup.AddProperty(PropertyNames.OutputDir, cfg.OutputDir);
            }

            if (!String.IsNullOrEmpty(cfg.AdditionalOptions))
            {
                propertyGroup.AddProperty(PropertyNames.AdditionalOptions, cfg.AdditionalOptions);
            }

            if (!String.IsNullOrEmpty(cfg.IncludeDirectories))
            {
                propertyGroup.AddProperty(PropertyNames.IncludeDirectories,
                    String.Format(@"{0};$(IceHome)\slice", cfg.IncludeDirectories));
            }
            else
            {
                propertyGroup.AddProperty(PropertyNames.IncludeDirectories, @"$(IceHome)\slice");
            }

            if (cfg.Stream)
            {
                propertyGroup.AddProperty(PropertyNames.Stream, "True");
            }

            if (cfg.Checksum)
            {
                propertyGroup.AddProperty(PropertyNames.Checksum, "True");
            }

            if (cfg.Ice)
            {
                propertyGroup.AddProperty(PropertyNames.AllowIcePrefix, "True");
            }

            if (cfg.Tie)
            {
                propertyGroup.AddProperty(PropertyNames.Tie, "True");
            }

            foreach (String assembly in AssemblyNames)
            {
                VSLangProj80.Reference3 reference = ProjectUtil.FindAssemblyReference(dteProject, assembly) as VSLangProj80.Reference3;
                if(reference != null)
                {
                    reference.SpecificVersion = false;
                }
            }

            List<ProjectItem> sliceItems =
                project.GetItems("None").Where(item => Path.GetExtension(item.UnevaluatedInclude).Equals(".ice")).ToList();

            //
            // Default output directory has changed
            //
            if (String.IsNullOrEmpty(cfg.OutputDir))
            {
                project.GetItems("Compile").Where(
                    item =>
                    {
                        return sliceItems.FirstOrDefault(
                            slice =>
                            {
                                return slice.UnevaluatedInclude.Equals(Path.ChangeExtension(item.UnevaluatedInclude, ".ice"));
                            }) != null;
                    })
                .ToList()
                .ForEach(item => project.RemoveItem(item));
            }

            return true;
        }
        private static bool UpgadeCppConfiguration(Microsoft.Build.Evaluation.Project project, OldConfiguration cfg)
        {
            ProjectPropertyGroupElement propertyGroup = project.Xml.PropertyGroups.FirstOrDefault(g => g.Label.Equals("IceBuilder"));
            if (propertyGroup == null)
            {
                propertyGroup = project.Xml.AddPropertyGroup();
                propertyGroup.Label = "IceBuilder";
            }

            if (!String.IsNullOrEmpty(cfg.OutputDir))
            {
                propertyGroup.AddProperty(PropertyNames.OutputDir, cfg.OutputDir);
            }

            if (!String.IsNullOrEmpty(cfg.HeaderExt))
            {
                propertyGroup.AddProperty(PropertyNames.HeaderExt, cfg.HeaderExt);
            }

            if (!String.IsNullOrEmpty(cfg.SourceExt))
            {
                propertyGroup.AddProperty(PropertyNames.SourceExt, cfg.SourceExt);
            }

            if (!String.IsNullOrEmpty(cfg.AdditionalOptions))
            {
                propertyGroup.AddProperty(PropertyNames.AdditionalOptions, cfg.AdditionalOptions);
            }

            if (!String.IsNullOrEmpty(cfg.IncludeDirectories))
            {
                propertyGroup.AddProperty(PropertyNames.IncludeDirectories,
                    String.Format("{0};$({1})", cfg.IncludeDirectories, PropertyNames.IncludeDirectories));
            }

            if (cfg.Stream)
            {
                propertyGroup.AddProperty(PropertyNames.Stream, "True");
            }

            if (cfg.Checksum)
            {
                propertyGroup.AddProperty(PropertyNames.Checksum, "True");
            }

            if (cfg.Ice)
            {
                propertyGroup.AddProperty(PropertyNames.AllowIcePrefix, "True");
            }

            if (!String.IsNullOrEmpty(cfg.DLLExport))
            {
                propertyGroup.AddProperty(PropertyNames.DLLExport, cfg.DLLExport);
            }

            foreach (ProjectItemDefinitionGroupElement group in project.Xml.ItemDefinitionGroups)
            {
                //
                // Remove old property sheet from all configurations
                //
                IEnumerable<ProjectImportElement> imports = project.Xml.Imports.Where(
                    p => p.Project.Equals("$(ALLUSERSPROFILE)\\ZeroC\\Ice.props"));
                if(imports != null)
                {
                    foreach (ProjectImportElement import in imports)
                    {
                        import.Parent.RemoveChild(import);
                    }
                }
                //
                // WinRT SDK old property sheet
                //
                imports = project.Xml.Imports.Where(
                    p => p.Project.IndexOf("CommonConfiguration\\Neutral\\Ice.props") != -1);
                if(imports != null)
                {
                    foreach (ProjectImportElement import in imports)
                    {
                        import.Parent.RemoveChild(import);
                    }
                }

                foreach (ProjectItemDefinitionElement i in group.ItemDefinitions)
                {
                    if (i.ItemType.Equals("ClCompile"))
                    {
                        if (!String.IsNullOrEmpty(cfg.OutputDir))
                        {
                            ProjectMetadataElement metaData = i.Metadata.FirstOrDefault(
                                e => e.Name.Equals("AdditionalIncludeDirectories"));

                            if (metaData != null)
                            {
                                List<String> values = new List<String>(metaData.Value.Split(new char[] { ';' }));
                                values.Remove(cfg.OutputDir);
                                metaData.Value = String.Join(";", values);

                                if (values.Count == 0 ||
                                    (values.Count == 1 && values[0].Equals("%(AdditionalIncludeDirectories)")))
                                {
                                    i.RemoveChild(metaData);
                                }
                                else
                                {
                                    if (!values.Contains("%(AdditionalIncludeDirectories)"))
                                    {
                                        values.Add("%(AdditionalIncludeDirectories)");
                                    }
                                    metaData.Value = String.Join(";", values);
                                }
                            }
                        }
                    }
                    else if (i.ItemType.Equals("Link"))
                    {
                        ProjectMetadataElement metaData = i.Metadata.FirstOrDefault(
                                e => e.Name.Equals("AdditionalDependencies"));

                        if (metaData != null)
                        {
                            List<String> values = new List<String>(metaData.Value.Split(new char[] { ';' }));
                            foreach (String name in CppLibNames)
                            {
                                values.Remove(String.Format("{0}.lib", name));
                                values.Remove(String.Format("{0}d.lib", name));
                            }

                            if (values.Count == 0 || (values.Count == 1 && values[0].Equals("%(AdditionalDependencies)")))
                            {
                                i.RemoveChild(metaData);
                            }
                            else
                            {
                                metaData.Value = String.Join(";", values);
                            }
                        }

                        metaData = i.Metadata.FirstOrDefault(e => e.Name.Equals("AdditionalLibraryDirectories"));
                        if (metaData != null)
                        {
                            if (metaData.Value.Equals("%(AdditionalLibraryDirectories)"))
                            {
                                i.RemoveChild(metaData);
                            }
                        }
                    }
                }
            }

            List<ProjectItem> sliceItems =
                project.GetItems("None").Where(item => Path.GetExtension(item.UnevaluatedInclude).Equals(".ice")).ToList();

            //
            // Default output directory has changed
            //
            if(String.IsNullOrEmpty(cfg.OutputDir))
            {
                foreach (String itemType in new String[] { "ClInclude", "ClCompile" })
                {
                    project.GetItems(itemType).Where(
                        item =>
                        {
                            return sliceItems.FirstOrDefault(
                                slice =>
                                {
                                    return slice.UnevaluatedInclude.Equals(Path.ChangeExtension(item.UnevaluatedInclude, ".ice"));
                                }) != null;
                        })
                    .ToList()
                    .ForEach(item => project.RemoveItem(item));
                }
            }

            sliceItems.ForEach(item =>
                {
                    project.RemoveItem(item);
                    project.AddItem("IceBuilder", item.UnevaluatedInclude);
                });
            return true;
        }
Пример #4
0
 void AddProjectReferences(Microsoft.Build.Evaluation.Project p)
 {
     foreach (Microsoft.Build.Evaluation.ProjectItem item in p.GetItems("ProjectReference"))
     {
         var projectName = item.GetMetadataValue("Name");
         var referenceGuid = Guid.Parse(item.GetMetadataValue("Project"));
         _logger.Debug("Adding project reference {0}, {1}", projectName, referenceGuid);
         AddReference(new ProjectReference(_solution, projectName, referenceGuid));
     }
 }
Пример #5
0
        void AddCSharpFiles(Microsoft.Build.Evaluation.Project p)
        {
            foreach (var item in p.GetItems("Compile"))
            {
                try
                {
                    string path = _fileSystem.Path.Combine(p.DirectoryPath, item.EvaluatedInclude).ForceNativePathSeparator();

                    if (_fileSystem.File.Exists(path))
                    {
                        string file = _fileSystem.FileInfo.FromFileName(path).FullName;
                        _logger.Debug("Loading " + file);
                        Files.Add(new CSharpFile(this, file));
                    }
                    else
                    {
                        _logger.Error("File does not exist - " + path);
                    }
                }
                catch (NullReferenceException e)
                {
                    _logger.Error(e);
                }
            }
        }
Пример #6
0
        void AddProjectReferences(Microsoft.Build.Evaluation.Project p)
        {
            foreach (Microsoft.Build.Evaluation.ProjectItem item in p.GetItems("ProjectReference"))
            {
                var projectName = item.HasMetadata("Name")
                    ? item.GetMetadataValue("Name")
                    : Path.GetFileNameWithoutExtension(item.EvaluatedInclude);

                var referenceGuid = Guid.Parse(item.GetMetadataValue("Project"));
                _logger.Debug("Adding project reference {0}, {1}", projectName, referenceGuid);
                AddReference(new ProjectReference(_solution, projectName, referenceGuid));
            }
        }
        private void ReadPageContent(ClientContext context, Microsoft.SharePoint.Client.List targetList)
        {
            ListItemCollection listItems = targetList.GetItems(CamlQuery.CreateAllItemsQuery());
            context.Load<ListItemCollection>(listItems, items => items.Include(itemFile => itemFile.File).Where(itemFile => itemFile.File != null)); //
            context.ExecuteQuery();

            context.Load(context.Site);
            context.ExecuteQuery();
            string siteUrl = context.Site.Url;

            foreach (var listItem in listItems)
            {
                var item = listItem;
                context.Load<ListItem>(item);
                context.ExecuteQuery();

                if (!menuPages.ContainsKey(item.File.Name) && item["WikiField"] != null)
                {
                    menuPages.Add(item.File.Name, new string[] { siteUrl + item["FileRef"], "-1", "0", System.Web.HttpUtility.HtmlDecode(item["WikiField"].ToString()) });
                }
            }

            int position = 1;
            int level = 0;

            if (menuPages.ContainsKey(Request.QueryString["DefaultPage"]))
                menuPages[Request.QueryString["DefaultPage"]][1] = "0";
            orderPages(Request.QueryString["DefaultPage"], level, ref position);

            foreach (var menuPage in menuPages)
            {
                if (menuPage.Value[1] == "-1" && Request.QueryString["DefaultPage"] != menuPage.Key && Convert.ToInt32(Request.QueryString["PageLimit"]) > position)
                {
                    menuPage.Value[1] = (position++).ToString();
                }
            }
        }
Пример #8
0
        public static void GetProjectDependencies(int iTabLevel, Microsoft.Build.Evaluation.Project prj)
        {
            string stab = Spaces(iTabLevel);
            int iIndex = proj_ref_list.Find(prj);
            if (iIndex >= 0)
            {
                return;
            }
            else
            {
                proj_ref_list.Add(prj);
            }

            var ProjectReference_Items = prj.GetItems("ProjectReference");

            foreach (Microsoft.Build.Evaluation.ProjectItem pitm in ProjectReference_Items)
            {
                Microsoft.Build.Evaluation.Project pr = pitm.Project;
                string EvaluatedInclude = pitm.EvaluatedInclude;
                string ReferenceProjectCombined = System.IO.Path.Combine(pr.DirectoryPath, EvaluatedInclude);
                string refprojfullpath = Path.GetFullPath(ReferenceProjectCombined);
                Microsoft.Build.Evaluation.Project ref_pr = Parser.FindProjectInCollection(refprojfullpath);

                if (ref_pr != null)
                {
                    GetProjectDependencies( iTabLevel + 1, ref_pr);
                }
                else
                {
                    MessageBox.Show("Project " + refprojfullpath + " not found in Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.LoadedProjects!");
                }
            }
        }