本文整理汇总了C#中IConstructor.ConstructPrivateType方法的典型用法代码示例。如果您正苦于以下问题:C# IConstructor.ConstructPrivateType方法的具体用法?C# IConstructor.ConstructPrivateType怎么用?C# IConstructor.ConstructPrivateType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConstructor
的用法示例。
在下文中一共展示了IConstructor.ConstructPrivateType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConstructYamlTimestamp
public static object ConstructYamlTimestamp(IConstructor ctor, Node node) {
ScalarNode scalar = node as ScalarNode;
if (scalar == null) {
throw new ConstructorException("can only contruct timestamp from scalar node");
}
Match match = TIMESTAMP_REGEXP.Match(scalar.Value);
if (!match.Success) {
return ctor.ConstructPrivateType(node);
}
string year_s = match.Groups[1].Value;
string month_s = match.Groups[2].Value;
string day_s = match.Groups[3].Value;
string hour_s = match.Groups[4].Value;
string min_s = match.Groups[5].Value;
string sec_s = match.Groups[6].Value;
string fract_s = match.Groups[7].Value;
string utc = match.Groups[8].Value;
string timezoneh_s = match.Groups[9].Value;
string timezonem_s = match.Groups[10].Value;
bool isUtc = utc == "Z" || utc == "z";
DateTime dt = new DateTime(
year_s != "" ? int.Parse(year_s) : 0,
month_s != "" ? int.Parse(month_s) : 1,
day_s != "" ? int.Parse(day_s) : 1,
hour_s != "" ? int.Parse(hour_s) : 0,
min_s != "" ? int.Parse(min_s) : 0,
sec_s != "" ? int.Parse(sec_s) : 0,
isUtc? DateTimeKind.Utc : DateTimeKind.Local
);
if (!string.IsNullOrEmpty(fract_s)) {
long fract = int.Parse(fract_s);
if (fract > 0) {
while (fract < 1000000) {
fract *= 10;
}
dt = dt.AddTicks(fract);
}
}
if (!isUtc) {
if (timezoneh_s != "" || timezonem_s != "") {
int zone = 0;
int sign = +1;
if (timezoneh_s != "") {
if (timezoneh_s.StartsWith("-")) {
sign = -1;
}
zone += int.Parse(timezoneh_s.Substring(1)) * 3600000;
}
if (timezonem_s != "") {
zone += int.Parse(timezonem_s) * 60000;
}
double utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(dt).TotalMilliseconds;
dt = dt.AddMilliseconds(utcOffset - sign * zone);
}
}
return dt;
}