public static void Main( ) { // <Snippet1> ServiceDescription myServiceDescription = new ServiceDescription(); myServiceDescription = ServiceDescription.Read("ServiceDescription_Imports_Input_CS.wsdl"); ImportCollection myImportCollection = myServiceDescription.Imports; // Create an Import. Import myImport = new Import(); myImport.Namespace = myServiceDescription.TargetNamespace; // Set the location for the Import. myImport.Location = "http://www.contoso.com/"; myImportCollection.Add(myImport); myServiceDescription.Write("ServiceDescription_Imports_Output_CS.wsdl"); myImportCollection.Clear(); myServiceDescription = ServiceDescription.Read("ServiceDescription_Imports_Output_CS.wsdl"); myImportCollection = myServiceDescription.Imports; Console.WriteLine( "The Import elements added to the ImportCollection are: "); for (int i = 0; i < myImportCollection.Count; i++) { Console.WriteLine((i + 1) + ". " + myImportCollection[i].Location); } // </Snippet1> }
public void TestICollectionMethods() { ObjectModelHelpers.DeleteTempProjectDirectory(); ObjectModelHelpers.CreateFileInTempProjectDirectory("import1.proj", @" <Project xmlns=`msbuildnamespace`> </Project> "); ObjectModelHelpers.CreateFileInTempProjectDirectory("import2.proj", @" <Project xmlns=`msbuildnamespace`> </Project> "); ObjectModelHelpers.CreateFileInTempProjectDirectory("main.proj", @" <Project xmlns=`msbuildnamespace`> <Import Project=`import1.proj` /> <Import Project=`import2.proj` /> <Target Name=`Build`> <WashCar/> </Target> </Project> "); Project project = ObjectModelHelpers.LoadProjectFileInTempProjectDirectory("main.proj", null); string import1Path = Path.Combine(ObjectModelHelpers.TempProjectDir, "import1.proj"); string import2Path = Path.Combine(ObjectModelHelpers.TempProjectDir, "import2.proj"); ImportCollection imports = project.Imports; Assertion.AssertEquals(2, imports.Count); Import[] array = new Import[2]; imports.CopyTo(array, 0); Dictionary <string, Import> hash = new Dictionary <string, Import>(StringComparer.OrdinalIgnoreCase); hash[array[0].EvaluatedProjectPath] = array[0]; hash[array[1].EvaluatedProjectPath] = array[1]; Assertion.AssertEquals(imports[import1Path], hash[import1Path]); Assertion.AssertEquals(imports[import2Path], hash[import2Path]); object[] arrayObjects = new object[2]; imports.CopyTo(arrayObjects, 0); hash.Clear(); hash[((Import)arrayObjects[0]).EvaluatedProjectPath] = ((Import)arrayObjects[0]); hash[((Import)arrayObjects[1]).EvaluatedProjectPath] = ((Import)arrayObjects[1]); Assertion.AssertEquals(imports[import1Path], hash[import1Path]); Assertion.AssertEquals(imports[import2Path], hash[import2Path]); Assertion.AssertEquals("import1.proj", imports[import1Path].ProjectPath); Assertion.AssertEquals("import2.proj", imports[import2Path].ProjectPath); }
void ResolveImportAssemblyReferences() { foreach (Boo.Lang.Compiler.Ast.Module module in CompileUnit.Modules) { ImportCollection imports = module.Imports; Import[] importArray = imports.ToArray(); for (int i = 0; i < importArray.Length; ++i) { Import u = importArray[i]; ReferenceExpression reference = u.AssemblyReference; if (null != reference) { try { Assembly asm = Parameters.FindAssembly(reference.Name); if (null == asm) { asm = Parameters.LoadAssembly(reference.Name); if (null != asm) { Parameters.AddAssembly(asm); } } reference.Entity = new TypeSystem.AssemblyReference(asm); } catch (Exception x) { Errors.Add(CompilerErrorFactory.UnableToLoadAssembly(reference, reference.Name, x)); imports.RemoveAt(i); } } } } }
void ResolveImportAssemblyReferences() { foreach (Module module in CompileUnit.Modules) { ImportCollection imports = module.Imports; ResolveAssemblyReferences(imports); } }
public static void Main() { ServiceDescription myServiceDescription = ServiceDescription.Read("StockQuoteService_cs.wsdl"); Console.WriteLine(" ImportCollection Sample "); // <Snippet2> // Get Import Collection. ImportCollection myImportCollection = myServiceDescription.Imports; Console.WriteLine("Total Imports in the document = " + myServiceDescription.Imports.Count); // Print 'Import' properties to console. for (int i = 0; i < myImportCollection.Count; ++i) { Console.WriteLine("\tImport Namespace :{0} Import Location :{1} " , myImportCollection[i].Namespace , myImportCollection[i].Location); } // </Snippet2> // <Snippet3> Import[] myImports = new Import[myServiceDescription.Imports.Count]; // Copy 'ImportCollection' to an array. myServiceDescription.Imports.CopyTo(myImports, 0); Console.WriteLine("Imports that are copied to Importarray ..."); for (int i = 0; i < myImports.Length; ++i) { Console.WriteLine("\tImport Namespace :{0} Import Location :{1} " , myImports[i].Namespace , myImports[i].Location); } // </Snippet3> // <Snippet4> // <Snippet5> // <Snippet6> // Get Import by Index. Import myImport = myServiceDescription.Imports[myServiceDescription.Imports.Count - 1]; Console.WriteLine("Import by Index..."); if (myImportCollection.Contains(myImport)) { Console.WriteLine("Import Namespace '" + myImport.Namespace + "' is found in 'ImportCollection'."); Console.WriteLine("Index of '" + myImport.Namespace + "' in 'ImportCollection' = " + myImportCollection.IndexOf(myImport)); Console.WriteLine("Deleting Import from 'ImportCollection'..."); myImportCollection.Remove(myImport); if (myImportCollection.IndexOf(myImport) == -1) { Console.WriteLine("Import is successfully removed from Import Collection."); } } // </Snippet6> // </Snippet5> // </Snippet4> }
/// <summary> /// Constructs a parse tree for an Imports declaration. /// </summary> /// <param name="importMembers">The members imported.</param> /// <param name="span">The location of the parse tree.</param> /// <param name="comments">The comments for the parse tree.</param> public ImportsDeclaration(ImportCollection importMembers, Span span, IList <Comment> comments) : base(TreeType.ImportsDeclaration, span, comments) { if (importMembers == null) { throw new ArgumentNullException("importMembers"); } SetParent(importMembers); _ImportMembers = importMembers; }
public void RemoveExistingImport() { ObjectModelHelpers.DeleteTempProjectDirectory(); ObjectModelHelpers.CreateFileInTempProjectDirectory("import1.proj", @" <Project xmlns=`msbuildnamespace`> </Project> "); ObjectModelHelpers.CreateFileInTempProjectDirectory("import2.proj", @" <Project xmlns=`msbuildnamespace`> </Project> "); ObjectModelHelpers.CreateFileInTempProjectDirectory("main.proj", @" <Project xmlns=`msbuildnamespace`> <Import Project=`import1.proj` /> <Import Project=`import2.proj` /> <Target Name=`Build`> <WashCar/> </Target> </Project> "); Project project = ObjectModelHelpers.LoadProjectFileInTempProjectDirectory("main.proj", null); ImportCollection imports = project.Imports; Assertion.AssertEquals(2, imports.Count); imports.RemoveImport(imports[Path.Combine(ObjectModelHelpers.TempProjectDir, "import1.proj")]); // First validate that the ImportCollection only contains a single Import Assertion.AssertEquals(1, imports.Count); // Now validate that the ImportCollection properly updated its parent Project (by inspecting the // project's in-memory Xml) int importCount = 0; foreach (XmlNode childNode in project.ProjectElement) { if (childNode.Name == XMakeElements.import) { importCount++; } } Assertion.AssertEquals(1, importCount); }
private void ExpandImport(Import import) { ImportCollection imports = _node.GetAncestor <Module>().Imports; if (imports.Contains(import.Matches)) { return; } imports.Add(import); BindImport(import); }
/// <summary> /// Iterate over a collection to find an import object matching on path /// </summary> internal static Import FindFirstMatchingImportByEvaludatedPath(ImportCollection importCollection, string evaluatedPathToMatch) { foreach (Import import in importCollection) { if (import.EvaluatedProjectPath.Equals(evaluatedPathToMatch, StringComparison.OrdinalIgnoreCase)) { return(import); } } return(null); }
/// <summary> /// Search import collection and return the matched Import object /// </summary> internal static Import GetImportByProjectPath(ImportCollection imports, string projPath) { foreach (Import import in imports) { if (import.ProjectPath == projPath) { return(import); } } return(null); }
public static void DisplayWorkspaceContents() { string jsonWorkspaces = ExecuteGetRequest(ProgramConstants.restUrlWorkspaces); WorkspaceCollection workspaces = JsonConvert.DeserializeObject <WorkspaceCollection>(jsonWorkspaces); Console.WriteLine("Group Workspaces:"); Console.WriteLine("-----------------"); foreach (Workspace workspace in workspaces.value) { Console.WriteLine(" - " + workspace.name + "(" + workspace.id + ")"); } Console.WriteLine(); Console.WriteLine("Now examining content in your personal workspace..."); Console.WriteLine(); string jsonDatasets = ExecuteGetRequest(ProgramConstants.restUrlDatasets); DatasetCollection datasets = JsonConvert.DeserializeObject <DatasetCollection>(jsonDatasets); Console.WriteLine("Datasets:"); Console.WriteLine("---------"); foreach (var ds in datasets.value) { Console.WriteLine(" - " + ds.name + "(" + ds.id + ")"); } Console.WriteLine(); string jsonReports = ExecuteGetRequest(ProgramConstants.restUrlReports); ReportCollection reports = JsonConvert.DeserializeObject <ReportCollection>(jsonReports); Console.WriteLine("Reports:"); Console.WriteLine("---------"); foreach (var report in reports.value) { Console.WriteLine(" - " + report.name + ": " + report.embedUrl); } Console.WriteLine(); string jsonImports = ExecuteGetRequest(ProgramConstants.restUrlImports); ImportCollection imports = JsonConvert.DeserializeObject <ImportCollection>(jsonImports); Console.WriteLine("Imports:"); Console.WriteLine("---------"); foreach (var import in imports.value) { Console.WriteLine(" - " + import.name + ": " + import.source); } Console.WriteLine(); }
public ImportViewModel(IVisualStateManager visualStateManager, IContainerStatus containerStatus, IMediator mediator) { _visualStateManager = visualStateManager; _mediator = mediator; Videos = new ImportCollection(); NextCommand = new DelegateCommand(ExecuteNextCommand); TargetCommand = new DelegateCommand(ExecuteTargetCommand); AddCommand = new DelegateCommand(ExecuteAddCommand); SelectedQuality = QualityList[0]; FileImport = true; containerStatus.ContainerUnloaded += ContainerClosed; }
public void AttemptToRemoveImportFromAnotherProjectShouldThrowException() { ObjectModelHelpers.DeleteTempProjectDirectory(); ObjectModelHelpers.CreateFileInTempProjectDirectory("import1.proj", @" <Project xmlns=`msbuildnamespace`> </Project> "); ObjectModelHelpers.CreateFileInTempProjectDirectory("main1.proj", @" <Project xmlns=`msbuildnamespace`> <Import Project=`import1.proj` /> <Target Name=`Build`> <WashCar/> </Target> </Project> "); ObjectModelHelpers.CreateFileInTempProjectDirectory("main2.proj", @" <Project xmlns=`msbuildnamespace`> <Import Project=`import1.proj` /> <Target Name=`Build`> <WashCar/> </Target> </Project> "); Project project1 = ObjectModelHelpers.LoadProjectFileInTempProjectDirectory("main1.proj", null); Project project2 = ObjectModelHelpers.LoadProjectFileInTempProjectDirectory("main2.proj", null); ImportCollection imports1 = project1.Imports; ImportCollection imports2 = project2.Imports; // Should throw an InvalidOperationException imports1.RemoveImport(imports2[Path.Combine(ObjectModelHelpers.TempProjectDir, "import1.proj")]); }
private ImportCollection LoadImports(XmlNode node) { ImportCollection imports = new ImportCollection(); foreach (XmlNode xn in node.ChildNodes) { if ("#comment" == xn.Name) { continue; } Import import = LoadImport(xn); imports.Add(import.Id, import); } return(imports); }
/// <summary> /// Resolve the type we are casting to /// </summary> /// <param name="destTypeParts"></param> /// <param name="context"></param> /// <returns></returns> private static Type?GetDestType(string[] destTypeParts, ExpressionContext context) { Type?type = null; // Try to find a builtin type with the name if (destTypeParts.Length == 1) { type = ImportCollection.GetBuiltinType(destTypeParts[0]); } if (type != null) { return(type); } // Try to find the type in an import return(context.Imports.FindType(destTypeParts)); }
// </Snippet5> // </Snippet4> // </Snippet3> // <Snippet6> public static void PrintImportCollection(string fileName_wsdl) { // Read import collection properties from generated WSDL file. ServiceDescription myServiceDescription1 = ServiceDescription.Read(fileName_wsdl); ImportCollection myImportCollection = myServiceDescription1.Imports; Console.WriteLine("Enumerating Import Collection for file '" + fileName_wsdl + "'..."); // Print Import properties to console. for (int i = 0; i < myImportCollection.Count; ++i) { Console.WriteLine("Namespace : " + myImportCollection[i].Namespace); Console.WriteLine("Location : " + myImportCollection[i].Location); Console.WriteLine("ServiceDescription : " + myImportCollection[i].ServiceDescription.Name); } }
private void ResolveAssemblyReferences(ImportCollection imports) { Import[] importArray = imports.ToArray(); for (int i = 0; i < importArray.Length; ++i) { Import current = importArray[i]; ReferenceExpression reference = current.AssemblyReference; if (null == reference) { continue; } try { reference.Entity = ResolveAssemblyReference(reference); } catch (Exception x) { Errors.Add(CompilerErrorFactory.UnableToLoadAssembly(reference, reference.Name, x)); imports.RemoveAt(i); } } }
public ExpressionBuilder(ExpressionBuilderOptions builderOptions) { Options = builderOptions; Imports = new ImportCollection(Options); CreateParser(); }