public static void UpdateTreeViewItem(this TreeViewItem treeViewItem, XElement xElement) { treeViewItem.DataContext = xElement; var head = new StackPanel {Orientation = Orientation.Horizontal}; var text = new TextBlock(); // ScriptType->Type->type->_Type var icon = xElement.GetIconType(); var name = xElement.GetAttributeValue(Constants.NAME); var description = xElement.GetAttributeValue("Description"); var height = text.FontSize; if (!string.IsNullOrWhiteSpace(icon)) { AddIcon(head, icon, description, height); } var maturity = xElement.GetAttributeValue("Maturity"); if (!string.IsNullOrEmpty(maturity)) { AddIcon(head, maturity,"",height); } text.Text = name; text.Margin = new Thickness(1, 0, 1, 0); text.ToolTip = new ToolTip {Content = xElement.GetSimpleDescriptionFromXElement()}; head.Children.Add(text); treeViewItem.Header = head; }
private ColorPair GetDefinitionColors(XElement fontElement) { var foreColor = Color.FromName(fontElement.GetAttributeValue("foreColor")); var backColor = Color.FromName(fontElement.GetAttributeValue("backColor")); return new ColorPair(foreColor, backColor); }
public void Configure(XElement xml) { EventLogSource = xml.GetAttributeValue("EventLogSource"); EntryFormatter = ConstructOrDefault<IEntryConverter<string>>(xml.GetAttributeValue("Formatter", "EntryFormatter")); }
public void Configure(XElement xml) { EntryFormatter = ConstructOrDefault<IEntryConverter<string>>(xml.GetAttributeValue("EntryFormatter", "Formatter")); var cap = xml.GetAttributeValue("cap") ?? xml.GetAttributeValue("capacity"); Capacity = Attempt.Get<int?>(() => int.Parse(cap)).Value; }
private static void GetRenderOptionsFromXml(SXL.XElement el, MsaglLayoutOptions options) { System.Func <string, double> double_parse = str => double.Parse(str, System.Globalization.CultureInfo.InvariantCulture); options.UseDynamicConnectors = el.GetAttributeValue("usedynamicconnectors", bool.Parse); options.ScalingFactor = el.GetAttributeValue("scalingfactor", double_parse); }
public IContentProvider InitFromConfig(XElement element){ var resourceAssembly = element.GetAttributeValue("resourceAssembly", false); if (resourceAssembly != null) _resourceAssembly = AppDomain.CurrentDomain.GetOrLoadAssembly(resourceAssembly); _rootNameSpace = element.GetAttributeValue("rootNameSpace", false) ?? _rootNameSpace; if (_resourceAssembly == null) throw new TemplateConfigurationException("{0}: attribute resourceAssembly is required and not allowed null".FormatWith(element)); if (_rootNameSpace == null) throw new TemplateConfigurationException("{0}: attribute rootNameSpace is required and not allowed null".FormatWith(element)); return this; }
private Definition GetDefinition(XElement definitionElement) { var name = definitionElement.GetAttributeValue("name"); var patterns = GetPatterns(definitionElement); var caseSensitive = Boolean.Parse(definitionElement.GetAttributeValue("caseSensitive")); var style = GetDefinitionStyle(definitionElement); return new Definition(name, caseSensitive, style, patterns); }
private static void _get_render_options_from_xml(SXL.XElement el, MsaglOptions layoutoptions) { var culture = System.Globalization.CultureInfo.InvariantCulture; double DoubleParse(string str) => double.Parse(str, culture); layoutoptions.UseDynamicConnectors = el.GetAttributeValue("usedynamicconnectors", bool.Parse); layoutoptions.ScalingFactor = el.GetAttributeValue("scalingfactor", DoubleParse); }
public void ShouldGetAttributeValue() { var element = new XElement("root"); element.GetAttributeValue("id").ShouldBe(null); element.GetAttributeValue("id", "default").ShouldBe("default"); element.SetAttributeValue("id", "1234"); element.GetAttributeValue("id").ShouldBe("1234"); }
private BlockPattern GetBlockPattern(XElement patternElement) { var name = patternElement.GetAttributeValue("name"); var style = GetPatternStyle(patternElement); var beginsWith = patternElement.GetAttributeValue("beginsWith"); var endsWith = patternElement.GetAttributeValue("endsWith"); var escapesWith = patternElement.GetAttributeValue("escapesWith"); return new BlockPattern(name, style, beginsWith, endsWith, escapesWith); }
internal void LoadUserData(XElement node) { bool tryParseBool; if (bool.TryParse(node.GetAttributeValue("showMessages"), out tryParseBool)) this.buttonMessages.Checked = tryParseBool; if (bool.TryParse(node.GetAttributeValue("showWarnings"), out tryParseBool)) this.buttonWarnings.Checked = tryParseBool; if (bool.TryParse(node.GetAttributeValue("showErrors"), out tryParseBool)) this.buttonErrors.Checked = tryParseBool; if (bool.TryParse(node.GetAttributeValue("showCore"), out tryParseBool)) this.buttonCore.Checked = tryParseBool; if (bool.TryParse(node.GetAttributeValue("showEditor"), out tryParseBool)) this.buttonEditor.Checked = tryParseBool; if (bool.TryParse(node.GetAttributeValue("showGame"), out tryParseBool)) this.buttonGame.Checked = tryParseBool; if (bool.TryParse(node.GetAttributeValue("autoClear"), out tryParseBool)) this.checkAutoClear.Checked = tryParseBool; if (bool.TryParse(node.GetAttributeValue("pauseOnError"), out tryParseBool)) this.buttonPauseOnError.Checked = tryParseBool; this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.SourceCore, this.buttonCore.Checked); this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.SourceEditor, this.buttonEditor.Checked); this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.SourceGame, this.buttonGame.Checked); this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.TypeMessage, this.buttonMessages.Checked); this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.TypeWarning, this.buttonWarnings.Checked); this.logEntryList.SetFilterFlag(LogEntryList.MessageFilter.TypeError, this.buttonErrors.Checked); }
public CustomizedFeedProperty(XElement nodeDecl, XElement entry) { this.entry = entry; this.node = nodeDecl; this.fcTargetPath = nodeDecl.GetAttributeValue("m:FC_TargetPath", ODataNamespaceManager.Instance); this.fc_KeepInContent = nodeDecl.GetAttributeValue("m:FC_KeepInContent", ODataNamespaceManager.Instance); if (string.IsNullOrEmpty(fc_KeepInContent)) { this.fc_KeepInContent = "true"; // default setting } this.fc_ContentKind = nodeDecl.GetAttributeValue("m:FC_ContentKind", ODataNamespaceManager.Instance); if (string.IsNullOrEmpty(this.fc_ContentKind)) { this.fc_ContentKind = "text"; //default setting } string target; this.isAtomSpecific = AtomTargetMapping.TryGetTarget(this.fcTargetPath, out target); if (isAtomSpecific) { this.targetPath = target.Split('/'); this.nsResolver = ODataNamespaceManager.Instance; extraNamespaceDecl = string.Empty; } else { this.targetPath = fcTargetPath.Split('/'); string fc_NsPrefix = nodeDecl.GetAttributeValue("m:FC_NsPrefix", ODataNamespaceManager.Instance); string fc_NsUri = nodeDecl.GetAttributeValue("m:FC_NsUri", ODataNamespaceManager.Instance); if (string.IsNullOrEmpty(fc_NsPrefix)) { fc_NsPrefix = "ioftNs_wfnqpz"; //just make up a random one } this.AddNsPrefixToTarget(fc_NsPrefix); // a custom resolver is needed sice there is non standard namespace definition this.nsResolver = CreateCustomNSResolver(fc_NsPrefix, fc_NsUri); this.extraNamespaceDecl = string.Format(@"xmlns:{0}=""{1}""", fc_NsPrefix, fc_NsUri); } this.isAttributeTarget = IsAttributeTarget(this.targetPath[this.targetPath.Length - 1]); this.ProcessPropertyInContent(); this.ProcessPropertyInTarget(); }
private static TreeViewItem GetItemFromXElement(XElement element, string parentId) { var guid = element.GetAttributeValue(Constants._ID); if (string.IsNullOrEmpty(guid)) { guid = Guid.NewGuid().ToString(); element.SetAttributeValue(Constants._ID, guid); } var rootPart = element.GetRootPartElement(); rootPart.SetAttributeValue(Constants.PARENT_ID, parentId); if (!DBFactory.GetData().Save(rootPart)) { MessageBox.Show("update Tree item Failed."); } else { var itself = rootPart.GetTreeViewItemFromXElement(); foreach (XElement kid in element.Descendants()) { itself.Items.Add(GetItemFromXElement(kid, guid)); } return itself; } return null; }
public Target Construct(string typeName, XElement config) { if (config == null) throw new ArgumentNullException(nameof(config)); try { // make sure that a type name is present (explicitly passed in or through config) if (string.IsNullOrWhiteSpace(typeName)) { typeName = config.GetAttributeValue("type"); if (string.IsNullOrWhiteSpace(typeName)) throw new ArgumentNullException(nameof(typeName)); } // find the target type var targetType = FindTargetTypeInfo(typeName); if (targetType == null) throw new LoggingConfigurationException("Could not find a target type by the name " + typeName); // construct target var target = (Target)Activator.CreateInstance(targetType.TargetType); target.ConfigureInternal(config); return target; } catch (Exception ex) { throw new TargetConstructionException("Target construction failed", ex); } }
public static uBaseObject Create(XElement container) { if (container == null) { throw new ArgumentNullException("container"); } return new uBaseObject { Id = container.GetAttributeValue(uPnpNamespaces.Id), ParentId = container.GetAttributeValue(uPnpNamespaces.ParentId), Title = container.GetValue(uPnpNamespaces.title), IconUrl = container.GetValue(uPnpNamespaces.Artwork), UpnpClass = container.GetValue(uPnpNamespaces.uClass) }; }
public void FindUIObject(XElement uiObj) { if (uiObj == null) return; XPath = uiObj.GetAttributeValue("XPath"); UIObject = Browser.GetWebElement(uiObj); }
public void PublishXml(XElement xml) { _contentType = xml.GetAttributeValue(Common.ContentTypes.AttribName); // Change the button image to correspond to the type of content for this field string buttonImageUri = null; switch (_contentType) { case Common.ContentTypes.URL: buttonImageUri = "/Expanz.ThinRIA.Core.Silverlight;component/Images/Globe.png"; break; case Common.ContentTypes.EmailAddress: buttonImageUri = "/Expanz.ThinRIA.Core.Silverlight;component/Images/Envelope.png"; break; } if (buttonImageUri != null) { Image image = new Image(); image.Stretch = Stretch.None; image.Source = new BitmapImage(new Uri(buttonImageUri, UriKind.RelativeOrAbsolute)); this.Content = image; } }
public static DGShapeInfo FromXml(Client client, SXL.XElement shape_el) { var info = new DGShapeInfo(); info.ID = shape_el.Attribute("id").Value; client.WriteVerbose("Reading shape id={0}", info.ID); info.Label = shape_el.Attribute("label").Value; info.Stencil = shape_el.Attribute("stencil").Value; info.Master = shape_el.Attribute("master").Value; info.Element = shape_el; info.URL = shape_el.GetAttributeValue("url", null); info.custprops = new CustomPropertyDictionary(); foreach (var customprop_el in shape_el.Elements("customprop")) { string cp_name = customprop_el.Attribute("name").Value; string cp_value = customprop_el.Attribute("value").Value; var cp = new CustomPropertyCells(); cp.Value = cp_value; info.custprops.Add(cp_name, cp); } return(info); }
public void GetAttributeValue_Throws_OnNullObjects() { typeof(NullReferenceException).ShouldBeThrownBy(() => ((XElement) null).GetAttributeValue(null)); //attribute not exist var elem = new XElement("elem", "This is a test"); typeof(NullReferenceException).ShouldBeThrownBy(() => elem.GetAttributeValue("MissingAttributeName")); }
private Font GetDefinitionFont(XElement fontElement) { var fontName = fontElement.GetAttributeValue("name"); var fontSize = Convert.ToSingle(fontElement.GetAttributeValue("size")); var fontStyle = (FontStyle) Enum.Parse(typeof(FontStyle), fontElement.GetAttributeValue("style"), true); return new Font(fontName, fontSize, fontStyle); }
public static double AttributeAsInches(this SXL.XElement el, string name, double def) { var culture = System.Globalization.CultureInfo.InvariantCulture; double DoubleParse(string str) => double.Parse(str, culture); return(el.GetAttributeValue(name, def, s => XmlLinqExtensions._points_to_inches(DoubleParse(s)))); }
public void AttributeDoesNotExist__ReturnsSpecifiedDefaultValue() { var el = new XElement("el"); var v = el.GetAttributeValue("attrib", "default-value"); Assert.AreEqual("default-value", v); }
public void AttributeDoesNotExist__ReturnsNullByDefault() { var el = new XElement("el"); var v = el.GetAttributeValue("attrib"); Assert.AreEqual(null, v); }
public static XElement Execute(XElement steps, Browser browser, Config config) { var ret = new XElement(Constants.RESULT); ret.SetAttributeValue("Created", DateTime.UtcNow.ToString(Constants.DATE_TIME_FORMAT)); ret.SetAttributeValue(Constants.RESULT, Constants.SUCCESS); ret.SetAttributeValue(Constants._ID, Guid.NewGuid().ToString()); var instanceId = steps.GetAttributeValue(Constants.INSTANCE_ID); var runtimeId = steps.GetAttributeValue(Constants.RUNTIME_ID); var onError = steps.GetAttributeValue(Constants.ON_ERROR); string link = null; if (!string.IsNullOrEmpty(onError)) ret.SetAttributeValue(Constants.ON_ERROR, onError); if (!string.IsNullOrEmpty(instanceId)) { ret.SetAttributeValue(Constants.INSTANCE_ID, instanceId); browser.DismissUnexpectedAlert(); } if (!string.IsNullOrEmpty(runtimeId)) ret.SetAttributeValue(Constants.RUNTIME_ID, runtimeId); var setEnv = steps.Element(Constants.SET_ENV); if (setEnv != null) { foreach (var env in setEnv.Attributes()) { config.Set(env.Name.ToString(), env.Value); } return ret; } var query = from o in steps.Elements(Constants.STEP) select o; foreach (var step in query) { var xAttribute = step.Attribute(Constants.ACTION); //var xId = step.GetAttributeValue(Constants._ID); if (xAttribute != null) { if (!HandleOneStep(browser, config, ref ret, instanceId, link, step, xAttribute)) break; } } return ret; }
public bool Save(XElement xElement) { xElement.SetAttributeValue("Updated", DateTime.UtcNow.ToString(Constants.DATE_TIME_FORMAT)); var id = xElement.GetAttributeValue(Constants._ID); var parentId = xElement.GetAttributeValue(Constants.PARENT_ID); if (MysqlDBManager.GetInstance().Find(id) == null) { xElement.SetAttributeValue("Created", DateTime.UtcNow.ToString(Constants.DATE_TIME_FORMAT)); MysqlDBManager.GetInstance().CreateContent(id, xElement.ToString()); } else { MysqlDBManager.GetInstance().UpdateContent(id, xElement.ToString()); MysqlDBManager.GetInstance().RemoveRelationship(id); } MysqlDBManager.GetInstance().CreateRelationship(parentId, "Parent-Kid", id); return true; }
public void Configure(XElement xml) { var template = new FileTarget(); // used for default values KeepFileOpen = Attempt.Get(() => bool.Parse(xml.GetAttributeValue("KeepFileOpen", "KeepOpen")), template.KeepFileOpen) .Value; Path = xml.GetAttributeValue("path", "file", "folder", "dir", "directory", "filepath"); ArchiveCount = Attempt.Get(() => int.Parse(xml.GetAttributeValue("archivecount")), template.ArchiveCount).Value; EntryFormatter = ConstructOrDefault<IEntryConverter<string>>(xml.GetAttributeValue("entryformatter", "formatter")); Interval = Attempt.Get(() => LoggingInterval.Parse(xml.GetAttributeValue("interval"))).Value; }
public void AttributeExistsWithoutValue__ReturnsNullByDefault() { var el = new XElement("el"); var attrib = new XAttribute("attrib", ""); el.Add(attrib); var v = el.GetAttributeValue("attrib"); Assert.AreEqual(null, v); }
public void AttributeExistsWithoutValue__ReturnsSpecifiedDefaultValue() { var el = new XElement("el"); var attrib = new XAttribute("attrib", ""); el.Add(attrib); var v = el.GetAttributeValue("attrib", "default-value"); Assert.AreEqual("default-value", v); }
public void AttributeExistsAndHasValue__ReturnsValueOfTheAttribute() { var el = new XElement("el"); var attrib = new XAttribute("attrib", 13); el.Add(attrib); var v = el.GetAttributeValue("attrib"); Assert.AreEqual("13", v); }
public new void Configure(XElement xml) { base.Configure(xml); Func<string, ConsoleColor, ConsoleColor> getColor = (str, def) => Attempt.Get(() => Enums.Parse<ConsoleColor>(xml.GetAttributeValue(str)), def).Value; TraceColor = getColor("TraceColor",DefaultTraceColor); DebugColor = getColor("DebugColor",DefaultDebugColor); InfoColor = getColor("InfoColor", DefaultInfoColor); WarnColor = getColor("WarnColor", DefaultWarnColor); ErrorColor = getColor("ErrorColor", DefaultErrorColor); FatalColor = getColor("FatalColor", DefaultFatalColor); }
public static Computer FromXElement(XElement xComputer) { //return xComputer.GetObjectFromXElement() as Computer; var computer = new Computer { _id = xComputer.GetAttributeValue(Constants._ID), Created = DateTime.Parse(xComputer.GetAttributeValue("Created")), Updated = DateTime.Parse(xComputer.GetAttributeValue("Updated")), ComputerName = xComputer.GetAttributeValue("ComputerName"), IPAddress = xComputer.GetAttributeValue("IPAddress"), Version = xComputer.GetAttributeValue("Version"), Status = xComputer.GetAttributeValue("Status"), DefaultURL = xComputer.GetAttributeValue("DefaultURL") }; return computer; }
internal static KernelTypeInfo Deserialize(XElement xe, string directory = null) { string name = xe.GetAttributeValue(csNAME); bool? isDummy = xe.TryGetAttributeBoolValue(csISDUMMY); string behaviourStr = xe.TryGetAttributeValue(csDUMMYBEHAVIOUR); string typeName = xe.Element(csTYPE).Value; string assemblyFullName = xe.Element(csASSEMBLY).Value; string assemblyName = xe.Element(csASSEMBLYNAME).Value; string assemblyPath = xe.TryGetElementValue(csASSEMBLYPATH); long checksum = XmlConvert.ToInt64(xe.Element(csCHECKSUM).Value); eCudafyDummyBehaviour behaviour = string.IsNullOrEmpty(behaviourStr) ? eCudafyDummyBehaviour.Default : (eCudafyDummyBehaviour)Enum.Parse(typeof(eCudafyDummyBehaviour), behaviourStr); Type type = null; KernelTypeInfo kti = new KernelTypeInfo(null); if (!string.IsNullOrEmpty(typeName) && !string.IsNullOrEmpty(assemblyFullName)) { Assembly assembly = null; try { assembly = Assembly.Load(assemblyFullName); } catch (FileNotFoundException) { directory = directory != null ? directory : string.Empty; assemblyName = directory + Path.DirectorySeparatorChar + assemblyName; if (File.Exists(assemblyName + ".dll")) { assembly = Assembly.LoadFrom(assemblyName + ".dll"); } else if (File.Exists(assemblyName + ".exe")) { assembly = Assembly.LoadFrom(assemblyName + ".exe"); } else if (!string.IsNullOrEmpty(assemblyPath)) { assembly = Assembly.LoadFrom(assemblyPath); } else throw; } if (assembly == null) throw new CudafyException(CudafyException.csCOULD_NOT_LOAD_ASSEMBLY_X, assemblyFullName); type = assembly.GetType(typeName); kti = new KernelTypeInfo(type, isDummy == true ? true : false, behaviour); } kti.DeserializedChecksum = checksum; return kti; }
public static Prediction BuildPrediction(XElement predictionElement) { var result = new Prediction { Seconds = predictionElement.GetAttributeValue(NextBusName.Seconds, int.Parse), Minutes = predictionElement.GetAttributeValue(NextBusName.Minutes, int.Parse), IsDeparture = predictionElement.GetAttributeValue(NextBusName.IsDeparture, bool.Parse), AffectedByLayover = predictionElement.GetAttributeValue(NextBusName.AffectedByLayover, bool.Parse), DirectionTag = predictionElement.GetAttributeValue(NextBusName.DirectionTag), Block = predictionElement.GetAttributeValue(NextBusName.Block), VehicleId = predictionElement.GetAttributeValue(NextBusName.VehicleId) }; var epochAttribute = predictionElement.Attribute(NextBusName.EpochTime); if (epochAttribute != null) { var epochTime = predictionElement.GetAttributeValue(NextBusName.EpochTime, long.Parse); result.DateTimeUtc = UnixTime.ToDateTimeFrom(epochTime); } return result; }
public void LoadFromXml(XElement xElement) { Id = xElement.GetAttributeValue<string>("Id"); //throw new NotImplementedException(); Name = xElement.GetElementValue<string>("Name"); PointOfContact = xElement.GetElementValue<string>("PointOfContact"); PhoneNumber = xElement.GetElementValue<string>("PhoneNumber"); Comments = xElement.GetElementValue<string>("Comments"); foreach (XElement addressesElement in xElement.Elements("Addresses")) { foreach (XElement addressElement in addressesElement.Elements("Address")) { Address address = new Address(); address.LoadFromXml(addressElement); Addresses.Add(address); } } }
private static void GetRenderOptionsFromXml(SXL.XElement el, Models.Layouts.DirectedGraph.MsaglLayoutOptions options) { options.UseDynamicConnectors = el.GetAttributeValue("usedynamicconnectors", bool.Parse); options.ScalingFactor = el.GetAttributeValue("scalingfactor", double.Parse); }
public static double AttributeAsInches(this SXL.XElement el, string name, double def) { return(el.GetAttributeValue(name, def, s => XmlLinqExtensions.PointsToInches(double.Parse(s)))); }
public static ColorRGB AttributeAsColor(this SXL.XElement el, string name, ColorRGB def) { return(el.GetAttributeValue(name, def, ColorRGB.ParseWebColor)); }
public static VisioAutomation.Models.Color.ColorRgb AttributeAsColor(this SXL.XElement el, string name, VisioAutomation.Models.Color.ColorRgb def) { return(el.GetAttributeValue(name, def, VisioAutomation.Models.Color.ColorRgb.ParseWebColor)); }
public static VisioAutomation.Drawing.ColorRGB AttributeAsColor(this SXL.XElement el, string name, VisioAutomation.Drawing.ColorRGB def) { return(el.GetAttributeValue(name, def, VisioAutomation.Drawing.ColorRGB.ParseWebColor)); }
public static double AttributeAsInches(this SXL.XElement el, string name, double def) { System.Func <string, double> double_parse = str => double.Parse(str, System.Globalization.CultureInfo.InvariantCulture); return(el.GetAttributeValue(name, def, s => XmlLinqExtensions.PointsToInches(double_parse(s)))); }