Ejemplo n.º 1
0
        public void Properties()
        {
            var nc = new NamedContent
            {
                ContentPath = "/ipfs/...",
                NamePath    = "/ipns/..."
            };

            Assert.AreEqual("/ipfs/...", nc.ContentPath);
            Assert.AreEqual("/ipns/...", nc.NamePath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Создать сообщение со служебным документом.
        /// </summary>
        /// <param name="message">Сообщение.</param>
        /// <param name="parentDocument">Родительский документ.</param>
        /// <param name="serviceDocumentType">Тип служебного документа.</param>
        /// <param name="generatedNotice">Содержимое служебного документа.</param>
        /// <param name="signatureFactory">Фабрика подписи.</param>
        /// <returns>Сообщение.</returns>
        private Message CreateServiceDocumentMessage(
            Message message,
            Document parentDocument,
            DocumentType serviceDocumentType,
            NamedContent generatedNotice,
            Func <Document, ISignature> signatureFactory)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (parentDocument == null)
            {
                throw new ArgumentNullException(nameof(parentDocument));
            }
            if (generatedNotice == null)
            {
                throw new ArgumentNullException(nameof(generatedNotice));
            }
            if (signatureFactory == null)
            {
                throw new ArgumentNullException(nameof(signatureFactory));
            }

            var document = new Document
            {
                Id               = Guid.NewGuid().ToString(),
                DocumentType     = serviceDocumentType,
                ParentDocumentId = parentDocument.Id,
                FileName         = generatedNotice.Name,
                Content          = generatedNotice.Content
            };

            return(AddDocumentWithSignature(
                       new Message
            {
                Id = Guid.NewGuid().ToString(),
                From = _currentBox,
                Recipients = message.GetRecipientListForSender(_currentBox),
            },
                       document,
                       signatureFactory(document)));
        }
Ejemplo n.º 3
0
        public ContentTreeBuilder AddContent(Action <NamedContent> optionsBuilder, string zoneName = null, string parentNodeId = null)
        {
            ContentNode node    = null;
            var         options = new NamedContent();

            optionsBuilder.Invoke(options);

            if (options.WidgetType != null && options.ModelName != null)
            {
                var content = _widgetProvider.Create(options.WidgetType, options.ModelName);

                if (content == null)
                {
                    throw new Exception($"Could not build tree content. Invalid ModelName: {options.ModelName}.");
                }

                node = CreateContentNode(options.WidgetType, options.Style, content, zoneName, parentNodeId);
                _targetTree.ContentNodes.Add(node);
            }

            return(this);
        }
Ejemplo n.º 4
0
        public Message CreateServiceDocumentMessage(Message message, Document document, X509Certificate2 certificate2,
                                                    DocumentType documentType, NamedContent generatedNotice)
        {
            var noticeMessage = AddDocumentToNewMessage(
                new Message()
            {
                Id         = Guid.NewGuid().ToString(),
                From       = CurrentBox,
                Recipients = message.GetRecipientListForSender(CurrentBox),
            },
                new Document()
            {
                Id           = (Guid.NewGuid().ToString()),
                DocumentType =
                    documentType,
                ParentDocumentId = document.Id,
                FileName         = generatedNotice.Name,
                Content          = generatedNotice.Content
            },
                CryptoApiHelper.Sign(certificate2,
                                     generatedNotice.Content, true));

            return(noticeMessage);
        }