public Trainer(IQuestion[] questions, TType trainingType) { _questions = new List<IQuestion>(questions); _trainingType = trainingType; _isFinished = false; _isStarted = false; }
public TMap(TType keyType, TType valueType, int count) :this() { this.keyType = keyType; this.valueType = valueType; this.count = count; }
private static byte[] GetTypeNameForTypeID(TType typeID) { switch (typeID) { case TType.Bool: return NAME_BOOL; case TType.Byte: return NAME_BYTE; case TType.I16: return NAME_I16; case TType.I32: return NAME_I32; case TType.I64: return NAME_I64; case TType.Double: return NAME_DOUBLE; case TType.String: return NAME_STRING; case TType.Struct: return NAME_STRUCT; case TType.Map: return NAME_MAP; case TType.Set: return NAME_SET; case TType.List: return NAME_LIST; default: throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED, "Unrecognized type"); } }
public TMap(TType keyType, TType valueType, int count) : this() { KeyType = keyType; ValueType = valueType; Count = count; }
public static bool isUnknownType(TType type) { var types = new HashSet<string>(new string[] { "Boolean", "int", "uint", "Object", "Number", "Array", "String", "void", "*", "Function" }); string typeName = type.name; //if (type.name == "sequence") typeName = "Vector.<" + type.genericType.name + ">"; if (types.Contains(typeName)) return false; var fType = Generator.findFileType(type.name); if ((fType != null) && fType.CheckExport()) { return false; } return true; }
public Field(string name, TType type, short id) : this() { this.name = name; this.type = type; this.id = id; }
public static void Skip(Serializer prot, TType type) { switch (type) { case TType.Bool: prot.ReadBool(); break; case TType.Byte: prot.ReadByte(); break; case TType.I16: prot.ReadI16(); break; case TType.I32: prot.ReadI32(); break; case TType.I64: prot.ReadI64(); break; case TType.Double: prot.ReadDouble(); break; case TType.String: // Don't try to decode the string, just skip it. prot.ReadBinary(); break; case TType.DataObject: prot.ReadDataObjectBegin(); while (true) { Field field = prot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } Skip(prot, field.Type); prot.ReadFieldEnd(); } prot.ReadDataObjectEnd(); break; case TType.Map: TMap map = prot.ReadMapBegin(); for (int i = 0; i < map.Count; i++) { Skip(prot, map.KeyType); Skip(prot, map.ValueType); } prot.ReadMapEnd(); break; case TType.List: TList list = prot.ReadListBegin(); for (int i = 0; i < list.Count; i++) { Skip(prot, list.ElementType); } prot.ReadListEnd(); break; } }
public void GetDMVinfo(string GetQueryInfo,string Method, string parametrs, string Table, string Extra) { int StructCount = 0; string connectionString = @"Data Source=(local)\SERVER2012; Initial Catalog=AdventureWorks2012; Integrated Security=True"; string DMVString = "SELECT query_hash, st.text,total_worker_time,cp.objtype,qs.execution_count,qp.query_plan,qs.query_hash FROM sys.dm_exec_query_stats qs " + "CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st " + "CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp " + "JOIN sys.dm_exec_cached_plans cp " + "ON cp.plan_handle = qs.plan_handle " + "WHERE (st.text like'%" + Method + "%%"+ parametrs+"%%" + Table + "%%" + Extra + "%' AND st.text NOT like '%st.text%')"; //Console.WriteLine(DMVString); using (SqlConnection connection = new SqlConnection(connectionString)) { Console.WriteLine("GetDMVInfo Connection Success \n"); SqlCommand command = new SqlCommand(DMVString, connection); try { connection.Open(); SqlDataReader reader = command.ExecuteReader(); Console.WriteLine("Select info from DMV"); Console.ForegroundColor = ConsoleColor.Cyan; while (reader.Read()) { TType newTType = new TType(); Console.WriteLine("---------------> New Query has been searshed <------------ \n"); Console.WriteLine("\t{0}\t{1}\t{2}\t{3}", reader[0], reader[1], reader[2], reader[3]); Console.WriteLine(""); newTType.query_hash = reader[0].ToString(); newTType.QueryText = reader[1].ToString(); newTType.CPUTime = Int32.Parse(reader[2].ToString()); newTType.ObjType = reader[3].ToString(); newTType.ExecCount = Int32.Parse(reader[4].ToString()); newTType.QueryPlan = reader[5].ToString(); newTType.QueryHash = (byte[])reader[6]; newTType.temp = reader[6].ToString(); if (newTType.ObjType != "Adhoc") { InfoStruct.Add(newTType); StructCount++; } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("GetDMVinfo: Status -----> Complete \n"); Console.ForegroundColor = ConsoleColor.White; reader.Close(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Не удалось получить DMVinfo \n"); } } }
public Test(TType type, IQuestion[] questions, DateTime timeToStart, string description) { _type = type; _questions=new List<IQuestion>(questions); _isStarted = false; _isFinished = false; _timeToStart = timeToStart; _description = description; }
//advanced constructor public Tile(Rectangle r, Texture2D asset, Int16 i) { dirt = asset; rect = r; switch (i) { default: type = TType.air; drawme = false; break; case 1: type = TType.ground; drawme = true; break; case 2: type = TType.misha; drawme = true; break; } }
public CharWKSOrT(TType t) { C = null; WKS = null; T = t; }
public OpRel(K kind, TType type, params OpExprOrType[] ooes) : this(kind, null, type, ooes) { }
public TList(TType elementType, int count) :this() { this.elementType = elementType; this.count = count; }
public RangeValidator(TType type, string strRange) { Type = type; _str = strRange.Trim(); }
public TList(TType elementType, int count) : this() { ElementType = elementType; Count = count; }
public static void Skip(TProtocol prot, TType type) { switch (type) { case TType.Bool: prot.ReadBool(); break; case TType.Byte: prot.ReadByte(); break; case TType.I16: prot.ReadI16(); break; case TType.I32: prot.ReadI32(); break; case TType.I64: prot.ReadI64(); break; case TType.Double: prot.ReadDouble(); break; case TType.String: // Don't try to decode the string, just skip it. prot.ReadBinary(); break; case TType.Struct: prot.ReadStructBegin(); while (true) { TField field = prot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } Skip(prot, field.Type); prot.ReadFieldEnd(); } prot.ReadStructEnd(); break; case TType.Map: TMap map = prot.ReadMapBegin(); for (int i = 0; i < map.Count; i++) { Skip(prot, map.KeyType); Skip(prot, map.ValueType); } prot.ReadMapEnd(); break; case TType.Set: TSet set = prot.ReadSetBegin(); for (int i = 0; i < set.Count; i++) { Skip(prot, set.ElementType); } prot.ReadSetEnd(); break; case TType.List: TList list = prot.ReadListBegin(); for (int i = 0; i < list.Count; i++) { Skip(prot, list.ElementType); } prot.ReadListEnd(); break; } }
static string ConvertToGenericArgsString(Type type, TType thriftType) { var sb = new StringBuilder(); var parameters = type.GetGenericArguments(); for (var i = 0; i < parameters.Length; i++) { var param = parameters[i]; sb.Append(param.FullName); if (i < parameters.Length - 1) sb.Append(", "); } return sb.ToString(); }
private static TType GetTypeIDForTypeName(byte[] name) { TType result = TType.Stop; if (name.Length > 1) { switch (name[0]) { case (byte)'d': result = TType.Double; break; case (byte)'i': switch (name[1]) { case (byte)'8': result = TType.Byte; break; case (byte)'1': result = TType.I16; break; case (byte)'3': result = TType.I32; break; case (byte)'6': result = TType.I64; break; } break; case (byte)'l': result = TType.List; break; case (byte)'m': result = TType.Map; break; case (byte)'r': result = TType.Struct; break; case (byte)'s': if (name[1] == (byte)'t') { result = TType.String; } else if (name[1] == (byte)'e') { result = TType.Set; } break; case (byte)'t': result = TType.Bool; break; } } if (result == TType.Stop) { throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED, "Unrecognized type"); } return(result); }
public bool Accept(TMap type, TType x, Dictionary <DefTypeBase, bool> y, HashSet <DefTypeBase> z) { TMap m = (TMap)x; return(type.KeyType.Apply(this, m.KeyType, y, z) && type.ValueType.Apply(this, m.ValueType, y, z)); }
public bool Accept(TSet type, TType x, Dictionary <DefTypeBase, bool> y, HashSet <DefTypeBase> z) { return(type.ElementType.Apply(this, ((TSet)x).ElementType, y, z)); }
private static byte GetCompactType(TType ttype) { // Given a TType value, find the appropriate TCompactProtocol.Types constant. return(TTypeToCompactType[(int)ttype]); }
public TList(TType elementType, Int32 count) : this() { ElementType = elementType; Count = count; }
public DateToken(TType type, object payload = null) { _type = type; _payload = payload; }
public OpRel(K kind, Expr identity, TType type, params OpExprOrType[] ooes) { _kind = kind; TType deftype = type; _identity = identity; List<WOrC> ops = new List<WOrC>(); List<Expr> heads = new List<Expr>(); List<TType> types = new List<TType>(); foreach (OpExprOrType ooe in ooes) { switch (ooe.Which) { case OpExprOrType.which.Op: ops.Add(ooe.Op); heads.Add(null); types.Add(deftype); break; case OpExprOrType.which.Expr: heads[heads.Count - 1] = ooe.Exp; break; case OpExprOrType.which.Type: types[types.Count - 1] = ooe.Type; break; } } _ops = ops.ToArray(); _heads = heads.ToArray(); _types = types.ToArray(); }
static string ConvertToTypeString(TType type) { switch (type) { case TType.Void: return "void"; case TType.Bool: return "bool"; case TType.Byte: return "byte"; case TType.Double: return "double"; case TType.I16: return "short"; case TType.I32: return "int"; case TType.String: return "string"; default: throw new NotImplementedException(); } }
public OpExprOrType(TType type) { _type = type; _which = which.Type; }
public TSet(TType elementType, int count) { ElementType = elementType; Count = count; }
static string ConvertToGenericTypeString(Type type, TType thriftType) { var sb = new StringBuilder(); Debug.Assert(type.IsGenericType); switch (thriftType) { default: throw new NotSupportedException(); case TType.List: sb.Append("IList<"); break; case TType.Map: sb.Append("IDictionary<"); break; case TType.Set: sb.Append("ISet<"); break; } sb.Append(ConvertToGenericArgsString(type, thriftType)); sb.Append(">"); return sb.ToString(); }
public bool Accept(TBean type, TType x, Dictionary <DefTypeBase, bool> y, HashSet <DefTypeBase> z) { return(Compare(type.GetBeanAs <DefBean>(), ((TBean)x).GetBeanAs <DefBean>(), y, z)); }
/// <summary> /// Конструктор для полноценной задачи /// </summary> /// <param name="pname">Название задачи</param> /// <param name="ptext">Расшифровка задачи</param> /// <param name="plabel">Метка задачи</param> /// <param name="ptags">Тэги</param> /// <param name="pstatus">Статус</param> /// <param name="ptype">Тип задачи</param> /// <param name="ppriority">Приоритет</param> public TToDoItem(string pname, string ptext, string plabel, string ptags, TStatus pstatus, TType ptype, TPriority ppriority) { name = pname; text = ptext; label = plabel; tags = ptags; status = pstatus; type = ptype; priority = ppriority; dateCreated = DateTime.Now; // везде берем за отчет текущее время и дату, момент создания progress = 0; // инициализируем массив задач Items = new TToDoItem[0]; // добавляем историю теперь history = new THistory[0]; AddHistory(); }
public static async Task SkipAsync(TProtocol prot, TType type, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { await Task.FromCanceled(cancellationToken); } prot.IncrementRecursionDepth(); try { switch (type) { case TType.Bool: await prot.ReadBoolAsync(cancellationToken); break; case TType.Byte: await prot.ReadByteAsync(cancellationToken); break; case TType.I16: await prot.ReadI16Async(cancellationToken); break; case TType.I32: await prot.ReadI32Async(cancellationToken); break; case TType.I64: await prot.ReadI64Async(cancellationToken); break; case TType.Double: await prot.ReadDoubleAsync(cancellationToken); break; case TType.String: // Don't try to decode the string, just skip it. await prot.ReadBinaryAsync(cancellationToken); break; case TType.Struct: await prot.ReadStructBeginAsync(cancellationToken); while (true) { var field = await prot.ReadFieldBeginAsync(cancellationToken); if (field.Type == TType.Stop) { break; } await SkipAsync(prot, field.Type, cancellationToken); await prot.ReadFieldEndAsync(cancellationToken); } await prot.ReadStructEndAsync(cancellationToken); break; case TType.Map: var map = await prot.ReadMapBeginAsync(cancellationToken); for (var i = 0; i < map.Count; i++) { await SkipAsync(prot, map.KeyType, cancellationToken); await SkipAsync(prot, map.ValueType, cancellationToken); } await prot.ReadMapEndAsync(cancellationToken); break; case TType.Set: var set = await prot.ReadSetBeginAsync(cancellationToken); for (var i = 0; i < set.Count; i++) { await SkipAsync(prot, set.ElementType, cancellationToken); } await prot.ReadSetEndAsync(cancellationToken); break; case TType.List: var list = await prot.ReadListBeginAsync(cancellationToken); for (var i = 0; i < list.Count; i++) { await SkipAsync(prot, list.ElementType, cancellationToken); } await prot.ReadListEndAsync(cancellationToken); break; default: throw new TProtocolException(TProtocolException.INVALID_DATA, "Unknown data type " + type.ToString("d")); } } finally { prot.DecrementRecursionDepth(); } }
public static void Skip(TProtocol prot, TType type) { prot.IncrementRecursionDepth(); try { switch (type) { case TType.Bool: prot.ReadBool(); break; case TType.Byte: prot.ReadByte(); break; case TType.I16: prot.ReadI16(); break; case TType.I32: prot.ReadI32(); break; case TType.I64: prot.ReadI64(); break; case TType.Double: prot.ReadDouble(); break; case TType.String: // Don't try to decode the string, just skip it. prot.ReadBinary(); break; case TType.Struct: prot.ReadStructBegin(); while (true) { TField field = prot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } Skip(prot, field.Type); prot.ReadFieldEnd(); } prot.ReadStructEnd(); break; case TType.Map: TMap map = prot.ReadMapBegin(); for (int i = 0; i < map.Count; i++) { Skip(prot, map.KeyType); Skip(prot, map.ValueType); } prot.ReadMapEnd(); break; case TType.Set: TSet set = prot.ReadSetBegin(); for (int i = 0; i < set.Count; i++) { Skip(prot, set.ElementType); } prot.ReadSetEnd(); break; case TType.List: TList list = prot.ReadListBegin(); for (int i = 0; i < list.Count; i++) { Skip(prot, list.ElementType); } prot.ReadListEnd(); break; } } finally { prot.DecrementRecursionDepth(); } }
public bool Accept(TDateTime type, TType x, Dictionary <DefTypeBase, bool> y, HashSet <DefTypeBase> z) { return(true); }
/** * Given a TType value, find the appropriate TCompactProtocol.Types constant. */ private byte getCompactType(TType ttype) { return ttypeToCompactType[(int)ttype]; }
public TSet(TType elementType, int count) : this() { this.elementType = elementType; this.count = count; }
// // Internal writing methods // /** * Abstract method for writing the start of lists and sets. List and sets on * the wire differ only by the type indicator. */ protected void WriteCollectionBegin(TType elemType, int size) { if (size <= 14) { WriteByteDirect(size << 4 | getCompactType(elemType)); } else { WriteByteDirect(0xf0 | getCompactType(elemType)); WriteVarint32((uint)size); } }
public static bool isUnknownType(TType type) { var types = new HashSet<string>(new string[] { "bool", "int", "float", "double", "short", "ushort", "uint", "long", "ulong", "object", "Array", "byte", "JsString", "string", "JsObject", "JsArray", "void", }); string typeName = type.name; if (type.name == "sequence") typeName = type.genericType.name; //if (typeName.EndsWith("Constructor")) return true; if (types.Contains(typeName)) return false; foreach (var pFile in Generator.parsedFiles) { foreach (var ns in pFile.nsList) { foreach (var t in ns.types) { if (t.name == typeName) { return false; } } } } return true; }
private static byte[] GetTypeNameForTypeId(TType typeId) { switch (typeId) { case TType.Bool: return NameBool; case TType.Byte: return NameByte; case TType.I16: return NameI16; case TType.I32: return NameI32; case TType.I64: return NameI64; case TType.Double: return NameDouble; case TType.String: return NameString; case TType.Struct: return NameStruct; case TType.Map: return NameMap; case TType.Set: return NameSet; case TType.List: return NameList; default: throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED, "Unrecognized exType"); } }
public SetValidator(TType ttype, string param) { _type = ttype; _datas = new HashSet <DType>(); _valueSetStr = DefUtil.TrimBracePairs(param); }
private TType readType() { var type = new TType(); //Program.allTypes.Add(type); type.name = currentToken.value; if (type.name == "unsigned") type.name += " " + getNextToken().value; getNextToken(); if (currentToken.value == "long") { type.name += " long"; getNextToken(); } if (currentToken.token == ECodeToken.blLessThan) { getNextToken(); type.genericType = readType(); getNextToken(); } if (currentToken.token == ECodeToken.brSmallBraceBegin) { type.isArray = true; getNextToken(); getNextToken(); } if (currentToken.token == ECodeToken.syQuestionmark) { type.isNullable = true; getNextToken(); } type.name = getTypeName(type.name); return type; }
public TField(string name, TType type, short id) { Name = name; Type = type; ID = id; }
//~ Methods ---------------------------------------------------------------- /// <summary> /// Returns the next token in the stream, or null at EOS. /// </summary> /// <returns>Token</returns> public override Token Next() { /** how many character(s) has been stored in buffer */ int length = 0; /** the position used to create Token */ int start = offset; while (true) { /** current charactor */ char c; /** unicode block of current charactor for detail */ //Character.UnicodeBlock ub; offset++; if (bufferIndex >= dataLen) { dataLen = input.Read(ioBuffer, 0, ioBuffer.Length); bufferIndex = 0; } if (dataLen == -1) { if (length > 0) { if (preIsTokened == true) { length = 0; preIsTokened = false; } break; } else { return null; } } else { //get current character c = Char.ToLowerInvariant(ioBuffer[bufferIndex++]); //get the UnicodeBlock of the current character //ub = Character.UnicodeBlock.of(c); } //if the current character is ASCII or Extend ASCII if (('\u0000' <= c && c <= '\u007F') || ('\uFF00' <= c && c <= '\uFFEF')) { if ('\uFF00' <= c && c <= '\uFFEF') { /** convert HALFWIDTH_AND_FULLWIDTH_FORMS to BASIC_LATIN */ int i = (int) c; i = i - 65248; c = (char) i; } // if the current character is a letter or "_" "+" "#" if (Char.IsLetterOrDigit(c) || ((c == '_') || (c == '+') || (c == '#')) ) { if (length == 0) { // "javaC1C2C3C4linux" <br> // ^--: the current character begin to token the ASCII // letter start = offset - 1; } else if (tokenType == TType.Double) { // "javaC1C2C3C4linux" <br> // ^--: the previous non-ASCII // : the current character offset--; bufferIndex--; tokenType = TType.Single; if (preIsTokened == true) { // there is only one non-ASCII has been stored length = 0; preIsTokened = false; break; } else { break; } } // store the LowerCase(c) in the buffer // maybe, just maybe this will not break everything... buffer[length++] = c; tokenType = TType.Single; // break the procedure if buffer overflowed! if (length == MAX_WORD_LEN) { break; } } else if (length > 0) { if (preIsTokened == true) { length = 0; preIsTokened = false; } else { break; } } } else { // non-ASCII letter, eg."C1C2C3C4" if (Char.IsLetter(c)) { if (length == 0) { start = offset - 1; buffer[length++] = c; tokenType = TType.Double; } else { if (tokenType == TType.Single) { offset--; bufferIndex--; //return the previous ASCII characters break; } else { buffer[length++] = c; tokenType = TType.Double; if (length == 2) { offset--; bufferIndex--; preIsTokened = true; break; } } } } else if (length > 0) { if (preIsTokened == true) { // empty the buffer length = 0; preIsTokened = false; } else { break; } } } } return new Token(new String(buffer, 0, length), start, start + length, tokenType == TType.Word ? "word" : (tokenType == TType.Single ? "single" : "double") ); }
public MethodInfo ResolveMethod(TType[] paramTypes) { // The name of the class String typeName; // The name of the invokation method in the class. String methodName; // The object specification that must be matched. If any entry is 'null' // then the argument parameter is discovered. Type[] argTypes; bool firstProcedureConnectionIgnore; if (!HasMethodName) { // This means the typeString only specifies a class name, so we use // 'Invoke' as the static method to call, and discover the arguments. typeName = TypeName; methodName = "Invoke"; // All null which means we discover the arg types dynamically argTypes = new Type[paramTypes.Length]; // ignore IProcedureConnection is first argument firstProcedureConnectionIgnore = true; } else { // This means we specify a class and method name and argument // specification. typeName = TypeName; methodName = MethodName; argTypes = new Type[Arguments.Length]; for (int i = 0; i < Arguments.Length; ++i) { String typeSpec = Arguments[i]; argTypes[i] = ResolveToType(typeSpec); } firstProcedureConnectionIgnore = false; } Type routineType = Type.GetType(typeName, false, true); if (routineType == null) throw new Exception("Procedure class not found: " + typeName); // Get all the methods in this class MethodInfo[] methods = routineType.GetMethods(BindingFlags.Public | BindingFlags.Static); MethodInfo invokeMethod = null; // Search for the invoke method foreach (MethodInfo method in methods) { if (method.Name.Equals(methodName)) { bool paramsMatch; // Get the parameters for this method ParameterInfo[] methodArgs = method.GetParameters(); // If no methods, and object_specification has no args then this is a // match. if (methodArgs.Length == 0 && argTypes.Length == 0) { paramsMatch = true; } else { int searchStart = 0; // Is the first arugments a IProcedureConnection implementation? if (firstProcedureConnectionIgnore && typeof(IProcedureConnection).IsAssignableFrom(methodArgs[0].ParameterType)) { searchStart = 1; } // Do the number of arguments match if (argTypes.Length == methodArgs.Length - searchStart) { // Do they match the specification? bool matchSpec = true; for (int n = 0; n < argTypes.Length && matchSpec; ++n) { Type argType = argTypes[n]; if (argType != null && argType != methodArgs[n + searchStart].ParameterType) { matchSpec = false; } } paramsMatch = matchSpec; } else { paramsMatch = false; } } if (paramsMatch) { if (invokeMethod != null) throw new Exception("Ambiguous public static " + methodName + " methods in stored procedure class '" + typeName + "'"); invokeMethod = method; } } } // Return the invoke method we found return invokeMethod; }
internal TypeAttributeMapping(TypeMapping declaringType, string memberName, TType type, bool nullable) : base(declaringType, memberName) { this.type = type; this.nullable = nullable; }
// Returns the minimum amount of bytes needed to store the smallest possible instance of TType. public override int GetMinSerializedSize(TType type) { return(_wrappedProtocol.GetMinSerializedSize(type)); }