Here are the examples of the csharp api System.Collections.Generic.IDictionary.ContainsKey(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
49 Examples
19
Source : DialogParticipation.cs
with Apache License 2.0
from beckzhu
with Apache License 2.0
from beckzhu
internal static bool IsRegistered(object context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
return ContextRegistrationIndex.ContainsKey(context);
}
19
Source : DeepCloneExtensions.cs
with Apache License 2.0
from buehler
with Apache License 2.0
from buehler
private static object? DeepClone_Internal(object? obj, IDictionary<object, object> visited)
{
if (obj == null)
{
return null;
}
var typeToReflect = obj.GetType();
if (IsPrimitive(typeToReflect))
{
return obj;
}
if (visited.ContainsKey(obj))
{
return visited[obj];
}
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect))
{
return null;
}
var cloneObject = CloneMethod.Invoke(obj, null);
if (typeToReflect.IsArray)
{
var arrayType = typeToReflect.GetElementType() ?? throw new ArgumentNullException();
if (!IsPrimitive(arrayType))
{
var clonedArray = (Array)cloneObject!;
clonedArray.ForEach(
(array, indices) => array.SetValue(
DeepClone_Internal(clonedArray.GetValue(indices), visited),
indices));
}
}
visited.Add(obj, cloneObject!);
CopyFields(obj, visited, cloneObject!, typeToReflect);
RecursiveCopyBaseTypePrivateFields(obj, visited, cloneObject!, typeToReflect);
return cloneObject;
}
19
Source : EnumTypeDescriptor.cs
with MIT License
from ChilliCream
with MIT License
from ChilliCream
protected void AddImplicitValues(
EnumTypeDefinition typeDefinition,
IDictionary<object, EnumValueDefinition> values)
{
if (typeDefinition.Values.IsImplicitBinding())
{
foreach (var value in Context.TypeInspector.GetEnumValues(typeDefinition.RuntimeType))
{
EnumValueDefinition valueDefinition =
EnumValueDescriptor.New(Context, value)
.CreateDefinition();
if (valueDefinition.RuntimeValue is not null &&
!values.ContainsKey(valueDefinition.RuntimeValue))
{
values.Add(valueDefinition.RuntimeValue, valueDefinition);
}
}
}
}
19
Source : DeepCloneExtensions.cs
with Apache License 2.0
from Coldairarrow
with Apache License 2.0
from Coldairarrow
private static object InternalCopy(object originalObject, IDictionary<object, object> visited)
{
if (originalObject == null) return null;
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect)) return originalObject;
if (visited.ContainsKey(originalObject)) return visited[originalObject];
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect)) return null;
var cloneObject = CloneMethod.Invoke(originalObject, null);
if (typeToReflect.IsArray)
{
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false)
{
Array clonedArray = (Array)cloneObject;
ArrayExtensions.ForEach(clonedArray, (array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
}
19
Source : DynamicOptionsBase.cs
with GNU General Public License v3.0
from CommentViewerCollection
with GNU General Public License v3.0
from CommentViewerCollection
private static Object InternalCopy(Object originalObject, IDictionary<Object, Object> visited)
{
if (originalObject == null) return null;
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect)) return originalObject;
if (visited.ContainsKey(originalObject)) return visited[originalObject];
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect))
{
//デリゲートの場合はオリジナルをそのまま帰すようにした。
return originalObject;
}
var cloneObject = CloneMethod.Invoke(originalObject, null);
if (typeToReflect.IsArray)
{
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false)
{
Array clonedArray = (Array)cloneObject;
clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
}
19
Source : ReflectionBasedDestructurer.ValueDictionary.cs
with Apache License 2.0
from cosmos-loops
with Apache License 2.0
from cosmos-loops
private object DestructureValueDictionary(
IDictionary value,
int level,
IDictionary<object, IDictionary<string, object>> destructuredObjects,
ref int nextCycleRefId) {
if (destructuredObjects.ContainsKey(value)) {
var destructureObj = destructuredObjects[value];
var refId = GetOrCreateRefId(ref nextCycleRefId, destructureObj);
return new Dictionary<string, object> {{REF_LABEL, refId}};
}
var destructureDictionary = value.MapToStrObjDictionary();
destructuredObjects.Add(value, destructureDictionary);
foreach (var pair in destructureDictionary.ToDictionary(k => k.Key, v => v.Value)) {
destructureDictionary[pair.Key] = DestructureValue(value, level + 1, destructuredObjects, ref nextCycleRefId);
}
return destructureDictionary;
}
19
Source : ReflectionBasedDestructurer.ValueEnumerable.cs
with Apache License 2.0
from cosmos-loops
with Apache License 2.0
from cosmos-loops
private object DestructureValueEnumerable(
IEnumerable value,
int level,
IDictionary<object, IDictionary<string, object>> destructuredObjects,
ref int nextCyclicRefId) {
if (destructuredObjects.ContainsKey(value)) {
return new Dictionary<string, object> {{REF_LABEL, CYCLIC_REF_MSG}};
}
destructuredObjects.Add(value, new Dictionary<string, object>());
var destructureList = new List<object>();
foreach (var o in value.Cast<object>())
destructureList.Add(DestructureValue(o, level + 1, destructuredObjects, ref nextCyclicRefId));
return destructureList;
}
19
Source : ContextRegistration.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
public bool ContainsKey(object context)
{
if (context == null)
return false;
return _RegistrationIndex.ContainsKey(context);
}
19
Source : ContextRegistration.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
public bool IsRegistered(object context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
return _RegistrationIndex.ContainsKey(context);
}
19
Source : DeepCloneExtensions.cs
with MIT License
from dotnet-toolbelt
with MIT License
from dotnet-toolbelt
private static object InternalCopy(object originalObject, IDictionary<object, object> visited)
{
if (originalObject == null) return null;
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect)) return originalObject;
if (visited.ContainsKey(originalObject)) return visited[originalObject];
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect)) return null;
var cloneObject = CloneMethod.Invoke(originalObject, null);
if (typeToReflect.IsArray)
{
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false)
{
Array clonedArray = (Array)cloneObject;
clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
}
19
Source : SqlClientDiagnosticListener.cs
with Apache License 2.0
from elastic
with Apache License 2.0
from elastic
private void HandleStopCommand(object payloadData, PropertyFetcherSet propertyFetcherSet)
{
try
{
if (propertyFetcherSet.StopCorrelationId.Fetch(payloadData) is Guid operationId
&& propertyFetcherSet.StopCommand.Fetch(payloadData) is IDbCommand dbCommand)
{
if (!_spans.TryRemove(operationId, out var span)) return;
TimeSpan? duration = null;
if (propertyFetcherSet.Statistics.Fetch(payloadData) is IDictionary<object, object> statistics &&
statistics.ContainsKey("ExecutionTime") && statistics["ExecutionTime"] is long durationInMs && durationInMs > 0)
duration = TimeSpan.FromMilliseconds(durationInMs);
_agent?.TracerInternal.DbSpanCommon.EndSpan(span, dbCommand, Outcome.Success, duration);
}
}
catch (Exception ex)
{
// ignore
Logger.Error()?.LogException(ex, "Exception was thrown while handling 'command succeeded event'");
}
}
19
Source : MockActorProxyFactory.cs
with MIT License
from FabricatorsGuild
with MIT License
from FabricatorsGuild
public TActor GetActor<TActor>(IActor proxy)
where TActor : clreplaced
{
if (_actorProxies.ContainsKey(proxy.GetHashCode()))
{
return _actorProxies[proxy.GetHashCode()] as TActor;
}
return null;
}
19
Source : DocumentConstructionRulePackage.cs
with MIT License
from graphql-aspnet
with MIT License
from graphql-aspnet
public IEnumerable<IRuleStep<DoreplacedentConstructionContext>> FetchRules(DoreplacedentConstructionContext context)
{
var type = context?.ActiveNode?.GetType();
if (type == null || !_stepCollection.ContainsKey(type))
return Enumerable.Empty<IRuleStep<DoreplacedentConstructionContext>>();
// append special rules for root nodes of a query doreplacedent when encountered
return context.ParentContext == null
? _topLevelSteps.Concat(_stepCollection[type])
: _stepCollection[type];
}
19
Source : DocumentValidationRulePackage.cs
with MIT License
from graphql-aspnet
with MIT License
from graphql-aspnet
public IEnumerable<IRuleStep<DoreplacedentValidationContext>> FetchRules(DoreplacedentValidationContext context)
{
var type = context?.ActivePart?.GetType();
if (type == null || !_stepCollection.ContainsKey(type))
return Enumerable.Empty<IRuleStep<DoreplacedentValidationContext>>();
return _stepCollection[type];
}
19
Source : MemberwiseClone.cs
with MIT License
from GTANetworkDev
with MIT License
from GTANetworkDev
private static object InternalCopy(object originalobject, IDictionary<object, object> visited)
{
if (originalobject == null) return null;
var typeToReflect = originalobject.GetType();
if (IsPrimitive(typeToReflect)) return originalobject;
if (visited.ContainsKey(originalobject)) return visited[originalobject];
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect)) return null;
var cloneobject = CloneMethod.Invoke(originalobject, null);
if (typeToReflect.IsArray)
{
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false)
{
Array clonedArray = (Array)cloneobject;
clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalobject, cloneobject);
CopyFields(originalobject, visited, cloneobject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalobject, visited, cloneobject, typeToReflect);
return cloneobject;
}
19
Source : TestPlainCompoundLayoutWindow.xaml.cs
with MIT License
from KeRNeLith
with MIT License
from KeRNeLith
private void AddLine([NotNull] object lineKey, Point pos1, Point pos2, bool b)
{
Debug.replacedert(lineKey != null);
Line line;
if (_lines.ContainsKey(lineKey))
{
line = _lines[lineKey];
}
else
{
line = new Line();
_lines[lineKey] = line;
Layout.Children.Add(line);
line.StrokeThickness = 2;
line.Stroke = b ? System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Silver;
}
Animate(line, Line.X1Property, pos1.X, _animationDuration);
Animate(line, Line.Y1Property, pos1.Y, _animationDuration);
Animate(line, Line.X2Property, pos2.X, _animationDuration);
Animate(line, Line.Y2Property, pos2.Y, _animationDuration);
}
19
Source : TestPlainCompoundLayoutWindow.xaml.cs
with MIT License
from KeRNeLith
with MIT License
from KeRNeLith
private void AddRectangle([NotNull] object rectKey, Point point, Size size)
{
Debug.replacedert(rectKey != null);
point.X -= size.Width / 2;
point.Y -= size.Height / 2;
Rectangle rect;
if (_rectangles.ContainsKey(rectKey))
{
rect = _rectangles[rectKey];
}
else
{
rect = new Rectangle();
_rectangles[rectKey] = rect;
Layout.Children.Add(rect);
rect.Fill = Brushes[_brushIndex];
rect.Stroke = System.Windows.Media.Brushes.Black;
rect.StrokeThickness = 1;
_brushIndex = (_brushIndex + 1) % Brushes.Length;
rect.Opacity = 0.7;
}
Animate(rect, WidthProperty, size.Width, _animationDuration);
Animate(rect, HeightProperty, size.Height, _animationDuration);
Animate(rect, Canvas.LeftProperty, point.X, _animationDuration);
Animate(rect, Canvas.TopProperty, point.Y, _animationDuration);
}
19
Source : ObjectExtensions.cs
with MIT License
from LagradOst
with MIT License
from LagradOst
private static Object InternalCopy(Object originalObject, IDictionary<Object, Object> visited)
{
if (originalObject == null) return null;
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect)) return originalObject;
if (visited.ContainsKey(originalObject)) return visited[originalObject];
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect)) return null;
var cloneObject = CloneMethod.Invoke(originalObject, null);
if (typeToReflect.IsArray) {
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false) {
Array clonedArray = (Array)cloneObject;
clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
}
19
Source : DeduplicatingEntityMapper.cs
with MIT License
from landmarkhw
with MIT License
from landmarkhw
protected virtual TEnreplacedyType Deduplicate(TEnreplacedyType enreplacedy)
{
if (enreplacedy == default(TEnreplacedyType))
{
return default(TEnreplacedyType);
}
if (PrimaryKey == null)
{
throw new InvalidOperationException("PrimaryKey selector is not defined, but is required to use DeduplicatingEnreplacedyMapper.");
}
var previous = enreplacedy;
// Get the primary key for this enreplacedy
var primaryKey = PrimaryKey(enreplacedy);
if (primaryKey == null)
{
throw new InvalidOperationException("A null primary key was provided, which results in an unpredictable state.");
}
// Deduplicate the enreplacedy using available information
if (KeyCache.ContainsKey(primaryKey))
{
// Get the duplicate enreplacedy
enreplacedy = KeyCache[primaryKey];
}
else
{
// Cache a reference to the enreplacedy
KeyCache[primaryKey] = enreplacedy;
}
return enreplacedy;
}
19
Source : Extensions.cs
with MIT License
from LayTec-AG
with MIT License
from LayTec-AG
private static object InternalCopy(object originalObject, IDictionary<object, object> visited)
{
if (originalObject == null)
{
return null;
}
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect))
{
return originalObject;
}
if (visited.ContainsKey(originalObject))
{
return visited[originalObject];
}
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect))
{
return null;
}
var cloneObject = CloneMethod.Invoke(originalObject, null);
if (typeToReflect.IsArray)
{
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false)
{
var clonedArray = (Array)cloneObject;
clonedArray.ForEach((array, indices) =>
array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
}
19
Source : ObjectExtensions.cs
with MIT License
from ldqk
with MIT License
from ldqk
private static object InternalCopy(object originalObject, IDictionary<object, object> visited)
{
if (originalObject == null)
{
return null;
}
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect))
{
return originalObject;
}
if (visited.ContainsKey(originalObject))
{
return visited[originalObject];
}
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect))
{
return null;
}
var cloneObject = CloneMethod.Invoke(originalObject, null);
if (typeToReflect.IsArray)
{
var arrayType = typeToReflect.GetElementType();
if (!IsPrimitive(arrayType))
{
Array clonedArray = (Array)cloneObject;
clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
}
19
Source : ReflectionCloner.cs
with MIT License
from marcelltoth
with MIT License
from marcelltoth
private static Object InternalCopy(Object originalObject, IDictionary<Object, Object> visited)
{
if (originalObject == null) return null;
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect)) return originalObject;
if (visited.ContainsKey(originalObject)) return visited[originalObject];
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect)) return null;
var cloneObject = CloneMethod.Invoke(originalObject, null);
if (typeToReflect.IsArray)
{
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false)
{
Array clonedArray = (Array)cloneObject;
clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
}
19
Source : ColumnBarBaseSeries.cs
with Microsoft Public License
from microsoftarchive
with Microsoft Public License
from microsoftarchive
protected bool GetIsDataPointGrouped(object category)
{
return _categoriesWithMultipleDataPoints.ContainsKey(category);
}
19
Source : RamUsageEstimator.cs
with MIT License
from nelemans1971
with MIT License
from nelemans1971
private long Size(System.Object obj)
{
if (obj == null)
{
return 0;
}
// interned not part of this object
if (checkInterned && obj is System.String && obj == (System.Object) String.Intern(((System.String) obj)))
{
// interned string will be eligible
// for GC on
// estimateRamUsage(Object) return
return 0;
}
// skip if we have seen before
if (seen.ContainsKey(obj))
{
return 0;
}
// add to seen
seen[obj] = null;
System.Type clazz = obj.GetType();
if (clazz.IsArray)
{
return SizeOfArray(obj);
}
long size = 0;
// walk type hierarchy
while (clazz != null)
{
System.Reflection.FieldInfo[] fields = clazz.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Static);
for (int i = 0; i < fields.Length; i++)
{
if (fields[i].IsStatic)
{
continue;
}
if (fields[i].FieldType.IsPrimitive)
{
size += memoryModel.GetPrimitiveSize(fields[i].FieldType);
}
else
{
size += refSize;
fields[i].GetType();
try
{
System.Object value_Renamed = fields[i].GetValue(obj);
if (value_Renamed != null)
{
size += Size(value_Renamed);
}
}
catch (System.UnauthorizedAccessException)
{
// ignore for now?
}
}
}
clazz = clazz.BaseType;
}
size += clreplacedSize;
return size;
}
19
Source : CBORTypeMapper.cs
with MIT License
from neos-sdi
with MIT License
from neos-sdi
internal object ConvertBackWithConverter(
CBORObject cbor,
Type type) {
ConverterInfo convinfo = null;
if (this.converters.ContainsKey(type)) {
convinfo = this.converters[type];
} else {
return null;
}
if (convinfo == null) {
return null;
}
return (convinfo.FromObject == null) ? null :
PropertyMap.CallFromObject(convinfo, cbor);
}
19
Source : CBORTypeMapper.cs
with MIT License
from neos-sdi
with MIT License
from neos-sdi
internal CBORObject ConvertWithConverter(object obj) {
Object type = obj.GetType();
ConverterInfo convinfo = null;
if (this.converters.ContainsKey(type)) {
convinfo = this.converters[type];
} else {
return null;
}
return (convinfo == null) ? null :
PropertyMap.CallToObject(convinfo, obj);
}
19
Source : HSSettings.cs
with GNU Affero General Public License v3.0
from nikeee
with GNU Affero General Public License v3.0
from nikeee
private static object? InternalCopy(object? originalObject, IDictionary<object, object> visited)
{
if (originalObject == null)
return null;
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect))
return originalObject;
if (visited.ContainsKey(originalObject))
return visited[originalObject];
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect))
return null;
var cloneObject = CloneMethod.Invoke(originalObject, null)!;
if (typeToReflect.IsArray)
{
var arrayType = typeToReflect.GetElementType();
if (arrayType is not null && IsPrimitive(arrayType) == false)
{
var clonedArray = cloneObject as Array;
if (clonedArray is not null)
ArrayExtensions.ForEach(clonedArray, (array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
}
19
Source : ScriptMethodContext.cs
with MIT License
from NtreevSoft
with MIT License
from NtreevSoft
public void Logout(string token)
{
if (token == null)
throw new ArgumentNullException(nameof(token));
if (this.token != token)
throw new ArgumentException("token is not valid.", nameof(token));
if (this.Properties.ContainsKey(LoginKey) == false)
throw new InvalidOperationException("this method is invalid operation");
this.cremaHost.Dispatcher.Invoke(() => this.cremaHost.Logout(this.authentication));
this.authentication = null;
this.token = null;
}
19
Source : BranchManager.cs
with MIT License
from Nucs
with MIT License
from Nucs
public bool HasLabel(object key) {
return MyKeyLabelMap.ContainsKey(key);
}
19
Source : CheckGroup.cs
with MIT License
from Phenek
with MIT License
from Phenek
protected override void OnChildAdded(Element child)
{
base.OnChildAdded(child);
if (child is ICheckable checkable)
{
checkable.Clicked += OnCheckedChanged;
checkable.Index = CheckList.Count;
CheckList.Add(checkable);
if (ItemsSource == null) return;
if (ItemsSource is IDictionary<object, object> dic && !dic.ContainsKey(checkable.Key))
dic.Add(checkable.Key, checkable.Value);
else if (ItemsSource is IList list && !list.Contains(checkable.Value))
{
list.Add(checkable.Value);
var index = 0;
foreach (var check in CheckList)
check.Key = index++.ToString();
}
}
else
{
Console.WriteLine("{CheckGroup}: Element does not implement interface Icheckable");
throw new Exception("{CheckGroup}: Element does not implement interface Icheckable");
}
}
19
Source : RadioGroup.cs
with MIT License
from Phenek
with MIT License
from Phenek
protected override void OnChildAdded(Element child)
{
base.OnChildAdded(child);
if (child is ICheckable checkable)
{
checkable.Clicked += OnItemClicked;
checkable.Index = CheckList.Count;
CheckList.Add(checkable);
if (ItemsSource == null) return;
if (DefaultIndex == checkable.Index) checkable.Checked = true;
if (ItemsSource is IDictionary<object, object> dic && !dic.ContainsKey(checkable.Key))
dic.Add(checkable.Key, checkable.Value);
else if (ItemsSource is IList list && !list.Contains(checkable.Value))
{
list.Add(checkable.Value);
var index = 0;
foreach (var check in CheckList)
check.Key = index++.ToString();
}
}
else
{
Console.WriteLine("{RadioGroup}: Element does not implement interface Icheckable");
throw new Exception("{RadioGroup}: Element does not implement interface Icheckable");
}
}
19
Source : RateGroup.cs
with MIT License
from Phenek
with MIT License
from Phenek
private void ChildCheckAdded(object sender, ElementEventArgs e)
{
if (e.Element is ICheckable checkable)
{
checkable.DisableCheckOnClick = true;
checkable.Clicked += OnItemClicked;
checkable.Index = CheckList.Count;
CheckList.Add(checkable);
if (ItemsSource == null) return;
if(DefaultIndex == checkable.Index) checkable.Checked = true;
if (ItemsSource is IDictionary<object, object> dic && !dic.ContainsKey(checkable.Key))
dic.Add(checkable.Key, checkable.Value);
else if (ItemsSource is IList list && !list.Contains(checkable.Value))
{
list.Add(checkable.Value);
var index = 0;
foreach (var check in CheckList)
check.Key = index++.ToString();
}
}
else
{
Console.WriteLine("{RateGroup}: Element does not implement interface Icheckable");
throw new Exception("{RateGroup}: Element does not implement interface Icheckable");
}
}
19
Source : ObjectExtensions.cs
with MIT License
from phucan1108
with MIT License
from phucan1108
private static object InternalCopy(object originalObject, IDictionary<object, object> visited)
{
if (originalObject == null)
{
return null;
}
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect))
{
return originalObject;
}
if (visited.ContainsKey(originalObject))
{
return visited[originalObject];
}
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect))
{
return null;
}
var cloneObject = CloneMethod.Invoke(originalObject, null);
if (typeToReflect.IsArray)
{
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false)
{
var clonedArray = (Array)cloneObject;
clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
}
19
Source : DiscreteColorScheme.cs
with Apache License 2.0
from ProteoWizard
with Apache License 2.0
from ProteoWizard
public void AddValues(IEnumerable values)
{
int index;
IEnumerable<object> newValues = values.OfType<object>().Distinct();
if (_objectIndexes.Count == 0)
{
index = 2;
}
else
{
index = _objectIndexes.Values.Max() + 1;
newValues = newValues.Where(v=>!_objectIndexes.ContainsKey(v));
}
var valueToIndex = new Dictionary<object, int>();
var valuesByType = newValues.ToLookup(v => v.GetType());
foreach (var grouping in valuesByType.OrderBy(group => group.Count()))
{
foreach (var v in grouping)
{
valueToIndex.Add(v, index++);
}
}
_objectIndexes = valueToIndex;
}
19
Source : DeepCopy.cs
with MIT License
from rhelmot
with MIT License
from rhelmot
private static Object InternalCopy(Object originalObject, IDictionary<Object, Object> visited) {
if (originalObject == null) return null;
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect)) return originalObject;
if (visited.ContainsKey(originalObject)) return visited[originalObject];
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect)) return null;
var cloneObject = CloneMethod.Invoke(originalObject, null);
if (typeToReflect.IsArray) {
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false) {
Array clonedArray = (Array)cloneObject;
clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
}
19
Source : ObjectStoreBinder.cs
with MIT License
from shinyorg
with MIT License
from shinyorg
protected virtual void OnPropertyChanged(object sender, PropertyChangedEventArgs args)
{
var prop = this
.GetTypeProperties(sender.GetType())
.FirstOrDefault(x => x.Name.Equals(args.PropertyName));
if (prop != null)
{
var key = GetBindingKey(sender.GetType(), prop);
var value = prop.GetValue(sender);
if (!this.bindings.ContainsKey(sender))
throw new ArgumentException("No key/value store found for current binding object - " + sender.GetType().FullName);
this.bindings[sender].SetOrRemove(key, value);
}
}
19
Source : BuildSectionParser.cs
with MIT License
from skbkontur
with MIT License
from skbkontur
private T FindValue<T>(IDictionary<object, object> dict, string key, T defaultValue = default(T))
{
return dict.ContainsKey(key) ? (T)dict[key] : defaultValue;
}
19
Source : RequestCache.cs
with GNU General Public License v3.0
from smartstore
with GNU General Public License v3.0
from smartstore
public bool Contains(string key)
{
return Gereplacedems().ContainsKey(BuildKey(key));
}
19
Source : RequestCache.cs
with GNU General Public License v3.0
from smartstore
with GNU General Public License v3.0
from smartstore
public void Remove(string key)
{
var items = Gereplacedems();
key = BuildKey(key);
if (items.ContainsKey(key))
{
items.Remove(key);
}
}
19
Source : TreeNodeBase.cs
with GNU General Public License v3.0
from smartstore
with GNU General Public License v3.0
from smartstore
private void RemoveNodeId(object value /* Id */, IDictionary<object, TreeNodeBase<T>> idNodeMap)
{
if (value != null)
{
// We support multi-keys for single nodes
var ids = value as IEnumerable<object> ?? new object[] { value };
foreach (var id in ids)
{
if (idNodeMap.ContainsKey(id))
{
idNodeMap.Remove(id);
}
}
}
}
19
Source : ReflectHelper.cs
with MIT License
from SonicZentropy
with MIT License
from SonicZentropy
public static string GetEnumValueText<T>(this T value)
where T : struct, IConvertible, IComparable, IFormattable {
if (!typeof (T).IsEnum) {
throw new ArgumentException($"The type {nameof(T)} must be an Enum.", nameof(value));
}
var boxed = (object) value;
if (_enumDescriptions.ContainsKey(boxed)) {
return _enumDescriptions[boxed];
}
var statFields = typeof (T).GetFields(CommonBindingFlags.Everything & BindingFlags.Static);
var attrAndValues =
from field in statFields
let descAttr = field.GetCustomAttribute<DescriptionAttribute>()
let text = descAttr?.Description
let fieldValue = field.GetValue(null)
select new {
field,
text,
fieldValue
};
foreach (var item in attrAndValues) {
_enumDescriptions[item.fieldValue] = item.text;
}
return _enumDescriptions[boxed];
}
19
Source : MethodInvokingMessageProcessorAnnotationTest.cs
with Apache License 2.0
from SteeltoeOSS
with Apache License 2.0
from SteeltoeOSS
[Fact]
public void FromMessageWithMapAndObjectMethod()
{
var method = _testService.GetType().GetMethod("MapHeadersAndPayload");
var context = GetDefaultContext();
var processor = new MethodInvokingMessageProcessor<object>(context, _testService, method);
var message = MessageBuilder.WithPayload("test")
.SetHeader("prop1", "foo")
.SetHeader("prop2", "bar")
.Build();
var result = (IDictionary<object, object>)processor.ProcessMessage(message);
replacedert.Equal(5, result.Count);
replacedert.True(result.ContainsKey(MessageHeaders.ID));
replacedert.True(result.ContainsKey(MessageHeaders.TIMESTAMP));
replacedert.Equal("foo", result["prop1"]);
replacedert.Equal("bar", result["prop2"]);
replacedert.Equal("test", result["payload"]);
}
19
Source : BogusDataProvider.cs
with MIT License
from Steveiwonder
with MIT License
from Steveiwonder
private bool HasValueMapping(
ColumnConfig columnConfig,
object existingValue)
{
if (columnConfig.UseGlobalValueMappings)
{
return _globalValueMappings.ContainsKey(columnConfig.Name) &&
_globalValueMappings[columnConfig.Name]
.ContainsKey(existingValue);
}
return columnConfig.UseLocalValueMappings && columnConfig.ValueMappings.ContainsKey(existingValue);
}
19
Source : PreviewParseExtension.cs
with MIT License
from vein-lang
with MIT License
from vein-lang
private static bool IsEnabled(this IDictionary<object, object> value, MemoFlags flag)
=> value.ContainsKey(flag);
19
Source : PreviewParseExtension.cs
with MIT License
from vein-lang
with MIT License
from vein-lang
private static void Enable(this IDictionary<object, object> value, MemoFlags flag)
{
if (!value.ContainsKey(flag))
value[flag] = flag;
}
19
Source : PreviewParseExtension.cs
with MIT License
from vein-lang
with MIT License
from vein-lang
private static void Disable(this IDictionary<object, object> value, MemoFlags flag)
{
if (value.ContainsKey(flag))
value.Remove(flag);
}
19
Source : Helpers.cs
with MIT License
from Vek17
with MIT License
from Vek17
private static Object InternalCopy(Object originalObject, IDictionary<Object, Object> visited) {
if (originalObject == null) return null;
var typeToReflect = originalObject.GetType();
if (IsPrimitive(typeToReflect)) return originalObject;
if (originalObject is BlueprintReferenceBase) return originalObject;
if (visited.ContainsKey(originalObject)) return visited[originalObject];
if (typeof(Delegate).IsreplacedignableFrom(typeToReflect)) return null;
var cloneObject = CloneMethod.Invoke(originalObject, null);
if (typeToReflect.IsArray) {
var arrayType = typeToReflect.GetElementType();
if (IsPrimitive(arrayType) == false) {
Array clonedArray = (Array)cloneObject;
ForEach(clonedArray, (array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices));
}
}
visited.Add(originalObject, cloneObject);
CopyFields(originalObject, visited, cloneObject, typeToReflect);
RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect);
return cloneObject;
void ForEach(Array array, Action<Array, int[]> action) {
if (array.LongLength == 0) return;
ArrayTraverse walker = new ArrayTraverse(array);
do action(array, walker.Position);
while (walker.Step());
}
}
19
Source : ReadOnlyMapELResolver.cs
with Apache License 2.0
from zhangzihan
with Apache License 2.0
from zhangzihan
public override object GetValue(ELContext context, object @base, object property)
{
if (@base == null)
{
if (wrappedMap.ContainsKey(property))
{
context.IsPropertyResolved = true;
return wrappedMap[property];
}
}
return null;
}
19
Source : ReadOnlyMapELResolver.cs
with Apache License 2.0
from zhangzihan
with Apache License 2.0
from zhangzihan
public override void SetValue(ELContext context, object @base, object property, object value)
{
if (@base is null)
{
if (wrappedMap.ContainsKey(property))
{
throw new ActivitiException("Cannot set value of '" + property + "', it's readonly!");
}
}
}