本文整理汇总了C#中IValueProvider类的典型用法代码示例。如果您正苦于以下问题:C# IValueProvider类的具体用法?C# IValueProvider怎么用?C# IValueProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IValueProvider类属于命名空间,在下文中一共展示了IValueProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRenderTextureToBuffer
/// <summary>
/// given color and depth textures, render them.
/// </summary>
public static RenderPass CreateRenderTextureToBuffer(
TextureBase source,
TextureBase depth_source,
IValueProvider<Vector2> viewportSize,
Action<GameWindow> beforeState,
Action<GameWindow> beforeRender,
params StatePart[] stateParts
)
{
//TODO: BUG see System21.State.cs: line 351. Order of states has also some influence
var states = new StatePart[]{
new TextureBindingSet
(
new TextureBinding { VariableName = "source_texture", Texture = source },
new TextureBinding { VariableName = "depth_texture", Texture = depth_source }
)
};
states = stateParts.Concat(states).ToArray();
return CreateFullscreenQuad
(
"rendertexture", "RenderPassFactory",
viewportSize,
beforeState,
beforeRender,
states);
}
示例2: eval
public virtual System.Object eval(IValueProvider provider, System.Object corr)
{
System.Object oLhs = lhs_.eval(provider, corr);
System.Object oRhs = rhs_.eval(provider, corr);
return eval(oLhs, oRhs);
}
示例3: QuestionSelected
private bool QuestionSelected(IValueProvider provider, int idx)
{
var valResult = provider.GetValue(ResultName(idx));
return ((valResult != null)
&& !string.IsNullOrEmpty(valResult.AttemptedValue)
&& valResult.AttemptedValue.Contains("true"));
}
示例4: CreateSolidBox
/// <summary>
/// given color and depth textures, render them.
/// </summary>
public static RenderPass CreateSolidBox(
TextureBase depth_texture,
BufferObject<Vector4> sprite_pos_buffer,
BufferObject<Vector4> sprite_color_buffer,
BufferObject<Vector4> sprite_dimensions_buffer,
BufferObject<Matrix4> sprite_rotation_local_buffer,
BufferObject<Matrix4> sprite_rotation_buffer,
IValueProvider<int> particles_count,
IValueProvider<float> particle_scale_factor,
IValueProvider<string> fragdepthroutine,
ModelViewProjectionParameters mvp
)
{
var viewport = ValueProvider.Create (() => new Vector2 (depth_texture.Width, depth_texture.Height));
var outputroutine = ValueProvider.Create (() => "SetOutputsNone");
return CreateSolidBox
(
new FramebufferBindingSet(
new DrawFramebufferBinding { Attachment = FramebufferAttachment.DepthAttachment, Texture = depth_texture }
),
sprite_pos_buffer, sprite_color_buffer, sprite_dimensions_buffer, sprite_rotation_local_buffer, sprite_rotation_buffer,
viewport,
particles_count, particle_scale_factor, fragdepthroutine, outputroutine,
mvp,
null,
null
);
}
示例5: CValidate
/// <summary>
/// Validation function for WrapNumericModelValidator.
/// </summary>
/// <param name="container"></param>
/// <param name="conditionPropertyName"></param>
/// <param name="validateIfNot"></param>
/// <param name="propertyName"></param>
/// <param name="containerName"></param>
/// <param name="valueProvider"></param>
/// <param name="modelState"></param>
/// <param name="baseFunction"></param>
/// <returns></returns>
internal static IEnumerable<ModelValidationResult> CValidate(object container, string conditionPropertyName, bool validateIfNot, string propertyName, string containerName, IValueProvider valueProvider, ModelStateDictionary modelState, Func<object, IEnumerable<ModelValidationResult>> baseFunction)
{
// default to regular behavior if we don't have model.
if (container == null)
{
return baseFunction(container);
}
var property = container.GetType().GetProperty(propertyName);
var shouldValidate = ShouldValidate(conditionPropertyName, validateIfNot, propertyName, containerName, container, property, valueProvider, modelState);
if (shouldValidate == null)
{
// value for condition property is not supplied.
return new ModelValidationResult[]
{
new ModelValidationResult()
{
Message = PropertyNotFound(conditionPropertyName)
}
};
}
else if (shouldValidate.Value)
{
return baseFunction(container);
}
else
{
return Enumerable.Empty<ModelValidationResult>();
}
}
示例6: CreateAoc
//computed world-space normal and clipping space depth (depth in range 0, 1)
//where the result will be stored, results will be stored to the first component of the texture
//how many samples will be used for occlusion estimation
public static RenderPass CreateAoc(
TextureBase normalDepth,
TextureBase aoc,
IValueProvider<Matrix4> modelviewprojection,
IValueProvider<Matrix4> modelviewprojection_inv,
IValueProvider<Matrix4> projection,
IValueProvider<Matrix4> projection_inv,
IValueProvider<int> samplesCount,
IValueProvider<float> occ_max_dist = null,
IValueProvider<float> occ_pixmax = null,
IValueProvider<float> occ_pixmin = null,
IValueProvider<float> occ_min_sample_ratio = null,
IValueProvider<bool> occ_constant_area = null,
IValueProvider<float> strength = null,
IValueProvider<float> bias = null)
{
var viewport = ValueProvider.Create (() => new Vector2 (aoc.Width, aoc.Height));
// var sampling_pattern = ValueProvider.Create
// (
// () => MathHelper2.RandomVectorSet (256, new Vector2 (1, 1))
// );
var current_pattern = MathHelper2.RandomVectorSet (256, new Vector2 (1, 1));
var sampling_pattern = ValueProvider.Create
(
() => current_pattern
);
var uniformState = new UniformState ();
uniformState.Set ("viewport_size", viewport);
uniformState.Set ("sampling_pattern", sampling_pattern);
uniformState.Set ("sampling_pattern_len", samplesCount);
uniformState.Set ("modelviewprojection_transform", modelviewprojection);
uniformState.Set ("modelviewprojection_inv_transform", modelviewprojection_inv);
uniformState.Set ("projection_transform", projection);
uniformState.Set ("projection_inv_transform", projection_inv);
uniformState.Set ("OCCLUDER_MAX_DISTANCE", occ_max_dist ?? ValueProvider.Create(35.0f));
uniformState.Set ("PROJECTED_OCCLUDER_DISTANCE_MAX_SIZE", occ_pixmax ?? ValueProvider.Create(35.0f));
uniformState.Set ("PROJECTED_OCCLUDER_DISTANCE_MIN_SIZE", occ_pixmin ?? ValueProvider.Create(2.0f));
uniformState.Set ("MINIMAL_SAMPLES_COUNT_RATIO", occ_min_sample_ratio ?? ValueProvider.Create(0.1f));
uniformState.Set ("USE_CONSTANT_OCCLUDER_PROJECTION", occ_constant_area ?? ValueProvider.Create(false));
uniformState.Set ("AOC_STRENGTH", strength ?? ValueProvider.Create(2f));
uniformState.Set ("AOC_BIAS", bias ?? ValueProvider.Create(-0.5f));
return CreateFullscreenQuad (
"aoc", "RenderPassFactory",
viewport, null,
window =>
{
GL.Clear (ClearBufferMask.ColorBufferBit);
GL.Disable (EnableCap.DepthTest);
GL.Disable (EnableCap.Blend);
},
new FramebufferBindingSet{{ "OUT_FragData_aoc", aoc }},
uniformState,
new TextureBindingSet {{ "normaldepth_texture", normalDepth }});
}
示例7: GetDictionaryModel
protected virtual object GetDictionaryModel(ControllerContext controllerContext, Type modelType, IValueProvider valueProvider, string prefix)
{
List<KeyValuePair<object, object>> list = new List<KeyValuePair<object, object>>();
bool numericIndex;
IEnumerable<string> indexes = GetIndexes(prefix, valueProvider, out numericIndex);
Type[] genericArguments = modelType.GetGenericArguments();
Type keyType = genericArguments[0];
Type valueType = genericArguments[1];
foreach (var index in indexes)
{
string indexPrefix = prefix + "[" + index + "]";
if (!valueProvider.ContainsPrefix(indexPrefix) && numericIndex)
{
break;
}
string keyPrefix = indexPrefix + ".Key";
string valulePrefix = indexPrefix + ".Value";
object key = GetModel(controllerContext, keyType,
valueProvider, keyPrefix);
object value = GetModel(controllerContext, valueType,
valueProvider, valulePrefix);
list.Add(new KeyValuePair<object, object>(key, value));
}
object model = CreateModel(modelType);
ReplaceHelper.ReplaceDictionary(keyType, valueType, model, list);
return model;
}
示例8: GetModel
public object GetModel(ControllerContext controllerContext, Type modelType, IValueProvider valueProvider, string key)
{
if (!valueProvider.ContainsPrefix(key))
{
return null;
}
ModelMetadata modelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, modelType);
if (!modelMetadata.IsComplexType)
{
return valueProvider.GetValue(key).ConvertTo(modelType);
}
if (modelType.IsArray)
{
return GetArrayModel(controllerContext, modelType, valueProvider,key);
}
Type enumerableType = ExtractGenericInterface(modelType, typeof(IEnumerable<>));
if (null != enumerableType)
{
return GetCollectionModel(controllerContext, modelType, valueProvider, key);
}
if (modelMetadata.IsComplexType)
{
return GetComplexModel(controllerContext, modelType, valueProvider, key);
}
return null;
}
示例9: Bind
public dynamic Bind(dynamic formShape, IValueProvider valueProvider, string prefix = "")
{
Action<object> process = shape => BindValue(shape, valueProvider, prefix);
FormNodesProcessor.ProcessForm(formShape, process);
return formShape;
}
示例10: BaseValueGenerator
protected BaseValueGenerator(IValueProvider valueProvider, Func<ITypeGenerator> getTypeGenerator,
Func<IArrayRandomizer> getArrayRandomizer, IUniqueValueGenerator uniqueValueGenerator, IAttributeDecorator attributeDecorator)
{
BaseValueGenerator.Logger.Debug("Entering constructor");
this.ValueProvider = valueProvider;
this.GetTypeGenerator = getTypeGenerator;
this.GetArrayRandomizer = getArrayRandomizer;
this.UniqueValueGenerator = uniqueValueGenerator;
this.AttributeDecorator = attributeDecorator;
this.typeValueGetterDictionary = new Dictionary<Type, GetValueForTypeDelegate>
{
{typeof (EmailAttribute), x => this.ValueProvider.GetEmailAddress()},
{typeof (PrimaryKeyAttribute), this.GetPrimaryKey},
{typeof (string), this.GetString},
{typeof (decimal), this.GetDecimal},
{typeof (int), this.GetInteger},
{typeof (uint), this.GetInteger},
{typeof (long), this.GetLong},
{typeof (ulong), this.GetLong},
{typeof (short), this.GetShort},
{typeof (ushort), this.GetShort},
{typeof (bool), x => this.ValueProvider.GetBoolean()},
{typeof (char), x => this.ValueProvider.GetCharacter()},
{typeof (DateTime), this.GetDateTime},
{typeof (byte), x => this.ValueProvider.GetByte()},
{typeof (double), this.GetDouble},
{typeof (float), this.GetFloat},
{typeof (Guid), this.GetGuid },
};
BaseValueGenerator.Logger.Debug("Exiting constructor");
}
示例11: OverrideValueProvider
public OverrideValueProvider(IValueProvider originalValueProvider, IDictionary<string, string> values)
{
OriginalValueProvider = originalValueProvider;
HardcodedValues = values.ToDictionary(
x => x.Key,
x => new ValueProviderResult(x.Value, x.Value, System.Globalization.CultureInfo.InvariantCulture));
}
示例12: Merge
public void Merge(IValueProvider valueProvider)
{
if (valueProvider.CanMerge)
{
valueProvider.Values.ToList().ForEach(x => Values.Add(x));
}
}
示例13: SchoolIdValueProvider
public SchoolIdValueProvider(ControllerContext controllerContext, IRouteValueResolutionService schoolRouteValueResolutionService,
IValueProvider localEducationAgencyIdValueProvider)
{
this.controllerContext = controllerContext;
this.schoolRouteValueResolutionService = schoolRouteValueResolutionService;
this.localEducationAgencyIdValueProvider = localEducationAgencyIdValueProvider;
}
示例14: GetResult
public override QuestionResult GetResult(IValueProvider provider)
{
int value = 0;
TryGetValue(provider, ResultName, out value);
return new QuestionResult { Answer = value.ToString(), Value = 0};
}
示例15: MetricIdFromOperationalDashboardSubtypeValueProvider
public MetricIdFromOperationalDashboardSubtypeValueProvider(ControllerContext controllerContext, IDomainSpecificMetricNodeResolver domainSpecificMetricNodeResolver,
IValueProvider schoolIdValueProvider)
{
this.controllerContext = controllerContext;
this.domainSpecificMetricNodeResolver = domainSpecificMetricNodeResolver;
this.schoolIdValueProvider = schoolIdValueProvider;
}