コード例 #1
0
        public XmlWriter Resolve(string resultDocumentUri,
                                 XdmWriterSettings settings)
        {
            Assert.ArgumentNotNull(resultDocumentUri, "resultDocumentUri");
            Assert.ArgumentNotNull(settings, "settings");

            settings.CloseOutput = true;

            var uri = new Uri(new Uri(_baseOutputUri), resultDocumentUri);

            if (uri.Scheme !=
                Uri.UriSchemeFile)
            {
                _task.Log.LogError(Resources.CannotCreateResultDocument,
                                   resultDocumentUri);
                return(null);
            }

            var fileInfo = new AnyUri(resultDocumentUri).Normalize() == _baseOutputUri
                               ? _primaryOutput
                               : new FileInfo(uri.LocalPath);

            if (fileInfo == null)
            {
                _task.Log.LogMessage(MessageImportance.Low,
                                     Resources.DiscardingPrimaryResultDocument,
                                     resultDocumentUri);
                return(null);
            }

            return(CreateResultDocument(settings, fileInfo));
        }
コード例 #2
0
        public ResultDocumentHandler([NotNull] XmlPrimeTask task,
                                     [CanBeNull] ITaskItem output,
                                     [NotNull] AnyUri baseOutputUri)
        {
            Assert.ArgumentNotNull(task, "task");
            Assert.ArgumentNotNull(baseOutputUri, "baseOutputUri");

            _task          = task;
            _primaryOutput = output == null
                                 ? null
                                 : new FileInfo(output.ItemSpec);
            _baseOutputUri = baseOutputUri.Normalize();
        }
コード例 #3
0
        /// <summary>
        ///     Loads the collections.
        /// </summary>
        /// <param name = "dynamicContextSettings">The dynamic context settings.</param>
        /// <param name = "staticSettings">The static settings.</param>
        protected void LoadCollections([NotNull] DynamicContextSettings dynamicContextSettings,
                                       [NotNull] StaticContextSettings staticSettings)
        {
            Assert.ArgumentNotNull(dynamicContextSettings, "dynamicContextSettings");
            Assert.ArgumentNotNull(staticSettings, "staticSettings");

            // TODO: We should be specifying collections as a list of URIs, not as a list of files.
            // This way the collection can contain nodes wihtin a document (with fragment identifiers).
            // We are going to have to move this way anyway to handle uri-collection

            if (Collections == null)
            {
                return;
            }

            var collections = new Dictionary <AnyUri, List <IXPathNavigable> >();

            foreach (var item in Collections)
            {
                var uriString = item.GetMetadata("CollectionURI");
                Log.LogMessage(MessageImportance.Low, "adding " + item.ItemSpec + " to collection " + uriString);

                //TODO: use AnyURI when it supports windows paths
                var itemUri   = new Uri(item.GetMetadata("FullPath"));
                var navigable = dynamicContextSettings.DocumentSet.Document(new AnyUri(itemUri));

                if (string.IsNullOrEmpty(uriString))
                {
                    uriString = DefaultCollection;
                }
                List <IXPathNavigable> list;
                var uri = new AnyUri(uriString);
                if (!collections.TryGetValue(uri, out list))
                {
                    list             = new List <IXPathNavigable>();
                    collections[uri] = list;
                }
                list.Add(navigable);
            }

            foreach (var collection in collections)
            {
                dynamicContextSettings.DocumentSet.AddCollection(collection.Key, collection.Value.ToArray());
            }
            dynamicContextSettings.DefaultCollectionURI = new AnyUri(DefaultCollection);
            staticSettings.CollectionTypeResolver       = dynamicContextSettings.DocumentSet.CollectionTypeResolver;
        }
コード例 #4
0
        private DynamicContextSettings GetDynamicContextSettings([NotNull] DocumentSet documentSet)
        {
            Assert.ArgumentNotNull(documentSet, "documentSet");

            //TODO: switch to constructing directly when AnyUri fully supports windows paths
            var outputPath = Output == null ? BuildEngine.ProjectFileOfTaskNode : Output.GetMetadata("FullPath");
            var outputUri  = new Uri(outputPath);
            var baseOutput = new AnyUri(outputUri);

            var dynamicContextSettings = new DynamicContextSettings
            {
                BaseOutputURI = baseOutput,
                DocumentSet   = documentSet
            };

            dynamicContextSettings.Trace += OnTrace;
            return(dynamicContextSettings);
        }
コード例 #5
0
 static DataTypeDescriptor()
 {
     DnsName = new DnsNameDataType();
     IpAddress = new IpAddress();
     Bag = new Bag();
     Time = new Time();
     String = new StringDataType();
     Rfc822Name = new Rfc822Name();
     X500Name = new X500Name();
     Double = new DoubleDataType();
     YearMonthDuration = new YearMonthDuration();
     DaytimeDuration = new DaytimeDuration();
     DateTime = new DateTime();
     Date = new DateDataType();
     Integer = new IntegerDataType();
     Boolean = new BooleanDataType();
     HexBinary = new HexBinary();
     Base64Binary = new Base64Binary();
     AnyUri = new AnyUri();
     Function = new FunctionDataType();
 }
コード例 #6
0
ファイル: DataTypeDescriptor.cs プロジェクト: zszqwe/anycmd
 static DataTypeDescriptor()
 {
     DnsName           = new DnsNameDataType();
     IpAddress         = new IpAddress();
     Bag               = new Bag();
     Time              = new Time();
     String            = new StringDataType();
     Rfc822Name        = new Rfc822Name();
     X500Name          = new X500Name();
     Double            = new DoubleDataType();
     YearMonthDuration = new YearMonthDuration();
     DaytimeDuration   = new DaytimeDuration();
     DateTime          = new DateTime();
     Date              = new DateDataType();
     Integer           = new IntegerDataType();
     Boolean           = new BooleanDataType();
     HexBinary         = new HexBinary();
     Base64Binary      = new Base64Binary();
     AnyUri            = new AnyUri();
     Function          = new FunctionDataType();
 }
コード例 #7
0
ファイル: Transform.cs プロジェクト: krwq/XmlPrime
        private DynamicContextSettings GetDynamicContextSettings([NotNull] DocumentSet documentSet)
        {
            Assert.ArgumentNotNull(documentSet, "documentSet");

            //TODO: switch to constructing directly when AnyUri fully supports windows paths
            var outputUri  = new Uri(Output.GetMetadata("FullPath"));
            var baseOutput = new AnyUri(outputUri);

            var dynamicContextSettings = new DynamicContextSettings
            {
                BaseOutputURI = baseOutput,
                DocumentSet   = documentSet,
                AvailableEnvironmentVariables =
                    EnvironmentVariables.Create()
            };

            dynamicContextSettings.Message += OnMessage;
            dynamicContextSettings.Trace   += OnTrace;

            return(dynamicContextSettings);
        }
コード例 #8
0
 public void ChangeBase_NullNewBaseUri()
 {
     NullUri
     .Invoking(u => AnyUri.ChangeBase(AnyUri, u))
     .Should().Throw <ArgumentNullException>();
 }
コード例 #9
0
 public void ChangeBase_RelativeNewBaseUri()
 {
     RelativeUri
     .Invoking(u => AnyUri.ChangeBase(AnyUri, u))
     .Should().Throw <ArgumentException>();
 }