Example #1
0
        private static void _WriterSingleTable(DataTable dt, StringBuilder strb, GetValueMethod getvalue = null)
        {
            strb.Append($"<div><h4>{dt.TableName}</h4></div>");
            //开始写表
            strb.Append($"<table>");
            //写入列标题
            strb.Append($"<tr>");
            foreach (System.Data.DataColumn dcol in dt.Columns)
            {
                strb.Append($"<td >{dcol.ColumnName}</td>");
            }
            strb.Append($"</tr>");

            var cols = dt.Columns;

            //写入数据行
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                strb.Append($"<tr>");
                foreach (System.Data.DataColumn col in cols)
                {
                    strb.Append($"<td>{getvalue(dr[col.ColumnName].ToString(), col)}</td>");
                }
                strb.Append($"</tr>");
            }
            strb.Append($"</table>");
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="getvalue">获取数据的方法</param>
        /// <returns></returns>
        public static string WriterSingleTable(DataTable dt, GetValueMethod getvalue = null)
        {
            getvalue = getvalue ?? GetValue;
            StringBuilder strb = new StringBuilder();

            //开始写表
            strb.Append($"<table>");
            //写入列标题
            strb.Append($"<tr>");
            foreach (System.Data.DataColumn dcol in dt.Columns)
            {
                strb.Append($"<td >{dcol.ColumnName}</td>");
            }
            strb.Append($"</tr>");

            var cols = dt.Columns;

            //写入数据行
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                strb.Append($"<tr>");
                foreach (System.Data.DataColumn col in cols)
                {
                    strb.Append($"<td>{getvalue(dr[col.ColumnName].ToString(), col)}</td>");
                }
                strb.Append($"</tr>");
            }
            strb.Append($"</table>");

            return(strb.ToString());
        }
Example #3
0
        public PropertyMap(ISerializer serializer, PropertyDefinition propertyDefinition, ITypeMap typeMap, IEnumerable <string> availableFilters)
        {
            this.serializer = serializer;

            this.typeMap = typeMap is IContentTypeMap contentTypeMap && propertyDefinition.Content.UseXop
                ? contentTypeMap.GetOptimizedContentTypeMap()
                : typeMap;

            Definition = propertyDefinition;

            getValueMethod = Definition.PropertyInfo.CreateGetValueMethod();
            setValueMethod = Definition.PropertyInfo.CreateSetValueMethod();

            if (availableFilters == null)
            {
                return;
            }

            foreach (var availableFilter in availableFilters.Where(f => Definition.DeclaringTypeDefinition.Type.IsFilterableField(Definition.RuntimeName, f)))
            {
                filters.Add(availableFilter);
            }
        }
Example #4
0
        public void SetValue_GetValue_KnownCoseHeaderLabel(SetValueMethod setMethod, GetValueMethod getMethod)
        {
            var map = new CoseHeaderMap();

            SetValue(map, CoseHeaderLabel.Algorithm, (int)ECDsaAlgorithm.ES256, setMethod);

            if (setMethod != SetValueMethod.AddShortcut)
            {
                SetEncodedValue(map, CoseHeaderLabel.CriticalHeaders, GetDummyCritHeaderValue(), setMethod);
            }

            SetValue(map, CoseHeaderLabel.ContentType, ContentTypeDummyValue, setMethod);
            SetValue(map, CoseHeaderLabel.KeyIdentifier, s_sampleContent, setMethod);

            Assert.Equal((int)ECDsaAlgorithm.ES256, GetValue <int>(map, CoseHeaderLabel.Algorithm, getMethod));

            if (getMethod != GetValueMethod.GetValueShortcut)
            {
                AssertExtensions.SequenceEqual(GetDummyCritHeaderValue(), GetEncodedValue(map, CoseHeaderLabel.CriticalHeaders, getMethod));
            }

            Assert.Equal(ContentTypeDummyValue, GetValue <string>(map, CoseHeaderLabel.ContentType, getMethod));
            AssertExtensions.SequenceEqual(s_sampleContent, GetValue <byte[]>(map, CoseHeaderLabel.KeyIdentifier, getMethod));
        }
 public StructListProperty(string name, GetValueMethod getValue, SetValueMethod setValue, CreateInstanceMethod createInstance = null)
     : base(name, getValue, setValue)
 {
     m_CreateInstanceMethod = createInstance ?? DefaultCreateInstance;
 }
Example #6
0
        public void SetEncodedValue_GetEncodedValue_KnownCoseHeaderLabel(int knownHeader, byte[] encodedValue, SetValueMethod setMethod, GetValueMethod getMethod)
        {
            var map   = new CoseHeaderMap();
            var label = new CoseHeaderLabel(knownHeader);

            SetEncodedValue(map, label, encodedValue, setMethod);

            ReadOnlySpan <byte> returnedEncocedValue = GetEncodedValue(map, label, getMethod);

            AssertExtensions.SequenceEqual(encodedValue, returnedEncocedValue);
        }
Example #7
0
 public ValueClassProperty(string name, GetValueMethod getValue, SetValueMethod setValue) : base(name, getValue, setValue)
 {
 }
 public EnumListProperty(string name, GetValueMethod getValue, SetValueMethod setValue, CreateInstanceMethod createInstance = null) : base(name, getValue, setValue, createInstance)
 {
     Assert.IsTrue(typeof(TItem).IsEnum);
 }
Example #9
0
 public StructContainerProperty(string name, GetValueMethod getValue, SetValueMethod setValue) : base(name, getValue, setValue)
 {
 }
Example #10
0
 protected DelegateValueClassPropertyBase(string name, GetValueMethod getValue, SetValueMethod setValue)
     : base(name)
 {
     m_GetValue = getValue;
     m_SetValue = setValue;
 }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dts"></param>
        /// <param name="title"></param>
        /// <param name="getvalue">获取数据的方法</param>
        /// <returns></returns>
        public static string WriterTableArray(System.Data.DataTable[] dts, string title, GetValueMethod getvalue = null)
        {
            getvalue = getvalue ?? GetValue;

            StringBuilder strb = new StringBuilder();


            //写入网页标题
            strb.Append($@"<!DOCTYPE html><html><head>
<title>{title}</title>
<style>
div{{text-align:center}}
table{{border-collapse:collapse;border-spacing:0;border-left:1px solid #888;border-top:1px solid #888;background:#efefef;width:100%;margin:0 auto;
}}
table tr:first-child{{text-align:center}}
th,td{{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;word-break:break-all}}
th{{font-weight:bold;background:#ccc}}
</style>
</head><body>");
            //写标题
            strb.Append($"<div><h2>{title}</h2></div>");


            foreach (var dt in dts)
            {
                _WriterSingleTable(dt, strb, getvalue);
                strb.Append("<br/><br/><br/>");
            }

            strb.Append($@"</body></html>");
            return(strb.ToString());
        }
Example #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="title"></param>
        /// <param name="size"></param>
        /// <param name="maxszie"></param>
        /// <param name="minsize"></param>
        /// <param name="getvalue">获取数据的方法</param>
        /// <returns></returns>
        public static string WriterTableInfo(System.Data.DataTable dt, string title, int[] size, int maxszie = 0, int minsize = 0, GetValueMethod getvalue = null)
        {
            getvalue = getvalue ?? GetValue;
            StringBuilder strb = new StringBuilder();

            size = size ?? new int[0];

            //写入网页标题
            strb.Append($@"<!DOCTYPE html><html><head>
<title>{title}</title>
<style>
div{{text-align:center}}
table{{border-collapse:collapse;border-spacing:0;border-left:1px solid #888;border-top:1px solid #888;background:#efefef;width:100%;margin:0 auto;
{(minsize <= 0 ? "" : $"min-width:{minsize}px;")}{(maxszie <= 0 ? "" : $"max-width:{maxszie}px;")}
}}
table tr:first-child{{text-align:center}}
th,td{{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;word-break:break-all}}
th{{font-weight:bold;background:#ccc}}
</style>
</head><body>");
            //写标题
            strb.Append($"<div><h2>{title}</h2></div>");

            //开始写表
            strb.Append($"<table>");
            //写入列标题
            strb.Append($"<tr>");
            int index = 0;

            foreach (System.Data.DataColumn dcol in dt.Columns)
            {
                strb.Append($"<td {(size.Length < index + 1 ? "" : $"style=\"width:{size[index++]}px\"")}>{dcol.ColumnName}</td>");
            }
            strb.Append($"</tr>");


            var cols = dt.Columns;

            //写入数据行
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                strb.Append($"<tr>");
                foreach (System.Data.DataColumn col in cols)
                {
                    strb.Append($"<td>{getvalue(dr[col.ColumnName].ToString(), col)}</td>");
                }
                strb.Append($"</tr>");
            }
            strb.Append($"</table>");
            strb.Append($@"</body></html>");


            return(strb.ToString());
        }
Example #13
0
 public TypeIdStructProperty(GetValueMethod getValue) : base("$TypeId", getValue, null)
 {
 }
Example #14
0
 public TypeIdClassProperty(GetValueMethod getValue) : base("$TypeId", getValue, null)
 {
 }
 public StructMutableContainerListProperty(string name, GetValueMethod getValue, SetValueMethod setValue, CreateInstanceMethod createInstanceMethod = null)
     : base(name, getValue, setValue, createInstanceMethod)
 {
 }
Example #16
0
 public StructValueStructProperty(string name, GetValueMethod getValue, SetValueMethod setValue, GetValueRefMethod getValueRef) : base(name, getValue, setValue)
 {
     Assert.IsNotNull(getValueRef);
     m_GetValueRef = getValueRef;
 }
Example #17
0
 public Property(string name, GetValueMethod getValue, SetValueMethod setValue)
     : this(name)
 {
     m_GetValue = getValue;
     m_SetValue = setValue;
 }
Example #18
0
 public ClassValueStructProperty(string name, GetValueMethod getValue, SetValueMethod setValue)
     : base(name, getValue, setValue)
 {
 }
Example #19
0
 public StructMutableContainerProperty(string name, GetValueMethod getValue, SetValueMethod setValue, RefAccessMethod refAccess) : base(name, getValue, setValue)
 {
     RefAccess = refAccess;
 }
 public StructEnumProperty(string name, GetValueMethod getValue, SetValueMethod setValue) : base(name, getValue, setValue)
 {
 }