Example #1
0
        public Property(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // Key
            XPathNavigator navigatorKey = navigator.SelectSingleNode("Key");
            if (navigatorKey != null) {
                this._key = navigatorKey.Value;
            }

            // Type & Value
            XPathNavigator navigatorValue = navigator.SelectSingleNode("Value");
            if (navigatorValue == null) {
                // Set VALUE to null if the node does not exist
                this._value = null;
            }
            else {
                // Type
                this._type = navigatorValue.GetAttribute(Xml._TYPE, Xml.XMLSCHEMAINSTANCE);

                // Value
                if (this._type == "esri:XMLPersistedObject") {
                    XPathNavigator navigatorBytes = navigatorValue.SelectSingleNode("Bytes");
                    if (navigatorBytes != null) {
                        this._value = navigatorBytes.Value;
                    }
                }
                else {
                    this._value = navigatorValue.Value;
                }
            }
        }
        public GeometricNetworkControllerMembership(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <GeometricNetworkName>Empty_Net</GeometricNetworkName> 
            XPathNavigator navigatorGeometricNetworkName = navigator.SelectSingleNode("GeometricNetworkName");
            if (navigatorGeometricNetworkName != null) {
                this._geometricNetworkName = navigatorGeometricNetworkName.Value;
            }

            // <EnabledFieldName>Enabled</EnabledFieldName> 
            XPathNavigator navigatorEnabledFieldName = navigator.SelectSingleNode("EnabledFieldName");
            if (navigatorEnabledFieldName != null) {
                this._enabledFieldName = navigatorEnabledFieldName.Value;
            }

            // <AncillaryRoleFieldName /> 
            XPathNavigator navigatorAncillaryRoleFieldName = navigator.SelectSingleNode("AncillaryRoleFieldName");
            if (navigatorAncillaryRoleFieldName != null) {
                this._ancillaryRoleFieldName = navigatorAncillaryRoleFieldName.Value;
            }

            // <NetworkClassAncillaryRole>esriNCARNone</NetworkClassAncillaryRole> 
            XPathNavigator navigatorNetworkClassAncillaryRole = navigator.SelectSingleNode("NetworkClassAncillaryRole");
            if (navigatorNetworkClassAncillaryRole != null) {
                this._networkClassAncillaryRole = (esriNetworkClassAncillaryRole)Enum.Parse(typeof(esriNetworkClassAncillaryRole), navigatorNetworkClassAncillaryRole.Value, true);
            }
        }
        public SubtypeField(IXPathNavigable path) : base(path) {
            XPathNavigator navigator = path.CreateNavigator();

            // <FieldName></FieldName>
            XPathNavigator navigatorFieldName = navigator.SelectSingleNode("FieldName");
            if (navigatorFieldName != null) {
                this._fieldName = navigatorFieldName.Value;
            }

            // <DomainName></DomainName>
            XPathNavigator navigatorDomainName = navigator.SelectSingleNode("DomainName");
            if (navigatorDomainName != null) {
                this._domainName = navigatorDomainName.Value;
            }

            // <DefaultValue></DefaultValue>
            XPathNavigator navigatorDefaultValue = navigator.SelectSingleNode("DefaultValue");
            if (navigatorDefaultValue != null) {
                this._defaultValue = navigatorDefaultValue.Value;
            }

            // Initialize
            this.UpdateText();

            // Set Element Properties
            this.Image = new Crainiate.ERM4.Image("Resource.publicfield.gif", "Crainiate.ERM4.Component");
        }
Example #4
0
		public static XmlEquivalent To(IXPathNavigable source)
		{
			if (source == null)
				throw new ArgumentNullException("source");

			return XmlEquivalent.To(GetElement(source));
		}
        private void setupTabs(IXPathNavigable data) {

            GraphSetupTabPage graphSetupTabPage = null;
            TabPage tabPage = null;
            for (int i = 0; i < tabCount; i++) {

                // graphSetupTabPage            
                graphSetupTabPage = new GraphSetupTabPage(i, data);
                graphSetupTabPage.Location = new System.Drawing.Point(-4, 0);
                graphSetupTabPage.Name = "graphSetupTabPage" + i;
                graphSetupTabPage.Size = new System.Drawing.Size(332, 200);
                graphSetupTabPage.ActivateEvent += 
                    new GraphSetupTabPage.EventHandler(this.graphSetupTabPage_ActivateEvent);
                if (i > 0) //enable only the first tab
                    graphSetupTabPage.Enabled = false;

                // tabPage1
                tabPage = new TabPage("Graph " + (i + 1));
                tabPage.Controls.Add(graphSetupTabPage);
                tabPage.Location = new System.Drawing.Point(4, 22);
                tabPage.Name = "tabPage" + i;
                tabPage.Padding = new System.Windows.Forms.Padding(3);
                tabPage.Size = new System.Drawing.Size(324, 193);
                tabPage.TabIndex = i;
                tabPage.UseVisualStyleBackColor = true;

                this.graphPanel.Controls.Add(tabPage);
            }
        }
Example #6
0
        /// <summary>
        /// The preferred way to save - this should be a <see cref="System.Xml.XmlDocument" /> straight from CCP.
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <param name="xdoc">The xml to save.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        public static async Task SaveAsync(string filename, IXPathNavigable xdoc)
        {
            xdoc.ThrowIfNull(nameof(xdoc));

            EveMonClient.EnsureCacheDirInit();

            XmlDocument xmlDoc = (XmlDocument)xdoc;
            XmlNode characterNode = xmlDoc.SelectSingleNode("//name");
            filename = characterNode?.InnerText ?? filename;

            // Writes in the target file
            string fileName = Path.Combine(EveMonClient.EVEMonXmlCacheDir, $"{filename}.xml");
            string content = Util.GetXmlStringRepresentation(xdoc);
            await FileHelper.OverwriteOrWarnTheUserAsync(fileName,
                async fs =>
                {
                    using (StreamWriter writer = new StreamWriter(fs, Encoding.UTF8))
                    {
                        await writer.WriteAsync(content);
                        await writer.FlushAsync();
                        await fs.FlushAsync();
                    }
                    return true;
                });
        }
Example #7
0
		public static void AreXmlEquivalent(string expected, IXPathNavigable actual)
		{
			if (expected == null) throw new ArgumentNullException("expected");
			if (actual == null) throw new ArgumentNullException("actual");

			AreXmlEquivalent(GetElement(expected), GetElement(actual));
		}
Example #8
0
        public Index(IXPathNavigable path): base(path) {
            // Suspend Events
            this.SuspendEvents = true;

            // Get Naviagator
            XPathNavigator navigator = path.CreateNavigator();

            // <Name></Name>
            XPathNavigator navigatorIndexName = navigator.SelectSingleNode("Name");
            if (navigatorIndexName != null) {
                this._name = navigatorIndexName.Value;
            }

            // <IsUnique></IsUnique>
            XPathNavigator navigatorIsUnique = navigator.SelectSingleNode("IsUnique");
            if (navigatorIsUnique != null) {
                this._isUnique = navigatorIsUnique.ValueAsBoolean;
            }

            // <IsAscending></IsAscending>
            XPathNavigator navigatorIsAscending = navigator.SelectSingleNode("IsAscending");
            if (navigatorIsAscending != null) {
                this._isAscending = navigatorIsAscending.ValueAsBoolean;
            }

            // Initialize Text
            this.UpdateText();

            // Collapse group
            this.Expanded = false;

            // Resume Events
            this.SuspendEvents = false;
        }
        //
        // CONSTRUCTOR
        //
        //public EdgeFeatureSource() : base() { }
        public EdgeFeatureSource(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <FromElevationFieldName>
            XPathNavigator navigatorFromElevationFieldName = navigator.SelectSingleNode("FromElevationFieldName");
            if (navigatorFromElevationFieldName != null) {
                this._fromElevationFieldName = navigatorFromElevationFieldName.Value;
            }

            // <ToElevationFieldName>
            XPathNavigator navigatorToElevationFieldName = navigator.SelectSingleNode("ToElevationFieldName");
            if (navigatorToElevationFieldName != null) {
                this._toElevationFieldName = navigatorToElevationFieldName.Value;
            }

            // <Connectivity><PropertyArray><PropertySetProperty>
            this._connectivity = new List<Property>();
            XPathNodeIterator interatorProperty = navigator.Select("Connectivity/PropertyArray/PropertySetProperty");
            while (interatorProperty.MoveNext()) {
                // Get <Property>
                XPathNavigator navigatorProperty = interatorProperty.Current;

                // Add Property
                Property property = new Property(navigatorProperty);
                this._connectivity.Add(property);
            }
        }
        public TopologyControllerMembership(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <TopologyName>Landbase_Topology</TopologyName> 
            XPathNavigator navigatorTopologyName = navigator.SelectSingleNode("TopologyName");
            if (navigatorTopologyName != null) {
                this._topologyName = navigatorTopologyName.Value;
            }

            //    <Weight>5</Weight> 
            XPathNavigator navigatorWeight = navigator.SelectSingleNode("Weight");
            if (navigatorWeight != null) {
                this._weight = navigatorWeight.ValueAsInt;
            }

            //    <XYRank>1</XYRank> 
            XPathNavigator navigatorXYRank = navigator.SelectSingleNode("XYRank");
            if (navigatorXYRank != null) {
                this._xyRank = navigatorXYRank.ValueAsInt;
            }

            //    <ZRank>1</ZRank> 
            XPathNavigator navigatorZRank = navigator.SelectSingleNode("ZRank");
            if (navigatorZRank != null) {
                this._zRank = navigatorZRank.ValueAsInt;
            }

            //    <EventNotificationOnValidate>false</EventNotificationOnValidate> 
            XPathNavigator navigatorEventNotificationOnValidate = navigator.SelectSingleNode("EventNotificationOnValidate");
            if (navigatorEventNotificationOnValidate != null) {
                this._eventNotificationOnValidate = navigatorEventNotificationOnValidate.ValueAsBoolean;
            }
        }
Example #11
0
        public RasterDef(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <Description></Description>
            XPathNavigator navigatorDescription = navigator.SelectSingleNode("Description");
            if (navigatorDescription != null) {
                this._description = navigatorDescription.Value;
            }

            // <IsByRef></IsByRef>
            XPathNavigator navigatorIsByRef = navigator.SelectSingleNode("IsByRef");
            if (navigatorIsByRef != null) {
                this._isByRef = navigatorIsByRef.ValueAsBoolean;
            }

            // <SpatialReference></SpatialReference>
            XPathNavigator navigatorSpatialReference = navigator.SelectSingleNode("SpatialReference");
            if (navigatorSpatialReference != null) {
                this._spatialReference = new SpatialReference(navigatorSpatialReference);
            }
            else {
                this._spatialReference = new SpatialReference();
            }
        }
Example #12
0
        public NetWeight(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <WeightID>0</WeightID> 
            XPathNavigator navigatorWeightID = navigator.SelectSingleNode("WeightID");
            if (navigatorWeightID != null) {
                this._weightID = navigatorWeightID.ValueAsInt;
            }

            // <WeightName>MMElectricTraceWeight</WeightName> 
            XPathNavigator navigatorWeightName = navigator.SelectSingleNode("WeightName");
            if (navigatorWeightName != null) {
                this._weightName = navigatorWeightName.Value;
            }

            // <WeightType>esriWTInteger</WeightType> 
            XPathNavigator navigatorWeightType = navigator.SelectSingleNode("WeightType");
            if (navigatorWeightType != null) {
                this._weightType = (esriWeightType)Enum.Parse(typeof(esriWeightType), navigatorWeightType.Value, true);
            }

            // <BitGateSize>0</BitGateSize> 
            XPathNavigator navigatorBitGateSize = navigator.SelectSingleNode("BitGateSize");
            if (navigatorBitGateSize != null) {
                this._bitGateSize = navigatorBitGateSize.ValueAsInt;
            }
        }
		public void Transform( IXPathNavigable xpnav, TextWriter writer )
		{
			// NOTE: Not compatable with .NET 1.0.
			// xslTransform.Transform(xpnav, null, writer, null);

			xslTransform.Transform(xpnav, null, writer);
		}
        public NetworkAttributeParameter(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <Name>
            XPathNavigator navigatorName = navigator.SelectSingleNode("Name");
            if (navigatorName != null) {
                this._name = navigatorName.Value;
            }

            // <VarType>
            XPathNavigator navigatorVarType = navigator.SelectSingleNode("VarType");
            if (navigatorVarType != null) {
                this._varType = navigatorVarType.ValueAsInt;
            }

            // <Value>
            XPathNavigator navigatorValue = navigator.SelectSingleNode("Value");
            if (navigatorValue != null) {
                this._value = navigatorValue.Value;
            }

            // <DefaultValue>
            XPathNavigator navigatorDefaultValue = navigator.SelectSingleNode("DefaultValue");
            if (navigatorDefaultValue != null) {
                this._defaultValue = navigatorDefaultValue.Value;
            }
        }
        public Domain.ErrorCode Validate(IXPathNavigable configSectionNode)
        {
            log.Debug("Validating the configuration");

            lock (syncLock)
            {
                try
                {
                    isValid = true;

                    //TODO: is there a better way to do this?
                    var navigator = configSectionNode.CreateNavigator();
                    var doc = new XmlDocument();
                    doc.LoadXml(navigator.OuterXml);
                    doc.Schemas.Add(Schema);
                    doc.Validate(ValidationCallback);

                    if (isValid)
                    {
                        log.Debug("The configuration is valid");
                    }
                    else
                    {
                        log.Error("The configuration is invalid");
                    }
                }
                catch (XmlException ex)
                {
                    log.Error("An error occurred when validating the configuration", ex);
                    isValid = false;
                }

                return isValid ? Domain.ErrorCode.Ok : Domain.ErrorCode.InvalidConfig;
            }
        }
        public PolicyResponseSummary(string xmlPath)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(xmlPath);

            m_xmlWrapper = xmlDoc as IXPathNavigable;
        }
        //
        // CONSTRUCTOR
        //
        //public NetworkSourceDirections() : base() { }
        public NetworkSourceDirections(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <AdminAreaFieldName>
            XPathNavigator navigatorAdminAreaFieldName = navigator.SelectSingleNode("AdminAreaFieldName");
            if (navigatorAdminAreaFieldName != null) {
                this._adminAreaFieldName = navigatorAdminAreaFieldName.Value;
            }

            // <Shields>
            XPathNavigator navigatorShields = navigator.SelectSingleNode("Shields");
            if (navigatorShields != null) {
                this._shields = new Shields(navigatorShields);
            }
            else {
                this._shields = new Shields();
            }

            // <StreetNameFields><StreetNameFields>
            this._streetNameFields = new List<StreetNameFields>();
            XPathNodeIterator interatorStreetNameFields = navigator.Select("StreetNameFields/StreetNameFields");
            while (interatorStreetNameFields.MoveNext()) {
                // Get <StreetNameFields>
                XPathNavigator navigatorStreetNameFields = interatorStreetNameFields.Current;

                // Add StreetNameFields
                StreetNameFields streetNameFields = new StreetNameFields(navigatorStreetNameFields);
                this._streetNameFields.Add(streetNameFields);
            }
        }
        public TerrainPyramid(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            //<PyramidLevelStatus>1</PyramidLevelStatus> 
            XPathNavigator navigatorPyramidLevelStatus = navigator.SelectSingleNode("PyramidLevelStatus");
            if (navigatorPyramidLevelStatus != null) {
                this._pyramidLevelStatus = (TerrainElementStatus)Enum.Parse(typeof(TerrainElementStatus), navigatorPyramidLevelStatus.Value, true);
            }

            //<PointCount>-1</PointCount> 
            XPathNavigator navigatorPointCount = navigator.SelectSingleNode("PointCount");
            if (navigatorPointCount != null) {
                this._pointCount = navigatorPointCount.ValueAsInt;
            }

            //<MaxScale>1000</MaxScale> 
            XPathNavigator navigatorMaxScale = navigator.SelectSingleNode("MaxScale");
            if (navigatorMaxScale != null) {
                this._maxScale = navigatorMaxScale.ValueAsInt;
            }

            //<Resolution>2</Resolution> 
            XPathNavigator navigatorSourceStatus = navigator.SelectSingleNode("Resolution");
            if (navigatorSourceStatus != null) {
                this._resolution = navigatorSourceStatus.ValueAsDouble;
            }
        }
Example #19
0
        public IResourceActions ReadXml(IXPathNavigable idoc)
        {
            // Basic check on the input
            if (idoc == null)
            {
				Logger.LogError("XmlResourceReader.ReadXml: null XmlDoc input");
                throw new ApplicationException(Properties.Resources.COULD_NOT_READ_RESOURCES);
            }

            XPathNavigator doc = idoc.CreateNavigator();
            XPathNavigator rootNode = doc.SelectSingleNode(@"PolicySetResources");
            if (rootNode == null)
            {
                XmlNode node = new XmlDocument().CreateElement("PolicySetResources");                
                rootNode = node.CreateNavigator();
                doc.AppendChild(rootNode);
            }

            // Check if the document contains an actions node
            XPathNavigator actionsNode = rootNode.SelectSingleNode(@"Actions");
            if (actionsNode == null)
            {
                // No actions already defined in the resources so nothing to read
                // Return an empty collection of resource actions
                return new ResourceActions();
            }

            return ReadActions(actionsNode);
        }
Example #20
0
 public Feed(IXPathNavigable navigable)
 {
     navigator = navigable.CreateNavigator();
     manager = new XmlNamespaceManager(navigator.NameTable);
     manager.AddNamespace("f", "http://hl7.org/fhir");
     manager.AddNamespace("atom", "http://www.w3.org/2005/Atom");
 }
Example #21
0
        //
        // CONSTRUCTOR
        //
        public Subtype(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <SubtypeName>
            XPathNavigator navigatorSubtypeName = navigator.SelectSingleNode("SubtypeName");
            if (navigatorSubtypeName != null) {
                this._subtypeName = navigatorSubtypeName.Value;
            }

            // <SubtypeCode>
            XPathNavigator navigatorSubtypeCode = navigator.SelectSingleNode("SubtypeCode");
            if (navigatorSubtypeCode != null) {
                this._subtypeCode = navigatorSubtypeCode.ValueAsInt;
            }

            // <FieldInfos><SubtypeFieldInfo>
            XPathNodeIterator interatorSubtypeFieldInfo = navigator.Select("FieldInfos/SubtypeFieldInfo");
            while (interatorSubtypeFieldInfo.MoveNext()) {
                // Create Field
                XPathNavigator navigatorSubtypeFieldInfo = interatorSubtypeFieldInfo.Current;
                SubtypeField subtypeField = new SubtypeField(navigatorSubtypeFieldInfo);

                // Add Field To Group
                this.Rows.Add(subtypeField);
            }

            // Refresh
            this.Refresh();
        }
        //
        // CONSTRUCTOR
        //
        public DomainRange(IXPathNavigable path): base(path) {
            //
            XPathNavigator navigator = path.CreateNavigator();

            // Add Min/Max Row
            DomainRangeRow row = new DomainRangeRow(navigator);
            this.Rows.Add(row);
        }
Example #23
0
 /// <summary>
 /// Persists the license document to local storage.
 /// </summary>
 /// <param name="licenseDocument">The license document to store.</param>
 public void Save(IXPathNavigable licenseDocument)
 {
     if (licenseDocument == null)
     {
         throw new ArgumentNullException("licenseDocument");
     }
     ((XmlDocument)licenseDocument).Save(_path);
 }
Example #24
0
 /// <summary>
 /// Factory method for creating new instances of AuthorizationMap.
 /// </summary>
 /// <param name="xmlDocument">The XML document.</param>
 /// <returns></returns>
 public static AuthorizationMap FromXml(IXPathNavigable xmlDocument)
 {
     var map = new AuthorizationMap();
     XmlElement root = ((XmlDocument)xmlDocument).DocumentElement;
     map.AddAuthorizationsFromXml(root, "/Authorizations/WebParts/WebPart", "className");
     map.AddAuthorizationsFromXml(root, "/Authorizations/NamedBehaviors/NamedBehavior", "name");
     return map;
 }
        public FormAddNode(IXPathNavigable node, Office.CustomXMLPart part)
        {
            InitializeComponent();

            //set up state
            m_xn = node as XmlNode;
            m_cxp = part;
        }
Example #26
0
 private async Task TransformAsync(IRequestContext context, IXPathNavigable xml)
 {
     using (var writer = context.Response.GetStreamWriter())
     using (var xWriter = new XmlTextWriter(writer)) {
         Xslt.Transform(xml, XsltArgs ?? new XsltArgumentList(), xWriter);
         await xWriter.FlushAsync();
     }
 }
 public void Load(IXPathNavigable stylesheet, XmlResolver resolver)
 {
     if (stylesheet == null)
     {
         throw new ArgumentNullException(nameof(stylesheet));
     }
     Load(stylesheet.CreateNavigator(), resolver);
 }
Example #28
0
 public XPathDataRow(XPathDataRowRule rule, IXPathNavigable row, Uri uri, int rowIndex, int pageIndex)
 {
     this.rule = rule;
       this.row = row;
       this.PageUri = uri;
       this.RowIndex = rowIndex;
       this.PageIndex = pageIndex;
 }
Example #29
0
 /// <summary>
 /// Determines if the XmlDocument has a valid signature.
 /// </summary>
 /// <param name="xmlDocument">The XmlDocument to check.</param>
 /// <returns>True if the document has a valid signature.</returns>
 public bool HasValidSignature(IXPathNavigable xmlDocument)
 {
     var signedXml = ExtractSignature(xmlDocument as XmlDocument);
     using (var key = GetPublicKeyAlgorithm())
     {
         return signedXml.CheckSignature(key);
     }
 }
Example #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReBugContext"/> class.
        /// </summary>
        /// <param name="bug">The bug.</param>
        protected ReBugContext(IXPathNavigable bug)
        {
            XPathNavigator xml = bug.CreateNavigator();
            _QueryString = HttpValueCollection.CreateCollectionFromXmlNode(xml.SelectSingleNode("/bugx/queryString"));

            _Form = HttpValueCollection.CreateCollectionFromXmlNode(xml.SelectSingleNode("/bugx/form"));

            XPathNavigator cookie = xml.SelectSingleNode("/bugx/headers/Cookie");
            if (cookie != null)
            {
                _Cookies = HttpValueCollection.CreateCollectionFromCookieHeader(cookie.Value);
            }
            _Headers = HttpValueCollection.CreateCollectionFromXmlNode(xml.SelectSingleNode("/bugx/headers"));

            _Session = FillNameValue(xml.Select("/bugx/sessionVariables/add"));
            _Cache = FillNameValue(xml.Select("/bugx/cacheVariables/add"));
            _Application = FillNameValue(xml.Select("/bugx/applicationVariables/add"));
            _Context = FillHashtable(xml.Select("/bugx/contextVariables/add"));

            XPathNavigator exception = xml.SelectSingleNode("/bugx/exception");
            if (exception != null)
            {
                try
                {
                    _Exception = (Exception)BugSerializer.Deserialize(exception.Value);
                }catch(SerializationException){}
            }
            XPathNavigator url = xml.SelectSingleNode("/bugx/url");
            if (url != null)
            {
                _Url = new Uri(url.Value);
            }
            XPathNavigator pathInfo = xml.SelectSingleNode("/bugx/pathInfo");
            if (pathInfo != null)
            {
                _PathInfo = pathInfo.Value;
            }
            XPathNavigator machineName = xml.SelectSingleNode("/bugx/machineName");
            if (machineName != null)
            {
                _MachineName = machineName.Value;
            }
            XPathNavigator scriptTimeout = xml.SelectSingleNode("/bugx/scriptTimeout");
            if (scriptTimeout != null)
            {
                _ScriptTimeout = Convert.ToInt32(scriptTimeout.Value, CultureInfo.InvariantCulture);
            }
            XPathNavigator user = xml.SelectSingleNode("/bugx/user");
            if (user != null)
            {
                try
                {
                    _User = (IPrincipal)BugSerializer.Deserialize(user.Value);
                }
                catch(SerializationException){}
                catch(TargetInvocationException){}
            }
        }
Example #31
0
      public static XdmNode ToXdmNode(this IXPathNavigable value, SaxonItemFactory itemFactory) {

         if (value == null) throw new ArgumentNullException("value");

         return ToXdmNode(value.CreateNavigator(), itemFactory);
      }
Example #32
0
        protected object ProcessResult(object value)
        {
            if (value is string)
            {
                return(value);
            }
            if (value is double)
            {
                return(value);
            }
            if (value is bool)
            {
                return(value);
            }
            if (value is XPathNavigator)
            {
                return(value);
            }
            if (value is int)
            {
                return((double)(int)value);
            }

            if (value == null)
            {
                _queryIterator = XPathEmptyIterator.Instance;
                return(this); // We map null to NodeSet to let $null/foo work well.
            }

            ResetableIterator resetable = value as ResetableIterator;

            if (resetable != null)
            {
                // We need Clone() value because variable may be used several times
                // and they shouldn't
                _queryIterator = (ResetableIterator)resetable.Clone();
                return(this);
            }
            XPathNodeIterator nodeIterator = value as XPathNodeIterator;

            if (nodeIterator != null)
            {
                _queryIterator = new XPathArrayIterator(nodeIterator);
                return(this);
            }
            IXPathNavigable navigable = value as IXPathNavigable;

            if (navigable != null)
            {
                return(navigable.CreateNavigator());
            }

            if (value is short)
            {
                return((double)(short)value);
            }
            if (value is long)
            {
                return((double)(long)value);
            }
            if (value is uint)
            {
                return((double)(uint)value);
            }
            if (value is ushort)
            {
                return((double)(ushort)value);
            }
            if (value is ulong)
            {
                return((double)(ulong)value);
            }
            if (value is float)
            {
                return((double)(float)value);
            }
            if (value is decimal)
            {
                return((double)(decimal)value);
            }
            return(value.ToString());
        }
Example #33
0
 /// <summary>
 /// Initializes a new instance of the class from the specified XML node.
 /// </summary>
 /// <param name="node">The XML node to initialize from.</param>
 /// <param name="builtIn">The value indicating whether the element is built-in.</param>
 public ActionElement(IXPathNavigable node, bool builtIn)
     : base(node)
 {
     m_BuiltIn = builtIn;
 }
Example #34
0
        public static IList <XmlScheme> GetXmlTree(IXPathNavigable inputNode, int loopdeep, int outdeep, string xpath, int outype, int stat)
        {
            IList <XmlScheme> list = new List <XmlScheme>();

            if ((outdeep == 0) || (outdeep > 100))
            {
                outdeep = 100;
            }
            if (loopdeep < outdeep)
            {
                System.Xml.XmlNode node = (System.Xml.XmlNode)inputNode;
                int num = loopdeep;
                num++;
                XmlScheme item = new XmlScheme();
                item.Level   = loopdeep;
                item.Station = stat;
                item.Path    = xpath;
                item.Name    = node.Name;
                item.Text    = node.InnerText;
                if (!node.HasChildNodes)
                {
                    item.Type = "onlyone";
                    list.Add(item);
                    return(list);
                }
                XmlNodeList childNodes           = node.ChildNodes;
                IList <System.Xml.XmlNode> list3 = new List <System.Xml.XmlNode>();
                bool flag = false;
                foreach (System.Xml.XmlNode node2 in childNodes)
                {
                    if (string.Compare(node2.GetType().Name, "XmlElement", StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        continue;
                    }
                    flag = true;
                    bool flag2 = false;
                    if (outype > 0)
                    {
                        foreach (System.Xml.XmlNode node3 in list3)
                        {
                            if (string.Compare(node3.Name, node2.Name, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                XmlElement element = (XmlElement)node3;
                                element.SetAttribute("pe_tempshownum", (Convert.ToInt32(element.GetAttribute("pe_tempshownum")) + 1).ToString());
                                flag2 = true;
                            }
                        }
                    }
                    if (!flag2)
                    {
                        ((XmlElement)node2).SetAttribute("pe_tempshownum", "1");
                        list3.Add(node2);
                    }
                }
                if (flag)
                {
                    item.Type = "havechile";
                }
                else
                {
                    item.Type = "nochile";
                }
                XmlElement element3 = (XmlElement)node;
                if (element3.HasAttribute("pe_tempshownum"))
                {
                    item.Repnum = Convert.ToInt32(element3.GetAttribute("pe_tempshownum").ToString());
                }
                list.Add(item);
                foreach (System.Xml.XmlNode node4 in list3)
                {
                    int num3 = 0;
                    if (list3.IndexOf(node4) == 0)
                    {
                        num3 = 1;
                    }
                    else if (list3.IndexOf(node4) == (list3.Count - 1))
                    {
                        num3 = 2;
                    }
                    if (string.Compare(node4.Name, "#text", StringComparison.OrdinalIgnoreCase) > 0)
                    {
                        string str = xpath + "/" + node.Name;
                        foreach (XmlScheme scheme2 in GetXmlTree(node4, num, outdeep, str, outype, num3))
                        {
                            list.Add(scheme2);
                        }
                        continue;
                    }
                }
            }
            return(list);
        }
Example #35
0
 // SxS: This method does not take any resource name and does not expose any resources to the caller.
 // It's OK to suppress the SxS warning.
 public void Load(IXPathNavigable stylesheet)
 {
     Reset();
     LoadInternal(stylesheet, XsltSettings.Default, CreateDefaultResolver());
 }
        protected object ProcessResult(object value)
        {
            if (value is string)
            {
                return(value);
            }
            if (value is double)
            {
                return(value);
            }
            if (value is bool)
            {
                return(value);
            }
            if (value is XPathNavigator)
            {
                return(value);
            }
            if (value is Int32)
            {
                return((double)(Int32)value);
            }

            if (value == null)
            {
                queryIterator = XPathEmptyIterator.Instance;
                return(this); // We map null to NodeSet to let $null/foo work well.
            }

            ResetableIterator resetable = value as ResetableIterator;

            if (resetable != null)
            {
                // We need Clone() value because variable may be used several times
                // and they shouldn't
                queryIterator = (ResetableIterator)resetable.Clone();
                return(this);
            }
            XPathNodeIterator nodeIterator = value as XPathNodeIterator;

            if (nodeIterator != null)
            {
                queryIterator = new XPathArrayIterator(nodeIterator);
                return(this);
            }
            IXPathNavigable navigable = value as IXPathNavigable;

            if (navigable != null)
            {
                return(navigable.CreateNavigator());
            }

            if (value is Int16)
            {
                return((double)(Int16)value);
            }
            if (value is Int64)
            {
                return((double)(Int64)value);
            }
            if (value is UInt32)
            {
                return((double)(UInt32)value);
            }
            if (value is UInt16)
            {
                return((double)(UInt16)value);
            }
            if (value is UInt64)
            {
                return((double)(UInt64)value);
            }
            if (value is Single)
            {
                return((double)(Single)value);
            }
            if (value is Decimal)
            {
                return((double)(Decimal)value);
            }
            return(value.ToString());
        }
        //
        // CONSTRUCTOR
        //
        public NetworkAssignment(IXPathNavigable path) : base(path)
        {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <IsDefault>
            XPathNavigator navigatorIsDefault = navigator.SelectSingleNode("IsDefault");

            if (navigatorIsDefault != null)
            {
                this._isDefault = navigatorIsDefault.ValueAsBoolean;
            }

            // <ID>
            XPathNavigator navigatorID = navigator.SelectSingleNode("ID");

            if (navigatorID != null)
            {
                this._id = navigatorID.ValueAsInt;
            }

            // <NetworkAttributeName>
            XPathNavigator navigatorNetworkAttributeName = navigator.SelectSingleNode("NetworkAttributeName");

            if (navigatorNetworkAttributeName != null)
            {
                this._networkAttributeName = navigatorNetworkAttributeName.Value;
            }

            // <NetworkElementType>
            XPathNavigator navigatorNetworkElementType = navigator.SelectSingleNode("NetworkElementType");

            if (navigatorNetworkElementType != null)
            {
                this._networkElementType = (esriNetworkElementType)Enum.Parse(typeof(esriNetworkElementType), navigatorNetworkElementType.Value, true);
            }

            // <NetworkSourceName>
            XPathNavigator navigatorNetworkSourceName = navigator.SelectSingleNode("NetworkSourceName");

            if (navigatorNetworkSourceName != null)
            {
                this._networkSourceName = navigatorNetworkSourceName.Value;
            }

            // <NetworkEvaluatorCLSID>
            XPathNavigator navigatorNetworkEvaluatorCLSID = navigator.SelectSingleNode("NetworkEvaluatorCLSID");

            if (navigatorNetworkEvaluatorCLSID != null)
            {
                this._networkEvaluatorCLSID = navigatorNetworkEvaluatorCLSID.Value;
            }

            // <NetworkEdgeDirection>
            XPathNavigator navigatorNetworkEdgeDirection = navigator.SelectSingleNode("NetworkEdgeDirection");

            if (navigatorNetworkEdgeDirection != null)
            {
                this._networkEdgeDirection = (esriNetworkEdgeDirection)Enum.Parse(typeof(esriNetworkEdgeDirection), navigatorNetworkEdgeDirection.Value, true);
            }

            // <NetworkEvaluatorData><PropertyArray><PropertySetProperty>
            this._networkEvaluatorData = new List <Property>();
            XPathNodeIterator interatorProperty = navigator.Select("NetworkEvaluatorData/PropertyArray/PropertySetProperty");

            while (interatorProperty.MoveNext())
            {
                // Get <PropertySetProperty>
                XPathNavigator navigatorProperty = interatorProperty.Current;

                // Add PropertySetProperty
                Property property = new Property(navigatorProperty);
                this._networkEvaluatorData.Add(property);
            }
        }
Example #38
0
 /// <summary>
 /// Pravi proizvoljan query
 /// </summary>
 /// <param name="__xPath"></param>
 /// <param name="__source"></param>
 public xPathQueryCache(String __xPath, IXPathNavigable __source)
 {
     basic(__xPath, __source);
 }
Example #39
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("ImageUrl", typeof(string)));
            DataRow         dr;
            IXPathNavigable navigable = XmlBuilder.GetXml(StructureType.Navigation);

            XPathNavigator tabs = navigable.CreateNavigator().SelectSingleNode("Navigation/Tabs");

            foreach (XPathNavigator tabItem in tabs.SelectChildren(string.Empty, string.Empty))
            {
                dr = dt.NewRow();
                string title = UtilHelper.GetResFileString(tabItem.GetAttribute("text", string.Empty));
                string id    = tabItem.GetAttribute("id", string.Empty);

                CommandParameters param = new CommandParameters(id);
                param.CommandArguments = new Dictionary <string, string>();
                param.CommandArguments.Add("permissions", tabItem.GetAttribute("permissions", string.Empty));

                string enableHandler = String.Empty;

                if (!ProfileConfiguration.Instance.EnablePermissions)
                {
                    enableHandler = tabItem.GetAttribute("enableHandler", string.Empty);
                }
                else
                {
                    enableHandler = tabItem.GetAttribute("enableHandler2", string.Empty);
                }

                if (!String.IsNullOrEmpty(enableHandler))
                {
                    ICommandEnableHandler enHandler = (ICommandEnableHandler)AssemblyUtil.LoadObject(enableHandler);
                    if (enHandler != null && !enHandler.IsEnable(sender, param))
                    {
                        continue;
                    }
                }

                string imageUrl = tabItem.GetAttribute("imageUrl", string.Empty);
                if (String.IsNullOrEmpty(imageUrl))
                {
                    imageUrl = "~/App_Themes/Default/Images/ext/default/s.gif";
                }

                string type = tabItem.GetAttribute("contentType", string.Empty).ToLower();
                if (String.IsNullOrEmpty(type))
                {
                    type = "default";
                }

                string configUrl = tabItem.GetAttribute("configUrl", string.Empty);
                string checkUrl  = configUrl;
                if (checkUrl.IndexOf("?") >= 0)
                {
                    checkUrl = checkUrl.Substring(0, checkUrl.IndexOf("?"));
                }
                if (type.Equals("default") && String.IsNullOrEmpty(checkUrl))
                {
                    checkUrl  = "~/Apps/Shell/Pages/TreeSource.aspx";
                    configUrl = "~/Apps/Shell/Pages/TreeSource.aspx?tab=" + id;
                }

                if (File.Exists(Server.MapPath(checkUrl)))
                {
                    switch (type)
                    {
                    case "default":
                        ClientScript.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("leftTemplate_ECFAddMenuTab('{0}', '{1}', '{2}');", id, title, ResolveClientUrl(configUrl)), true);
                        break;

                    case "custom":
                        break;

                    default:
                        break;
                    }
                }

                dr["Title"]    = title;
                dr["ImageUrl"] = imageUrl;
                dt.Rows.Add(dr);
            }
            TabItems.DataSource = dt.DefaultView;
            TabItems.DataBind();

            RegisterScripts();

            //Register navigation commands
            IList <XmlCommand> list = XmlCommand.GetListNavigationCommands("", "", "");
            CommandManager     cm   = CommandManager.GetCurrent(this.Page);

            foreach (XmlCommand cmd in list)
            {
                cm.AddCommand("", "", "", cmd.CommandName);
            }
        }
Example #40
0
 public void Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results)
 {
     CheckArguments(input, results);
     Transform(input, arguments, results, CreateDefaultResolver());
 }
Example #41
0
        private static void CheckFieldNames(IXPathNavigable xml)
        {
            XPathNavigator      rootNav = xml.CreateNavigator();
            XmlNamespaceManager nsmgr   = new XmlNamespaceManager(rootNav.NameTable);

            nsmgr.AddNamespace("x", ContentDefinitionXmlNamespace);

            XPathNodeIterator x = rootNav.Select("/x:ContentType", nsmgr);

            x.MoveNext();
            XPathNavigator rootNode = x.Current;
            string         ctdName  = rootNode.GetAttribute("name", "");

            List <string> allBindings = new List <string>();

            foreach (XPathNavigator fieldNode in rootNav.Select("//x:Field", nsmgr))
            {
                string        name     = fieldNode.GetAttribute("name", "");
                List <string> bindings = new List <string>();
                foreach (XPathNavigator bindNode in fieldNode.Select("x:Bind", nsmgr))
                {
                    string property = bindNode.GetAttribute("property", "");
                    bindings.Add(property);
                }
                if (bindings.Count == 0)
                {
                    bindings.Add(name);
                }
                allBindings.AddRange(bindings);
            }
            Dictionary <string, string> names = new Dictionary <string, string>();

            foreach (string name in allBindings)
            {
                if (names.ContainsKey(name.ToLower()))
                {
                    if (names[name.ToLower()] != name)
                    {
                        throw new RegistrationException(String.Concat(
                                                            SR.Exceptions.Registration.Msg_InvalidContentTypeDefinitionXml, ": '", ctdName, "'. ",
                                                            "Two Field or Binding names are case insensitive equal, but case sensitive they are not equal: '", names[name.ToLower()], "' != '", name, "'"));
                    }
                }
                else
                {
                    names.Add(name.ToLower(), name);
                }
            }
            foreach (PropertyType propType in ActiveSchema.PropertyTypes)
            {
                string newName;
                if (names.TryGetValue(propType.Name.ToLower(), out newName))
                {
                    if (propType.Name != newName)
                    {
                        throw new RegistrationException(String.Concat(
                                                            SR.Exceptions.Registration.Msg_InvalidContentTypeDefinitionXml, ": '", ctdName, "'. ",
                                                            "A Field or Binding name and an existing RepositoryProperty name are case insensitive equal, but case sensitive they are not equal: '", propType.Name,
                                                            "', Field or Binding name: '", newName, "'"));
                    }
                }
            }
        }
Example #42
0
        /// <summary>
        /// Signs the specified xml document with the certificate found in
        /// the local machine matching the provided friendly name and
        /// referring to the specified target reference ID.
        /// </summary>
        /// <param name="certFriendlyName">
        /// Friendly Name of the X509Certificate to be retrieved
        /// from the LocalMachine keystore and used to sign the xml document.
        /// Be sure to have appropriate permissions set on the keystore.
        /// </param>
        /// <param name="xmlDoc">
        /// XML document to be signed.
        /// </param>
        /// <param name="targetReferenceId">
        /// Reference element that will be specified as signed.
        /// </param>
        /// <param name="includePublicKey">
        /// Flag to determine whether to include the public key in the
        /// signed xml.
        /// </param>
        public static void SignXml(string certFriendlyName, IXPathNavigable xmlDoc, string targetReferenceId, bool includePublicKey)
        {
            if (string.IsNullOrEmpty(certFriendlyName))
            {
                throw new Saml2Exception(Resources.SignedXmlInvalidCertFriendlyName);
            }

            if (xmlDoc == null)
            {
                throw new Saml2Exception(Resources.SignedXmlInvalidXml);
            }

            if (string.IsNullOrEmpty(targetReferenceId))
            {
                throw new Saml2Exception(Resources.SignedXmlInvalidTargetRefId);
            }

            X509Certificate2 cert = FedletCertificateFactory.GetCertificateByFriendlyName(certFriendlyName);

            if (cert == null)
            {
                throw new Saml2Exception(Resources.SignedXmlCertNotFound);
            }

            XmlDocument xml       = (XmlDocument)xmlDoc;
            SignedXml   signedXml = new SignedXml(xml);

            signedXml.SigningKey = cert.PrivateKey;

            if (includePublicKey)
            {
                KeyInfo keyInfo = new KeyInfo();
                keyInfo.AddClause(new KeyInfoX509Data(cert));
                signedXml.KeyInfo = keyInfo;
            }

            Reference reference = new Reference();

            reference.Uri = "#" + targetReferenceId;

            XmlDsigEnvelopedSignatureTransform envelopSigTransform = new XmlDsigEnvelopedSignatureTransform();

            reference.AddTransform(envelopSigTransform);

            signedXml.AddReference(reference);
            signedXml.ComputeSignature();

            XmlElement xmlSignature = signedXml.GetXml();

            XmlNamespaceManager nsMgr = new XmlNamespaceManager(xml.NameTable);

            nsMgr.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
            nsMgr.AddNamespace("saml", Saml2Constants.NamespaceSamlAssertion);
            nsMgr.AddNamespace("samlp", Saml2Constants.NamespaceSamlProtocol);

            XmlNode issuerNode = xml.DocumentElement.SelectSingleNode("saml:Issuer", nsMgr);

            if (issuerNode != null)
            {
                xml.DocumentElement.InsertAfter(xmlSignature, issuerNode);
            }
            else
            {
                // Insert as a child to the target reference id
                XmlNode targetNode = xml.DocumentElement.SelectSingleNode("//*[@ID='" + targetReferenceId + "']", nsMgr);
                targetNode.PrependChild(xmlSignature);
            }
        }
Example #43
0
        /// <summary>
        /// Populates this <see cref="BasicV2"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the basic data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a basic node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator basicNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("basic");

            Validator.ThrowInvalidIfNull(basicNav, Resources.BasicUnexpectedNode);

            XPathNavigator genderNav =
                basicNav.SelectSingleNode("gender");

            if (genderNav != null)
            {
                string genderString = genderNav.Value;
                if (string.Equals(
                        genderString,
                        "m",
                        StringComparison.Ordinal))
                {
                    _gender = ItemTypes.Gender.Male;
                }
                else if (
                    string.Equals(
                        genderString,
                        "f",
                        StringComparison.Ordinal))
                {
                    _gender = ItemTypes.Gender.Female;
                }
                else
                {
                    _gender = ItemTypes.Gender.Unknown;
                }
            }

            _birthYear  = XPathHelper.GetOptNavValueAsInt(basicNav, "birthyear");
            _country    = XPathHelper.GetOptNavValue <CodableValue>(basicNav, "country");
            _postalCode = XPathHelper.GetOptNavValue(basicNav, "postcode");
            _city       = XPathHelper.GetOptNavValue(basicNav, "city");

            _stateOrProvince =
                XPathHelper.GetOptNavValue <CodableValue>(basicNav, "state");

            XPathNavigator dayOfWeekNav =
                basicNav.SelectSingleNode("firstdow");

            if (dayOfWeekNav != null)
            {
                _firstDayOfWeek = (DayOfWeek)(dayOfWeekNav.ValueAsInt - 1);
            }

            XPathNodeIterator languageIterator =
                basicNav.Select("language");

            if (languageIterator != null)
            {
                foreach (XPathNavigator languageNav in languageIterator)
                {
                    Language newLanguage = new Language();
                    newLanguage.ParseXml(languageNav);

                    _languages.Add(newLanguage);
                }
            }
        }
Example #44
0
        /// <summary>
        /// Process XML document.
        /// </summary>
        /// <typeparam name="T">The type to deserialize from the document</typeparam>
        /// <param name="transform">The XSL transformation to apply. May be <c>null</c>.</param>
        /// <param name="doc">The XML document to deserialize from.</param>
        /// <returns>The result of the deserialization.</returns>
        private static CCPAPIResult <T> DeserializeAPIResultCore <T>(IXPathNavigable doc, XslCompiledTransform transform = null)
        {
            CCPAPIResult <T> result;

            try
            {
                // Deserialization with a transform
                using (XmlNodeReader reader = new XmlNodeReader((XmlDocument)doc))
                {
                    XmlSerializer xs = new XmlSerializer(typeof(CCPAPIResult <T>));

                    if (transform != null)
                    {
                        MemoryStream stream = GetMemoryStream();
                        using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8))
                        {
                            // Apply the XSL transform
                            writer.Formatting = Formatting.Indented;
                            transform.Transform(reader, writer);
                            writer.Flush();

                            // Deserialize from the given stream
                            stream.Seek(0, SeekOrigin.Begin);
                            result = (CCPAPIResult <T>)xs.Deserialize(stream);
                        }
                    }
                    // Deserialization without transform
                    else
                    {
                        result = (CCPAPIResult <T>)xs.Deserialize(reader);
                    }
                }

                // Fix times
                if (result.Result is ISynchronizableWithLocalClock)
                {
                    DateTime requestTime = DateTime.UtcNow;
                    double   offsetCCP   = result.CurrentTime.Subtract(requestTime).TotalMilliseconds;
                    result.SynchronizeWithLocalClock(offsetCCP);
                }
            }
            // An error occurred during the XSL transform
            catch (XsltException exc)
            {
                ExceptionHandler.LogException(exc, true);
                result = new CCPAPIResult <T>(exc);
            }
            // An error occurred during the deserialization
            catch (InvalidOperationException exc)
            {
                ExceptionHandler.LogException(exc, true);
                result = new CCPAPIResult <T>(exc);
            }
            catch (XmlException exc)
            {
                ExceptionHandler.LogException(exc, true);
                result = new CCPAPIResult <T>(exc);
            }

            // Stores XMLDocument
            result.XmlDocument = doc;
            return(result);
        }
Example #45
0
        /// <summary>
        /// Validates a signed xml document with the given certificate,
        /// the xml signature, and the target reference id.
        /// </summary>
        /// <param name="cert">
        /// X509Certificate used to verify the signature of the xml document.
        /// </param>
        /// <param name="xmlDoc">
        /// XML document whose signature will be checked.
        /// </param>
        /// <param name="xmlSignature">Signature of the XML document.</param>
        /// <param name="targetReferenceId">
        /// Reference element that should be signed.
        /// </param>
        public static void ValidateSignedXml(X509Certificate2 cert, IXPathNavigable xmlDoc, IXPathNavigable xmlSignature, string targetReferenceId)
        {
            SignedXml signedXml = new SignedXml((XmlDocument)xmlDoc);

            signedXml.LoadXml((XmlElement)xmlSignature);

            bool results = signedXml.CheckSignature(cert, true);

            if (results == false)
            {
                throw new Saml2Exception(Resources.SignedXmlCheckSignatureFailed);
            }

            bool foundValidSignedReference = false;

            foreach (Reference r in signedXml.SignedInfo.References)
            {
                string referenceId = r.Uri.Substring(1);
                if (referenceId == targetReferenceId)
                {
                    foundValidSignedReference = true;
                }
            }

            if (!foundValidSignedReference)
            {
                throw new Saml2Exception(Resources.SignedXmlInvalidReference);
            }
        }
Example #46
0
        public int TransformResolver(string szXmlFile, XmlResolver xr, bool errorCase, TransformType transformType, DocType docType)
        {
            lock (s_outFileMemoryLock)
            {
                szXmlFile = FullFilePath(szXmlFile);

                _output.WriteLine("Loading XML {0}", szXmlFile);
                IXPathNavigable xd = LoadXML(szXmlFile, docType);

                _output.WriteLine("Executing transform");
                xrXSLT = null;
                Stream strmTemp = null;

                switch (transformType)
                {
                case TransformType.Reader:
                    xrXSLT = xslt.Transform(xd, null, xr);

                    using (FileStream outFile = new FileStream(_strOutFile, FileMode.Create, FileAccess.ReadWrite))
                        using (XmlWriter writer = XmlWriter.Create(outFile))
                        {
                            writer.WriteNode(xrXSLT, true);
                        }

                    if (errorCase)
                    {
                        try
                        {
                            while (xrXSLT.Read())
                            {
                            }
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                        finally
                        {
                            if (xrXSLT != null)
                            {
                                xrXSLT.Dispose();
                            }
                        }
                    }
                    break;

                case TransformType.Stream:
                    try
                    {
                        strmTemp = new FileStream(_strOutFile, FileMode.Create, FileAccess.ReadWrite);
                        xslt.Transform(xd, null, strmTemp, xr);
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                    finally
                    {
                        if (strmTemp != null)
                        {
                            strmTemp.Dispose();
                        }
                    }
                    break;

                case TransformType.Writer:
                    XmlWriter xw = null;
                    try
                    {
                        xw = new XmlTextWriter(_strOutFile, Encoding.UTF8);
                        xw.WriteStartDocument();
                        xslt.Transform(xd, null, xw, xr);
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                    finally
                    {
                        if (xw != null)
                        {
                            xw.Dispose();
                        }
                    }
                    break;

                case TransformType.TextWriter:
                    TextWriter tw = null;
                    try
                    {
                        using (FileStream outFile = new FileStream(_strOutFile, FileMode.Create, FileAccess.Write))
                        {
                            tw = new StreamWriter(outFile, Encoding.UTF8);
                            xslt.Transform(xd, null, tw, xr);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                    break;
                }
                return(1);
            }
        }
Example #47
0
 //
 // CONSTRUCTOR
 //
 public EvaluatedNetworkAttribute(IXPathNavigable path) : base(path)
 {
 }
Example #48
0
 // SxS: This method does not take any resource name and does not expose any resources to the caller.
 // It's OK to suppress the SxS warning.
 public void Load(IXPathNavigable stylesheet)
 {
     Reset();
     LoadInternal(stylesheet, XsltSettings.Default, XmlNullResolver.Singleton);
 }
Example #49
0
 /// <summary>
 /// Initializes a new instance of the class from the specified XML node.
 /// </summary>
 /// <param name="node">The XML node to initialize from.</param>
 public SupportElement(IXPathNavigable node) : base(node)
 {
 }
Example #50
0
 // SxS: This method does not take any resource name and does not expose any resources to the caller.
 // It's OK to suppress the SxS warning.
 public void Load(IXPathNavigable stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
 {
     Reset();
     LoadInternal(stylesheet, settings, stylesheetResolver);
 }
Example #51
0
 /// <summary>
 /// Initializes a new instance of the class from the specified XML node.
 /// </summary>
 /// <param name="node">The XML node to initialize from.</param>
 public ActionElement(IXPathNavigable node) : base(node)
 {
 }
Example #52
0
 public void Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results)
 {
     CheckArguments(input, results);
     Transform(input, arguments, results, XmlNullResolver.Singleton);
 }
Example #53
0
 // SxS: This method does not take any resource name and does not expose any resources to the caller.
 // It's OK to suppress the SxS warning.
 public void Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
 {
     CheckArguments(input, results);
     CheckCommand();
     _command.Execute((object)input.CreateNavigator(), documentResolver, arguments, results);
 }
Example #54
0
 public XPathAdapter(IXPathNavigable source)
 {
     Source  = source;
     Context = new XPathContext();
     root    = source.CreateNavigator();
 }
Example #55
0
 /// <summary>
 /// Initializes a new instance of the class from the specified XML node.
 /// </summary>
 /// <param name="node">The XML node to initialize from.</param>
 public WebsiteConfiguration(IXPathNavigable node) : base(node)
 {
 }
        //
        // CONSTRUCTOR
        //
        public NetworkAttribute(IXPathNavigable path) : base(path)
        {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <ID>
            XPathNavigator navigatorID = navigator.SelectSingleNode("ID");

            if (navigatorID != null)
            {
                this._id = navigatorID.ValueAsInt;
            }

            // <Name>
            XPathNavigator navigatorName = navigator.SelectSingleNode("Name");

            if (navigatorName != null)
            {
                this._name = navigatorName.Value;
            }

            // <Units>
            XPathNavigator navigatorUnits = navigator.SelectSingleNode("Units");

            if (navigatorUnits != null)
            {
                this._units = GeodatabaseUtility.GetNetworkAttributeUnits(navigatorUnits.Value);
            }

            // <DataType>
            XPathNavigator navigatorDataType = navigator.SelectSingleNode("DataType");

            if (navigatorDataType != null)
            {
                this._dataType = (esriNetworkAttributeDataType)Enum.Parse(typeof(esriNetworkAttributeDataType), navigatorDataType.Value, true);
            }

            // <UsageType>
            XPathNavigator navigatorUsageType = navigator.SelectSingleNode("UsageType");

            if (navigatorUsageType != null)
            {
                this._usageType = (esriNetworkAttributeUsageType)Enum.Parse(typeof(esriNetworkAttributeUsageType), navigatorUsageType.Value, true);
            }

            // <UserData><PropertyArray><PropertySetProperty>
            this._userData = new List <Property>();
            XPathNodeIterator interatorProperty = navigator.Select("UserData/PropertyArray/PropertySetProperty");

            while (interatorProperty.MoveNext())
            {
                // Get <PropertySetProperty>
                XPathNavigator navigatorProperty = interatorProperty.Current;

                // Add PropertySetProperty
                Property property = new Property(navigatorProperty);
                this._userData.Add(property);
            }

            // <UseByDefault>
            XPathNavigator navigatorUseByDefault = navigator.SelectSingleNode("UseByDefault");

            if (navigatorUseByDefault != null)
            {
                this._useByDefault = navigatorUseByDefault.ValueAsBoolean;
            }

            // <AttributedParameters><AttributedParameter>
            this._attributeParameters = new List <NetworkAttributeParameter>();
            XPathNodeIterator interatorAttributedParameter = navigator.Select("AttributedParameters/AttributedParameter");

            while (interatorAttributedParameter.MoveNext())
            {
                // Get <AttributedParameter>
                XPathNavigator navigatorAttributedParameter = interatorAttributedParameter.Current;

                // Add AttributedParameter
                NetworkAttributeParameter networkAttributeParameter = new NetworkAttributeParameter(navigatorAttributedParameter);
                this._attributeParameters.Add(networkAttributeParameter);
            }
        }
Example #57
0
      public static XdmNode ToXdmNode(this IXPathNavigable value, DocumentBuilder documentBuilder) {

         if (value == null) throw new ArgumentNullException("value");

         return ToXdmNode(value.CreateNavigator(), documentBuilder);
      }
Example #58
0
 internal ClipPath(string name, IXPathNavigable path)
 {
     Name = name;
     Path = path;
 }
Example #59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlInput"/> class.
 /// </summary>
 /// <param name="page">
 /// The owning page.
 /// </param>
 /// <param name="node">
 /// The node.
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// The <paramref name="page"/> parameter is <c>null</c>.
 /// </exception>
 /// <exception cref="System.ArgumentNullException">
 /// The <paramref name="node"/> parameter is <c>null</c>.
 /// </exception>
 public HtmlInput(IHtmlPage page, IXPathNavigable node) : base(page, node)
 {
 }
Example #60
0
 /// <summary>
 /// Creates <c>XPointerReader</c> instnace with given <see cref="IXPathNavigable"/>
 /// and xpointer.
 /// </summary>
 public XPointerReader(IXPathNavigable doc, string xpointer)
     : this(doc.CreateNavigator(), xpointer)
 {
 }