Beispiel #1
0
 internal DeliverArgs(long deliveryTag, ContentHeader header, byte[] body)
 {
     DeliveryTag = deliveryTag;
     _body       = body;
     _bodySize   = (int)header.BodySize;
     _header     = header;
 }
Beispiel #2
0
        public static void CreateGameVariant(Stream output, GameVariant gameVariant)
        {
            Contract.Requires <ArgumentNullException>(output != null && gameVariant != null);
            Contract.Requires(output.CanWrite);

            gameVariant.Metadata.ContentType  = ContentType.GameVariant;
            gameVariant.Metadata.FileLength   = 0x7F29;
            gameVariant.Metadata.DateModified = DateTime.Now;

            if (gameVariant.Metadata.Engine == GameEngine.None)
            {
                gameVariant.Metadata.Engine = GameEngine.PVP;
            }

            var contentHeader      = new ContentHeader(gameVariant.Metadata);
            var multiplayerVariant = new MultiplayerVariant(gameVariant);

            var chdr = new Chunk("chdr", version: 10, flags: ChunkFlags.IsHeader, payload: contentHeader);
            var mpvr = new Chunk("mpvr", version: 132, flags: ChunkFlags.IsInitialized, payload: multiplayerVariant);

            var blob = new Blob(chdr, mpvr);

            using (var s = new BinaryStream(output, StreamState.Write, ByteOrder.BigEndian, false))
                s.Serialize(blob);
        }
        protected GameEngineBaseVariant(GameEngineVariant variantManager)
        {
            BuildHandle = variantManager.GameBuild;
            Header      = ContentHeader.Create(BuildHandle);

            OptionsSocial = new GameOptionsSocial();
        }
Beispiel #4
0
        protected override string ContentHeader()
        {
            ContentHeader contentHeader = new ContentHeader("Elements");

            contentHeader.AddAnchor(new Anchor(RedirectRoute.Index, "Home", "Go to Home", "icon-home", "tip-bottom"));
            return(contentHeader.Render());
        }
        private void Restart(ContentHeader header)
        {
            _deliverPosition = 0;
            _activeDeliver   = ArrayPool <byte> .Shared.Rent((int)header.BodySize);

            _reader.Restart(header);
        }
Beispiel #6
0
        public static ContentHeader AnalyzeContentHeader(ReadOnlySpan <char> line)
        {
            ContentHeader       result   = new ContentHeader();
            ReadOnlySpan <char> property = line;
            int offset = 0;

            for (int i = 0; i < line.Length; i++)
            {
                if (line[i] == ':')
                {
                    result.Name = new string(line.Slice(0, i));
                    offset      = i + 1;
                }
                else if (offset > 0 && line[i] == ' ')
                {
                    offset = i + 1;
                }
                else if (line[i] == ';')
                {
                    result.Value = new string(line.Slice(offset, i - offset));
                    property     = line.Slice(i + 1);
                    offset       = 0;
                    break;
                }
            }
            if (offset > 0)
            {
                result.Value = new string(line.Slice(offset, line.Length - offset));
            }
            if (property.Length != line.Length)
            {
                result.Properties = GetProperties(property);
            }
            return(result);
        }
Beispiel #7
0
 public PublishAllInfo(ushort channelId, ref ReadOnlyMemory <byte> body, ref BasicPublishInfo info, ContentHeader header)
 {
     Body           = body;
     _info          = info;
     _contentHeader = header;
     ChannelId      = channelId;
 }
Beispiel #8
0
        public string Render(object viewModel, string settingType)
        {
            var           setting = UISettings.Current.Items[settingType] as UISetting;
            StringBuilder sb      = new StringBuilder();

            if (setting != null)
            {
                sb.Append(setting.ContentHeader);
            }
            if (!string.IsNullOrEmpty(ContentHeader))
            {
                sb.Append(ContentHeader.ReplaceContextParameters(viewModel, viewModel));
            }
            Render(sb, viewModel);
            if (!string.IsNullOrEmpty(ContentFooter))
            {
                sb.Append(ContentFooter.ReplaceContextParameters(viewModel, viewModel));
            }
            if (setting != null)
            {
                sb.Append(setting.ContentFooter);
            }

            return(sb.ToString());
        }
 public EvaluationCriteriaViewModel(Projekt project, Kriterij criteria, List <UsporedbaKriterija> criteriaComparison, List <Kriterij> listOfCriteria)
 {
     this.Projekt          = project;
     this.KriterijRoditelj = criteria;
     this.ListaUsporedaba  = criteriaComparison;
     this.ListaKriterija   = listOfCriteria;
     this.ContentHeader    = GetContentHeader(project.naziv, criteria.naziv);
 }
Beispiel #10
0
 public ProjectViewModel(Projekt project, List <Kriterij> criteria, List <Alternativa> alternatives, List <Dnevnik> logs)
 {
     this.Project       = project;
     this.Criteria      = criteria;
     this.Alternatives  = alternatives;
     this.Logs          = logs;
     this.ContentHeader = GetContentHeader(project.naziv);
 }
Beispiel #11
0
        protected override string ContentHeader()
        {
            ContentHeader contentHeader = new ContentHeader(MenuIndexResource.MenuManageTitle);

            contentHeader.AddAnchor(new Anchor(RedirectRoute.Index, "Home", "Go to Home", "icon-home", "tip-bottom"));
            string html = contentHeader.Render();

            return(html);
        }
Beispiel #12
0
        protected override string ContentHeader()
        {
            ContentHeader contentHeader = new ContentHeader(Resources.WidgetTitle);

            contentHeader.AddAnchor(new Anchor(RedirectRoute.Index, "首页", "返回首页", "icon-home", "tip-bottom"));
            string html = contentHeader.Render();

            return(html);
        }
Beispiel #13
0
        protected override string ContentHeader()
        {
            ContentHeader contentHeader = new ContentHeader(ErrorResource.Header);

            contentHeader.AddAnchor(new Anchor(RedirectRoute.Index, "Home", "Go to Home", "Error-home", "tip-bottom"));
            string html = contentHeader.Render();

            return(html);
        }
Beispiel #14
0
        private void ParseMultipartFormData()
        {
            while (this.MoveToNextContent())
            {
                ContentHeader cH = this.ReadContentHeader();

                this.HandleContent(cH);
            }
        }
        public async ValueTask Publish(string exchangeName, string routingKey, bool mandatory, bool immediate, ContentHeaderProperties properties, byte[] message)
        {
            var info    = new BasicPublishInfo(exchangeName, routingKey, mandatory, immediate);
            var content = new ContentHeader(60, message.Length, ref properties);
            await _protocol.Writer.WriteAsync(new BasicPublishWriter(_channelId), info).ConfigureAwait(false);

            await _protocol.Writer.WriteAsync(new ContentHeaderWriter(_channelId), content).ConfigureAwait(false);

            await _protocol.Writer.WriteAsync(new BodyFrameWriter(_channelId), message).ConfigureAwait(false);
        }
        public static async Task <Entity> ReadEntityAsync(this IRequest request)
        {
            var contentHeader = new ContentHeader(request.Headers);
            var mimeType      = contentHeader.Type;
            var encoding      = contentHeader.Encoding;

            var serializer = new MediaSerializer(mimeType);
            var entity     = serializer.Deserialize(request.Body, encoding);

            return(await Task.FromResult(entity));
        }
Beispiel #17
0
        public async ValueTask <bool> Publish(string exchangeName, string routingKey, bool mandatory, bool immediate, ContentHeaderProperties properties, ReadOnlyMemory <byte> message)
        {
            if (IsClosed)
            {
                return(false);
            }
            Session.LockEvent.Wait();
            var info    = new BasicPublishInfo(exchangeName, routingKey, mandatory, immediate);
            var content = new ContentHeader(60, message.Length, ref properties);

            if (message.Length <= Session.Tune.FrameMax)
            {
                var allinfo = new PublishAllInfo(ChannelId, ref message, ref info, content);
                try
                {
                    await Session.PublishAllAsync(allinfo).ConfigureAwait(false);
                }catch (Exception e)
                {
                    Debugger.Break();
                    var cts = new CancellationTokenSource(Session.Options.ConnectionTimeout);
                    using (var timeoutRegistratiuon = cts.Token.Register(() => cts.Cancel()))
                    {
                        return(await PublishAllContinuation(allinfo, cts.Token));
                    }
                }
            }


            await WriterSemaphore.WaitAsync().ConfigureAwait(false);

            var written     = 0;
            var partialInfo = new PublishPartialInfo(ref info, ref content);
            await Session.PublishPartialAsync(ChannelId, partialInfo).ConfigureAwait(false);

            while (written < content.BodySize)
            {
                var batchCnt = 0;
                while (batchCnt < _publishBatchSize && written < content.BodySize)
                {
                    var writable = Math.Min(Session.Tune.FrameMax, (int)content.BodySize - written);
                    _publishBatch[batchCnt] = message.Slice(written, writable);
                    batchCnt++;
                    written += writable;
                }
                await Session.PublishBodyAsync(ChannelId, _publishBatch).ConfigureAwait(false);

                _publishBatch.AsSpan().Fill(ReadOnlyMemory <byte> .Empty);
            }

            WriterSemaphore.Release();
            return(true);
        }
        internal override async ValueTask ReadBodyMessage(RabbitMQDeliver deliver, ContentHeader header)
        {
            var headerResult = await _protocol.Reader.ReadAsync(new FrameHeaderReader()).ConfigureAwait(false);

            _protocol.Reader.Advance();
            _reader.Restart(header);

            while (!_reader.IsComplete)
            {
                var result = await _protocol.Reader.ReadAsync(_reader).ConfigureAwait(false);

                var chunk = new ChunkedConsumeResult(result.Message, _reader.IsComplete);
                Received?.Invoke(deliver, chunk);
                _protocol.Reader.Advance();
            }
        }
        public override void OnExecute(ICommandContext context, CommandConfig config, CommandResult result)
        {
            var viewResult = result as ExtendedActionResult;

            #region 创建ReportViewer

            ReportViewerSetting reportViewer = new ReportViewerSetting
            {
                DataSources = new List <ReportDataSource>(),
                Parameters  = new List <ReportParameter>()
            };
            reportViewer.ReportPath = ReportPath;

            DataSources.ForEach(p =>
            {
                var pValue = p.GetValue(context);
                if (pValue == null)
                {
                    throw new Exception(string.Format("参数[{0}]不能为空", p.Name));
                }
                reportViewer.DataSources.Add(new ReportDataSource(p.Name, pValue));
            });

            Parameters.ForEach(p =>
            {
                var pValue = p.GetValue(context);
                if (pValue == null)
                {
                    throw new Exception(string.Format("参数[{0}]不能为空", p.Name));
                }
                reportViewer.Parameters.Add(new ReportParameter(p.Name, pValue.ToString()));
            });

            reportViewer.ContentHeader = string.IsNullOrEmpty(ContentHeader) ? "" :
                                         ContentHeader.ReplaceContextParameters(context, context);

            reportViewer.ContentFooter = string.IsNullOrEmpty(ContentFooter) ? "" :
                                         ContentFooter.ReplaceContextParameters(context, context);
            #endregion

            string id = Guid.NewGuid().ToString();
            ReportViewers.Add(id, reportViewer);
            viewResult.ActionResult = ReportViewers.Redirect(id, ReportViewerUrl);

            result.End(NextCommand);
            context.Execute(NextCommand);
        }
Beispiel #20
0
        public static void CreateMapVariant(Stream output, MapVariant mapVariant)
        {
            Contract.Requires <ArgumentNullException>(output != null && mapVariant != null);
            Contract.Requires(output.CanWrite);

            mapVariant.Metadata.ContentType = ContentType.MapVariant;
            mapVariant.Metadata.FileLength  = 0x7329;

            var contentHeader = new ContentHeader(mapVariant.Metadata);
            var usermap       = new Usermap(mapVariant);

            var chdr = new Chunk("chdr", version: 10, flags: ChunkFlags.IsHeader, payload: contentHeader);
            var mvar = new Chunk("mvar", version: 50, flags: ChunkFlags.IsInitialized, payload: usermap);

            var blob = new Blob(chdr, mvar);

            using (var s = new BinaryStream(output, StreamState.Write, ByteOrder.BigEndian, false))
                s.Serialize(blob);
        }
        internal override async ValueTask ReadBodyMessage(RabbitMQDeliver deliver, ContentHeader header)
        {
            var headerResult = await _protocol.Reader.ReadAsync(new FrameHeaderReader()).ConfigureAwait(false);

            _protocol.Reader.Advance();
            Restart(header);

            while (!_reader.IsComplete)
            {
                var result = await _protocol.Reader.ReadAsync(_reader).ConfigureAwait(false);

                Copy(result.Message);
                _protocol.Reader.Advance();
            }
            Received?.Invoke(deliver, _activeDeliver);
            ArrayPool <byte> .Shared.Return(_activeDeliver);

            _activeDeliver = null;
        }
Beispiel #22
0
        private ContentHeader ParseContentHeader(string contentHeader)
        {
            ContentHeader rCH = new ContentHeader();
            StringReader  sR  = new StringReader(contentHeader);

            while (sR.Peek() > -1)
            {
                string line = sR.ReadLine();

                if (line.IndexOf(this._Header.Boundary) > -1)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                string[] keyValues = line.Split(';');

                foreach (string keyValue in keyValues)
                {
                    int sepIndex = keyValue.IndexOf(':');
                    if (sepIndex == -1)
                    {
                        sepIndex = keyValue.IndexOf('=');

                        if (sepIndex == -1)
                        {
                            continue;
                        }
                    }

                    string key = keyValue.Substring(0, sepIndex);
                    key = key.Trim();
                    string value = keyValue.Substring(sepIndex + 1);
                    value = value.Trim();

                    if (value.StartsWith("\""))
                    {
                        value = value.Substring(1);
                    }

                    if (value.EndsWith("\""))
                    {
                        value = value.Substring(0, value.Length - 1);
                    }

                    int semiIndex = value.IndexOf(';');
                    if (semiIndex > -1)
                    {
                        value = value.Substring(0, semiIndex);
                    }

                    switch (key.ToLowerInvariant())
                    {
                    case "content-disposition":
                        rCH.ContentDisposition = value;

                        break;

                    case "name":
                        rCH.Name = value;

                        break;

                    case "filename":
                        rCH.FileName = value;

                        break;

                    case "content-type":
                        rCH.ContentType = value;

                        break;

                    case "charset":
                        try
                        {
                            rCH.ContentEncoding = Encoding.GetEncoding(value);
                        }
                        catch (Exception)
                        {
                            rCH.ContentEncoding = null;
                        }

                        break;
                    }
                }
            }

            return(rCH);
        }
Beispiel #23
0
        private void HandleContent(ContentHeader contentHeader)
        {
            if (string.IsNullOrEmpty(contentHeader.Name))
            {
                return;
            }

            if (string.IsNullOrEmpty(contentHeader.ContentType))
            {
                Stream       contentStream = null;
                StreamReader sR            = null;

                try
                {
                    contentStream = new MemoryStream();

                    if (this.ReadContentBody(contentStream))
                    {
                        if (contentHeader.ContentEncoding != null)
                        {
                            sR = new StreamReader(contentStream, contentHeader.ContentEncoding, true);
                        }
                        else if (this._Header.ContentEncoding != null)
                        {
                            sR = new StreamReader(contentStream, this._Header.ContentEncoding, true);
                        }
                        else
                        {
                            sR = new StreamReader(contentStream, true);
                        }

                        ((HttpRequestForm)this.Form).AddOrUpdate(contentHeader.Name, sR.ReadToEnd());
                    }
                }
                catch (Exception)
                {
                    // Just Handle Exceptions
                }
                finally
                {
                    if (sR != null)
                    {
                        sR.Close();
                        GC.SuppressFinalize(sR);
                    }

                    if (contentStream != null)
                    {
                        contentStream.Close();
                        GC.SuppressFinalize(contentStream);
                    }
                }

                return;
            }

            // if the request size smaller than 3,5 MB, use the memory.
            HttpRequestFileInfo requestFI =
                new HttpRequestFileInfo(
                    this._ContextID,
                    contentHeader.ContentType,
                    contentHeader.ContentEncoding,
                    contentHeader.FileName,
                    this._Header.ContentLength < 3670016
                    );

            if (this.ReadContentBody(requestFI._ContentStream))
            {
                ((HttpRequestFile)this.File).AddOrUpdate(contentHeader.Name, requestFI);
            }
        }
 internal abstract ValueTask ReadBodyMessage(RabbitMQDeliver deliver, ContentHeader header);
 public PublishPartialInfo(ref BasicPublishInfo info, ref ContentHeader header)
 {
     _info          = info;
     _contentHeader = header;
 }
Beispiel #26
0
        public HomeViewModel(IEnumerable <Projekt> projects)
        {
            ContentHeader = GetContentHeader();

            this.Projects = projects;
        }
Beispiel #27
0
 public HomeViewModel()
 {
     ContentHeader = GetContentHeader();
 }