/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() { unchecked { return((GenericArgs != null ? GenericArgs.GetHashCode() * 397 : 0) ^ (Name.GetHashCode())); } }
private string GetTypeNameInCode(HashSet <string> omitNamespaces, bool includeNamespaces) { var sb = new StringBuilder(); if (!string.IsNullOrEmpty(Namespace) && (omitNamespaces == null && includeNamespaces) || omitNamespaces != null && !omitNamespaces.Contains(Namespace)) { sb.Append(Namespace).Append('.'); } if (GenericArgCounts != null) { sb.Append(string.Join(".", GetNestedClassesInCode(omitNamespaces, includeNamespaces))); } else { sb.Append(ClassName); if (IsGeneric) { sb.Append("<"); sb.Append( string.Join(", ", GenericArgs .Select(a => a.GetTypeNameInCode(omitNamespaces, includeNamespaces)) .ToArray())); sb.Append(">"); } } sb.Append(MemoryMagic); return(sb.ToString()); }
public EnumerableDetails MapGenericTypeParams(IReadOnlyDictionary <string, string> map) { var syntaxMap = map.ToDictionary(kv => kv.Key, kv => SyntaxFactory.ParseTypeName(kv.Value)); var updatedEnumerable = ReplaceNodes(Enumerable, syntaxMap); var updatedEnumerator = ReplaceNodes(Enumerator, syntaxMap); var updatedOutItem = map.ContainsKey(OutItem) ? map[OutItem] : OutItem; var updatedGenericArgs = GenericArgs .Where(g => !map.ContainsKey(g)) .Concat( GenericArgs .Where(g => map.ContainsKey(g)) .Select(g => map[g]) ) .ToList(); var updatedConstraints = Constraints.Select(c => ReplaceNodes(c, syntaxMap)).ToList(); var updatedBridgeEnumerable = ReplaceNodes(BridgeEnumerable, syntaxMap); var updatedBridgeEnumerator = ReplaceNodes(BridgeEnumerator, syntaxMap); return (new EnumerableDetails { BridgeEnumerable = updatedBridgeEnumerable, BridgeEnumerator = updatedBridgeEnumerator, Constraints = updatedConstraints, Enumerable = updatedEnumerable, Enumerator = updatedEnumerator, GenericArgs = updatedGenericArgs, IsBridgeType = IsBridgeType, OutItem = updatedOutItem }); }
private void GetAndProcessFirebaseHttpResponse(CancellationToken cancellationToken) { var result = Task.Run(() => { var httpResponse = ListenAsync().Result; using (httpResponse) { using (Stream contentStream = httpResponse.GetResponseStream()) { using (StreamReader contentStreamReader = new StreamReader(contentStream)) { while (true) { cancellationToken.ThrowIfCancellationRequested(); string read = contentStreamReader.ReadLineAsync().Result; Debug.Log("FIREBASE: " + read); if (read.Contains("{")) { read = read.Substring(6); JSONObject obj = new JSONObject(read); var string_path = obj["path"].str; string_path = string_path.Substring(1); var data = obj["data"]; GenericArgs args = new GenericArgs(); args.data = data; Changed?.Invoke(string_path, args); } } } } } }, cancellationToken); }
private void HandleOnStatus(object sender, GenericArgs <StreamStatus> e) { var session = (StreamSession <StreamResponse>)sender; OnStatus?.Invoke(this, new StatusArgs(session.Kind, e.Data)); if (e.Data == StreamStatus.WebError) { OnWebError?.Invoke(this, new WebErrorArgs(session.Kind, session.ErrorStatus.Value, session.ErrorMessage)); } }
public CacheMethod(MethodInfo methodInfo, object declaringInstance, GameObject parent) : base(methodInfo, declaringInstance, parent) { GenericArgs = methodInfo.GetGenericArguments(); GenericConstraints = GenericArgs.Select(x => x.GetGenericParameterConstraints()) .Where(x => x != null) .ToArray(); m_genericArgInput = new string[GenericArgs.Length]; m_arguments = methodInfo.GetParameters(); m_argumentInput = new string[m_arguments.Length]; CreateIValue(null, methodInfo.ReturnType); }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <param name="full">if set to <c>true</c> includes full information /// about generic parameters and assembly properties.</param> /// <param name="includeAssembly">if set to <c>true</c> include assembly properties and generic parameters.</param> /// <returns> /// A <see cref="System.String"/> that represents this instance. /// </returns> public string ToString(bool full, bool includeAssembly) { var sb = new StringBuilder(); if (!string.IsNullOrEmpty(Namespace)) { sb.Append(Namespace).Append('.'); } if (GenericArgCounts != null) { sb.Append(string.Join("+", ClassName .Split('+') .Zip(GenericArgCounts, (n, c) => c > 0 ? String.Format("{0}`{1}", n, c) : n))); } else { sb.Append(ClassName); if (IsGeneric) { sb.Append('`').Append(GenericArgs.Count); } } if (IsGeneric) { sb.Append('['); sb.Append(String.Join(",", GenericArgs.Select(a => string.Format("[{0}]", a.ToString(full))))); sb.Append(']'); } sb.Append(MemoryMagic); if (includeAssembly && AssemblyName != null) { sb.Append(", ").Append(AssemblyName); if (full) { foreach (var property in AssemblyAttribues) { sb.Append(", ").Append(property.Key).Append('=').Append(property.Value); } } } return(sb.ToString()); }
public override void InitMember(MemberInfo member, object declaringInstance) { base.InitMember(member, declaringInstance); var mi = MemInfo as MethodInfo; GenericArgs = mi.GetGenericArguments(); GenericConstraints = GenericArgs.Select(x => x.GetGenericParameterConstraints()) .ToArray(); GenericArgInput = new string[GenericArgs.Length]; m_arguments = mi.GetParameters(); m_argumentInput = new string[m_arguments.Length]; base.Init(null, mi.ReturnType); }
public override void Write(ICSharpFormatter formatter, bool comment = true) { if (comment) { if (Comment != null) { Comment.Write(formatter); } } string @params = string.Join(", ", Parameters.ConvertAll(p => p.ToString())); string @paramsName = string.Join(", ", Parameters.ConvertAll(p => p.Name)); foreach (var attr in Attributes) { formatter.WriteLine($"[{attr}]"); } if (!IsIndexer) { string generics = ""; if (GenericArgs != null && GenericArgs.Count > 0) { generics = "<" + string.Join(", ", GenericArgs.ConvertAll(a => { var v = a.ToString(); if (v == "void") { v = "undefined"; } return(v); })) + ">"; } var name = Name.Split(new char[] { '<' })[0]; formatter.WriteLine($"{((Closure.ClosureType != ClosureType.Interface && Closure.ClosureType != ClosureType.AnonymousInterface && Access != AccessSpecifier.Private) ? Access.ToString().ToLower() + " " : "")}{(Closure.ClosureType != ClosureType.Interface && Closure.ClosureType != ClosureType.AnonymousInterface &&!IsImplicitConverter && !IsConstructor ? /*"extern "*/"virtual " : "")}{(IsImplicitConverter ? "static " : "")}{(Abstract ? "abstract " : "")}{(Return != null ? Return.ToString() + " " : "")}{name.FormatCSharpName()}{generics}({@params}){( Body != null ? Body : Closure.ClosureType != ClosureType.Interface && Closure.ClosureType != ClosureType.AnonymousInterface && !IsImplicitConverter ? ((Return?.Name??"void") != "void" && !IsConstructor ? $" => default({Return});" : ((IsConstructor && Closure is Class && (Closure as Class).Extends.Any(m=> (m is Class) && (m as Class).Methods.Any(mm => mm.IsConstructor)) && false ? $" : base({@paramsName})" : "") + "{ }")) : ";")}"); } else { formatter.WriteLine($"{((Closure.ClosureType != ClosureType.Interface && Closure.ClosureType != ClosureType.AnonymousInterface && Access != AccessSpecifier.Private) ? Access.ToString().ToLower() + " " : "")}{(Closure.ClosureType != ClosureType.Interface && Closure.ClosureType != ClosureType.AnonymousInterface ? /*"extern "*/"virtual " : "")}{(Static ? /*"static "*/"" : "")}{(Abstract ? "abstract " : "")}{Return} this[{@params}]{{ get; set; }}"); } }
private IEnumerable <string> GetNestedClassesInCode(HashSet <string> omitNamespaces, bool includeAllNamespaces) { var i = 0; foreach (var pair in ClassName.Split('+').Zip(GenericArgCounts, (n, c) => new { n, c })) { if (pair.c == 0) { yield return(pair.n); } else { yield return(string.Format("{0}<{1}>", pair.n, string.Join(",", GenericArgs .GetRange(i, pair.c) .Select(a => a.GetTypeNameInCode(omitNamespaces, includeAllNamespaces))))); i += pair.c; } } }
private void Firebase_Changed(object sender, GenericArgs e) { if (!e.data.IsString && !e.data.IsNumber) { return; } var path_raw = sender.ToString(); var path = path_raw.Split('/'); if (path[0].Equals(currentGame)) { //Field Spell Code currData.gameAttribute = path[1]; int pathLength = path.Length; if (currData.gameAttribute.Equals(Constants.Players)) { currData.playerName = path[2]; currData.playerAttribute = path[3]; if (currData.playerAttribute.Equals(Constants.Field)) { pathLength--; currData.cardType = path[4]; currData.cardNumber = path[5]; } } currData.data = e.data; var newpath = new string[pathLength - 1]; for (int i = 1; i < pathLength; i++) { newpath[i - 1] = path[i]; } currData.path = string.Join("/", newpath); currData.ready = true; } }
private void DisplayControlOnView(object sender, GenericArgs<Control> e) { if (e.Value != null) Controls.Add(e.Value); }