public TypesBuilder(XElement element)
        {
            Types = new HashSet<Type>();
            XAttribute typeAttribute = element.Attribute("type");
            if (typeAttribute == null)
            {
                Types.Add(new Type { TypeKind = TypeKind.Text });
                return;
            }

            IEnumerable<XElement> targets = element.Descendants(Constants.TCM_NAMESPACE + "TargetSchema");
            if (targets.Count() > 0)
            {
                TypeKind typeKind = Util.Parse(element.Descendants(Constants.TCM_NAMESPACE + "linktype").First().Value);
                foreach (XElement target in targets)
                {
                    Types.Add(new Type { Name = target.Attribute(Constants.XLINK_NAMESPACE + "title").Value, TypeKind = typeKind });
                }
                return;
            }

            XElement embedded = element.Descendants(Constants.TCM_NAMESPACE + "EmbeddedSchema").FirstOrDefault();
            if (embedded != null)
            {
                Types.Add(new Type { Name = embedded.Attribute(Constants.XLINK_NAMESPACE + "title").Value, TypeKind = TypeKind.Embedded });
                return;
            }

            Types.Add(new Type { TypeKind = Util.Parse(typeAttribute.Value) });
        }
Ejemplo n.º 2
0
 public UpdateInfo(XElement element)
 {
     XElement versionElement = element.Descendants().First();
     XElement urlElement = element.Descendants().Last();
     Version = new Version(versionElement.Value);
     Url = urlElement.Value;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Recovers the "after" SrcML from a SrcDiff representation.
        /// </summary>
        /// <param name="xml">The root element of the SrcDiff XML to filter.</param>
        /// <returns>A copy of the input XML, with the diff elements removed, representing the modified file.</returns>
        public static XElement GetAfterVersion(XElement xml) {
            if(xml == null) { throw new ArgumentNullException("xml"); }

            var root = new XElement(xml);

            //trim any nodes that were deleted (but keeping any common elements that might be within)
            foreach(var deleteElement in root.Descendants(DIFF.Delete).ToList()) {
                var commonElements = deleteElement.Descendants(DIFF.Common).ToList();
                if(commonElements.Count > 0) {
                    deleteElement.ReplaceWith(commonElements.SelectMany(ce => ce.Nodes()).ToList());
                } else {
                    deleteElement.Remove();
                }
            }

            //add the nodes that were added
            foreach(var addElement in root.Descendants(DIFF.Insert).ToList()) {
                addElement.ReplaceWith(addElement.Nodes());
            }

            //remove the diff tags from any remaining common elements
            foreach(var commonElement in root.Descendants(DIFF.Common).ToList()) {
                commonElement.ReplaceWith(commonElement.Nodes());
            }

            return root;
        }
Ejemplo n.º 4
0
        public water_base(XElement xml)
            : base(xml)
        {
            var diff = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "DiffuseColour").FirstOrDefault();
            var nor1 = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Normal_Map").FirstOrDefault();
            var spec = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Spec_Map").FirstOrDefault();
            var nor2 = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Normal_Map2").FirstOrDefault();
            var foam = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Foam_Map").FirstOrDefault();
            var cube = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "EnvironmentCube").FirstOrDefault();

            if (diff != null) { diffuse = diff.Attribute("FileName").Value; }
            if (nor1 != null) { normal = nor1.Attribute("FileName").Value; }
            if (spec != null) { specular = spec.Attribute("FileName").Value; }
            if (nor2 != null) { normal2 = nor2.Attribute("FileName").Value; }
            if (foam != null) { foamMap = foam.Attribute("FileName").Value; }
            if (cube != null) { cubeMap = cube.Attribute("FileName").Value; }

            var mind = xml.Descendants("Constant").Where(e => e.Attribute("Alias").Value == "Min_distance").FirstOrDefault();
            var maxd = xml.Descendants("Constant").Where(e => e.Attribute("Alias").Value == "Max_distance").FirstOrDefault();
            var seaf = xml.Descendants("Constant").Where(e => e.Attribute("Alias").Value == "Sea_Falloff").FirstOrDefault();
            var shor = xml.Descendants("Constant").Where(e => e.Attribute("Alias").Value == "shore_factor").FirstOrDefault();

            if (mind != null) { minDistance = ReadConstant(mind); }
            if (maxd != null) { maxDistance = ReadConstant(maxd); }
            if (seaf != null) { seaFalloff = ReadConstant(seaf); }
            if (shor != null) { shoreFactor = ReadConstant(shor); }
        }
Ejemplo n.º 5
0
        public FailureExpression(XElement expressionNode)
        {
            Location = SourceLocation.FromXElement(expressionNode);

            var exprTypeAttr = expressionNode.Attribute("type");
            if (exprTypeAttr != null)
            {
                ExpressionType = exprTypeAttr.Value.Trim();
            }
            
            var originalNode = expressionNode.Descendants("Original").FirstOrDefault();
            if (originalNode != null)
            {
                OriginalExpression = originalNode.Value.Trim();
            }

            var expandedNode = expressionNode.Descendants("Expanded").FirstOrDefault();
            if (expandedNode != null)
            {
                ExpandedExpression = expandedNode.Value.Trim();
            }

            var ExceptionNode = expressionNode.Descendants("Exception").FirstOrDefault();
            if (ExceptionNode != null)
            {
                ExceptionMessage = ExceptionNode.Value.Trim();
            }
        }
Ejemplo n.º 6
0
        private void GetValue(Dictionary<string, TmpTestNodeMethod> resultDictionary, XElement test)
        {
            try
            {
                var result = new TmpTestNodeMethod(test.Attribute("name").Value);
                result.State = Switch.Into<TestNodeState>()
                    .From(test.Attribute("result").Value)
                    .Case("Pass", TestNodeState.Success)
                    .Case("Skip", TestNodeState.Inactive)
                    .Case("Fail", TestNodeState.Failure)
                    .Default(TestNodeState.Inconclusive);

                if (result.State != TestNodeState.Success)
                {
                    result.Message = test.Descendants(XName.Get("message", ""))
                        .Select(d => d.Value).MaySingle().Else("");
                    result.StackTrace = 
                        test.Descendants(XName.Get("stack-trace", "")).Select(d => d.Value).MaySingle().Else("");

                    result.Message = result.Message + "\n" + result.StackTrace;
                }

                resultDictionary.Add(result.Name, result);

            }
            catch (Exception e)
            {
                _log.Error("Log file parsing error", e);
            }
        }
Ejemplo n.º 7
0
        public static Playlist Deserialize(XElement xml)
        {
            Playlist playlist = null;
            Guid id;

            var idElement = xml.Descendants("Id").FirstOrDefault();
            var nameElement = xml.Descendants("Name").FirstOrDefault();
            var tracksElement = xml.Descendants("Tracks").FirstOrDefault();

            if (null != nameElement &&
                null != idElement &&
                Guid.TryParse(idElement.Value, out id) &&
                null != tracksElement)
            {
                playlist = new Playlist()
                {
                    Name = nameElement.Value,
                    Id = id
                };

                foreach(var trackElement in tracksElement.Descendants("Track"))
                {
                    playlist.Tracks.Add(Track.Deserialize(trackElement));
                }
            }
            else
            {
                Debug.WriteLine("Playlist: Invalid track XML");
            }

            return playlist;
        }
Ejemplo n.º 8
0
	/// <summary>
	/// The method for creating a trigger
	/// </summary>
	/// <param name="_trigger">The xml element containing the trigger description (Root node = Trigger)</param>
	/// <returns>The newly created trigger.</returns>
	public override Trigger CreateTrigger(XElement _trigger)
	{
		String id = _trigger.Attribute("id").Value;
		String question = _trigger.Descendants("Question").First().Value;
		String answer = _trigger.Descendants("Answer").First().Value;

		QuestionAnswerTrigger t = new QuestionAnswerTrigger(id, question, answer);

		t.preTriggerObjectIds = new List<string>();
		t.postTriggerObjectIds = new List<string>();

		if (_trigger.Element("PreTriggerObject") != null)
			foreach (XElement objectIdElement in _trigger.Element("PreTriggerObject").Elements())
			{
				t.preTriggerObjectIds.Add(objectIdElement.Value);
			}

		if (_trigger.Element("PostTriggerObject") != null)
			foreach (XElement objectIdElement in _trigger.Element("PostTriggerObject").Elements())
			{
				t.postTriggerObjectIds.Add(objectIdElement.Value);
			}

		return t;
	}
Ejemplo n.º 9
0
        public override void FromXml(XElement artistBaseXml)
        {
            // ReSharper disable PossibleNullReferenceException
            string uriString;
            if (artistBaseXml.Descendants("image")
                    .FirstOrDefault(x =>x.Attribute("size").Value == "medium") != null)
            {
                uriString = artistBaseXml.Descendants("image")
                    .FirstOrDefault(x => x.Attribute("size").Value == "medium")
                    .Value;
            }
            else
            {
                uriString = artistBaseXml.Descendants("image")
                    .FirstOrDefault()
                    .Value;
            }

            BitmapImage img = null;
            if (!string.IsNullOrEmpty(uriString))
                img = new BitmapImage(new Uri(uriString));

            Name = artistBaseXml.Element("name").Value;
            MusicBrainzId = artistBaseXml.Element("mbid").Value;

            if (artistBaseXml.Element("match") == null
                || string.IsNullOrEmpty(artistBaseXml.Element("match").Value))
                SimilarMatch = 0;
            else
                SimilarMatch = (int) Math.Round(Convert.ToDouble(artistBaseXml.Element("match").Value), 0);

            Url = new Uri(artistBaseXml.Element("url").Value, UriKind.RelativeOrAbsolute);
            if (img != null) PictureSmall = img;
            // ReSharper restore PossibleNullReferenceException
        }
Ejemplo n.º 10
0
 public ReportRow(XElement xml, IEnumerable<ReportColumnDescription> columnDescriptions)
 {
     _columnDescriptions = columnDescriptions;
     Type = xml.Name.ToString();
     RowType = "";
     RowValue = "";
     if (xml.Name == "TextRow")
     {
         if (xml.Attribute("value") != null)
             RowValue = xml.Attribute("value").Value;
         Columns = new List<ReportColumn>();
     }
     else
     {
         var rowData = xml.Descendants("RowData").FirstOrDefault();
         if (rowData != null)
         {
             RowType = rowData.Attribute("rowType").Value;
             RowValue = rowData.Attribute("value").Value;
         }
         
         var columns = new List<ReportColumn>();
         foreach (var columnXML in xml.Descendants("ColData"))
             columns.Add(new ReportColumn(columnXML));
         Columns = columns;
     }
 }
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="currentConfig">The current XML configuration XML fragment</param>
        public ESentResolveReferenceLinksConfigDlg(string currentConfig)
        {
            XElement node;

            InitializeComponent();

            lnkProjectSite.Links[0].LinkData = "https://GitHub.com/EWSoftware/SHFB";

            // Load the current settings.  Note that there are multiple configurations (one for each help file
            // format).  However, the settings will be the same across all of them.
            config = XElement.Parse(currentConfig);

            node = config.Descendants("msdnContentIdCache").First();
            txtContentIdCachePath.Text = node.Attribute("cachePath").Value;
            udcContentIdLocalCacheSize.Value = ((int?)node.Attribute("localCacheSize") ?? 2500);

            node = config.Descendants("targets").First(d => d.Attribute("id").Value == "FrameworkTargets");
            txtFrameworkTargetsCachePath.Text = node.Attribute("cachePath").Value;
            udcFrameworkTargetsLocalCacheSize.Value = ((int?)node.Attribute("localCacheSize") ?? 2500);

            node = config.Descendants("targets").First(d => d.Attribute("id").Value == "ProjectTargets");
            txtProjectTargetsCachePath.Text = (string)node.Attribute("cachePath");
            udcProjectTargetsLocalCacheSize.Value = ((int?)node.Attribute("localCacheSize") ?? 2500);

            chkEnableLocalCache.Checked = !String.IsNullOrWhiteSpace(txtProjectTargetsCachePath.Text);
        }
Ejemplo n.º 12
0
        public List<Error> Validate(XElement doc)
        {
            XNamespace ns = "http://www.wfmc.org/2008/XPDL2.1";
            var activities = from intermediateEvent in doc.Descendants(ns + "IntermediateEvent")
                let triggerResultMessageElement = intermediateEvent.Element(ns + "TriggerResultMessage")
                let triggerAttribute = intermediateEvent.Attribute("Trigger")
                let catchThrowAttribute = triggerResultMessageElement.Attribute("CatchThrow")
                let eventElement = intermediateEvent.Parent
                where
                    triggerResultMessageElement != null &&
                    triggerAttribute != null &&
                    catchThrowAttribute != null &&
                    catchThrowAttribute.Value == "THROW" &&
                    triggerAttribute.Value == "Message" &&
                    eventElement != null
                select eventElement.Parent;

            return (from activity in activities
                let activityId = activity.Attribute("Id").Value
                let messageFlows = (from messageFlow in doc.Descendants(ns + "MessageFlow")
                    where messageFlow.Attribute("Source").Value == activityId
                    select messageFlow)
                where !messageFlows.Any()
                select new Error
                {
                    ElementId = Guid.Parse(activityId),
                    ElementName = activity.Attribute("Name").Value,
                    ElementXpath = activity.GetAbsoluteXPath(),
                    Message = "El elemento viola la regla Style 0123"
                }).ToList();
        }
Ejemplo n.º 13
0
        public override bool Parse(XElement xmlElement)
        {
            var parseOK = false;
            if (base.Parse(xmlElement))
            {
                var attributes = xmlElement.Attributes();
                var portable = (from attr in attributes where attr.Name == "Portable" select attr.Value).FirstOrDefault();
                CommandLine = (from element in xmlElement.Descendants() where element.Name == "CommandLine" select element.Value).FirstOrDefault();
                UpdateURL = (from element in xmlElement.Descendants() where element.Name == "UpdateURL" select element.Value).FirstOrDefault();
                CanUpdate = !string.IsNullOrEmpty(UpdateURL) && !string.IsNullOrWhiteSpace(UpdateURL);

                bool isPortable;
                IsPortable = bool.TryParse(portable, out isPortable) ? isPortable : true; // portable by default?

                var properties = from element in xmlElement.Descendants() where element.Name == "Property" select element;

                foreach (var prop in properties)
                {
                    attributes = prop.Attributes();
                    var propName = (from attr in attributes where attr.Name == "Name" select attr.Value).FirstOrDefault();
                    var propValue = (from attr in attributes where attr.Name == "Value" select attr.Value).FirstOrDefault();

                    if (string.IsNullOrEmpty(propName) || string.IsNullOrEmpty(propValue)) { continue; }

                    Properties.Add(propName, propValue);
                }

                parseOK = true;
            }

            return parseOK;
        }
Ejemplo n.º 14
0
        private static IExerciseDefinition GetExercise(XElement exerciseXml, IDictionary<string, IConstraint> allConstraints)
        {
            var exercise = new ExerciseDefinition(exerciseXml.Attribute("name").Value,
                                                  new ExerciseTemplate(exerciseXml.Attribute("template").Value));

            var numbersXml = from n in exerciseXml.Descendants("numbers").First().Descendants("number")
                             select n;

            foreach (var number in numbersXml)
            {
                var minValue = int.Parse(number.Attribute("minvalue").Value);
                var maxValue = int.Parse(number.Attribute("maxvalue").Value);
                var decimals = int.Parse(number.Attribute("decimals").Value);
                exercise.AddNumberDefinition(new NumberDefinition("", minValue, maxValue, decimals));
            }

            var constraintsRoot = exerciseXml.Descendants("constraints").FirstOrDefault();
            if (constraintsRoot != null)
            {
                var constraintsXml = from c in constraintsRoot.Descendants("constraint")
                                     select c;

                foreach (var constraint in constraintsXml)
                {
                    var constraintName = constraint.Attribute("type").Value;

                    exercise.AddConstraint(allConstraints[constraintName]);
                }
            }

            return exercise;
        }
Ejemplo n.º 15
0
        private Polygon ParsePolygon(string name, XElement pg, string ns, bool onlyOuter)
        {
            PolygonReader polyReader = new PolygonReader();
            var outerBoundary = pg.Descendants(XName.Get("outerBoundaryIs", ns)).FirstOrDefault();
            var innerPolygons = pg.Descendants(XName.Get("innerBoundaryIs", ns)).ToList();

            if (outerBoundary == null)
            {
                //check if the linear ring has been added without outer/inner boundaries
                var linearRing = pg.Descendants(XName.Get("LinearRing", ns)).FirstOrDefault();
                if (linearRing != null)
                {
                    return polyReader.FromPointList(name, linearRing.Descendants(XName.Get("coordinates", ns)).First().Value);
                }

                return null;
            }

            Polygon p = polyReader.FromPointList(name, outerBoundary.Descendants(XName.Get("coordinates", ns)).First().Value);
            if (!onlyOuter) {
                foreach (var innerPolygon in innerPolygons)
                {
                    var linearRings = innerPolygon.Descendants(XName.Get("LinearRing", ns)).ToList();
                    foreach (var ring in linearRings)
                    {
                        p.InnerPolygons.Add(polyReader.FromPointList(name, ring.Descendants(XName.Get("coordinates", ns)).First().Value));
                    }

                }
            }
            
            return p;
        }
Ejemplo n.º 16
0
        public glass_base(XElement xml)
            : base(xml)
        {
            coreDefaults = new glass_base
            {
                Translucent = Troolean.True,
                DoubleSided = Troolean.False,

                FogEnabled = Troolean.True,
                NeedsWorldSpaceVertexNormal = Troolean.True,
                NeedsWorldEyePos = Troolean.True,
                NeedsWorldVertexPos = Troolean.True,
                //NEEDS_TANGENT_FRAME = 1,
                //NEEDS_PER_PIXEL_SPECULAR_LIGHTING = 1,
                NeedsLocalCubeMap = Troolean.True,
                //NEEDS_SPECULAR_MASK = 1,
                ReceivesShadows = Troolean.True,
                //IS_THIN_GLASS = 1,

                TextureCoordSources =
                {
                    new TextureCoordSource
                    {
                        Alias = "Tex0",
                        UVStream = 0
                    }
                },

                Samplers =
                {
                    new Sampler
                    {
                        Alias = "SAMPLER_DiffuseColour",
                        UsageRGB = Sampler.Usage.DiffuseAlbedo,
                        sRGBRead = true
                    },
                    new Sampler
                    {
                        Alias = "SAMPLER_NormalMap",
                        UsageRGB = Sampler.Usage.TangentSpaceNormals
                    },
                    new Sampler
                    {
                        Alias = "SAMPLER_SpecMap",
                        UsageRGB = Sampler.Usage.SpecColour,
                        UsageAlpha = Sampler.Usage.SpecPower
                    }
                }
            };

            var diff = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "DiffuseColour").FirstOrDefault();
            var norm = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Normal_Map").FirstOrDefault();
            var spec = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Spec_Map").FirstOrDefault();
            var cube = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "EnvironmentCube").FirstOrDefault();

            if (diff != null) { diffuse = diff.Attribute("FileName").Value; }
            if (norm != null) { normal = norm.Attribute("FileName").Value; }
            if (spec != null) { specular = spec.Attribute("FileName").Value; }
            if (cube != null) { cubeMap = cube.Attribute("FileName").Value; }
        }
Ejemplo n.º 17
0
        public override void FromXml(XElement albumXml)
        {
            // ReSharper disable PossibleNullReferenceException
            Name = albumXml.Element("name").Value;

            if (albumXml.Element("artist") != null)
            {
                ArtistName = albumXml.Element("artist").HasElements 
                    ? albumXml.Element("artist").Element("name").Value 
                    : albumXml.Element("artist").Value;
            }
                
            MusicBrainzId = albumXml.Element("mbid").Value;
            Url = new Uri(albumXml.Element("url").Value, UriKind.RelativeOrAbsolute);
            if (albumXml.Element("releasedate") != null
                && !string.IsNullOrEmpty(albumXml.Element("releasedate").Value))
                ReleaseDate = Convert.ToDateTime(albumXml.Element("releasedate").Value);

            string uriString = albumXml.Descendants("image")
                .First(descendant => descendant.Attribute("size").Value == "medium")
                .Value;
            if (!string.IsNullOrEmpty(uriString))
                Picture = new BitmapImage(new Uri(uriString));

            uriString = albumXml.Descendants("image")
                .First(descendant => descendant.Attribute("size").Value == "small")
                .Value;
            if (!string.IsNullOrEmpty(uriString))
                PictureSmall = new BitmapImage(new Uri(uriString));

            uriString = albumXml.Descendants("image")
                .LastOrDefault()
                .Value;
            if (!string.IsNullOrEmpty(uriString))
                PictureLarge = new BitmapImage(new Uri(uriString));

            Listeners = albumXml.Element("listeners") == null
                            ? 0
                            : Convert.ToInt32(albumXml.Element("listeners").Value);
            PlayCount = albumXml.Element("playcount") == null
                            ? 0
                            : Convert.ToInt32(albumXml.Element("playcount").Value);

            Wiki = new Biography(albumXml.Descendants("wiki").FirstOrDefault());

            var tags = albumXml.Descendants("tag");
            Tags = new List<Tag>(tags.Count());
            foreach (var tag in tags)
                Tags.Add(new Tag(tag));

            var tracks = albumXml.Descendants("track");
            Tracks = new List<Track>(tracks.Count());
            foreach (var track in tracks)
                Tracks.Add(new Track(track));

            // ReSharper restore PossibleNullReferenceException
        }
Ejemplo n.º 18
0
        private StackFrameFilterDefinition GenerateDefinition(XElement element)
        {
            var definition = new StackFrameFilterDefinition();
            definition.Order = int.Parse(element.Descendants().First(x => x.Name.LocalName == "Order").Value);
            definition.FilterType = ConvertToFilterType(element.Descendants().First(x => x.Name.LocalName == "Type").Value);
            definition.RegexFilterPattern = element.Descendants().First(x => x.Name.LocalName == "RegexPattern").Value;

            return definition;
        }
Ejemplo n.º 19
0
        public simple_spec_base(XElement xml)
            : base(xml)
        {
            var diff = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "DiffuseColour").FirstOrDefault();
            var spec = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Spec_Map").FirstOrDefault();

            if (diff != null) { diffuse = diff.Attribute("FileName").Value; }
            if (spec != null) { specular = spec.Attribute("FileName").Value; }
        }
Ejemplo n.º 20
0
 public static IBucket FromXml(XElement element, SharpGsClient connector)
 {
     var bucket = new Bucket(connector)
                      {
                          Name = element.Descendants("Name").First().Value,
                          CreationDate = DateTime.Parse(element.Descendants("CreationDate").First().Value)
                      };
     return bucket;
 }
Ejemplo n.º 21
0
        private static ChangeLogVersionDetails BuildChangeLogVersionDetails(XElement changeVersion)
        {
            var name = changeVersion.Attribute("Name").Value;
            var features = changeVersion.Descendants("Feature").Select(item => item.Value).ToList();
            var bugs = changeVersion.Descendants("Bug").Select(item => item.Value).ToList();
            var others = changeVersion.Descendants("Other").Select(item => item.Value).ToList();

            return new ChangeLogVersionDetails(name, features, bugs, others);
        }
Ejemplo n.º 22
0
 public static IOwner FromXml(XElement element, SharpGsClient connector)
 {
     if (element == null)
         return null;
     var owner = new Owner(connector);
     owner.ID = element.Descendants("ID").Select(o => o.Value).FirstOrDefault();
     owner.DisplayName = element.Descendants("DisplayName").Select(o => o.Value).FirstOrDefault();
     return owner;
 }
Ejemplo n.º 23
0
        public XsdFileGenerator()
        {
            this.template = LoadTemplateXSD();

            this.filtersGoHere = template.Descendants("filters-go-here").Single();
            this.typesGoHere = template.Descendants("types-go-here").Single();

            this.typesEmitted = new HashSet<string>();
        }
Ejemplo n.º 24
0
        public decal_base(XElement xml)
            : base(xml)
        {
            var diff = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "DiffuseColour").FirstOrDefault();
            var tile = xml.Descendants("Constant").Where(e => e.Attribute("Alias").Value == "TileSize").FirstOrDefault();

            if (diff != null) { diffuse = diff.Attribute("FileName").Value; }
            if (tile != null) { tileSize = ReadConstant(tile); }
        }
        public object Deserialize(XElement xml, Type targetType, bool elementNameMayContainTargetTypeName)
        {
            //# check NULL attribute
            var null_attrib = xml.Attribute(Options.NullValueAttributeName);
            if (null_attrib != null && null_attrib.Value != null && null_attrib.Value.ToLower() == "true")
            {
                return null;
            }

            //# check if has only one child with NULL attribute (i.e. wrapped element signifies null)
            if(xml.Descendants().Count() == 1)
            {
                var nullElementCandidate = xml.Descendants().Single();

                null_attrib = nullElementCandidate.Attribute(Options.NullValueAttributeName);
                if (null_attrib != null && null_attrib.Value != null && null_attrib.Value.ToLower() == "true")
                {
                    return null;
                }
            }

            //# try to derive member type from element name
            var suggestedMemberTypeName = xml.Name.LocalName;

            if (elementNameMayContainTargetTypeName && !string.Equals(suggestedMemberTypeName, targetType.Name))
            {
                //# try to find type with suggested name
                var typeCandidate = (Type)null;
                
                //# first look in KnownTypes map
                typeCandidate =
                        TypeResolver.ResolveTypes(
                        candidates: KnownTypes.GetValues(XName.Get(suggestedMemberTypeName)).EmptyIfNull(),
                        baseTypes: new Type[] { targetType }).FirstOrDefault();


                //# then try to find in loaded assemblies (slower than lookup)
                if (typeCandidate == null)
                {
                    typeCandidate =
                        TypeResolver.ResolveType(
                        suggestedMemberTypeName,
                        ignoreCase: true,
                        baseTypes: new Type[] { targetType });
                }

                if (typeCandidate != null)
                {
                    targetType = typeCandidate;
                }
            }

            var strategy = (IFlexiXmlTypeSerializationStrategy) GetTypeSerializationStrategy(targetType);

            return strategy.Deserialize(xml, targetType, this);
        }
 protected override IEnumerable<ActionConfiguration> Parse(XElement gooseConfigRootNode)
 {
     var workingDirectory = gooseConfigRootNode.Descendants("build-directory").SingleOrDefault();
     var command = gooseConfigRootNode.Descendants("compile-command").SingleOrDefault();
     return new[] { this.CreateCommandConfiguration(
                 trigger: "save",
                 glob: "*.less",
                 workingDirectory : workingDirectory == null ? null : workingDirectory.Value,
                 command: command == null ? null : command.Value)};
 }
        public override void Initialize(XElement configRoot)
        {
            var connectionStringElem = configRoot.Descendants("ConnectionString").FirstOrDefault();
            if (connectionStringElem == null) throw new Exception("Missing 'ConnectionString' element.");
            _connectionString = connectionStringElem.Value;

            var locationStringElem = configRoot.Descendants("BaseLocation").FirstOrDefault();
            if (locationStringElem == null) throw new Exception("Missing 'BaseLocation' element.");
            _baseLocation = locationStringElem.Value;
        }
Ejemplo n.º 28
0
		public TextReplaceElement (XElement XmlTextReplaceElement)
			{
			if (XmlTextReplaceElement == null)
				{
				From = "NeuFrom";
				To = "NeuTo";
				return;
				}
			From = XmlTextReplaceElement.Descendants("From").First().Value;
			To = XmlTextReplaceElement.Descendants("To").First().Value;
			}
Ejemplo n.º 29
0
        public car_shader_base(XElement xml)
            : base(xml)
        {
            var norm = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Normal_Map").FirstOrDefault();
            var deca = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Decals").FirstOrDefault();
            var decs = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "DecalsSpec").FirstOrDefault();

            if (norm != null) { normal = norm.Attribute("FileName").Value; }
            if (deca != null) { decal = deca.Attribute("FileName").Value; }
            if (decs != null) { decalSpec = decs.Attribute("FileName").Value; }
        }
        public vertex_norm_spec_env_base(XElement xml)
            : base(xml)
        {
            var diff = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "DiffuseColour").FirstOrDefault();
            var norm = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Normal_Map").FirstOrDefault();
            var spec = xml.Descendants("Texture").Where(e => e.Attribute("Alias").Value == "Spec_Map").FirstOrDefault();

            if (diff != null) { diffuse = diff.Attribute("FileName").Value; }
            if (norm != null) { normal = norm.Attribute("FileName").Value; }
            if (spec != null) { specular = spec.Attribute("FileName").Value; }
        }
Ejemplo n.º 31
0
    /// <summary>
    /// xmlのファイルパスから読み込む場合。
    /// </summary>
    private void LoadFromPath( string i_path )
    {
        try
        {
            System.Xml.Linq.XDocument xml   = System.Xml.Linq.XDocument.Load( i_path );
            System.Xml.Linq.XElement root   = xml.Root;

            // xmlデータをログに表示するよ。
            ShowData( root );

            // 名前を指定して検索する場合は、この関数を使おう!
            var titles = root.Descendants( "title" );
            if( titles != null )
            {
                foreach( var title in titles )
                {
                    string nameText     = title.Name.LocalName;
                    string valueText    = title.Value;
                    Debug.LogFormat( "name:{0}, value:{1}", nameText, valueText );
                }
            }
        }
        catch( System.Exception i_exception )
        {
            Debug.LogErrorFormat( "うーむ、このXML情報は読み込めなかったらしい。エラーの詳細を添付しておくよ。{0}", i_exception );
        }
    }
Ejemplo n.º 32
0
 protected override SendResult ParseResponseImp(System.Xml.Linq.XElement xml)
 {
     if (null != xml.Descendants("Mute").FirstOrDefault())
     {
         return(SendResult.Succcess);
     }
     else
     {
         return(SendResult.Empty);
     }
 }
Ejemplo n.º 33
0
        public void RemoveFromXml(System.Xml.Linq.XElement option)
        {
            var result = option.Descendants(key).ToArray();

            if (result.Count() > 0)
            {
                foreach (var item in result)
                {
                    item.Remove();
                }
            }
        }
Ejemplo n.º 34
0
        public void Deserialize(System.Xml.Linq.XElement node, XmlDeserializeContext context)
        {
            IEnumerable <XElement> nodes = node.Descendants("pvDesp");

            foreach (XElement item in nodes)
            {
                PropertyValidatorDescriptor pvDesp = new PropertyValidatorDescriptor();
                pvDesp.Deserialize(item, context);

                this.Add(pvDesp);
            }
        }
        public static void LoadFromXml(this Dictionary <string, List <string> > dic, System.Xml.Linq.XElement option, string nodeName, ref string pattern)
        {
            dic.Clear();

            if (option.Element(nodeName) == null && option.Element("ClassificationSet") != null)
            {
                nodeName = "ClassificationSet";
            }

            var result =
                (from item in option.Descendants(nodeName)
                 select item).FirstOrDefault();

            if (null == result)
            {
                return;
            }

            if (result.Element("Pattern") == null)
            {
                pattern = "(.*)";
            }
            else
            {
                pattern = result.Element("Pattern").Value;
            }

            if (result.Element("ClassificationItem") == null)
            {
                foreach (var node in result.Descendants("Set"))
                {
                    var lst = new List <string>();
                    dic[node.Attribute("Key").Value] = lst;
                    foreach (var subNode in node.Descendants("Value"))
                    {
                        lst.Add(subNode.Value);
                    }
                }
            }
            else
            {
                foreach (var node in result.Descendants("ClassificationItem"))
                {
                    var lst = new List <string>();
                    dic[node.Element("classifiedName").Value] = lst;
                    foreach (var subNode in node.Descendants("experimentName"))
                    {
                        lst.Add(subNode.Value);
                    }
                }
            }
        }
Ejemplo n.º 36
0
        //TODO: add a link for Trinity Configuration File Format Specification v1.
        /// <summary>
        /// Constructs a new configuration entry from an XML element.
        /// </summary>
        /// <param name="entry">The XML element.</param>
        public ConfigurationEntry(System.Xml.Linq.XElement entry) :
            this(entry.Name.LocalName)
        {
            foreach (var attribute in entry.Attributes())
            {
                m_settings.Add(attribute.Name.LocalName, new ConfigurationSetting(attribute));
            }

            foreach (var child in entry.Descendants())
            {
                m_children.Add(new ConfigurationEntry(child));
            }
        }
Ejemplo n.º 37
0
        private void readXML(string filename)
        {
            // Create and load the XML document.
            // XmlDocument doc = new XmlDocument();
            // doc.Load("xTree.xml");

            // Create an XmlNodeReader using the XML document.
            //XmlNodeReader nodeReader = new XmlNodeReader(doc);

            // Set the validation settings on the XmlReaderSettings object.
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.ValidationType          = ValidationType.Schema;
            settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
            xTree = new XElement("root", "");
            // Parse the XML file.
            try{
                xTree = XElement.Load(filename);
            } catch (Exception evt) {
                this.toolStripStatusLabel1.Text = evt.Message + "\nenthält keine XML Daten";
                return;
            }
            keineEingaben();            // alle Leave-Handler und hscrollbar deaktivieren
            this.toolStripStatusLabel1.Text = " xTree gelesen";
            sortEtappen();
            XElement lastelem = xTree.Descendants("etappe").Last();

            strID  = lastelem.Element("ID").Value;
            lastID = strID;
            XElement firstelem = xTree.Descendants().First();

            strID     = firstelem.Element("ID").Value;
            tbID.Text = strID;
            int i = int.Parse(strID);

            hScrollBar1.Value = i;
            btFirst_Click(null, null);
            alleEingaben(); // alle Leave-Handler und hscrollbar setzen
        }
Ejemplo n.º 38
0
        protected override void LoadAttributes(System.Xml.Linq.XElement element)
        {
            if (!element.Name.LocalName.Equals("text", StringComparison.InvariantCulture))
            {
                throw new InvalidOperationException("'text' element expected.");
            }

            //this.Text = element.Attribute("text").Value;
            var textElement = element.Descendants("text").FirstOrDefault();

            if (textElement != null)
            {
                this.Text = textElement.Value;
            }

            if (element.Attribute("color") != null)
            {
                this.Color = (Color)ColorConverter.ConvertFromString(element.Attribute("color").Value);
            }
        }
Ejemplo n.º 39
0
        private bool etappeExist(XElement etappe)
        {
// input would be your edited XML, this is just sample data to illustrate
            string thisID = etappe.Element("ID").Value;

            if (thisID != null && thisID != "")
            {
                itemsID = from record in xTree.Descendants("etappe")
                          where record.Element("ID").Value.Equals(thisID)
                          select record;
                int rWert = itemsID.Elements().Count();
                if (rWert > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 40
0
        public override bool ParseDefinition(System.Xml.Linq.XElement element)
        {
            bool result = base.ParseDefinition(element);

            // parsing of the namedValue
            var ListOfNamedValues = element.Descendants("NamedValue");

            foreach (var namedValueDefinition in ListOfNamedValues)
            {
                //create the NamedValue container
                int             namedValuePosition = int.Parse(namedValueDefinition.Attribute("Position").Value);
                OptionContainer opsContainer       = new OptionContainer();
                opsContainer.Name     = namedValueDefinition.Attribute("Name").Value;
                opsContainer.Position = namedValuePosition;
                // check for the length, if its '*' then set the max int else parse it
                if (namedValueDefinition.Attribute("Length").Value == "*")
                {
                    opsContainer.Length = int.MaxValue;
                }
                else
                {
                    opsContainer.Length = int.Parse(namedValueDefinition.Attribute("Length").Value);
                }
                //fill up the created container
                var listOfOptions = namedValueDefinition.Descendants("Options");
                foreach (var option in listOfOptions)
                {
                    opsContainer.insertOption(option.Value, option.Attribute("Name").Value);
                }

                // add the container to array of options
                ArrayOfOptions.Add(opsContainer.Position, opsContainer);
            }


            return(result);
        }
Ejemplo n.º 41
0
 internal static string getNodeAttribute(System.Xml.Linq.XElement xmlNode, string nodeName, string attributeName)
 {
     return(xmlNode.Descendants(nodeName).FirstOrDefault() == null ? "" : xmlNode.Descendants(nodeName).FirstOrDefault().Attribute(attributeName).Value);
 }
 /// <summary>
 /// Gets the first descendant node with the given name.
 /// This is necessary for the node retrieval because the various namespaces in feeds.
 /// </summary>
 /// <param name="parentNode">The parent node.</param>
 /// <param name="nodeName">The name of the selected descendant node.</param>
 public static XElement GetDescendantNodeByName(this XElement parentNode, string nodeName)
 {
     return(parentNode.Descendants().FirstOrDefault(node => node.Name.LocalName == nodeName));
 }
Ejemplo n.º 43
0
        public static string getSqlHTML(string sql, DMClient dmc)
        {
            string retValue   = null;
            bool   compressed = ((dmc.origUrl.Contains(".php") && dmc.origUrl.Contains("cc1")) || dmc.origUrl.ToLower().Contains("postgres")) ? false : true;

            QTIUtility.RequesterAsync rr = new QTIUtility.RequesterAsync(sql, dmc.origUrl, dmc.token, compressed);
            DataTable dt = rr.execute();

            if (dt.Columns.Contains("qdecode") || dt.Columns.Contains("QDECODE"))
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string data = QTIUtility.BbQuery.getStringFromData(dr["qdecode"].ToString());
                    System.Xml.Linq.XElement qd = System.Xml.Linq.XElement.Parse(data);
                    var qs = qd.Descendants(XName.Get("mat_formattedtext"));
                    if (qs.Count() > 0)
                    {
                        dr["qdecode"] = QTIUtility.Utilities.StripTags(qs.FirstOrDefault().Value);
                    }
                }
            }
            if (dt.Columns.Contains("qrscore") || dt.Columns.Contains("QRSCORE"))
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string data = QTIUtility.BbQuery.getStringFromData(dr["qrscore"].ToString());
                    System.Xml.Linq.XElement qd = System.Xml.Linq.XElement.Parse(data);
                    string sc = "";
                    var    qs = qd.Descendants(XName.Get("score_value"));
                    if (qs.Count() > 0)
                    {
                        foreach (string v in qs)
                        {
                            sc += ":" + v;
                        }
                    }
                    qs = qd.Descendants(XName.Get("score_maximum"));
                    if (qs.Count() > 0)
                    {
                        foreach (string v in qs)
                        {
                            sc += ":" + v;
                        }
                    }
                    dr["qrscore"] = sc.Substring(1);
                }
            }

            StringBuilder sb = new StringBuilder("<table style=\"font-family: Tahoma, Arial, sans-serif;font-size:12px\" >");

            sb.Append("<tr>");
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataColumn dc in dt.Columns)
                {
                    sb.Append("<th>" + dc.ColumnName + "</th>");
                }
                sb.Append("</tr>");
                foreach (DataRow dr in dt.Rows)
                {
                    sb.Append("<tr>");
                    foreach (DataColumn dc in dt.Columns)
                    {
                        sb.Append("<td>" + dr[dc].ToString() + "</td>");
                    }
                    sb.Append("</tr>");
                }
                sb.Append("</table>");
            }
            retValue = sb.ToString();
            return(retValue);
        }
Ejemplo n.º 44
0
 internal static string getNodeValueByAttribute(System.Xml.Linq.XElement xmlNode, string nodeName, string attributeName, string attributeNameValue)
 {
     return((from x in xmlNode.Descendants(nodeName) where x.Attribute(attributeName).Value == attributeNameValue select x.Value).FirstOrDefault());
 }
Ejemplo n.º 45
0
        internal void WriteFixedWidth(System.Xml.Linq.XElement CommandNode, DataTable Table, string outputStrmFilePath)
        {
            try
            {
                int StartAt = CommandNode.Attribute("StartAt") != null?int.Parse(CommandNode.Attribute("StartAt").Value) : 0;

                var positions = from c in CommandNode.Descendants("Position")
                                orderby int.Parse(c.Attribute("Start").Value) ascending
                                select new
                {
                    Name          = c.Attribute("Name").Value,
                    Start         = int.Parse(c.Attribute("Start").Value) - StartAt,
                    Length        = int.Parse(c.Attribute("Length").Value),
                    DefaultValue  = c.Attribute("DefaultValue") != null?c.Attribute("DefaultValue").Value : string.Empty, //optional,
                    Type          = c.Attribute("Type") != null?c.Attribute("Type").Value                 : string.Empty, //optional
                    ExistsInTable = Table.Columns.Contains(c.Attribute("Name").Value)
                };

                int lineLength = positions.Last().Start + positions.Last().Length;

                using (var stream = new StreamWriter(outputStrmFilePath, true))
                {
                    // Use stream
                    foreach (DataRow row in Table.Rows)
                    {
                        StringBuilder line = new StringBuilder(lineLength);
                        foreach (var p in positions)

                        {
                            //check if the column exists in the datatable
                            if (p.ExistsInTable)
                            {
                                if (!string.IsNullOrEmpty(p.DefaultValue))
                                {
                                    line.Insert(p.Start, (p.DefaultValue ?? "").ToString().PadRight(p.Length, ' '));
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(p.Type) && p.Type == "N" && !string.IsNullOrEmpty(row[p.Name].ToString()))
                                    {
                                        int    lengthallotted = p.Length - p.Start;
                                        string withzeroes     = string.Empty;
                                        //check if the data is decimal, remove the decimal
                                        //padd zeroes to the right
                                        if (row[p.Name].ToString().Contains("."))
                                        {
                                            string decimalremoved = row[p.Name].ToString().Replace(".", string.Empty);
                                            withzeroes = string.Empty.PadLeft(lengthallotted - decimalremoved.Length, '0') + decimalremoved.ToString();
                                            line.Insert(p.Start, withzeroes);
                                        }
                                        else
                                        {
                                            withzeroes = lengthallotted > row[p.Name].ToString().Length ? string.Empty.PadLeft(lengthallotted - row[p.Name].ToString().Length, '0') + row[p.Name].ToString() : row[p.Name].ToString();
                                            //withzeroes = string.Empty.PadLeft(lengthallotted - row[p.Name].ToString().Length, '0') + row[p.Name].ToString();
                                            line.Insert(p.Start, withzeroes);
                                        }
                                    }
                                    else
                                    {
                                        line.Insert(p.Start, (row[p.Name] ?? "").ToString().PadRight(p.Length, ' '));
                                    }
                                }
                            }
                            else
                            {
                                //log an error and exit
                                _logger.LogError("Error while generating POAPL file. Column name mismatch for--{column}", p.Name);
                                break;
                            }
                        }
                        stream.WriteLine(line.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("Method Name -- WriteFixedWidth: {Reason}", ex.Message);
            }
        }
        private void WriteFixedWidth(System.Xml.Linq.XElement CommandNode, DataTable Table, string outputStrmFilePath)
        {
            try {
                int StartAt = CommandNode.Attribute("StartAt") != null?int.Parse(CommandNode.Attribute("StartAt").Value) : 0;

                var positions = from c in CommandNode.Descendants("Position")
                                orderby int.Parse(c.Attribute("Start").Value) ascending
                                select new
                {
                    Name          = c.Attribute("Name").Value,
                    Start         = int.Parse(c.Attribute("Start").Value) - StartAt,
                    Length        = int.Parse(c.Attribute("Length").Value),
                    DefaultValue  = c.Attribute("DefaultValue") != null?c.Attribute("DefaultValue").Value : string.Empty, //optional
                    Type          = c.Attribute("Type") != null?c.Attribute("Type").Value                 : string.Empty, //optional
                    ExistsInTable = Table.Columns.Contains(c.Attribute("Name").Value)
                };

                int lineLength = positions.Last().Start + positions.Last().Length;

                using (var stream = new StreamWriter(outputStrmFilePath, true))
                {
                    foreach (DataRow row in Table.Rows)
                    {
                        StringBuilder line = new StringBuilder(lineLength);
                        foreach (var p in positions)
                        {
                            //check if the column exists in the datatable
                            string rowData = string.Empty;
                            if (p.ExistsInTable)
                            {
                                if (!string.IsNullOrEmpty(p.Type) && p.Type == "N" && !string.IsNullOrEmpty(row[p.Name].ToString()))
                                {
                                    int    lengthAllotted = p.Length - p.Start;
                                    string withzeroes     = string.Empty;
                                    //check if the data is decimal, remove the decimal and padd zeroes to the right
                                    if (row[p.Name].ToString().Contains("."))
                                    {
                                        string decimalremoved = row[p.Name].ToString();
                                        withzeroes = string.Empty.PadLeft(lengthAllotted - decimalremoved.Length, '0') + decimalremoved.ToString();
                                    }
                                    else
                                    {
                                        withzeroes = lengthAllotted > row[p.Name].ToString().Length ? string.Empty.PadLeft(lengthAllotted - row[p.Name].ToString().Length, '0') + row[p.Name].ToString() : row[p.Name].ToString();
                                    }
                                    line.Append(withzeroes).Append("\t");
                                }
                                else
                                {
                                    rowData = row[p.Name] != null?Convert.ToString(row[p.Name]) : "";

                                    int dataLength = (p.Length - p.Start) > rowData.Length ? rowData.Length : (p.Length - p.Start);
                                    line.Append(rowData.Substring(0, dataLength)).Append("\t");
                                }
                            }
                            else
                            {
                                line.Append(rowData).Append("\t");
                                _logger.LogError("Error while generating POFineLine file---Column name mismatch--{column} - " + p.Name);
                                break;
                            }
                        }
                        stream.WriteLine(line.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("Method Name -- WriteFixedWidth: {Reason}", ex.Message);
            }
        }