Beispiel #1
0
        public MamChannel Create(
            Mode mode,
            Seed seed,
            int securityLevel = SecurityLevel.Medium,
            string channelKey = null,
            bool keyIsTrytes  = false,
            Hash nextRoot     = null,
            int index         = 0,
            int count         = 1,
            int nextCount     = 1,
            int start         = 0)
        {
            var channel = new MamChannel(this.MamFactory, this.TreeFactory, this.Repository);

            channel.Init(
                mode,
                seed,
                securityLevel,
                channelKey != null ? keyIsTrytes ? new TryteString(channelKey) : TryteString.FromAsciiString(channelKey) : Hash.Empty,
                nextRoot,
                index,
                count,
                nextCount,
                start);

            return(channel);
        }
        /// <summary>
        /// The create.
        /// </summary>
        /// <param name="mode">
        /// The mode.
        /// </param>
        /// <param name="seed">
        /// The seed.
        /// </param>
        /// <param name="securityLevel">
        /// The security level.
        /// </param>
        /// <param name="channelKey">
        /// The channel key.
        /// </param>
        /// <param name="nextRoot">
        /// The next Root.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <param name="count">
        /// The count.
        /// </param>
        /// <param name="nextCount">
        /// The next Count.
        /// </param>
        /// <param name="start">
        /// The start.
        /// </param>
        /// <returns>
        /// The <see cref="MamChannel"/>.
        /// </returns>
        public MamChannel Create(
            Mode mode,
            Seed seed,
            int securityLevel      = SecurityLevel.Medium,
            TryteString channelKey = null,
            Hash nextRoot          = null,
            int index     = 0,
            int count     = 1,
            int nextCount = 1,
            int start     = 0)
        {
            var channel = new MamChannel(this.MamFactory, this.TreeFactory, this.Repository);

            channel.Init(mode, seed, securityLevel, channelKey, nextRoot, index, count, nextCount, start);

            return(channel);
        }
        /// <summary>
        /// The create from json.
        /// </summary>
        /// <param name="serializedChannel">
        /// The serialized channel.
        /// </param>
        /// <returns>
        /// The <see cref="MamChannel"/>.
        /// </returns>
        public MamChannel CreateFromJson(string serializedChannel)
        {
            var unserializedChannelData = JsonConvert.DeserializeObject <dynamic>(serializedChannel);

            var channel = new MamChannel(this.MamFactory, this.TreeFactory, this.Repository);

            channel.Init(
                (Mode)unserializedChannelData.Mode,
                new Seed((string)unserializedChannelData.Seed.Value),
                (int)unserializedChannelData.SecurityLevel,
                new Hash((string)unserializedChannelData.Key.Value),
                new Hash((string)unserializedChannelData.NextRoot.Value),
                (int)unserializedChannelData.Index,
                (int)unserializedChannelData.Count,
                (int)unserializedChannelData.NextCount,
                (int)unserializedChannelData.Start);

            return(channel);
        }