コード例 #1
0
 public PairContentWriter(IContentWriter keyContentWriter, IContentWriter valueContentWriter, IXmlAttributeInterpreter xmlAttributeInterpreter)
 {
     this.keyContentWriter   = keyContentWriter;
     this.valueContentWriter = valueContentWriter;
     keyNodeInfo             = xmlAttributeInterpreter.GetPropertyNodeInfo(typeof(DictionaryKeyValuePair).GetProperty("Key"));
     valueNodeInfo           = xmlAttributeInterpreter.GetPropertyNodeInfo(typeof(DictionaryKeyValuePair).GetProperty("Value"));
 }
コード例 #2
0
ファイル: StageInstance.cs プロジェクト: SpectrumLib/Spectrum
 public ProcessorInstance(ProcessorType type)
 {
     Type           = type;
     Instance       = type.CreateInstance();
     WriterInstance = type.CreateWriterInstance();
     LoaderHash     = StringHash(LoaderName);
 }
コード例 #3
0
 public AssetWriter(IAssetContentCache cache, IContentWriter writer,
                    IETagGenerator <IEnumerable <AssetFile> > eTagGenerator)
 {
     _cache         = cache;
     _writer        = writer;
     _eTagGenerator = eTagGenerator;
 }
コード例 #4
0
ファイル: AssetWriter.cs プロジェクト: chadmyers/fubumvc
 public AssetWriter(IAssetContentCache cache, IContentWriter writer, IETagGenerator <IEnumerable <AssetFile> > eTagGenerator, IOutputWriter output, IAssetCacheHeaders cachingHeaders)
 {
     _cache          = cache;
     _writer         = writer;
     _eTagGenerator  = eTagGenerator;
     _output         = output;
     _cachingHeaders = cachingHeaders;
 }
コード例 #5
0
ファイル: AssetWriter.cs プロジェクト: ahjohannessen/fubumvc
 public AssetWriter(IAssetContentCache cache, IContentWriter writer, IETagGenerator<IEnumerable<AssetFile>> eTagGenerator, IOutputWriter output, IAssetCacheHeaders cachingHeaders)
 {
     _cache = cache;
     _writer = writer;
     _eTagGenerator = eTagGenerator;
     _output = output;
     _cachingHeaders = cachingHeaders;
 }
コード例 #6
0
 public ClipBoardContentWriter(IContentWriter contentWriter)
 {
     if (contentWriter is ClipBoardContentWriter)
     {
         throw new System.ArgumentException("参数类型错误");
     }
     _contentWriter = contentWriter;
 }
コード例 #7
0
 public BattleshipsGame(IGameBoardVisualizer boardVisualizer,
                        IInputReader inputReader,
                        IContentWriter writer,
                        IInputValidator validator)
 {
     _boardVisualizer = boardVisualizer;
     _inputReader     = inputReader;
     _writer          = writer;
     _validator       = validator;
 }
コード例 #8
0
 public void SetUp()
 {
     _boardVisualizer    = new Mock <IGameBoardVisualizer>().Object;
     _writer             = new Mock <IContentWriter>().Object;
     _inputValidatorMock = new Mock <IInputValidator>();
     _inputReaderMock    = new Mock <IInputReader>();
     _inputReaderMock.Setup(r => r.ReadInput()).Returns(USER_INPUT);
     _gameBoardMock = new Mock <IGameBoard>();
     _gameBoardMock.Setup(b => b.GetCurrentBoardState()).Returns(new BoardFields());
 }
コード例 #9
0
        public ContentNegotiator(IContentAccepts accepts, IContentWriter writer, INamingConventionSwitcher namingConventionSwitcher)
        {
            _accepts = accepts;
            _writer  = writer;

            _jsonSerializerSettings = new JsonSerializerSettings
            {
                ContractResolver = new NameSwitcherContractResolver(namingConventionSwitcher),
                //Converters = { new RestItemDataJsonConverter(namingConventionSwitcher) }
            };
        }
コード例 #10
0
        /// <summary>
        /// Gets the content writer for the item at the specified path.
        /// </summary>
        /// <param name="providerInstance">
        /// The provider instance to use.
        /// </param>
        /// <param name="path">
        /// The path to the item if it was specified on the command line.
        /// </param>
        /// <param name="context">
        /// The context which the core command is running.
        /// </param>
        /// <exception cref="NotSupportedException">
        /// If the <paramref name="providerInstance"/> does not support this operation.
        /// </exception>
        /// <exception cref="PipelineStoppedException">
        /// If the pipeline is being stopped while executing the command.
        /// </exception>
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        private IContentWriter GetContentWriterPrivate(
            CmdletProvider providerInstance,
            string path,
            CmdletProviderContext context)
        {
            // All parameters should have been validated by caller
            Dbg.Diagnostics.Assert(
                providerInstance != null,
                "Caller should validate providerInstance before calling this method");

            Dbg.Diagnostics.Assert(
                path != null,
                "Caller should validate path before calling this method");

            Dbg.Diagnostics.Assert(
                context != null,
                "Caller should validate context before calling this method");

            IContentWriter result = null;

            try
            {
                result = providerInstance.GetContentWriter(path, context);
            }
            catch (NotSupportedException)
            {
                throw;
            }
            catch (LoopFlowException)
            {
                throw;
            }
            catch (PipelineStoppedException)
            {
                throw;
            }
            catch (ActionPreferenceStopException)
            {
                throw;
            }
            catch (Exception e) // Catch-all OK, 3rd party callout.
            {
                throw NewProviderInvocationException(
                          "GetContentWriterProviderException",
                          SessionStateStrings.GetContentWriterProviderException,
                          providerInstance.ProviderInfo,
                          path,
                          e);
            }

            return(result);
        }
コード例 #11
0
ファイル: TestCommands.cs プロジェクト: bitwiseman/Pash
 protected override void ProcessRecord()
 {
     foreach (string path in Path)
     {
         using (IContentWriter writer = InvokeProvider.Content.GetWriter(path).Single())
         {
             IList items = writer.Write(Value);
             // Need to close writer before disposing it otherwise Microsoft's
             // FileSystemProvider throws an exception.
             writer.Close();
         }
     }
 }
コード例 #12
0
        public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context)
        {
            HttpResponse response = context.HttpContext.Response;

            IContentWriter writer = _writers[response.ContentType];

            (bool success, byte[] data) = await writer.Write(context.Object);

            if (success && data != null)
            {
                await response.Body.WriteAsync(data, 0, data.Length);
            }
        }
コード例 #13
0
 internal ContentHolder(PathInfo pathInfo, IContentReader reader, IContentWriter writer)
 {
     if (pathInfo != null)
     {
         this._pathInfo = pathInfo;
         this._reader   = reader;
         this._writer   = writer;
         return;
     }
     else
     {
         throw PSTraceSource.NewArgumentNullException("pathInfo");
     }
 }
コード例 #14
0
            internal ContentHolder(
                PathInfo pathInfo,
                IContentReader reader,
                IContentWriter writer)
            {
                if (pathInfo == null)
                {
                    throw PSTraceSource.NewArgumentNullException("pathInfo");
                }

                PathInfo = pathInfo;
                Reader   = reader;
                Writer   = writer;
            }
コード例 #15
0
 public GzipProcessor(
     IFileService fileService,
     ILogger logger,
     IContentReader reader,
     IContentWriter writer,
     IChunkProcessor processor,
     Settings settings)
 {
     _fileService = fileService;
     _logger      = logger;
     _reader      = reader;
     _writer      = writer;
     _processor   = processor;
     _settings    = settings;
 }
コード例 #16
0
        public FormOneline(ContentWriterFactory contentWriterFactory
                           , OnelineApp app
                           , IContentSource contentSource)
        {
            InitializeComponent();

            _contentWriterFactory   = contentWriterFactory;
            _textBoxContentWriter   = _contentWriterFactory.Create(ContentWriterType.TextBox, txtContent);
            _clipBoardContentWriter = _contentWriterFactory.Create(ContentWriterType.ClipBoard, txtContent);
            _app                  = app;
            _contentSource        = contentSource;
            _app.ContentWriter    = _textBoxContentWriter;
            _timerForAuto.Enabled = false;
            _timerForAuto.Tick   += TimerForAuto_AutoGetContent;
            _timerForAuto.Tick   += TimerForAuto_Transform;
        }
コード例 #17
0
        public void TestGetContentWriter()
        {
            FileSystemProvider fileSystemProvider = new FileSystemProvider();
            ProviderInfo       providerInfoToSet  = GetProvider();

            fileSystemProvider.SetProviderInformation(providerInfoToSet);
            fileSystemProvider.Context = new CmdletProviderContext(GetExecutionContext());

            IContentWriter contentWriter = fileSystemProvider.GetContentWriter(testPath);

            contentWriter.Write(new List <string>()
            {
                "contentWriterTestContent"
            });
            contentWriter.Close();
            Assert.Equal(File.ReadAllText(testPath), testContent + @"contentWriterTestContent" + System.Environment.NewLine);
        }
コード例 #18
0
        } // GetContentWriter

        /// <summary>
        /// Gets the content writer for the specified item.
        /// </summary>
        /// <param name="paths">
        /// The path(s) to the item(s) to get the content writer from.
        /// </param>
        /// <param name="context">
        /// The context which the core command is running.
        /// </param>
        /// <returns>
        /// The content writers for all items that the path resolves to.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="path"/> is null.
        /// </exception>
        /// <exception cref="ProviderNotFoundException">
        /// If the <paramref name="path"/> refers to a provider that could not be found.
        /// </exception>
        /// <exception cref="DriveNotFoundException">
        /// If the <paramref name="path"/> refers to a drive that could not be found.
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// If the provider that the <paramref name="path"/> refers to does
        /// not support this operation.
        /// </exception>
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        /// <exception cref="ItemNotFoundException">
        /// If <paramref name="path"/> does not contain glob characters and
        /// could not be found.
        /// </exception>
        internal Collection <IContentWriter> GetContentWriter(
            string[] paths,
            CmdletProviderContext context)
        {
            if (paths == null)
            {
                throw PSTraceSource.NewArgumentNullException("paths");
            }

            ProviderInfo   provider             = null;
            CmdletProvider providerInstance     = null;
            Collection <IContentWriter> results = new Collection <IContentWriter>();

            foreach (string path in paths)
            {
                if (path == null)
                {
                    throw PSTraceSource.NewArgumentNullException("paths");
                }

                Collection <string> providerPaths =
                    Globber.GetGlobbedProviderPathsFromMonadPath(
                        path,
                        true,
                        context,
                        out provider,
                        out providerInstance);

                foreach (string providerPath in providerPaths)
                {
                    IContentWriter result =
                        GetContentWriterPrivate(providerInstance, providerPath, context);

                    if (result != null)
                    {
                        results.Add(result);
                    }
                }
            }

            return(results);
        } // GetContentWriter
コード例 #19
0
        public IContentWriter Create(ContentWriterType writerType, TextBox textBox = null)
        {
            IContentWriter contentWriter = null;

            switch (writerType)
            {
            default:
            case ContentWriterType.TextBox:
                if (textBox == null)
                {
                    throw new ArgumentNullException(nameof(TextBox));
                }
                contentWriter = new TextBoxContentWriter(textBox);
                break;

            case ContentWriterType.ClipBoard:
                contentWriter = new ClipBoardContentWriter(new TextBoxContentWriter(textBox));
                break;
            }
            return(contentWriter);
        }
コード例 #20
0
 public ItemValueWriter(XmlElementInfo itemNodeInfo, IContentWriter contentWriter)
 {
     this.itemNodeInfo  = itemNodeInfo;
     this.contentWriter = contentWriter;
 }
コード例 #21
0
ファイル: ContentCommandBase.cs プロジェクト: 40a/PowerShell
            internal ContentHolder(
                PathInfo pathInfo,
                IContentReader reader,
                IContentWriter writer)
            {
                if (pathInfo == null)
                {
                    throw PSTraceSource.NewArgumentNullException("pathInfo");
                }

                PathInfo = pathInfo;
                Reader = reader;
                Writer = writer;
            } // constructor
コード例 #22
0
 public void SetWorker(IContentWriter writer)
 {
     worker = writer;
 }
コード例 #23
0
 public ProjectResourceUpdate WithContent(IContentWriter content)
 {
     DeferredContent = content;
     return(this);
 }
コード例 #24
0
 public ContentController(IContentReader contentReader, IContentWriter contentWriter)
 {
     _contentReader = contentReader;
     _contentWriter = contentWriter;
 }
コード例 #25
0
 /// <summary>
 /// Registers the specified content writer.
 /// </summary>
 /// <param name="writer">Writer to register.</param>
 public void RegisterContentWriter(IContentWriter writer)
 {
     _readerWriter.AddWriter(writer);
     Trace.TraceInformation("Added content writer \"{0}\" for content type [{1}]", writer.GetType().Name, writer.ContentType);
 }
コード例 #26
0
ファイル: AssetHttpHandler.cs プロジェクト: hartez/fubumvc
 public AssetHttpHandler(IContentWriter writer, IEnumerable<string> routeValues)
 {
     _writer = writer;
     _routeValues = routeValues;
 }
コード例 #27
0
 public AttributeValueWriter(XmlElementInfo xmlElementInfo, IContentWriter contentWriter)
 {
     this.xmlElementInfo = xmlElementInfo;
     this.contentWriter  = contentWriter;
 }
コード例 #28
0
 public void AddWriter(IContentWriter writer)
 {
     this.writers.Add(writer.ContentType, writer);
 }
コード例 #29
0
 public DictionaryValueWriter(XmlElementInfo xmlElementInfo, IContentWriter keyWriter, IContentWriter valueWriter, IXmlAttributeInterpreter xmlAttributeInterpreter)
 {
     itemContentWriter = new PairContentWriter(keyWriter, valueWriter, xmlAttributeInterpreter);
     arrayValueWriter  = new ArrayValueWriter(xmlElementInfo, itemContentWriter);
 }
コード例 #30
0
 public ArrayValueWriter(XmlElementInfo xmlElementInfo, IContentWriter itemContentWriter)
 {
     this.xmlElementInfo    = xmlElementInfo;
     this.itemContentWriter = itemContentWriter;
 }
コード例 #31
0
 public ListValueWriter(XmlElementInfo xmlElementInfo, IContentWriter itemContentWriter)
 {
     arrayValueWriter = new ArrayValueWriter(xmlElementInfo, itemContentWriter);
 }