Beispiel #1
0
        public string GetDigest()
        {
            var hashes = new string[]
            {
                $"{TimeStamp}-{BlockType}-{BlockId}-".ToBytes().ToSHA256Hash(),
                Properties.Aggregate("", (a, x) => a + $",{x.Key}={x.Value}").ToBytes().ToSHA256Hash(),
                Data.GetDigest(),
            };

            return(hashes.ToMerkleHash());
        }
Beispiel #2
0
 public override int GetHashCode()
 {
     if (Hash == null)
     {
         const int startValue = 17;
         const int multiplier = 59;
         Hash = Properties.Aggregate(startValue,
                                     (hash, property) => unchecked (hash * multiplier + property.Get(this).GetHashCode()));
     }
     return(Hash.Value);
 }
Beispiel #3
0
        public CypherSet Relationship(string name, Properties properties)
        {
            _sb.Append(properties.Aggregate(new StringBuilder(), (sb, p) => sb.AppendFormat("{0}{1}.{2} = {3}",
                                                                    sb.Length == 0 ? " " : ",",
                                                                    name,
                                                                    p.Key,
                                                                    JToken.FromObject(p.Value).ToString(Formatting.None, new IsoDateTimeConverter())
                                                                    ))
                        );

            return this;
        }
Beispiel #4
0
        public CypherSet Relationship(string name, Properties properties)
        {
            _sb.Append(properties.Aggregate(new StringBuilder(), (sb, p) => sb.AppendFormat("{0}{1}.{2} = {3}",
                                                                                            sb.Length == 0 ? " " : ",",
                                                                                            name,
                                                                                            p.Key,
                                                                                            JToken.FromObject(p.Value).ToString(Formatting.None, new IsoDateTimeConverter())
                                                                                            ))
                       );

            return(this);
        }
        public override IMap <string, INode> InitializeChildNodes(INode node, object snapshot)
        {
            IEnvironment env = node.Environment;

            return(Properties.Aggregate(new Map <string, INode>(), (map, pair) =>
            {
                var subpath = $"{pair.Key}";

                map[subpath] = pair.Value.Instantiate(node, subpath, env, GetPropertyValue((S)snapshot, pair.Key) ?? GetMutableDefault(pair.Key));

                return map;
            }));
        }
Beispiel #6
0
        public string PropertyRolesAsCS()
        {
            var allPropertyRoles = Properties.Aggregate(new List <string>(), (p, c) => p.Union(c.SecurityInfo.EditRolesList.Union(c.SecurityInfo.ReadRolesList)).ToList());

            var output = allPropertyRoles.Select(role => $"bool is{role} = false;").ToList();

            output.Add("if (user != null)");
            output.Add("{");
            output.AddRange(allPropertyRoles.Select(role => $"\tis{role} = user.IsInRole(\"{role}\");"));
            output.Add("}");

            return(string.Join($"{Environment.NewLine}\t\t\t", output));
        }
Beispiel #7
0
        internal ComponentBase(QsysCore core, JToken data)
        {
            try
            {
                Core        = core;
                Name        = data["Name"].Value <string>();
                _typeString = data["Type"].Value <string>();

                try
                {
                    Type =
                        (QsysComponentType)
                        Enum.Parse(typeof(QsysComponentType),
                                   Regex.Replace(_typeString, @"(?:^|_)([a-z])", m => m.Groups[1].ToString().ToUpper()),
                                   false);
                }
                catch
                {
                    Type = QsysComponentType.Unknown;
                }

                foreach (var property in data["Properties"])
                {
                    _properties[property["Name"].Value <string>()] = property["Value"].Value <string>();
                }
#if DEBUG
                var details = this + " created";
                details = details + "\r\nProperties:";
                details = Properties.Aggregate(details,
                                               (current, property) => current + string.Format("\r\n   - {0} = {1}", property.Key, property.Value));
                CloudLog.Debug(details);
#endif
            }
            catch (Exception e)
            {
                CloudLog.Exception(e);
            }
        }
Beispiel #8
0
 private void AddProperties()
 {
     Representation += Properties.Aggregate((x, y) => $"{x}{Environment.NewLine}{y}");
 }
 public bool AreFieldsValid()
 => Properties.Aggregate
 (
     true,
     (isTrue, next) => next.Validate() && isTrue
 );