/// <inheritdoc /> IDistributedDictionary <TKey, TValue> IGridion.GetDictionary <TKey, TValue>(string name) { Should.NotBeNullOrEmpty(name, nameof(name)); Should.NotBeNullOrWhitespace(name, nameof(name)); return(this.node.GetOrCreateDictionary <TKey, TValue>(name)); }
/// <summary> /// Registers the specified member. /// </summary> /// <param name="type">The specified type.</param> /// <param name="path">The path of member.</param> /// <param name="member">The specified member.</param> /// <param name="rewrite"><c>true</c> rewrite exist member, <c>false</c> throw an exception.</param> public void Register(Type type, string path, IBindingMemberInfo member, bool rewrite) { Should.NotBeNull(type, "type"); Should.NotBeNullOrEmpty(path, "path"); Should.NotBeNull(member, "member"); lock (_attachedMembers) { var key = new CacheKey(type, path, false); if (_attachedMembers.ContainsKey(key)) { if (rewrite) { Tracer.Warn("The member {0} on type {1} has been overwritten", type, path); } else { throw BindingExceptionManager.DuplicateBindingMember(type, path); } } _attachedMembers[key] = member; } lock (_tempMembersCache) _tempMembersCache.Clear(); Tracer.Info("The attached property (path: {0}, type: {1}, target type: {2}) was registered.", path, member.Type, type); }
/// <inheritdoc /> IDistributedSet <T> IGridion.GetSet <T>(string name) { Should.NotBeNullOrEmpty(name, nameof(name)); Should.NotBeNullOrWhitespace(name, nameof(name)); return(this.node.GetOrCreateSet <T>(name)); }
/// <summary> /// Sets the new source of <see cref="ITokenizer"/>. /// </summary> public void SetSource(string source) { Should.NotBeNullOrEmpty(source, "source"); _source = source; CurrentChar = source[0]; Position = 0; }
public void SetSource(string source) { Should.NotBeNullOrEmpty(source, nameof(source)); _source = source; CurrentChar = source[0]; Position = 0; Token = null; }
public static IBindingModeInfoBehaviorSyntax ToExpression <T>(this T syntax, [NotNull] Func <IDataContext, IList <object>, object> multiExpression, [NotNull] params Func <T, IBindingModeInfoBehaviorSyntax>[] sources) where T : IBindingToSyntax { Should.NotBeNull(syntax, "syntax"); Should.NotBeNull(multiExpression, "multiExpression"); Should.NotBeNullOrEmpty(sources, "sources"); for (int index = 0; index < sources.Length; index++) { sources[index].Invoke(syntax); } syntax.Builder.Add(BindingBuilderConstants.MultiExpression, multiExpression); return(syntax.Builder.GetOrAddSyntaxBuilder()); }
public DependencyPropertyBindingMember([NotNull] DependencyProperty dependencyProperty, [NotNull] string path, [NotNull] Type type, bool readOnly, [CanBeNull] object member, [CanBeNull] IBindingMemberInfo changePropertyMember) { Should.NotBeNull(dependencyProperty, nameof(dependencyProperty)); Should.NotBeNullOrEmpty(path, nameof(path)); Should.NotBeNull(type, nameof(type)); _dependencyProperty = dependencyProperty; _path = path; #if WPF _type = dependencyProperty.PropertyType; _canWrite = !dependencyProperty.ReadOnly; #else _type = type; _canWrite = !readOnly; #endif _member = member; _changePropertyMember = changePropertyMember; }
public virtual void AddMethodAlias(string bindingMethodName, Type type, string method, bool rewrite) { Should.NotBeNull(bindingMethodName, nameof(bindingMethodName)); Should.NotBeNull(type, nameof(type)); Should.NotBeNullOrEmpty(method, nameof(method)); var methods = type.GetMethodsEx(MemberFlags.Public | MemberFlags.NonPublic | MemberFlags.Static); if (methods.Count == 0) { throw BindingExceptionManager.InvalidBindingMember(type, method); } lock (_aliasToMethod) { var value = new KeyValuePair <Type, string>(type, method); if (rewrite) { _aliasToMethod[bindingMethodName] = value; } else { _aliasToMethod.Add(bindingMethodName, value); } } }
public MetadataTypeAttribute([NotNull] params Type[] metadataClassTypes) { Should.NotBeNullOrEmpty(metadataClassTypes, "metadataClassTypes"); _metadataClassTypes = metadataClassTypes; }
public DisplayNameAttribute([NotNull] string displayName) { Should.NotBeNullOrEmpty(displayName, nameof(displayName)); _displayName = displayName; }
private static string Generate(Type type, string memberName, Func <char, string, string> defaultBodyBuilder, char id) { Should.NotBeNull(type, nameof(type)); Should.NotBeNullOrEmpty(memberName, nameof(memberName)); var tab = new string(' ', 4); var builder = new StringBuilder(); var typeName = type.Name; #pragma warning disable IDE0056 // Use index operator while (char.IsNumber(typeName[typeName.Length - 1]) || typeName[typeName.Length - 1] == '`') #pragma warning restore IDE0056 // Use index operator { #pragma warning disable IDE0057 // Use range operator typeName = typeName.Substring(0, typeName.Length - 1); #pragma warning restore IDE0057 // Use range operator } if (typeName.StartsWith("I", StringComparison.Ordinal)) { #pragma warning disable IDE0057 // Use range operator typeName = typeName.Substring(1, typeName.Length - 1); #pragma warning restore IDE0057 // Use range operator } builder.AppendLine("/// <summary>"); builder.AppendLine($"/// Represents a set of test methods for <see cref=\"{memberName}\"/> interface."); builder.AppendLine("/// </summary>"); builder.AppendLine("[TestClass]"); builder.AppendLine( @"[System.Diagnostics.CodeAnalysis.SuppressMessage(""StyleCop.CSharp.DocumentationRules"", ""SA1650:ElementDocumentationMustBeSpelledCorrectly"", Justification = ""Reviewed."")]"); builder.AppendLine("public class " + typeName + "Tests"); builder.AppendLine("{"); var infos = new HashSet <MethodInfo>(); ReflectionUtils.GetInterfaceMethods(type, infos); var dictionary = new Dictionary <Key, List <Val> >(); var globalSet = new Dictionary <string, int>(); foreach (var info in infos) { var key = new Key( info.ReturnType.ToString(), info.Name.Contains("get_", StringComparison.InvariantCulture) || info.Name.Contains("set_", StringComparison.InvariantCulture), info.ReturnType.IsGenericType); if (!dictionary.ContainsKey(key)) { dictionary[key] = new List <Val>(); } var s = info.Name; var containsKey = globalSet.ContainsKey(s); if (!containsKey) { globalSet.Add(s, 0); } globalSet[s]++; if (globalSet.ContainsKey(info.Name)) { if (globalSet[info.Name] > 0) { s += globalSet[info.Name]; } } if (s.Contains("Values", StringComparison.InvariantCulture)) { Console.WriteLine(); } var fullName = info.ToString(); if (info.DeclaringType != null) { fullName = info.ReturnType.Name + " " + info.DeclaringType + "." + info.Name; } var paramInfo = ReflectionUtils.BuildMethodSignature(info); dictionary[key].Add(new Val(s, fullName, paramInfo)); } dictionary = dictionary.OrderBy(pair => !pair.Key.IsProperty).ThenBy(pair => pair.Key.ReturnType).ToDictionary(pair => pair.Key, pair => pair.Value); foreach (KeyValuePair <Key, List <Val> > info in dictionary) { foreach (var val in info.Value) { var generic = info.Key.IsGeneric ? "Generic" : string.Empty; builder.AppendLine(tab + "/// <summary>"); builder.AppendLine(tab + $"/// Tests the \"{val.FullName}\" "); builder.AppendLine(tab + "/// " + tab + $"{val.ParamInfo}"); builder.AppendLine(tab + "/// method."); builder.AppendLine(tab + "/// </summary>"); builder.AppendLine(tab + "[TestMethod]"); builder.AppendLine( tab + "public void " + val.Name.Replace("set_", "Set", StringComparison.InvariantCulture).Replace("get_", "Get", StringComparison.InvariantCulture) + generic + "Test()"); builder.AppendLine(tab + "{"); builder.AppendLine(tab + tab + "using (IGridion gridion = GridionFactory.Start())"); builder.AppendLine(tab + tab + "{"); builder.Append(defaultBodyBuilder(id, tab + tab + tab)); builder.AppendLine(tab + tab + "}"); builder.AppendLine(tab + "}"); builder.AppendLine(); } } builder.AppendLine("}"); builder.AppendLine(); return(builder.ToString()); }