本文整理汇总了C#中Options.CommandFilter方法的典型用法代码示例。如果您正苦于以下问题:C# Options.CommandFilter方法的具体用法?C# Options.CommandFilter怎么用?C# Options.CommandFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options.CommandFilter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TranslateFunctions
private void TranslateFunctions(XmlSpecData spec, DotNetApiData api, Options options)
{
foreach (var specCommand in spec.Commands.Where(x => options.CommandFilter(x)))
{
var specFeature = spec.Features.Where(x => x.Commands.Contains(specCommand.Name)).FirstOrDefault();
var functionData = new DotNetFunctionData()
{
IsNative = true,
OriginalName = specCommand.Name,
NativeName = this.InflectFunctionNativeName(specCommand.Name, options),
DotNetName = this.InflectFunctionDotNetName(specCommand.Name, options),
OriginalReturnType = specCommand.ReturnType,
NativeReturnType = this.InflectNativeReturnType(specCommand),
DotNetReturnType = this.InflectDotNetReturnType(specCommand)
};
if (specFeature != null)
{
functionData.VersionMajor = specFeature.VersionMajor;
functionData.VersionMinor = specFeature.VersionMinor;
functionData.CanPInvoke = specFeature.VersionMajor == 1 && specFeature.VersionMinor <= 1;
}
if (functionData.NativeReturnType == "string")
functionData.IsUnsafe = true;
foreach (var specCommandParam in specCommand.Params)
{
var functionParamData = new DotNetFunctionParamData()
{
OriginalName = specCommandParam.Name,
Name = this.InflectFunctionParamName(specCommandParam.Name),
OriginalType = specCommandParam.Type,
NativeType = this.InflectFunctionParamNativeType(specCommandParam),
DotNetType = this.InflectFunctionParamDotNetType(specCommandParam),
IsPointer = this.IsTypePointer(specCommandParam.Type),
IsOutput = this.IsTypeOutput(specCommandParam.Type),
ShouldUseGenerics = this.ShouldUseGenericsForType(specCommandParam.Type),
ShouldUseFixed = this.ShouldUseFixedForParam(specCommandParam),
ShouldUseAddressOfOperator = this.ShouldUseAddressOfOperatorForParam(specCommandParam)
};
if (functionParamData.IsPointer)
functionData.IsUnsafe = true;
if (functionParamData.ShouldUseGenerics)
functionData.ShouldUseGenerics = true;
if (functionParamData.IsOutput && functionParamData.DotNetType == "IntPtr")
{
functionParamData.ShouldUseOut = true;
}
functionData.Params.Add(functionParamData);
}
api.Functions.Add(functionData);
// Create overload which accepts the Enum variant.
if (specCommand.Params.Any(x => this.IsTypeEnum(x, api)))
{
api.Functions.Add(this.ChangeFunctionParamsToEnums(functionData, specCommand.Params.Where(x => this.IsTypeEnum(x, api))));
}
}
foreach (var functionData in api.Functions.ToArray())
{
var specCommand = spec.Commands.Single(x => x.Name == functionData.OriginalName);
// Commands which take a pointer and it could be a single element.
if (specCommand.Params.Any(x => this.ShouldChangeFunctionParamToRefOrOut(x)))
{
api.Functions.Add(this.ChangeFunctionParamsToRefOrOut(functionData, specCommand.Params.Where(x => this.ShouldChangeFunctionParamToRefOrOut(x)).Select(x => x.Name)));
}
// Commands which take a pointer and it could be a single element.
if (specCommand.Params.Any(x => this.ShouldChangeFunctionParamToIntPtr(x)))
{
api.Functions.Add(this.ChangeFunctionParamsToIntPtr(functionData, specCommand.Params.Where(x => this.ShouldChangeFunctionParamToIntPtr(x)).Select(x => x.Name)));
}
}
api.Functions.Sort((x, y) => x.OriginalName != null && y.OriginalName != null ? x.OriginalName.CompareTo(y.OriginalName) : 0);
}