Пример #1
0
        public RepresentedModel(Type classWithProps)
        {
            schema = new ValueMap<string, RepresentedModelValue>();
            PropertyInfo[] props = classWithProps.GetProperties();

            foreach (PropertyInfo prop in props)
            {
                if (prop.CanRead && prop.CanWrite)
                {
                    FieldDescription[] attrs = (FieldDescription[])prop.GetCustomAttributes(typeof(FieldDescription), true);
                    bool isnull;
                    FieldType itv = GetRType(prop.PropertyType, out isnull);
                    RepresentedModelValue sch_v = new RepresentedModelValue(itv)
                    {
                        propertyDescriptor = prop
                    };
                    if (attrs.Length > 0)
                    {
                        FieldDescription at = attrs[0];
                        if (!at.Ignore)
                        {
                            sch_v.Description = at.Description;
                            sch_v.Required = at.Required;
                            sch_v.Inherited = at.Inherited;

                            schema.Add(prop.Name, sch_v);
                        }
                    }
                    else
                    {
                        schema.Add(prop.Name, sch_v);
                    }
                }
            }
        }
Пример #2
0
        public RepresentedModel(Type classWithProps)
        {
            schema = new ValueMap <string, RepresentedModelValue>();
            PropertyInfo[] props = classWithProps.GetProperties();

            foreach (PropertyInfo prop in props)
            {
                if (prop.CanRead && prop.CanWrite)
                {
                    FieldDescription[] attrs = (FieldDescription[])prop.GetCustomAttributes(typeof(FieldDescription), true);
                    bool                  isnull;
                    FieldType             itv   = GetRType(prop.PropertyType, out isnull);
                    RepresentedModelValue sch_v = new RepresentedModelValue(itv)
                    {
                        propertyDescriptor = prop
                    };
                    if (attrs.Length > 0)
                    {
                        FieldDescription at = attrs[0];
                        if (!at.Ignore)
                        {
                            sch_v.Description = at.Description;
                            sch_v.Required    = at.Required;
                            sch_v.Inherited   = at.Inherited;

                            schema.Add(prop.Name, sch_v);
                        }
                    }
                    else
                    {
                        schema.Add(prop.Name, sch_v);
                    }
                }
            }
        }
Пример #3
0
        public SchemeValueSpec(TaskQueue.RepresentedModelValue schemeValue)
        {
            this.VType       = schemeValue.VType.ToString();
            this.Description = schemeValue.Description;
            this.Required    = schemeValue.Required;

            if (schemeValue.DefaultValue != null)
            {
                this.DefaultValue = schemeValue.DefaultValue.ToString();
            }
        }
Пример #4
0
        /// <summary>
        /// For Vector hash
        /// </summary>
        /// <returns></returns>
        public byte[] LightweightSchemeProjection()
        {
            List <byte> b = new List <byte>();

            for (int i = 0; i < schema.val1.Count; i++)
            {
                RepresentedModelValue rv = schema.val2[i];
                //if (!Ignored) ignored not in list anyway
                //{
                b.AddRange(Encoding.UTF8.GetBytes(schema.val1[i]));
                b.Add((byte)(rv.VType));
                //}
            }

            return(b.ToArray());
        }
Пример #5
0
        /// <summary>
        /// Compatibility hash
        /// </summary>
        /// <returns></returns>
        public string CalculateSchemeHash()
        {
            List <byte> b      = new List <byte>();
            string      result = "";

            for (int i = 0; i < schema.val1.Count; i++)
            {
                RepresentedModelValue rv = schema.val2[i];
                if (rv.Required)
                {
                    b.AddRange(Encoding.UTF8.GetBytes(schema.val1[i]));
                    b.Add((byte)(rv.VType));
                }
            }
            byte[] hash = (new System.Security.Cryptography.SHA1Managed()).ComputeHash(b.ToArray());
            for (int i = 0; i < hash.Length; i++)
            {
                result += hash[i].ToString("x2");
            }
            return(result);
        }