Here are the examples of the csharp api System.Collections.Generic.List.Contains(Variable) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
8 Examples
19
Source : ModelView.cs
with MIT License
from dotnet
with MIT License
from dotnet
protected void AddFactorEdges(GraphWriter g, MethodInvoke mi)
{
var parameters = mi.method.GetParameters();
for (int i = 0; i < mi.args.Count; i++)
{
var parameter = parameters[i];
if (parameter.IsOut)
AddEdge(g, mi, mi.args[i], parameter.Name);
else
AddEdge(g, mi.args[i], mi, parameter.Name);
}
if (mi.returnValue != null)
{
AddEdge(g, mi, mi.returnValue, "");
}
if (!UseContainers)
{
// add edges from condition variables to target (if there are no such edges already)
IModelExpression target = (mi.returnValue != null) ? mi.returnValue : mi;
Set<IStatementBlock> excluded = new Set<IStatementBlock>();
if (target is Variable)
{
// if target is in the ConditionBlock, then don't connect with the condition variable
Variable targetVar = (Variable)target;
excluded.AddRange(targetVar.Containers);
}
foreach (IStatementBlock block in mi.Containers)
{
if (excluded.Contains(block))
continue;
if (block is ConditionBlock)
{
ConditionBlock cb = (ConditionBlock)block;
Variable c = cb.ConditionVariableUntyped;
List<Variable> condVars;
if (!conditionVariables.TryGetValue(target, out condVars))
{
condVars = new List<Variable>();
conditionVariables[target] = condVars;
}
if (!condVars.Contains(c))
{
AddEdge(g, c, target, "condition");
condVars.Add(c);
}
}
}
}
}
19
Source : Flowchart.cs
with Apache License 2.0
from marcosecchi
with Apache License 2.0
from marcosecchi
protected virtual void CleanupComponents()
{
// Delete any unreferenced components which shouldn't exist any more
// Unreferenced components don't have any effect on the flowchart behavior, but
// they waste memory so should be cleared out periodically.
// Remove any null entries in the variables list
// It shouldn't happen but it seemed to occur for a user on the forum
variables.RemoveAll(item => item == null);
var allVariables = GetComponents<Variable>();
for (int i = 0; i < allVariables.Length; i++)
{
var variable = allVariables[i];
if (!variables.Contains(variable))
{
DestroyImmediate(variable);
}
}
var blocks = GetComponents<Block>();
var commands = GetComponents<Command>();
for (int i = 0; i < commands.Length; i++)
{
var command = commands[i];
bool found = false;
for (int j = 0; j < blocks.Length; j++)
{
var block = blocks[j];
if (block.CommandList.Contains(command))
{
found = true;
break;
}
}
if (!found)
{
DestroyImmediate(command);
}
}
var eventHandlers = GetComponents<EventHandler>();
for (int i = 0; i < eventHandlers.Length; i++)
{
var eventHandler = eventHandlers[i];
bool found = false;
for (int j = 0; j < blocks.Length; j++)
{
var block = blocks[j];
if (block._EventHandler == eventHandler)
{
found = true;
break;
}
}
if (!found)
{
DestroyImmediate(eventHandler);
}
}
}
19
Source : GlobalUniformVisitor.cs
with MIT License
from stride3d
with MIT License
from stride3d
public override Node Visit(replacedignmentExpression replacedignmentExpression)
{
var variable = GetUniform(replacedignmentExpression.Target);
bool isMemberExpression = replacedignmentExpression.Target is MemberReferenceExpression;
if (variable != null)
{
// Default == operator is the only write only operators
if (replacedignmentExpression.Operator == replacedignmentOperator.Default && !uniformReadList.Contains(variable) && !this.UniformUsedWriteFirstList.Contains(variable))
{
// Handle the case where the replacedignment operator is partial like vect.xy = 5; and later vect.zw += 6;
// In this case, the variable is considered as read and write (and not only write first)
if (isMemberExpression)
{
var variableType = variable.Type.ResolveType();
if (variableType is VectorType || variableType is MatrixType)
{
var dim = Math.Max(TypeBase.GetDimensionSize(variableType, 0), TypeBase.GetDimensionSize(variableType, 1));
var memberRef = replacedignmentExpression.Target as MemberReferenceExpression;
var numberOfMembers = memberRef.Member.Text.Length;
// If the variable is a global uniform, non static/const and is not already in the list used then
if (numberOfMembers < dim)
{
if (!uniformReadList.Contains(variable))
{
uniformReadList.Add(variable);
}
}
else
{
UniformUsedWriteFirstList.Add(variable);
}
}
}
else
{
UniformUsedWriteFirstList.Add(variable);
}
}
if (replacedignmentExpression.Operator != replacedignmentOperator.Default)
{
if (!UniformReadWriteList.Contains(variable))
UniformReadWriteList.Add(variable);
}
}
return replacedignmentExpression;
}
19
Source : SamplerMappingVisitor.cs
with MIT License
from stride3d
with MIT License
from stride3d
protected override void ProcessMethodInvocation(MethodInvocationExpression invoke, MethodDefinition method)
{
var textureParameters = new List<Parameter>();
var parameterValues = new List<Expression>();
var parameterGlobalValues = new List<Variable>();
var samplerTypes = new List<int>();
for (int i = 0; i < method.Parameters.Count; i++)
{
var parameter = method.Parameters[i];
if (parameter.Type is TextureType || parameter.Type.IsStateType())
{
textureParameters.Add(parameter);
// Find global variable
var parameterValue = this.FindGlobalVariable(invoke.Arguments[i]);
// Set the tag ScopeValue for the current parameter
parameter.SetTag(ScopeValueKey, parameterValue);
// Add only new variable
if (!parameterGlobalValues.Contains(parameterValue))
parameterGlobalValues.Add(parameterValue);
}
else if ( i < invoke.Arguments.Count)
{
parameterValues.Add(invoke.Arguments[i]);
if (parameter.Type.IsSamplerType())
{
samplerTypes.Add(i);
}
}
}
// We have texture/sampler parameters. We need to generate a new specialized method
if (textureParameters.Count > 0)
{
// Order parameter values by name
parameterGlobalValues.Sort((left, right) => left.Name.Text.CompareTo(right.Name.Text));
var methodKey = new TextureSamplerMethodKey(method);
int indexOf = textureSamplerMethods.IndexOf(methodKey);
if (indexOf < 0)
{
methodKey.Initialize(cloneContext);
textureSamplerMethods.Add(methodKey);
}
else
{
// If a key is found again, add it as it was reused in order to keep usage in order
methodKey = textureSamplerMethods[indexOf];
textureSamplerMethods.RemoveAt(indexOf);
textureSamplerMethods.Add(methodKey);
}
methodKey.Invokers.Add(invoke);
var newTarget = new VariableReferenceExpression(methodKey.NewMethod.Name) { TypeInference = { Declaration = methodKey.NewMethod, TargetType = invoke.TypeInference.TargetType } };
invoke.Target = newTarget;
invoke.Arguments = parameterValues;
invoke.TypeInference.Declaration = methodKey.NewMethod;
invoke.TypeInference.TargetType = invoke.TypeInference.TargetType;
this.VisitDynamic(methodKey.NewMethod);
}
else
{
// Visit the method callstack
this.VisitDynamic(method);
// There is an anonymous sampler type
// We need to resolve its types after the method definition was processed
if (samplerTypes.Count > 0)
{
foreach (var samplerTypeIndex in samplerTypes)
{
var samplerRef = invoke.Arguments[samplerTypeIndex] as VariableReferenceExpression;
if (samplerRef != null)
{
var samplerDecl = samplerRef.TypeInference.Declaration as Variable;
ChangeVariableType(samplerDecl, method.Parameters[samplerTypeIndex].Type);
}
}
}
}
// Remove temporary parameters
if (textureParameters.Count > 0)
{
foreach (var textureParameter in textureParameters)
{
textureParameter.RemoveTag(ScopeValueKey);
}
}
}
19
Source : GlobalUniformVisitor.cs
with MIT License
from stride3d
with MIT License
from stride3d
public bool IsVariableAsGlobalTemporary(Variable variable)
{
return UniformUsedWriteFirstList.Contains(variable);
}
19
Source : GlobalUniformVisitor.cs
with MIT License
from stride3d
with MIT License
from stride3d
public bool IsUniformReadWrite(Variable variable)
{
return UniformReadWriteList.Contains(variable);
}
19
Source : GlobalUniformVisitor.cs
with MIT License
from stride3d
with MIT License
from stride3d
public override Node Visit(VariableReferenceExpression variableRef)
{
var variable = GetUniform(variableRef);
// If the variable is a global uniform, non static/const and is not already in the list used then
if (variable != null && !uniformReadList.Contains(variable))
{
uniformReadList.Add(variable);
}
return variableRef;
}
19
Source : GlobalUniformVisitor.cs
with MIT License
from stride3d
with MIT License
from stride3d
protected override void ProcessMethodInvocation(MethodInvocationExpression invoke, MethodDefinition method)
{
// Handle the case where a parameter can be out
// If this is the case, we need to check that
for (int i = 0; i < invoke.Arguments.Count; i++)
{
var arg = invoke.Arguments[i];
var variable = this.GetUniform(arg);
var parameter = method.Parameters[i];
if (variable != null && parameter.Qualifiers.Contains(ParameterQualifier.Out))
{
bool isUniformWasAlreadyUsedAsRead = false;
for (int j = 0; j < countReadBeforeInvoke; j++)
{
if (ReferenceEquals(uniformReadList[i], variable))
{
isUniformWasAlreadyUsedAsRead = true;
break;
}
}
// If this is a out parameter, and the variable was not already used as a read, then
// we can remove it from the uniform read list
if (!isUniformWasAlreadyUsedAsRead)
{
uniformReadList.Remove(variable);
if (!UniformUsedWriteFirstList.Contains(variable))
UniformUsedWriteFirstList.Add(variable);
}
}
}
this.VisitDynamic(method);
}