internal protected override void Read (NodeElement elem) { base.Read (elem); typeName = elem.GetAttribute ("type"); if (typeName.Length == 0) typeName = elem.GetAttribute ("class"); if (typeName.Length == 0) typeName = elem.GetAttribute ("id"); }
protected override void Read (NodeElement elem) { base.Read (elem); actions = (SchemaActions)Enum.Parse (typeof (SchemaActions), action); parsedFlags = CapabilitiesUtility.Parse (category, flags); }
public override bool Evaluate(NodeElement conditionNode) { // don't allow recursion, getting the extension node can evaluate this condition again if (isEvaluating > 0) return false; isEvaluating++; try { var path = conditionNode.GetAttribute("path"); var invertString = conditionNode.GetAttribute("invert"); bool invert = string.Equals(invertString, "true", StringComparison.OrdinalIgnoreCase); // check if extension node is defined var extensionNode = AddinManager.GetExtensionNode(path); #if DEBUG Console.WriteLine("Extension '{0}' {1}", path, extensionNode != null ? "Exists" : "Does Not Exist"); #endif return invert ? extensionNode == null : extensionNode != null; } finally { isEvaluating--; } }
public override bool Evaluate (NodeElement conditionNode) { string plat = conditionNode.GetAttribute ("value"); bool negate = false; if (plat.StartsWith ("!", StringComparison.Ordinal)) { plat = plat.Substring (1); negate = true; } bool result; switch (plat.ToLower ()) { case "windows": case "win32": result = Platform.IsWindows; break; case "mac": case "macos": case "macosx": result = Platform.IsMac; break; case "unix": case "linux": result = !Platform.IsMac && !Platform.IsWindows; break; default: result = false; break; } Version version; if (Version.TryParse (conditionNode.GetAttribute ("minVersion"), out version)) result &= (Platform.IsMac ? MacSystemInformation.OsVersion : Environment.OSVersion.Version) >= version; if (Version.TryParse (conditionNode.GetAttribute ("maxVersion"), out version)) result &= (Platform.IsMac ? MacSystemInformation.OsVersion : Environment.OSVersion.Version) <= version; return negate ? !result : result; }
public override bool Evaluate (NodeElement conditionNode) { if (fileName == null) return false; string[] fileExtensions = conditionNode.GetAttribute ("fileExtensions").Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries); string[] mimeTypes = conditionNode.GetAttribute ("mimeTypes").Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries); string[] names = conditionNode.GetAttribute ("name").Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries); if (fileExtensions.Length > 0) { string ext = System.IO.Path.GetExtension (fileName); if (fileExtensions.Any (fe => string.Compare (fe, ext, StringComparison.OrdinalIgnoreCase) == 0)) return true; } if (mimeTypes.Length > 0) { if (mimeTypes.Any (t => DesktopService.GetMimeTypeIsSubtype (mimeType, t))) return true; } if (names.Length > 0) { string name = System.IO.Path.GetFileName (fileName); if (names.Any (fn => string.Compare (fn, name, StringComparison.OrdinalIgnoreCase) == 0)) return true; } return false; }
public override bool Evaluate (NodeElement conditionNode) { string plat = conditionNode.GetAttribute ("value"); bool negate = false; if (plat.StartsWith ("!")) { plat = plat.Substring (1); negate = true; } bool result; switch (plat.ToLower ()) { case "windows": case "win32": result = Platform.IsWindows; break; case "mac": case "macos": case "macosx": result = Platform.IsMac; break; case "unix": case "linux": result = !Platform.IsMac && !Platform.IsWindows; break; default: result = false; break; } return negate ? !result : result; }
public override bool Evaluate (NodeElement conditionNode) { return Environment.OSVersion.Platform == PlatformID.Unix && !Directory.Exists ("/Applications") && !Directory.Exists ("/Users") && !Directory.Exists ("/Library"); }
protected override void Read (NodeElement elem) { typeName = elem.GetAttribute ("class"); if (typeName.Length == 0) throw new InvalidOperationException ("Application type not provided"); description = elem.GetAttribute ("description"); }
public static NodeConflict Merge( NodeElement commonAncestrorElement, NodeElement elementInSourceBranch, NodeElement elementInDestinationBranch) { NodeDifference ignoreA, ignoreB; return Merge(commonAncestrorElement, elementInSourceBranch, elementInDestinationBranch, out ignoreA, out ignoreB); }
protected override void Read (NodeElement elem) { base.Read (elem); if (headerImageResource != null) HeaderImage = Addin.GetImageResource (headerImageResource); if (headerFillerImageResource != null) HeaderFillerImageResource = Addin.GetImageResource (headerFillerImageResource); }
public override bool Evaluate (NodeElement conditionNode) { foreach (string type in conditionNode.GetAttribute ("value").Split ('|')) { if (MatchesType (type.Trim ())) return true; } return false; }
public void Constructs_empty_element([Column(0, 123)] int index) { var element = new NodeElement(index, 123, "Planet", NodeAttributeCollection.Empty, EmptyArray<INode>.Instance); Assert.AreEqual(index, element.Index); Assert.IsEmpty(element.Children); Assert.IsEmpty(element.Attributes); Assert.AreEqual("Planet", element.Name); }
protected override void Read (NodeElement elem) { TypeName = elem.GetAttribute ("class"); if (string.IsNullOrEmpty (TypeName)) throw new InvalidOperationException ("type not provided"); MimeType = elem.GetAttribute ("mimeType"); if (string.IsNullOrEmpty (MimeType)) throw new InvalidOperationException ("type not provided"); }
protected override void Read(NodeElement elem) { base.Read (elem); vendor_name = elem.GetAttribute ("vendor-name"); product_name = elem.GetAttribute ("product-name"); vendor_ids = ParseIds (elem.GetAttribute ("vendor-id")); product_ids = ParseIds (elem.GetAttribute ("product-id")); }
public override bool Evaluate (NodeElement condition) { string activeproject = condition.GetAttribute ("value"); Project project = IdeApp.ProjectOperations.CurrentSelectedProject; if (activeproject == "*") { return project != null; } return project != null && project.GetTypeTags ().All (p => p != activeproject); }
private static void CheckSortOrder(NodeElement head) { for (; head.Next != null; head = head.Next) { if (head.Data.Key > head.Next.Data.Key) { Assert.Fail("Collection is not sorted correctly! Wrong Order!"); } } }
public override bool Evaluate(NodeElement conditionNode) { var selectedFile = IdeApp.ProjectOperations.CurrentSelectedItem as ProjectFile; if(selectedFile == null || selectedFile.Name == null) { return false; } bool visible = NativeTypeHandlers.All.FirstOrDefault(handler => handler.IsHandledFileType(selectedFile.Name.ToLowerInvariant())) != null; return visible; }
public override bool Evaluate (NodeElement conditionNode) { var project = IdeApp.ProjectOperations.CurrentSelectedProject as DotNetProject; if (project is PackagingProject) { return true; } else if (project != null) { return project.HasNuGetMetadata (); } return false; }
public void Constructs_non_empty_element() { var attribute1 = new Gallio.Common.Xml.NodeAttribute(0, "diameter", "4878 km", 2); var attribute2 = new Gallio.Common.Xml.NodeAttribute(1, "revolution", "58.6 d", 2); var mockChild1 = MockRepository.GenerateStub<INode>(); var mockChild2 = MockRepository.GenerateStub<INode>(); var element = new NodeElement(0, 123, "Planet", new[] { attribute1, attribute2 }, new[] { mockChild1, mockChild2 }); Assert.AreElementsSame(new[] { mockChild1, mockChild2 }, element.Children); Assert.AreElementsSame(new[] { attribute1, attribute2 }, element.Attributes); Assert.AreEqual("Planet", element.Name); }
public IAddinLocalizer CreateLocalizer (RuntimeAddin addin, NodeElement element) { string pkg = element.GetAttribute ("catalog"); if (pkg.Length == 0) pkg = addin.Id; string dir = element.GetAttribute ("location"); if (dir.Length == 0) dir = "locale"; dir = addin.GetFilePath (dir); domain = new GettextDomain (); domain.Init (pkg, dir); return this; }
public override bool Evaluate (NodeElement conditionNode) { // Get the required extension value from an attribute, // and check againts the extension of the currently open document string val = conditionNode.GetAttribute ("extension"); if (val.Length > 0) { string ext = Path.GetExtension (TextEditorApp.OpenFileName); foreach (string requiredExtension in val.Split (',')) if (ext == "." + requiredExtension) return true; } return false; }
public override bool Evaluate (NodeElement conditionNode) { var val = conditionNode.GetAttribute ("value"); if (val.IndexOf ('|') != -1) { string[] ors = val.Split ('|'); foreach (var cond in ors) { if (EvalAnd (cond)) return true; } return false; } return EvalAnd (val); }
public override bool Evaluate (NodeElement conditionNode) { string appName = conditionNode.GetAttribute ("value"); bool negate = false; if (appName.StartsWith ("!", StringComparison.Ordinal)) { appName = appName.Substring (1); negate = true; } bool result = BrandingService.ApplicationName.StartsWith (appName, StringComparison.OrdinalIgnoreCase); return negate ? !result : result; }
public override bool Evaluate (NodeElement condition) { string lang = condition.GetAttribute ("value"); Project project = IdeApp.ProjectOperations.CurrentSelectedProject; if (lang == "*") return (project is DotNetProject); if (project != null) foreach (string suppLang in project.SupportedLanguages) if (suppLang == lang) return true; return false; }
public override bool Evaluate(NodeElement conditionNode) { string val = conditionNode.GetAttribute ("mode"); if (val.Length > 0) { foreach (string mode in val.Split(',')) { if (mode == "single" && Mode == ViewMode.Single) { return true; } else if (mode == "library" && Mode == ViewMode.Library) { return true; } } } return false; }
public static NodeConflict Merge( NodeElement commonAncestrorElement, NodeElement elementInSourceBranch, NodeElement elementInDestinationBranch, out NodeDifference differenceInSourceBranch, out NodeDifference differenceInDestinationBranch) { differenceInSourceBranch = (NodeDifference) elementInSourceBranch.CompareTo(commonAncestrorElement) ?? new NodeDifference(new ElementIdentifier("SolutionFile"), OperationOnParent.Modified, null); differenceInDestinationBranch = (NodeDifference) elementInDestinationBranch.CompareTo(commonAncestrorElement) ?? new NodeDifference(new ElementIdentifier("SolutionFile"), OperationOnParent.Modified, null); return (NodeConflict)differenceInSourceBranch.CompareTo(differenceInDestinationBranch); }
public override bool Evaluate (NodeElement conditionNode) { int count = MainWindow.Toplevel.Selection.Count; string val = conditionNode.GetAttribute ("selection"); if (val.Length > 0) { foreach (string selection in val.Split(',')) { if (selection == "multiple" && count > 1) { return true; } else if (selection == "single" && count == 1) { return true; } } } return false; }
public override bool Evaluate (NodeElement conditionNode) { var target = conditionNode.GetAttribute ("target"); if (string.IsNullOrEmpty (target)) return false; string msbuild = Runtime.SystemAssemblyService.CurrentRuntime.GetMSBuildExtensionsPath (); Dictionary<string, string> variables = new Dictionary<string, string> (StringComparer.OrdinalIgnoreCase) { { "MSBuildExtensionsPath64", msbuild }, { "MSBuildExtensionsPath32", msbuild }, { "MSBuildExtensionsPath", msbuild } }; string path = StringParserService.Parse (target, variables); if (Path.DirectorySeparatorChar != '\\') path = path.Replace ('\\', Path.DirectorySeparatorChar); return File.Exists (path); }
public override bool Evaluate (NodeElement conditionNode) { string name = conditionNode.GetAttribute ("name"); var assemblies = Runtime.SystemAssemblyService.CurrentRuntime.RuntimeAssemblyContext.GetAssemblies () .Where (asm => asm.Name == name).ToList (); if (assemblies.Count == 0) return false; string version = conditionNode.GetAttribute ("version"); if (!String.IsNullOrEmpty (version)) return assemblies.Any (asm => asm.Version == version); string minVersion = conditionNode.GetAttribute ("minVersion"); if (!String.IsNullOrEmpty (minVersion)) { if (!assemblies.Any (asm => Addin.CompareVersions (minVersion, asm.Version) >= 0)) return false; } string maxVersion = conditionNode.GetAttribute ("maxVersion"); if (!String.IsNullOrEmpty(maxVersion)) { if (assemblies.Any (asm => Addin.CompareVersions (maxVersion, asm.Version) > 0)) return false; } return true; }
public IAddinLocalizer CreateLocalizer (RuntimeAddin addin, NodeElement element) { foreach (NodeElement nloc in element.ChildNodes) { if (nloc.NodeName != "Locale") throw new InvalidOperationException ("Invalid element found: '" + nloc.NodeName + "'. Expected: 'Locale'"); string ln = nloc.GetAttribute ("id"); if (ln.Length == 0) throw new InvalidOperationException ("Locale id not specified"); ln = ln.Replace ('_','-'); Hashtable messages = new Hashtable (); foreach (NodeElement nmsg in nloc.ChildNodes) { if (nmsg.NodeName != "Msg") throw new InvalidOperationException ("Locale '" + ln + "': Invalid element found: '" + nmsg.NodeName + "'. Expected: 'Msg'"); string id = nmsg.GetAttribute ("id"); if (id.Length == 0) throw new InvalidOperationException ("Locale '" + ln + "': Message id not specified"); messages [id] = nmsg.GetAttribute ("str"); } locales [ln] = messages; } return this; }
public static AnchorElement AnchorElement(int x, int y, NodeElement owner, Canvas canvas) { return(new Anchor(x, y, owner, canvas)); }
public override bool Evaluate(NodeElement conditionNode) { return(true); }
public IAddinLocalizer CreateLocalizer(RuntimeAddin addin, NodeElement element) { this.addin = addin; return(this); }
public EdgeElement(NodeElement fromNode, Vector2 toPosition) : this() { From = fromNode; ToPosition = toPosition; }
public static Project FromElement(string projectGuid, NodeElement element, Dictionary <string, string> solutionFolderGuids) { string projectTypeGuid = null; string projectName = null; string relativePath = null; string parentFolderGuid = null; var projectSections = new List <Section>(); var versionControlLines = new List <PropertyLine>(); var projectConfigurationPlatformsLines = new List <PropertyLine>(); foreach (var child in element.Childs) { var identifier = child.Identifier; if (identifier.Name == TagProjectTypeGuid) { projectTypeGuid = ((ValueElement)child).Value; } else if (identifier.Name == TagProjectName) { projectName = ((ValueElement)child).Value; } else if (identifier.Name == TagRelativePath) { relativePath = ((ValueElement)child).Value; } else if (identifier.Name == TagParentFolder) { var parentProjectFullName = ((ValueElement)child).Value; if (!solutionFolderGuids.ContainsKey(parentProjectFullName)) { var first = solutionFolderGuids.First(); string projectNameOrGuid = projectName ?? projectGuid; var message = $"The project {projectNameOrGuid} could not be added to the folder {parentProjectFullName} because this folder is no longer present. It will be added to the folder {first.Key} instead."; MessageBox.Show(message); parentFolderGuid = first.Value; } else { parentFolderGuid = solutionFolderGuids[parentProjectFullName]; } } else if (identifier.Name.StartsWith(TagProjectSection)) { var sectionName = identifier.Name.Substring(TagProjectSection.Length); projectSections.Add( Section.FromElement( sectionName, (NodeElement)child)); } else if (identifier.Name.StartsWith(TagVersionControlLines)) { var name = identifier.Name.Substring(TagVersionControlLines.Length); var value = ((ValueElement)child).Value; versionControlLines.Add(new PropertyLine(name, value)); } else if (identifier.Name.StartsWith(TagProjectConfigurationPlatformsLines)) { var name = identifier.Name.Substring(TagProjectConfigurationPlatformsLines.Length); var value = ((ValueElement)child).Value; projectConfigurationPlatformsLines.Add(new PropertyLine(name, value)); } else { throw new SolutionFileException(string.Format("Invalid identifier '{0}'.", identifier.Name)); } } if (projectTypeGuid == null) { throw new SolutionFileException(string.Format("Missing subelement '{0}' in a section element.", TagProjectTypeGuid)); } if (projectName == null) { throw new SolutionFileException(string.Format("Missing subelement '{0}' in a section element.", TagProjectName)); } if (relativePath == null) { throw new SolutionFileException(string.Format("Missing subelement '{0}' in a section element.", TagRelativePath)); } return(new Project( null, projectGuid, projectTypeGuid, projectName, relativePath, parentFolderGuid, projectSections, versionControlLines, projectConfigurationPlatformsLines)); }
public static Project FromElement(string projectGuid, NodeElement element, Dictionary <string, string> solutionFolderGuids) { string projectTypeGuid = null; string projectName = null; string relativePath = null; string parentFolderGuid = null; var projectSections = new List <Section>(); var versionControlLines = new List <PropertyLine>(); var projectConfigurationPlatformsLines = new List <PropertyLine>(); foreach (var child in element.Childs) { var identifier = child.Identifier; if (identifier.Name == TagProjectTypeGuid) { projectTypeGuid = ((ValueElement)child).Value; } else if (identifier.Name == TagProjectName) { projectName = ((ValueElement)child).Value; } else if (identifier.Name == TagRelativePath) { relativePath = ((ValueElement)child).Value; } else if (identifier.Name == TagParentFolder) { var parentProjectFullName = ((ValueElement)child).Value; if (!solutionFolderGuids.ContainsKey(parentProjectFullName)) { throw new Exception("TODO"); } parentFolderGuid = solutionFolderGuids[parentProjectFullName]; } else if (identifier.Name.StartsWith(TagProjectSection)) { var sectionName = identifier.Name.Substring(TagProjectSection.Length); projectSections.Add( Section.FromElement( sectionName, (NodeElement)child)); } else if (identifier.Name.StartsWith(TagVersionControlLines)) { var name = identifier.Name.Substring(TagVersionControlLines.Length); var value = ((ValueElement)child).Value; versionControlLines.Add(new PropertyLine(name, value)); } else if (identifier.Name.StartsWith(TagProjectConfigurationPlatformsLines)) { var name = identifier.Name.Substring(TagProjectConfigurationPlatformsLines.Length); var value = ((ValueElement)child).Value; projectConfigurationPlatformsLines.Add(new PropertyLine(name, value)); } else { throw new SolutionFileException(string.Format("Invalid identifier '{0}'.", identifier.Name)); } } if (projectTypeGuid == null) { throw new SolutionFileException(string.Format("Missing subelement '{0}' in a section element.", TagProjectTypeGuid)); } if (projectName == null) { throw new SolutionFileException(string.Format("Missing subelement '{0}' in a section element.", TagProjectName)); } if (relativePath == null) { throw new SolutionFileException(string.Format("Missing subelement '{0}' in a section element.", TagRelativePath)); } return(new Project( null, projectGuid, projectTypeGuid, projectName, relativePath, parentFolderGuid, projectSections, versionControlLines, projectConfigurationPlatformsLines)); }
protected override void Read(NodeElement elem) { IsAdd = elem.NodeName == "AddImport"; base.Read(elem); }
internal protected virtual void Read(NodeElement elem) { if (nodeType == null || nodeType.Fields == null) { return; } NodeAttribute[] attributes = elem.Attributes; Hashtable fields = (Hashtable)nodeType.Fields.Clone(); foreach (NodeAttribute at in attributes) { ExtensionNodeType.FieldData f = (ExtensionNodeType.FieldData)fields [at.name]; if (f == null) { continue; } fields.Remove(at.name); object val; if (f.Field.FieldType == typeof(string)) { if (f.Localizable) { val = Addin.Localizer.GetString(at.value); } else { val = at.value; } } else if (f.Field.FieldType == typeof(string[])) { string[] ss = at.value.Split(','); if (ss.Length == 0 && ss[0].Length == 0) { val = new string [0]; } else { for (int n = 0; n < ss.Length; n++) { ss [n] = ss[n].Trim(); } val = ss; } } else if (f.Field.FieldType.IsEnum) { val = Enum.Parse(f.Field.FieldType, at.value); } else { try { val = Convert.ChangeType(at.Value, f.Field.FieldType); } catch (InvalidCastException) { throw new InvalidOperationException("Property type not supported by [NodeAttribute]: " + f.Field.DeclaringType + "." + f.Field.Name); } } f.Field.SetValue(this, val); } if (fields.Count > 0) { // Check if one of the remaining fields is mandatory foreach (DictionaryEntry e in fields) { ExtensionNodeType.FieldData f = (ExtensionNodeType.FieldData)e.Value; if (f.Required) { throw new InvalidOperationException("Required attribute '" + e.Key + "' not found."); } } } }
public override bool Evaluate(NodeElement conditionNode) { return(MonoDroidFramework.IsInstalled); }
private static bool NodeIsText(NodeElement node) { return(node.Tag == "_text"); }
protected override void Read(NodeElement elem) { base.Read(elem); customizer = (IExecutionCommandCustomizer)GetInstance(typeof(IExecutionCommandCustomizer)); }
// つなげるときに呼ぶ public void ConnectTo(NodeElement node) { To = node; MarkDirtyRepaint(); // 再描画をリクエスト }
public EdgeElement(SerializableEdge edge, NodeElement fromNode, NodeElement toNode) : this() { serializableEdge = edge; From = fromNode; To = toNode; }
public void Diff_with_null_expected_value_should_throw_exception() { var actual = new NodeElement(123, 123, "Name", NodeAttributeCollection.Empty, EmptyArray <INode> .Instance); actual.Diff(null, XmlPathRoot.Strict.Empty, XmlPathRoot.Strict.Empty, XmlOptions.Strict.Value); }
public override bool Evaluate(NodeElement condition) { return(IdeApp.Workspace.IsOpen); }